All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: linux-kernel@vger.kernel.org,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Cris <linux-cris-kernel@axis.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH] cris: kgdb: use native hex2bin
Date: Tue, 28 May 2013 18:53:52 +0300	[thread overview]
Message-ID: <1369756432-5552-2-git-send-email-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <1369756432-5552-1-git-send-email-andriy.shevchenko@linux.intel.com>

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/cris/arch-v10/kernel/kgdb.c | 50 ++++++----------------------------------
 1 file changed, 7 insertions(+), 43 deletions(-)

diff --git a/arch/cris/arch-v10/kernel/kgdb.c b/arch/cris/arch-v10/kernel/kgdb.c
index 37e6d2c..07bccd8 100644
--- a/arch/cris/arch-v10/kernel/kgdb.c
+++ b/arch/cris/arch-v10/kernel/kgdb.c
@@ -278,19 +278,11 @@ void putDebugChar (int val);
 
 void enableDebugIRQ (void);
 
-/* Returns the integer equivalent of a hexadecimal character. */
-static int hex (char ch);
-
 /* Convert the memory, pointed to by mem into hexadecimal representation.
    Put the result in buf, and return a pointer to the last character
    in buf (null). */
 static char *mem2hex (char *buf, unsigned char *mem, int count);
 
-/* Convert the array, in hexadecimal representation, pointed to by buf into
-   binary representation. Put the result in mem, and return a pointer to
-   the character after the last byte written. */
-static unsigned char *hex2mem (unsigned char *mem, char *buf, int count);
-
 /* Put the content of the array, in binary representation, pointed to by buf
    into memory pointed to by mem, and return a pointer to
    the character after the last byte written. */
