diff options
author | Harvey Harrison <harvey.harrison@gmail.com> | 2008-05-12 15:05:43 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2008-05-16 02:09:08 -0400 |
commit | bfd3c7a728fbe642f79f99482a6c01158c675545 (patch) | |
tree | 5ab84c5e56924dd71fcf9b714430b2e84764bc16 | |
parent | 65b83427c6e5814556855c42bf9b4edeafd66623 (diff) |
sh: use the common ascii hex helpers
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
-rw-r--r-- | arch/sh/kernel/kgdb_stub.c | 11 | ||||
-rw-r--r-- | drivers/serial/sh-sci.c | 8 | ||||
-rw-r--r-- | include/asm-sh/kgdb.h | 14 |
3 files changed, 9 insertions, 24 deletions
diff --git a/arch/sh/kernel/kgdb_stub.c b/arch/sh/kernel/kgdb_stub.c index 832641bbd47d..bf8ac4c71640 100644 --- a/arch/sh/kernel/kgdb_stub.c +++ b/arch/sh/kernel/kgdb_stub.c | |||
@@ -274,8 +274,7 @@ static char *mem_to_hex(const char *mem, char *buf, const int count) | |||
274 | } | 274 | } |
275 | for (i = 0; i < count; i++) { | 275 | for (i = 0; i < count; i++) { |
276 | ch = *mem++; | 276 | ch = *mem++; |
277 | *buf++ = highhex(ch); | 277 | buf = pack_hex_byte(buf, ch); |
278 | *buf++ = lowhex(ch); | ||
279 | } | 278 | } |
280 | *buf = 0; | 279 | *buf = 0; |
281 | return (buf); | 280 | return (buf); |
@@ -427,8 +426,8 @@ static void put_packet(char *buffer) | |||
427 | 426 | ||
428 | /* '#' Separator, put high and low components of checksum */ | 427 | /* '#' Separator, put high and low components of checksum */ |
429 | put_debug_char('#'); | 428 | put_debug_char('#'); |
430 | put_debug_char(highhex(checksum)); | 429 | put_debug_char(hex_asc_hi(checksum)); |
431 | put_debug_char(lowhex(checksum)); | 430 | put_debug_char(hex_asc_lo(checksum)); |
432 | } | 431 | } |
433 | while ((get_debug_char()) != '+'); /* While no ack */ | 432 | while ((get_debug_char()) != '+'); /* While no ack */ |
434 | } | 433 | } |
@@ -650,8 +649,8 @@ static void undo_single_step(void) | |||
650 | static void send_signal_msg(const int signum) | 649 | static void send_signal_msg(const int signum) |
651 | { | 650 | { |
652 | out_buffer[0] = 'S'; | 651 | out_buffer[0] = 'S'; |
653 | out_buffer[1] = highhex(signum); | 652 | out_buffer[1] = hex_asc_hi(signum); |
654 | out_buffer[2] = lowhex(signum); | 653 | out_buffer[2] = hex_asc_lo(signum); |
655 | out_buffer[3] = 0; | 654 | out_buffer[3] = 0; |
656 | put_packet(out_buffer); | 655 | put_packet(out_buffer); |
657 | } | 656 | } |
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c index 8fdafc27fce8..ce6ee92b3a1b 100644 --- a/drivers/serial/sh-sci.c +++ b/drivers/serial/sh-sci.c | |||
@@ -184,15 +184,15 @@ static void put_string(struct sci_port *sci_port, const char *buffer, int count) | |||
184 | int h, l; | 184 | int h, l; |
185 | 185 | ||
186 | c = *p++; | 186 | c = *p++; |
187 | h = highhex(c); | 187 | h = hex_asc_hi(c); |
188 | l = lowhex(c); | 188 | l = hex_asc_lo(c); |
189 | put_char(port, h); | 189 | put_char(port, h); |
190 | put_char(port, l); | 190 | put_char(port, l); |
191 | checksum += h + l; | 191 | checksum += h + l; |
192 | } | 192 | } |
193 | put_char(port, '#'); | 193 | put_char(port, '#'); |
194 | put_char(port, highhex(checksum)); | 194 | put_char(port, hex_asc_hi(checksum)); |
195 | put_char(port, lowhex(checksum)); | 195 | put_char(port, hex_asc_lo(checksum)); |
196 | } while (get_char(port) != '+'); | 196 | } while (get_char(port) != '+'); |
197 | } else | 197 | } else |
198 | #endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_SH_KGDB */ | 198 | #endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_SH_KGDB */ |
diff --git a/include/asm-sh/kgdb.h b/include/asm-sh/kgdb.h index 4bc8cb187d11..24e42078f36f 100644 --- a/include/asm-sh/kgdb.h +++ b/include/asm-sh/kgdb.h | |||
@@ -66,18 +66,4 @@ extern int setjmp(jmp_buf __jmpb); | |||
66 | /* Forced breakpoint */ | 66 | /* Forced breakpoint */ |
67 | #define breakpoint() __asm__ __volatile__("trapa #0x3c") | 67 | #define breakpoint() __asm__ __volatile__("trapa #0x3c") |
68 | 68 | ||
69 | /* Taken from sh-stub.c of GDB 4.18 */ | ||
70 | static const char hexchars[] = "0123456789abcdef"; | ||
71 | |||
72 | /* Get high hex bits */ | ||
73 | static inline char highhex(const int x) | ||
74 | { | ||
75 | return hexchars[(x >> 4) & 0xf]; | ||
76 | } | ||
77 | |||
78 | /* Get low hex bits */ | ||
79 | static inline char lowhex(const int x) | ||
80 | { | ||
81 | return hexchars[x & 0xf]; | ||
82 | } | ||
83 | #endif | 69 | #endif |