mspdebug/device.h

102 lines
2.9 KiB
C
Raw Normal View History

2010-04-30 04:01:03 +00:00
/* MSPDebug - debugging tool for MSP430 MCUs
2010-01-08 08:17:24 +00:00
* Copyright (C) 2009, 2010 Daniel Beer
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef DEVICE_H_
#define DEVICE_H_
2010-05-13 00:57:21 +00:00
#include <stdint.h>
#include "util.h"
2010-04-30 04:01:03 +00:00
struct device;
typedef struct device *device_t;
extern device_t device_default;
typedef enum {
DEVICE_CTL_RESET,
DEVICE_CTL_RUN,
DEVICE_CTL_HALT,
DEVICE_CTL_STEP,
DEVICE_CTL_ERASE
} device_ctl_t;
typedef enum {
DEVICE_STATUS_HALTED,
DEVICE_STATUS_RUNNING,
DEVICE_STATUS_INTR,
DEVICE_STATUS_ERROR
} device_status_t;
2010-04-30 04:01:03 +00:00
#define DEVICE_NUM_REGS 16
#define DEVICE_MAX_BREAKPOINTS 32
#define DEVICE_BP_ENABLED 0x01
#define DEVICE_BP_DIRTY 0x02
struct device_breakpoint {
address_t addr;
int flags;
};
2010-04-30 04:01:03 +00:00
struct device {
/* Start of code memory. Required to distinguish between flash
* writes (which may require alignment) and RAM writes (which
* don't).
*/
address_t code_start;
/* Breakpoint table. This should not be modified directly.
* Instead, you should use the device_setbrk() helper function. This
* will set the appropriate flags and ensure that the breakpoint is
* reloaded before the next run.
*/
int max_breakpoints;
struct device_breakpoint breakpoints[DEVICE_MAX_BREAKPOINTS];
2010-04-30 04:01:03 +00:00
/* Close the connection to the device and destroy the driver object */
void (*destroy)(device_t dev);
2010-04-30 04:01:03 +00:00
/* Read/write memory */
int (*readmem)(device_t dev, address_t addr,
uint8_t *mem, address_t len);
int (*writemem)(device_t dev, address_t addr,
const uint8_t *mem, address_t len);
2010-04-30 04:01:03 +00:00
/* Read/write registers */
int (*getregs)(device_t dev, address_t *regs);
int (*setregs)(device_t dev, const address_t *regs);
2010-04-30 04:01:03 +00:00
/* CPU control */
int (*ctl)(device_t dev, device_ctl_t op);
2010-04-30 04:01:03 +00:00
/* Wait a little while for the CPU to change state */
device_status_t (*poll)(device_t dev);
};
2010-04-10 02:35:36 +00:00
/* Set or clear a breakpoint. The index of the modified entry is
* returned, or -1 if no free entries were available. The modified
* entry is flagged so that it will be reloaded on the next run.
*
* If which is specified, a particular breakpoint slot is
* modified. Otherwise, if which < 0, breakpoint slots are selected
* automatically.
*/
int device_setbrk(device_t dev, int which, int enabled, address_t address);
#endif