=== firmware/debug.c ================================================================== --- firmware/debug.c (/rockbox/trunk) (revision 20) +++ firmware/debug.c (/rockbox/branches/arm-gcc-debug) (revision 20) @@ -229,6 +229,86 @@ } #endif /* HAVE_GDB_API */ + +#ifdef CPU_ARM +void debug_init(void) +{ +} + +void breakpoint(void) +{ + /* search for "arm_bkpt" in openocd */ +#ifdef __ARM_ARCH_5TEJ__ + asm("bkpt 0"); +#else + asm(".long 0xdeeedeee"); +#endif +} + +/* WARNING: + These routines are extremely slow if there is no debugger attached to drain + the DCC FIFO. Don't enable -DDEBUG on a non-simulator (target) build unless + you plan on attaching a DCC-aware JTAG debugger to the CPU to receive the + debug messages. +*/ + +/* Borrowed from linux-2.6.22.6/arch/arm/kernel/debug.S */ +static void senduart(unsigned long ch) { + __asm__(" mov r4, #0x2000000\n\t" + "1001:\n\t" + " subs r4, r4, #1\n\t" + " bmi 1002f\n\t" + " mrc p14, 0, r5, c0, c0, 0\n\t" + " tst r5, #2\n\t" + " bne 1001b\n\t" + "1002:\n\t" : : : "cc", "r4", "r5"); + __asm__("mcr p14, 0, %0, c1, c0, 0" : : "r" (ch)); +} + +/* openocd protocol, see openocd/src/target_request.c */ +typedef enum target_req_cmd +{ + TARGET_REQ_TRACEMSG, + TARGET_REQ_DEBUGMSG, +/* TARGET_REQ_SEMIHOSTING, */ +} target_req_cmd_t; + +void trace_point(int number) { + senduart((number << 8) | TARGET_REQ_TRACEMSG); +} + +void hexmsg(const unsigned char *data, int size, uint32_t length) { + uint32_t word; + + senduart((length << 16) | (size << 8) | TARGET_REQ_DEBUGMSG); + + while (length >= 4) { + senduart(*(uint32_t *)data); + data += 4; + length -= 4; + } + + word = 0; + switch (length) { + case 3: word |= data[2] << 16; + case 2: word |= data[1] << 8; + case 1: word |= data[0]; + senduart(word); + case 0: + ; + } +} + +static void asciimsg(const char *msg) { + hexmsg((const unsigned char *)msg, 0, strlen(msg)); +} + +static void debug(const char *msg) +{ + asciimsg(msg); +} + +#endif #endif /* end of DEBUG section */ #ifdef __GNUC__ Property changes on: ___________________________________________________________________ Name: svk:merge +a1c6a512-1295-4272-9138-f99709370657:/trunk:16084