@@ -560,7 +552,7 @@ write_register (int regno, char *val)
 
         if (regno >= R0 && regno <= PC) {
 		/* 32-bit register with simple offset. */
-		hex2mem ((unsigned char *)current_reg + regno * sizeof(unsigned int),
+		hex2bin((unsigned char *)current_reg + regno * sizeof(unsigned int),
 			 val, sizeof(unsigned int));
 	}
         else if (regno == P0 || regno == VR || regno == P4 || regno == P8) {
@@ -570,12 +562,12 @@ write_register (int regno, char *val)
         else if (regno == CCR) {
 		/* 16 bit register with complex offset. (P4 is read-only, P6 is not implemented, 
                    and P7 (MOF) is 32 bits in ETRAX 100LX. */
-		hex2mem ((unsigned char *)&(current_reg->ccr) + (regno-CCR) * sizeof(unsigned short),
+		hex2bin((unsigned char *)&(current_reg->ccr) + (regno-CCR) * sizeof(unsigned short),
 			 val, sizeof(unsigned short));
 	}
 	else if (regno >= MOF && regno <= USP) {
 		/* 32 bit register with complex offset.  (P8 has been taken care of.) */
-		hex2mem ((unsigned char *)&(current_reg->ibr) + (regno-IBR) * sizeof(unsigned int),
+		hex2bin((unsigned char *)&(current_reg->ibr) + (regno-IBR) * sizeof(unsigned int),
 			 val, sizeof(unsigned int));
 	} 
         else {
@@ -595,7 +587,7 @@ write_stack_register (int thread_id, int regno, char *valptr)
 	stack_registers *d = (stack_registers *)stack_list[thread_id];
 	unsigned int val;
 	
-	hex2mem ((unsigned char *)&val, valptr, sizeof(unsigned int));
+	hex2bin((unsigned char *)&val, valptr, sizeof(unsigned int));
 	if (regno >= R0 && regno < SP) {
 		d->r[regno] = val;
 	}
@@ -659,18 +651,6 @@ read_register (char regno, unsigned int *valptr)
 }
 
 /********************************** Packet I/O ******************************/
-/* Returns the integer equivalent of a hexadecimal character. */
-static int
-hex (char ch)
-{
-	if ((ch >= 'a') && (ch <= 'f'))
-		return (ch - 'a' + 10);
-	if ((ch >= '0') && (ch <= '9'))
-		return (ch - '0');
-	if ((ch >= 'A') && (ch <= 'F'))
-		return (ch - 'A' + 10);
-	return (-1);
-}
 
 /* Convert the memory, pointed to by mem into hexadecimal representation.
    Put the result in buf, and return a pointer to the last character
@@ -703,22 +683,6 @@ mem2hex(char *buf, unsigned char *mem, int count)
 	return (buf);
 }
 
-/* Convert the array, in hexadecimal representation, pointed to by buf into
-   binary representation. Put the result in mem, and return a pointer to
-   the character after the last byte written. */
-static unsigned char*
-hex2mem (unsigned char *mem, char *buf, int count)
-{
-	int i;
-	unsigned char ch;
-	for (i = 0; i < count; i++) {
-		ch = hex (*buf++) << 4;
-		ch = ch + hex (*buf++);
-		*mem++ = ch;
-	}
-	return (mem);
-}
-
 /* Put the content of the array, in binary representation, pointed to by buf
    into memory pointed to by mem, and return a pointer to the character after
    the last byte written.
@@ -964,7 +928,7 @@ handle_exception (int sigval)
 				   Success: OK
 				   Failure: void. */
 #ifdef PROCESS_SUPPORT
-				hex2mem ((unsigned char *)&reg_g, &remcomInBuffer[1], sizeof(registers));
+				hex2bin((unsigned char *)&reg_g, &remcomInBuffer[1], sizeof(registers));
 				if (current_thread_g == executing_task) {
 					copy_registers (&reg, &reg_g, sizeof(registers));
 				}
@@ -972,7 +936,7 @@ handle_exception (int sigval)
 					copy_registers_to_stack(current_thread_g, &reg_g);
 				}
 #else
-				hex2mem((char *)&reg, &remcomInBuffer[1], sizeof(registers));
+				hex2bin((char *)&reg, &remcomInBuffer[1], sizeof(registers));
 #endif
 				gdb_cris_strcpy (remcomOutBuffer, "OK");
 				break;
@@ -1053,7 +1017,7 @@ handle_exception (int sigval)
 					int length = gdb_cris_strtol(lenptr+1, &dataptr, 16);
 					if (*lenptr == ',' && *dataptr == ':') {
 						if (remcomInBuffer[0] == 'M') {
-							hex2mem(addr, dataptr + 1, length);
+							hex2bin(addr, dataptr + 1, length);
 						}
 						else /* X */ {
 							bin2mem(addr, dataptr + 1, length);
-- 
1.8.2.rc0.22.gb3600c3


  reply	other threads:[~2013-05-28 15:54 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-23 20:09 Exotic architecture fixes Geert Uytterhoeven
2013-05-28  9:38 ` Geert Uytterhoeven
2013-06-02 19:39   ` Geert Uytterhoeven
2013-06-03  1:28     ` Stephen Rothwell
2013-06-04  7:14       ` Geert Uytterhoeven
2013-05-28 15:53 ` [PATCH] arch/cris: old patch to use hex2bin Andy Shevchenko
2013-05-28 15:53   ` Andy Shevchenko [this message]
2013-05-30  7:57     ` [PATCH] cris: kgdb: use native hex2bin Geert Uytterhoeven
2013-05-30  9:09       ` Andy Shevchenko
  -- strict thread matches above, loose matches on Subject: below --
2013-06-04  8:51 Andy Shevchenko
2013-06-04  9:33 ` Andy Shevchenko
2015-09-30 14:46 ` Andy Shevchenko
2015-09-30 15:22   ` Jesper Nilsson
2015-09-30 15:37     ` Andy Shevchenko
2015-09-30 18:02       ` Jesper Nilsson
2015-09-30 18:11         ` Jesper Nilsson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1369756432-5552-2-git-send-email-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=geert@linux-m68k.org \
    --cc=linux-cris-kernel@axis.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.