2 * Copyright (c) 2013 Qualcomm Atheros, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted (subject to the limitations in the
7 * disclaimer below) provided that the following conditions are met:
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the
17 * * Neither the name of Qualcomm Atheros nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
22 * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
23 * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
24 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
32 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
33 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 #include "athos_api.h"
38 #include "adf_os_io.h"
40 #if defined(PROJECT_K2)
41 #if SYSTEM_MODULE_SFLASH
42 #include "sflash_api.h"
44 #endif /* #if defined(PROJECT_K2) */
46 #if defined(SYSTEM_MODULE_DBG)
48 /* Function prototypes */
49 static int db_help_cmd(char *, char *, char *, char *);
50 static int db_ldr_cmd(char *, char *, char *, char *);
51 static int db_str_cmd(char *, char *, char *, char *);
52 static int db_info_cmd(char *, char *, char *, char *);
53 static int db_usb_cmd(char *, char *, char *, char *);
54 static int db_intr_cmd(char *, char *, char *, char *);
56 static int db_cmd_starthtc(char *cmd, char *param1, char *param2, char *param3);
58 static int db_wdt_cmd(char *cmd, char *param1, char *param2, char *param3);
60 #if defined(PROJECT_K2)
61 #if SYSTEM_MODULE_SFLASH
62 static int db_cmd_sferase(char *cmd, char *param1, char *param2, char *param3);
63 static int db_cmd_sfpg(char *cmd, char *param1, char *param2, char *param3);
64 static int db_cmd_sfru(char *cmd, char *param1, char *param2, char *param3);
65 static int db_cmd_sfrm(char *cmd, char *param1, char *param2, char *param3);
66 static int db_cmd_sfrdsr(char *cmd, char *param1, char *param2, char *param3);
68 #endif /* #if defined(PROJECT_K2) */
69 static int db_cmd_memcmp(char *cmd, char *param1, char *param2, char *param3);
70 static int db_cmd_memdump(char *cmd, char *param1, char *param2, char *param3);
72 static int db_clock_cmd(char *cmd, char *param1, char *param2, char *param3);
74 static uint16_t db_get_cmd_line(uint8_t ch, char *cmd_line, uint16_t *i);
75 static int db_formalize_command(char *, char *);
76 static int db_ascii_to_hex(char *, unsigned long *);
77 static int db_hex_to_ascii(unsigned long, char *);
78 static void zf_debug_task(void);
80 /* Console debug command table */
81 const struct DB_COMMAND_STRUCT command_table[] =
83 {"HELP", ", List all debug commands", db_help_cmd},
84 {"?", ", Equal to HELP comamnd", db_help_cmd},
86 /* Basic load/store/dump command */
87 {"LDR", "<Hex addr>, Load word", db_ldr_cmd},
88 {"LDRH", "<Hex addr>, Load half word", db_ldr_cmd},
89 {"LDRB", "<Hex addr>, Load byte", db_ldr_cmd},
90 {"STR", "<Hex addr> <Hex value>, Store word", db_str_cmd},
91 {"STRH", "<Hex addr> <Hex value>, Store half word", db_str_cmd},
92 {"STRB", "<Hex addr> <Hex value>, Store byte", db_str_cmd},
93 {"INFO", ", Print debug information", db_info_cmd},
94 {"USB", ", usb releated command", db_usb_cmd},
95 {"INTR", ", intr releated command", db_intr_cmd},
96 {"CLOCK", ", change the clock...", db_clock_cmd},
97 {"HTCR", "Issue HTC ready to host", db_cmd_starthtc},
98 {"WDT", ", wdt debug command", db_wdt_cmd},
99 #if defined(PROJECT_K2)
100 #if SYSTEM_MODULE_SFLASH
101 {"SFE", ", S<Hex>/B<Hex>/C, SPI Flash chip erase", db_cmd_sferase},
102 {"SFPG", "<Hex addr> <Hex len> <Hex buf>, SPI Flash program", db_cmd_sfpg},
103 {"SFRU", "f/r <Hex addr> <Hex addr>, SPI Flash fast read/read to UART", db_cmd_sfru},
104 {"SFRM", "f/r <Hex addr> <Hex addr>, SPI Flash fast read/read to Memory 0x520000", db_cmd_sfrm},
105 {"SFRDSR", ", SPI Flash status register read", db_cmd_sfrdsr},
107 #endif /* #if defined(PROJECT_K2) */
108 {"MEMCMP", "<Hex addr> <Hex addr> <Hex len>, memory comparison", db_cmd_memcmp},
109 {"MEMDMP", "<Hex addr> <Hex addr>, memory dump", db_cmd_memdump},
111 /* {Command, Help description, function} */
114 char cmd_buffer[COMMAND_BUFFER_SIZE][DB_MAX_COMMAND_LENGTH]; /* Backup previous command */
117 char raw_cmd[DB_MAX_COMMAND_LENGTH];
118 char cmd_str[DB_MAX_COMMAND_LENGTH*4];
123 static void db_incorect_format(void)
125 A_PRINTF("Error! Incorrect format.\n\r");
128 static void db_unknown_command(void)
130 A_PRINTF("Error! Unknown command.\n\r");
133 static void db_print_dump(const char *mem1, const char *mem2)
140 A_PRINTF("\n\r%06x: ", mem1);
144 A_PRINTF("%04x ", *(uint16_t *)mem1);
152 if (*tmp > 0x20 && *tmp < 0x7e)
153 A_PRINTF("%c", *tmp);
157 } while (tmp < mem1);
160 } while (mem1 < mem2);
164 static void zf_debug_init(void)
169 while ((zm_get_char(&ch)) != 0)
174 cmd_buf_full = FALSE;
179 static void zf_debug_task(void)
184 if ((zm_get_char(&ch)) == 0)
189 if (db_get_cmd_line(ch, raw_cmd, &gvLen) == 0)
194 if (db_formalize_command(raw_cmd, cmd_str))
199 cmd_not_found = TRUE;
200 while(command_table[i].cmd_func)
202 if (!strcmp(command_table[i].cmd_str, cmd_str))
204 cmd_not_found = FALSE;
205 command_table[i].cmd_func(cmd_str,
206 cmd_str+DB_MAX_COMMAND_LENGTH,
207 cmd_str+DB_MAX_COMMAND_LENGTH*2,
208 cmd_str+DB_MAX_COMMAND_LENGTH*3);
215 A_PRINTF("Error, HELP for command list.\n\r");
224 static uint16_t db_get_cmd_line(uint8_t ch, char *cmd_line, uint16_t *i)
230 case '\\' : /* Last command */
232 if (pressed_time >= COMMAND_BUFFER_SIZE)
236 cmd_buf_loc = cmd_buf_ptr - pressed_time;
239 if (cmd_buf_full == TRUE)
241 cmd_buf_loc += COMMAND_BUFFER_SIZE;
249 if (A_STRLEN(cmd_buffer[cmd_buf_loc]) != 0)
251 A_STRCPY(cmd_line, cmd_buffer[cmd_buf_loc]);
252 *i = A_STRLEN(cmd_buffer[cmd_buf_loc]);
254 A_PRINTF("%s", cmd_line);
257 case 13 : /* Return */
263 //Filter duplicated string in command history
264 if (strcmp(cmd_buffer[(cmd_buf_ptr==0)?(COMMAND_BUFFER_SIZE-1):(cmd_buf_ptr-1)], cmd_line) != 0)
266 A_STRCPY(cmd_buffer[cmd_buf_ptr++], cmd_line);
269 if (cmd_buf_ptr >= COMMAND_BUFFER_SIZE)
275 case '\b' : /* Backspace */
286 if ((ch >= ' ') && (ch <= '~'))
289 if (*i < DB_MAX_COMMAND_LENGTH-2)
291 if ((ch >= 0x11) && (ch <= 0x7e))
293 //if ((buf <= 'z') && (buf >= 'a'))
309 } /* end of switch */
315 static int db_formalize_command(char *raw_str, char *cmd_str)
324 /* Remove preceeding spaces */
325 while (raw_str[i++] == ' '){}
328 /* Copy command string */
330 while(raw_str[i] && (raw_str[i] != ' '))
334 if ((raw_str[i] <= 'z') && (raw_str[i] >= 'a'))
336 raw_str[i] -= 'a' - 'A';
338 cmd_str[k*DB_MAX_COMMAND_LENGTH + j++] = raw_str[i++];
342 cmd_str[k*DB_MAX_COMMAND_LENGTH + j++] = raw_str[i++];
345 cmd_str[k*DB_MAX_COMMAND_LENGTH + j] = 0;
347 return (int)A_STRLEN(cmd_str);
350 static int db_ascii_to_hex(char *num_str, unsigned long *hex_num)
357 if ((num_str[i] >= '0') && (num_str[i] <= '9'))
360 *hex_num += (num_str[i] - '0');
362 else if ((num_str[i] >= 'A') && (num_str[i] <= 'F'))
365 *hex_num += (num_str[i] - 'A' + 10);
367 else if ((num_str[i] >= 'a') && (num_str[i] <= 'f'))
370 *hex_num += (num_str[i] - 'a' + 10);
381 int db_ascii_to_int(char *num_str, unsigned long *int_num)
388 if ((num_str[i] >= '0') && (num_str[i] <= '9'))
391 *int_num += (num_str[i] - '0');
402 static int db_hex_to_ascii(unsigned long hex_num, char *num_str)
405 unsigned long four_bits;
409 four_bits = (hex_num >> i*4) & 0xf;
412 num_str[7-i] = four_bits + '0';
416 num_str[7-i] = four_bits - 10 + 'A';
423 int db_help_cmd(char *cmd, char *param1, char *param2, char *param3)
429 A_PRINTF("%s %s\n", ATH_DEBUGGER_VERSION_STR, ATH_COMMAND_LIST_STR);
431 while (command_table[i].cmd_func)
433 A_PRINTF("%s\t%s\n\r", command_table[i].cmd_str,
434 command_table[i].help_str);
440 static int db_ldr_cmd(char *cmd, char *param1, char *param2, char *param3)
447 if (db_ascii_to_hex(param1, &addr) != -1)
451 A_PRINTF("Error! bad address 0x%08x.\n\r",
452 (unsigned long)addr);
455 if (strcmp(cmd, "LDR") == 0)
458 //val = *(unsigned long *)addr;
460 val = ioread32(addr);
462 else if (strcmp(cmd, "LDRH") == 0)
465 val = ioread16(addr);
467 else if (strcmp(cmd, "LDRB") == 0)
471 db_hex_to_ascii(val, val_str);
472 db_hex_to_ascii(addr, addr_str);
474 A_PRINTF("%s : %s\n\r", addr_str, val_str);
478 db_incorect_format();
482 static int db_str_cmd(char *cmd, char *param1, char *param2, char *param3)
489 if ((A_STRLEN(param2) > 0) &&
490 (db_ascii_to_hex(param1, &addr) != -1) &&
491 (db_ascii_to_hex(param2, &val) != -1))
493 if (strcmp(cmd, "STR") == 0)
496 iowrite32(addr, val);
499 else if (strcmp(cmd, "STRH") == 0)
502 //*(volatile unsigned short *)(addr & 0xfffffffe) = (unsigned short)val;
503 iowrite16(addr, val);
505 else if (strcmp(cmd, "STRB") == 0)
507 if( addr & 0x00f00000 )
510 iowrite8(addr^3, val);
511 //*(volatile unsigned char *)addr = (unsigned char)val;
514 db_hex_to_ascii(val, val_str);
515 db_hex_to_ascii(addr, addr_str);
517 A_PRINTF("%s : %s\n\r", addr_str, val_str);
521 db_incorect_format();
525 LOCAL void dbg_timer_func(A_HANDLE alarm, void *data)
527 A_PRINTF("this is a timer alarm function 0x%08x\n\r", xthal_get_ccount());
532 static int db_intr_cmd(char *cmd, char *param1, char *param2, char *param3)
534 #if SYSTEM_MODULE_INTR
535 uint32_t pending_intrs;
537 if(strcmp(param1, "read") == 0 )
540 /* Update snapshot of pending interrupts */
542 pending_intrs = A_INTR_GET_INTRPENDING();
544 A_PRINTF("intr mask [0x%08x]\n\r", xthal_get_intenable());
545 A_PRINTF("intr on [0x%08x]\n\r", pending_intrs);
548 else if (strcmp(param1, "timer") == 0 )
552 if (strcmp(param2, "on") == 0 )
554 /* TODO: this part is probably dead. */
555 pending_intrs = A_INTR_GET_INTRENABLE()|CMNOS_IMASK_XTTIMER;
556 A_INTR_SET_INTRENABLE(pending_intrs);
557 A_PRINTF("- intr [0x%08x]\n\r", pending_intrs);
559 else if ( strcmp(param2, "off") == 0 )
561 pending_intrs = A_INTR_GET_INTRENABLE()&(~CMNOS_IMASK_XTTIMER);
562 A_INTR_SET_INTRENABLE(pending_intrs);
563 A_PRINTF("- intr [0x%08x]\n\r", pending_intrs);
566 else if( db_ascii_to_hex(param2, &data)==0 )
568 if( data>=0 && data <=10 )
573 A_PRINTF("==>set cb to %d seconds \n\r", delay);
579 A_PRINTF("\tintr read - read the interrenable status\n\r");
580 A_PRINTF("\tintr timer on/off/tick - timer attach on/off/ticks\n\r");
584 #endif //#if SYSTEM_MODULE_INTR
588 static int db_usb_cmd(char *cmd, char *param1, char *param2, char *param3)
590 A_PRINTF("THIS IS USB COMMAND\n\r");
592 if( strcmp(param1, "que") == 0 )
594 HIFusb_DescTraceDump();
598 A_PRINTF("\tusb que - dump descriptor queue\n\r");
599 A_PRINTF("\tusb fw on/off - enable/disable write fw download to ram\n\r");
605 static void clk_change(uint32_t clk, uint32_t ratio, uint32_t baud)
607 uint32_t clk_sel = 0;
630 iowrite32(0x50040, (0x300|clk_sel|(ratio>>1)<<12));
631 A_UART_HWINIT((clk*1000*1000)/ratio, baud);
635 static int db_clock_cmd(char *cmd, char *param1, char *param2, char *param3)
638 uint32_t baud = 19200;
641 if( db_ascii_to_int(param1, &clk) != -1 )
643 A_PRINTF("changing clock to %d\n", clk);
644 clk_change(clk, ratio, baud);
648 static int db_info_cmd(char *cmd, char *param1, char *param2, char *param3)
652 if(strcmp(param1, "ram") == 0 )
656 #if 0 /* TODO: SYSTEM_MODULE_SYS_MONITOR depends on _ROM_ or _RAM_ which
658 else if(strcmp(param1, "cpu") == 0)
659 zfPrintCpuUtilization();
662 HIFusb_DescTraceDump();
673 register uint32_t data1;
674 if( db_ascii_to_hex(param1, &data1)==0 )
676 __asm__ __volatile__ (
678 : "=a" (ccount1) : : "memory"
680 data = *(volatile uint32_t *)(data1);
681 __asm__ __volatile__ (
683 : "=a" (ccount2) : : "memory"
685 A_PRINTF("\n\rread 0x%08x (0x%08x) use %d clocks\n\r", data1, data, ccount2-ccount1);
688 __asm__ __volatile__ (
690 : "=a" (ccount1) : : "memory"
692 data = *(volatile uint32_t *)(data1);
693 __asm__ __volatile__ (
695 : "=a" (ccount2) : : "memory"
697 A_PRINTF("\n\rread 0x%08x (0x%08x) use %d clocks\n\r", data1, data, ccount2-ccount1);
700 __asm__ __volatile__ (
702 : "=a" (ccount1) : : "memory"
704 data = *(volatile uint32_t *)(data2);
705 __asm__ __volatile__ (
707 : "=a" (ccount2) : : "memory"
709 A_PRINTF("read 0x%08x (0x%08x) use %d clocks\n\r", data2, data, ccount2-ccount1);
712 __asm__ __volatile__ (
714 : "=a" (ccount1) : : "memory"
716 data = *(volatile uint32_t *)(data3);
717 __asm__ __volatile__ (
719 : "=a" (ccount2) : : "memory"
721 A_PRINTF("read 0x%08x (0x%08x) use %d clocks\n\r", data3, data, ccount2-ccount1);
728 static int db_cmd_starthtc(char *cmd, char *param1, char *param2, char *param3)
730 extern htc_handle_t htc_handle;
731 HTC_Ready(htc_handle);
734 static int db_wdt_cmd(char *cmd, char *param1, char *param2, char *param3)
736 if ( strcmp(param1, "rst") == 0 )
738 A_PRINTF(" reseting...\n\n\r");
741 else if( strcmp(param1, "on") == 0 )
745 else if (strcmp(param1, "off") == 0 )
749 else if ( strcmp(param1, "boot") == 0 )
751 A_PRINTF("Last BOOT is ");
752 if (ENUM_WDT_BOOT == A_WDT_LASTBOOT() )
755 A_PRINTF("normal boot");
757 else if (strcmp(param1, "loop") == 0 )
760 uint32_t time_offset;
761 A_PRINTF(" doing the wdt reseting...");
763 if( db_ascii_to_hex(param2, &time_offset)!=0 )
765 if( time_offset < 0 || time_offset >0xffffffff )
766 time_offset = 0xffffff;
768 A_PRINTF(" (wdt tick: 0x%08x...\n\n\r", time_offset);
769 wdt_cmd.cmd = WDT_TIMEOUT;
770 wdt_cmd.timeout = time_offset;
775 else if (strcmp(param1, "noloop") == 0 )
778 uint32_t time_offset;
779 A_PRINTF(" doing the wdt reseting...");
781 if( db_ascii_to_hex(param3, &time_offset)!=0 )
783 if( time_offset < 0 || time_offset >0xffffffff )
784 time_offset = 0xffffff;
786 A_PRINTF(" (wdt tick: 0x%08x...\n\n\r", time_offset);
788 wdt_cmd.cmd = WDT_TIMEOUT;
789 wdt_cmd.timeout = time_offset;
793 else if( strcmp(param1, "event") == 0 )
795 uint32_t event= 0x00123400;
797 /* disable ep3 intr */
798 iowrite8_usb(0x17, ioread8_usb(0x17)|0xc0);
800 /* ZM_CBUS_FIFO_SIZE_REG = 0xf */
801 iowrite32_usb(0x100, 0x0f);
803 /* ZM_EP3_DATA_REG = event; */
804 iowrite32_usb(0xF8, event);
807 iowrite8_usb(0xAE, ioread8_usb(0xAE) | 0x08);
809 /* enable ep3 intr */
810 iowrite8_usb(0x17, ioread8_usb(0x17) & 0xbf);
814 #if defined(PROJECT_K2)
815 #if SYSTEM_MODULE_SFLASH
816 /* Serial Flash -> Chip Erase, Sector Erase, Block Erase */
817 static int db_cmd_sferase(char *cmd, char *param1, char *param2, char *param3)
821 if (strcmp(param1, "s") == 0)
823 if (db_ascii_to_hex(param2, &addr) != -1 && addr < SPI_FLASH_MAX_SIZE)
825 /* Sector size is 4K (0x1000) */
826 A_PRINTF("Sector addr : 0x%08X\n\r", addr - addr%0x1000);
827 A_SFLASH_ERASE(ZM_SFLASH_SECTOR_ERASE, addr);
832 db_incorect_format();
835 else if (strcmp(param2, "b") == 0)
837 if (db_ascii_to_hex(param2, &addr) != -1 && addr < SPI_FLASH_MAX_SIZE)
839 /* Sector size is 64K (0x10000) */
840 A_PRINTF("Block addr : 0x%08X\n\r", addr - addr%0x10000);
841 A_SFLASH_ERASE(ZM_SFLASH_BLOCK_ERASE, addr);
846 db_incorect_format();
850 else if (strcmp(param1, "c") == 0)
852 A_SFLASH_ERASE(ZM_SFLASH_CHIP_ERASE, addr);
858 db_unknown_command();
862 /* Serial Flash -> Program */
863 static int db_cmd_sfpg(char *cmd, char *param1, char *param2, char *param3)
865 unsigned long addr, len, buf;
867 if (db_ascii_to_hex(param1, &addr) != -1 &&
868 db_ascii_to_hex(param2, &len) != -1 &&
869 db_ascii_to_hex(param3, &buf) != -1 &&
870 ((addr+len) <= SPI_FLASH_MAX_SIZE) &&
871 addr%4 == 0 && len%4 == 0 && buf%4 == 0 &&
872 ((buf >=0x500000 && buf < 0x528000) || (buf >=0x4e0000 && buf < 0x4e6000)) )
874 A_SFLASH_PROG(addr, len, (A_UINT8 *)buf);
880 db_incorect_format();
884 /* Serial Flash -> Read, Fast Read to UART */
885 static int db_cmd_sfru(char *cmd, char *param1, char *param2, char *param3)
888 unsigned long addr1, addr2, t_addr;
891 if (strcmp(param1, "r") == 0)
893 else if (strcmp(param1, "f") == 0)
897 db_unknown_command();
901 if (db_ascii_to_hex(param2, &addr1) != -1 &&
902 db_ascii_to_hex(param3, &addr2) != -1 &&
903 addr1 < addr2 && addr1 < SPI_FLASH_MAX_SIZE &&
904 addr2 < SPI_FLASH_MAX_SIZE && addr1%4 == 0)
906 A_PRINTF("addr data data data data data data data data\n\r");
907 A_PRINTF("====== ======== ======== ======== ======== ======== ======== ======== ========");
909 for (i = 0, t_addr = addr1; t_addr < addr2; i++, t_addr += 4)
912 A_PRINTF("\n\r%06X ", t_addr);
914 A_SFLASH_READ(fast, t_addr, 4, (A_UINT8 *)&val);
915 A_PRINTF("%08X ", val);
922 db_incorect_format();
926 /* Serial Flash -> Read, Fast Read to Memory */
927 static int db_cmd_sfrm(char *cmd, char *param1, char *param2, char *param3)
930 unsigned long addr1, addr2, t_addr;
932 A_UINT8 *buf = (A_UINT8 *)0x520000;
934 if (strcmp(param1, "r") == 0)
936 else if (strcmp(param1, "f") == 0)
940 db_unknown_command();
944 if (db_ascii_to_hex(param2, &addr1) != -1 &&
945 db_ascii_to_hex(param3, &addr2) != -1 &&
946 addr1 < addr2 && addr1 < SPI_FLASH_MAX_SIZE &&
947 addr2 < SPI_FLASH_MAX_SIZE && addr1%4 == 0)
949 for (i = 0, t_addr = addr1; t_addr < addr2; i++, t_addr += 4)
951 A_SFLASH_READ(fast, t_addr, 4, buf + i*4);
958 db_incorect_format();
962 /* Serial Flash -> Read Status Register */
963 static int db_cmd_sfrdsr(char *cmd, char *param1, char *param2, char *param3)
965 A_PRINTF("0x%02X\n\r", A_SFLASH_RDSR());
969 #endif /* #if defined(PROJECT_K2) */
971 /* Memory Comparison */
972 static int db_cmd_memcmp(char *cmd, char *param1, char *param2, char *param3)
974 unsigned long addr1, addr2, len;
975 A_UINT8 *buf1, *buf2;
977 if (db_ascii_to_hex(param1, &addr1) != -1 &&
978 db_ascii_to_hex(param2, &addr2) != -1 &&
979 db_ascii_to_hex(param3, &len) != -1 &&
980 addr1 != addr2 && addr1%4 == 0 && addr2%4 == 0 && len%4 == 0)
982 buf1 = (A_UINT8 *)addr1;
983 buf2 = (A_UINT8 *)addr2; ;
985 A_PRINTF("memcmp(buf1, buf2, len) = %d\n\r", A_MEMCMP(buf1, buf2, len));
989 db_incorect_format();
994 static int db_cmd_memdump(char *cmd, char *param1, char *param2, char *param3)
996 unsigned long addr1, addr2;
998 if (db_ascii_to_hex(param1, &addr1) != -1 && db_ascii_to_hex(param2, &addr2) != -1 && addr1 < addr2 && addr1%4 == 0)
1000 db_print_dump((const char *)addr1, (const char *)addr2);
1004 db_incorect_format();
1007 void cmnos_dbg_module_install(struct dbg_api *apis)
1009 apis->_dbg_init = zf_debug_init;
1010 apis->_dbg_task = zf_debug_task;
1013 #endif /* SYSTEM_MODULE_DBG */