tilib: fetch breakpoint counts and device ID via library API.

This commit is contained in:
Daniel Beer 2011-10-18 11:55:21 +13:00
parent d610f6471a
commit 000816adbd
2 changed files with 111 additions and 3 deletions

View File

@ -49,6 +49,8 @@ struct tilib_device {
STATUS_T WINAPI (*MSP430_OpenDevice)(char *Device, char *Password,
long PwLength, long DeviceCode,
long setId);
STATUS_T WINAPI (*MSP430_GetFoundDevice)(char *FoundDevice,
long count);
STATUS_T WINAPI (*MSP430_Close)(long vccOff);
STATUS_T WINAPI (*MSP430_Memory)(long address, char *buffer,
long count, long rw);
@ -150,6 +152,11 @@ static int get_all_funcs(struct tilib_device *dev)
if (!dev->MSP430_OpenDevice)
return -1;
dev->MSP430_GetFoundDevice = get_func(dev->hnd,
"MSP430_GetFoundDevice");
if (!dev->MSP430_GetFoundDevice)
return -1;
dev->MSP430_Close = get_func(dev->hnd, "MSP430_Close");
if (!dev->MSP430_Close)
return -1;
@ -471,6 +478,7 @@ static int do_init(struct tilib_device *dev, const struct device_args *args)
{
long version;
char buf[1024];
union DEVICE_T device;
/* Not sure if the path is actually modified by MSP430_Initialize,
* but the argument isn't const, so probably safest to copy it.
@ -519,6 +527,20 @@ static int do_init(struct tilib_device *dev, const struct device_args *args)
return -1;
}
printc_dbg("MSP430_GetFoundDevice\n");
if (dev->MSP430_GetFoundDevice(device.buffer,
sizeof(device.buffer)) < 0) {
report_error(dev, "MSP430_GetFoundDevice");
dev->MSP430_Close(0);
return -1;
}
printc_dbg("Device: %s (id = 0x%04x)\n", device.string, device.id);
printc_dbg("%d breakpoints available\n", device.nBreakpoints);
dev->base.max_breakpoints = device.nBreakpoints;
if (dev->base.max_breakpoints > DEVICE_MAX_BREAKPOINTS)
dev->base.max_breakpoints = DEVICE_MAX_BREAKPOINTS;
printc_dbg("MSP430_EEM_Init\n");
threads_lock_init(&dev->mb_lock);
if (dev->MSP430_EEM_Init(event_notify, (long)dev,
@ -529,9 +551,6 @@ static int do_init(struct tilib_device *dev, const struct device_args *args)
return -1;
}
/* Should find this out from EEM API, if possible */
dev->base.max_breakpoints = DEVICE_MAX_BREAKPOINTS;
return 0;
}

View File

@ -55,9 +55,16 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdint.h>
/* this is the definition for the DLL functions return value */
typedef long STATUS_T;
typedef long LONG;
typedef unsigned long ULONG;
typedef char CHAR;
typedef uint16_t WORD;
typedef uint8_t BYTE;
enum READ_WRITE {
WRITE = 0,
@ -294,4 +301,86 @@ typedef enum UPDATE_STATUS_MESSAGES {
BL_WAIT_FOR_TIMEOUT = 8
} UPDATE_STATUS_MESSAGES_t;
union DEVICE_T {
/* this buffer holds the complete device information */
/* and is overlayed by the following information structure */
CHAR buffer[110];
struct { /* actually 106 Bytes */
/* The value 0xaa55. */
WORD endian;
/* Identification number. */
WORD id;
/* Identification string. */
BYTE string[32];
/* MAIN MEMORY (FLASH) starting address. */
WORD mainStart;
/* INFORMATION MEMORY (FLASH) starting address. */
WORD infoStart;
/* RAM ending address. */
WORD ramEnd;
/* Number of breakpoints. */
WORD nBreakpoints;
/* Emulation level. */
WORD emulation;
/* Clock control level. */
WORD clockControl;
/* LCD starting address. */
WORD lcdStart;
/* LCD ending address. */
WORD lcdEnd;
/* Vcc minimum during operation [mVolts]. */
WORD vccMinOp;
/* Vcc maximum during operation [mVolts]. */
WORD vccMaxOp;
/* Device has TEST/VPP. */
WORD hasTestVpp;
/* RAM starting address. */
WORD ramStart;
/* RAM2 starting address. */
WORD ram2Start;
/* RAM2 ending address. */
WORD ram2End;
/* INFO ending address. */
WORD infoEnd;
/* MAIN ending address. */
ULONG mainEnd;
/* BSL starting address. */
WORD bslStart;
/* BSL ending address. */
WORD bslEnd;
/* Number of CPU Register Trigger. */
WORD nRegTrigger;
/* Number of EEM Trigger Combinations. */
WORD nCombinations;
/* The MSP430 architecture (non-X, X or Xv2). */
BYTE cpuArch;
/* The JTAG ID - value returned on an instruction shift. */
BYTE jtagId;
/* The CoreIP ID. */
WORD coreIpId;
/* The Device-ID Pointer. */
ULONG deviceIdPtr;
/* The EEM Version Number. */
WORD eemVersion;
/* Breakpoint Modes */
WORD nBreakpointsOptions;
WORD nBreakpointsReadWrite;
WORD nBreakpointsDma;
/* Trigger Mask for Breakpoint */
WORD TrigerMask;
/* Register Trigger modes */
WORD nRegTriggerOperations;
/* MSP430 has Stage Storage */
WORD nStateStorage ;
/* Numbr of cycle counters of MSP430 */
WORD nCycleCounter;
/* Cycle couter modes */
WORD nCycleCounterOperations;
/* Msp430 has Sqeuncer */
WORD nSequencer;
/* Msp430 has FRAM Memroy */
WORD HasFramMemroy;
};
};
#endif