FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/lldbg/cmdentry.c @ 865:f5affe83ba2d
lldbg hack (poor girl's substitute for JTAG) implemented
| author | Space Falcon <falcon@ivan.Harhan.ORG> |
|---|---|
| date | Fri, 15 May 2015 00:02:03 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 864:4fa939eada22 | 865:f5affe83ba2d |
|---|---|
| 1 /* | |
| 2 * This module implements ASCII command entry via the serial port, | |
| 3 * with normal echo and minimal editing (rubout and kill). | |
| 4 * | |
| 5 * The command string buffer is bss-allocated here as well. It is | |
| 6 * sized to allow a maximum-size S-record to be sent as a command, | |
| 7 * as that is how we expect flash loading and XRAM chain-loading | |
| 8 * to be done. | |
| 9 */ | |
| 10 | |
| 11 #define MAXCMD 527 | |
| 12 | |
| 13 char lldbg_command[MAXCMD+1]; | |
| 14 | |
| 15 /* | |
| 16 * The command_entry() function takes no arguments, and begins by waiting | |
| 17 * for serial input - hence the prompt should be printed before calling it. | |
| 18 * | |
| 19 * This function returns when one of the following characters is received: | |
| 20 * CR - accepts the command | |
| 21 * ^C or ^U - cancels the command | |
| 22 * | |
| 23 * The return value is non-zero if a non-empty command was accepted with CR, | |
| 24 * or 0 if the user hit CR with no input or if the command was canceled | |
| 25 * with ^C or ^U. In any case a CRLF is sent out the serial port | |
| 26 * to close the input echo line before this function returns. | |
| 27 */ | |
| 28 lldbg_command_entry() | |
| 29 { | |
| 30 int inlen, ch; | |
| 31 | |
| 32 for (inlen = 0; ; ) { | |
| 33 ch = lldbg_getchar(); | |
| 34 if (ch >= ' ' && ch <= '~') { | |
| 35 if (inlen < MAXCMD) { | |
| 36 lldbg_command[inlen++] = ch; | |
| 37 lldbg_putchar(ch); | |
| 38 } else | |
| 39 /* putchar(7) */; | |
| 40 continue; | |
| 41 } | |
| 42 switch (ch) { | |
| 43 case '\r': | |
| 44 case '\n': | |
| 45 lldbg_command[inlen] = '\0'; | |
| 46 lldbg_putchar('\n'); | |
| 47 return(inlen); | |
| 48 case '\b': /* BS */ | |
| 49 case 0x7F: /* DEL */ | |
| 50 if (inlen) { | |
| 51 lldbg_putchar('\b'); | |
| 52 lldbg_putchar(' '); | |
| 53 lldbg_putchar('\b'); | |
| 54 inlen--; | |
| 55 } else | |
| 56 /* putchar(7) */; | |
| 57 continue; | |
| 58 case 0x03: /* ^C */ | |
| 59 lldbg_putchar('^'); | |
| 60 lldbg_putchar('C'); | |
| 61 lldbg_putchar('\n'); | |
| 62 return(0); | |
| 63 case 0x15: /* ^U */ | |
| 64 lldbg_putchar('^'); | |
| 65 lldbg_putchar('U'); | |
| 66 lldbg_putchar('\n'); | |
| 67 return(0); | |
| 68 default: | |
| 69 /* putchar(7) */; | |
| 70 } | |
| 71 } | |
| 72 } |
