diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2015-10-01 07:42:29 -0400 |
---|---|---|
committer | Jesper Nilsson <jespern@axis.com> | 2015-11-02 14:03:04 -0500 |
commit | 4d0d39758d3e10a31e7f146d56760a92396feb85 (patch) | |
tree | ff92670f49e587f3896cda79c4767d5df9cc6fea | |
parent | 6a13feb9c82803e2b815eca72fa7a9f5561d7861 (diff) |
cris: kgdb: use native hex2bin
There are kernel native helpers to convert hex ascii to the binary format:
hex_to_bin() and hex2bin(). Thus, no need to reimplement them customly.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Jesper Nilsson <jespern@axis.com>
-rw-r--r-- | arch/cris/arch-v10/kernel/kgdb.c | 83 | ||||
-rw-r--r-- | arch/cris/arch-v32/kernel/kgdb.c | 96 |
2 files changed, 71 insertions, 108 deletions
diff --git a/arch/cris/arch-v10/kernel/kgdb.c b/arch/cris/arch-v10/kernel/kgdb.c index 22d846bfc570..6b7616476af5 100644 --- a/arch/cris/arch-v10/kernel/kgdb.c +++ b/arch/cris/arch-v10/kernel/kgdb.c | |||
@@ -275,7 +275,7 @@ static char remcomOutBuffer[BUFMAX]; | |||
275 | /* Error and warning messages. */ | 275 | /* Error and warning messages. */ |
276 | enum error_type | 276 | enum error_type |
277 | { | 277 | { |
278 | SUCCESS, E01, E02, E03, E04, E05, E06, E07 | 278 | SUCCESS, E01, E02, E03, E04, E05, E06, E07, E08 |
279 | }; | 279 | }; |
280 | static char *error_message[] = | 280 | static char *error_message[] = |
281 | { | 281 | { |
@@ -286,7 +286,8 @@ static char *error_message[] = | |||
286 | "E04 The command is not supported - [s,C,S,!,R,d,r] - internal error.", | 286 | "E04 The command is not supported - [s,C,S,!,R,d,r] - internal error.", |
287 | "E05 Change register content - P - the register is not implemented..", | 287 | "E05 Change register content - P - the register is not implemented..", |
288 | "E06 Change memory content - M - internal error.", | 288 | "E06 Change memory content - M - internal error.", |
289 | "E07 Change register content - P - the register is not stored on the stack" | 289 | "E07 Change register content - P - the register is not stored on the stack", |
290 | "E08 Invalid parameter" | ||
290 | }; | 291 | }; |
291 | /********************************* Register image ****************************/ | 292 | /********************************* Register image ****************************/ |
292 | /* Use the order of registers as defined in "AXIS ETRAX CRIS Programmer's | 293 | /* Use the order of registers as defined in "AXIS ETRAX CRIS Programmer's |
@@ -413,18 +414,6 @@ gdb_cris_strtol (const char *s, char **endptr, int base) | |||
413 | } | 414 | } |
414 | 415 | ||
415 | /********************************** Packet I/O ******************************/ | 416 | /********************************** Packet I/O ******************************/ |
416 | /* Returns the integer equivalent of a hexadecimal character. */ | ||
417 | static int | ||
418 | hex (char ch) | ||
419 | { | ||
420 | if ((ch >= 'a') && (ch <= 'f')) | ||
421 | return (ch - 'a' + 10); | ||
422 | if ((ch >= '0') && (ch <= '9')) | ||
423 | return (ch - '0'); | ||
424 | if ((ch >= 'A') && (ch <= 'F')) | ||
425 | return (ch - 'A' + 10); | ||
426 | return (-1); | ||
427 | } | ||
428 | 417 | ||
429 | /* Convert the memory, pointed to by mem into hexadecimal representation. | 418 | /* Convert the memory, pointed to by mem into hexadecimal representation. |
430 | Put the result in buf, and return a pointer to the last character | 419 | Put the result in buf, and return a pointer to the last character |
@@ -455,22 +444,6 @@ mem2hex(char *buf, unsigned char *mem, int count) | |||
455 | return (buf); | 444 | return (buf); |
456 | } | 445 | } |
457 | 446 | ||
458 | /* Convert the array, in hexadecimal representation, pointed to by buf into | ||
459 | binary representation. Put the result in mem, and return a pointer to | ||
460 | the character after the last byte written. */ | ||
461 | static unsigned char* | ||
462 | hex2mem (unsigned char *mem, char *buf, int count) | ||
463 | { | ||
464 | int i; | ||
465 | unsigned char ch; | ||
466 | for (i = 0; i < count; i++) { | ||
467 | ch = hex (*buf++) << 4; | ||
468 | ch = ch + hex (*buf++); | ||
469 | *mem++ = ch; | ||
470 | } | ||
471 | return (mem); | ||
472 | } | ||
473 | |||
474 | /* Put the content of the array, in binary representation, pointed to by buf | 447 | /* Put the content of the array, in binary representation, pointed to by buf |
475 | into memory pointed to by mem, and return a pointer to the character after | 448 | into memory pointed to by mem, and return a pointer to the character after |
476 | the last byte written. | 449 | the last byte written. |
@@ -524,8 +497,8 @@ getpacket (char *buffer) | |||
524 | buffer[count] = '\0'; | 497 | buffer[count] = '\0'; |
525 | 498 | ||
526 | if (ch == '#') { | 499 | if (ch == '#') { |
527 | xmitcsum = hex (getDebugChar ()) << 4; | 500 | xmitcsum = hex_to_bin(getDebugChar()) << 4; |
528 | xmitcsum += hex (getDebugChar ()); | 501 | xmitcsum += hex_to_bin(getDebugChar()); |
529 | if (checksum != xmitcsum) { | 502 | if (checksum != xmitcsum) { |
530 | /* Wrong checksum */ | 503 | /* Wrong checksum */ |
531 | putDebugChar ('-'); | 504 | putDebugChar ('-'); |
@@ -599,7 +572,7 @@ putDebugString (const unsigned char *str, int length) | |||
599 | 572 | ||
600 | /********************************* Register image ****************************/ | 573 | /********************************* Register image ****************************/ |
601 | /* Write a value to a specified register in the register image of the current | 574 | /* Write a value to a specified register in the register image of the current |
602 | thread. Returns status code SUCCESS, E02 or E05. */ | 575 | thread. Returns status code SUCCESS, E02, E05 or E08. */ |
603 | static int | 576 | static int |
604 | write_register (int regno, char *val) | 577 | write_register (int regno, char *val) |
605 | { | 578 | { |
@@ -608,8 +581,9 @@ write_register (int regno, char *val) | |||
608 | 581 | ||
609 | if (regno >= R0 && regno <= PC) { | 582 | if (regno >= R0 && regno <= PC) { |
610 | /* 32-bit register with simple offset. */ | 583 | /* 32-bit register with simple offset. */ |
611 | hex2mem ((unsigned char *)current_reg + regno * sizeof(unsigned int), | 584 | if (hex2bin((unsigned char *)current_reg + regno * sizeof(unsigned int), |
612 | val, sizeof(unsigned int)); | 585 | val, sizeof(unsigned int))) |
586 | status = E08; | ||
613 | } | 587 | } |
614 | else if (regno == P0 || regno == VR || regno == P4 || regno == P8) { | 588 | else if (regno == P0 || regno == VR || regno == P4 || regno == P8) { |
615 | /* Do not support read-only registers. */ | 589 | /* Do not support read-only registers. */ |
@@ -618,13 +592,15 @@ write_register (int regno, char *val) | |||
618 | else if (regno == CCR) { | 592 | else if (regno == CCR) { |
619 | /* 16 bit register with complex offset. (P4 is read-only, P6 is not implemented, | 593 | /* 16 bit register with complex offset. (P4 is read-only, P6 is not implemented, |
620 | and P7 (MOF) is 32 bits in ETRAX 100LX. */ | 594 | and P7 (MOF) is 32 bits in ETRAX 100LX. */ |
621 | hex2mem ((unsigned char *)&(current_reg->ccr) + (regno-CCR) * sizeof(unsigned short), | 595 | if (hex2bin((unsigned char *)&(current_reg->ccr) + (regno-CCR) * sizeof(unsigned short), |
622 | val, sizeof(unsigned short)); | 596 | val, sizeof(unsigned short))) |
597 | status = E08; | ||
623 | } | 598 | } |
624 | else if (regno >= MOF && regno <= USP) { | 599 | else if (regno >= MOF && regno <= USP) { |
625 | /* 32 bit register with complex offset. (P8 has been taken care of.) */ | 600 | /* 32 bit register with complex offset. (P8 has been taken care of.) */ |
626 | hex2mem ((unsigned char *)&(current_reg->ibr) + (regno-IBR) * sizeof(unsigned int), | 601 | if (hex2bin((unsigned char *)&(current_reg->ibr) + (regno-IBR) * sizeof(unsigned int), |
627 | val, sizeof(unsigned int)); | 602 | val, sizeof(unsigned int))) |
603 | status = E08; | ||
628 | } | 604 | } |
629 | else { | 605 | else { |
630 | /* Do not support nonexisting or unimplemented registers (P2, P3, and P6). */ | 606 | /* Do not support nonexisting or unimplemented registers (P2, P3, and P6). */ |
@@ -759,9 +735,11 @@ handle_exception (int sigval) | |||
759 | /* Write registers. GXX..XX | 735 | /* Write registers. GXX..XX |
760 | Each byte of register data is described by two hex digits. | 736 | Each byte of register data is described by two hex digits. |
761 | Success: OK | 737 | Success: OK |
762 | Failure: void. */ | 738 | Failure: E08. */ |
763 | hex2mem((char *)&cris_reg, &remcomInBuffer[1], sizeof(registers)); | 739 | if (hex2bin((char *)&cris_reg, &remcomInBuffer[1], sizeof(registers))) |
764 | gdb_cris_strcpy (remcomOutBuffer, "OK"); | 740 | gdb_cris_strcpy (remcomOutBuffer, error_message[E08]); |
741 | else | ||
742 | gdb_cris_strcpy (remcomOutBuffer, "OK"); | ||
765 | break; | 743 | break; |
766 | 744 | ||
767 | case 'P': | 745 | case 'P': |
@@ -771,7 +749,7 @@ handle_exception (int sigval) | |||
771 | for each byte in the register (target byte order). P1f=11223344 means | 749 | for each byte in the register (target byte order). P1f=11223344 means |
772 | set register 31 to 44332211. | 750 | set register 31 to 44332211. |
773 | Success: OK | 751 | Success: OK |
774 | Failure: E02, E05 */ | 752 | Failure: E02, E05, E08 */ |
775 | { | 753 | { |
776 | char *suffix; | 754 | char *suffix; |
777 | int regno = gdb_cris_strtol (&remcomInBuffer[1], &suffix, 16); | 755 | int regno = gdb_cris_strtol (&remcomInBuffer[1], &suffix, 16); |
@@ -791,6 +769,10 @@ handle_exception (int sigval) | |||
791 | /* Do not support non-existing registers on the stack. */ | 769 | /* Do not support non-existing registers on the stack. */ |
792 | gdb_cris_strcpy (remcomOutBuffer, error_message[E07]); | 770 | gdb_cris_strcpy (remcomOutBuffer, error_message[E07]); |
793 | break; | 771 | break; |
772 | case E08: | ||
773 | /* Invalid parameter. */ | ||
774 | gdb_cris_strcpy (remcomOutBuffer, error_message[E08]); | ||
775 | break; | ||
794 | default: | 776 | default: |
795 | /* Valid register number. */ | 777 | /* Valid register number. */ |
796 | gdb_cris_strcpy (remcomOutBuffer, "OK"); | 778 | gdb_cris_strcpy (remcomOutBuffer, "OK"); |
@@ -826,7 +808,7 @@ handle_exception (int sigval) | |||
826 | AA..AA is the start address, LLLL is the number of bytes, and | 808 | AA..AA is the start address, LLLL is the number of bytes, and |
827 | XX..XX is the hexadecimal data. | 809 | XX..XX is the hexadecimal data. |
828 | Success: OK | 810 | Success: OK |
829 | Failure: void. */ | 811 | Failure: E08. */ |
830 | { | 812 | { |
831 | char *lenptr; | 813 | char *lenptr; |
832 | char *dataptr; | 814 | char *dataptr; |
@@ -835,14 +817,15 @@ handle_exception (int sigval) | |||
835 | int length = gdb_cris_strtol(lenptr+1, &dataptr, 16); | 817 | int length = gdb_cris_strtol(lenptr+1, &dataptr, 16); |
836 | if (*lenptr == ',' && *dataptr == ':') { | 818 | if (*lenptr == ',' && *dataptr == ':') { |
837 | if (remcomInBuffer[0] == 'M') { | 819 | if (remcomInBuffer[0] == 'M') { |
838 | hex2mem(addr, dataptr + 1, length); | 820 | if (hex2bin(addr, dataptr + 1, length)) |
839 | } | 821 | gdb_cris_strcpy (remcomOutBuffer, error_message[E08]); |
840 | else /* X */ { | 822 | else |
823 | gdb_cris_strcpy (remcomOutBuffer, "OK"); | ||
824 | } else /* X */ { | ||
841 | bin2mem(addr, dataptr + 1, length); | 825 | bin2mem(addr, dataptr + 1, length); |
826 | gdb_cris_strcpy (remcomOutBuffer, "OK"); | ||
842 | } | 827 | } |
843 | gdb_cris_strcpy (remcomOutBuffer, "OK"); | 828 | } else { |
844 | } | ||
845 | else { | ||
846 | gdb_cris_strcpy (remcomOutBuffer, error_message[E06]); | 829 | gdb_cris_strcpy (remcomOutBuffer, error_message[E06]); |
847 | } | 830 | } |
848 | } | 831 | } |
diff --git a/arch/cris/arch-v32/kernel/kgdb.c b/arch/cris/arch-v32/kernel/kgdb.c index b06813aeb120..e0fdea706eca 100644 --- a/arch/cris/arch-v32/kernel/kgdb.c +++ b/arch/cris/arch-v32/kernel/kgdb.c | |||
@@ -384,19 +384,11 @@ int getDebugChar(void); | |||
384 | /* Serial port, writes one character. ETRAX 100 specific. from debugport.c */ | 384 | /* Serial port, writes one character. ETRAX 100 specific. from debugport.c */ |
385 | void putDebugChar(int val); | 385 | void putDebugChar(int val); |
386 | 386 | ||
387 | /* Returns the integer equivalent of a hexadecimal character. */ | ||
388 | static int hex(char ch); | ||
389 | |||
390 | /* Convert the memory, pointed to by mem into hexadecimal representation. | 387 | /* Convert the memory, pointed to by mem into hexadecimal representation. |
391 | Put the result in buf, and return a pointer to the last character | 388 | Put the result in buf, and return a pointer to the last character |
392 | in buf (null). */ | 389 | in buf (null). */ |
393 | static char *mem2hex(char *buf, unsigned char *mem, int count); | 390 | static char *mem2hex(char *buf, unsigned char *mem, int count); |
394 | 391 | ||
395 | /* Convert the array, in hexadecimal representation, pointed to by buf into | ||
396 | binary representation. Put the result in mem, and return a pointer to | ||
397 | the character after the last byte written. */ | ||
398 | static unsigned char *hex2mem(unsigned char *mem, char *buf, int count); | ||
399 | |||
400 | /* Put the content of the array, in binary representation, pointed to by buf | 392 | /* Put the content of the array, in binary representation, pointed to by buf |
401 | into memory pointed to by mem, and return a pointer to | 393 | into memory pointed to by mem, and return a pointer to |
402 | the character after the last byte written. */ | 394 | the character after the last byte written. */ |
@@ -449,7 +441,7 @@ static char output_buffer[BUFMAX]; | |||
449 | /* Error and warning messages. */ | 441 | /* Error and warning messages. */ |
450 | enum error_type | 442 | enum error_type |
451 | { | 443 | { |
452 | SUCCESS, E01, E02, E03, E04, E05, E06, | 444 | SUCCESS, E01, E02, E03, E04, E05, E06, E07, E08 |
453 | }; | 445 | }; |
454 | 446 | ||
455 | static char *error_message[] = | 447 | static char *error_message[] = |
@@ -461,6 +453,8 @@ static char *error_message[] = | |||
461 | "E04 The command is not supported - [s,C,S,!,R,d,r] - internal error.", | 453 | "E04 The command is not supported - [s,C,S,!,R,d,r] - internal error.", |
462 | "E05 Change register content - P - the register is not implemented..", | 454 | "E05 Change register content - P - the register is not implemented..", |
463 | "E06 Change memory content - M - internal error.", | 455 | "E06 Change memory content - M - internal error.", |
456 | "E07 Change register content - P - the register is not stored on the stack", | ||
457 | "E08 Invalid parameter" | ||
464 | }; | 458 | }; |
465 | 459 | ||
466 | /********************************** Breakpoint *******************************/ | 460 | /********************************** Breakpoint *******************************/ |
@@ -539,7 +533,7 @@ gdb_cris_strtol(const char *s, char **endptr, int base) | |||
539 | /********************************* Register image ****************************/ | 533 | /********************************* Register image ****************************/ |
540 | 534 | ||
541 | /* Write a value to a specified register in the register image of the current | 535 | /* Write a value to a specified register in the register image of the current |
542 | thread. Returns status code SUCCESS, E02 or E05. */ | 536 | thread. Returns status code SUCCESS, E02, E05 or E08. */ |
543 | static int | 537 | static int |
544 | write_register(int regno, char *val) | 538 | write_register(int regno, char *val) |
545 | { | 539 | { |
@@ -547,8 +541,9 @@ write_register(int regno, char *val) | |||
547 | 541 | ||
548 | if (regno >= R0 && regno <= ACR) { | 542 | if (regno >= R0 && regno <= ACR) { |
549 | /* Consecutive 32-bit registers. */ | 543 | /* Consecutive 32-bit registers. */ |
550 | hex2mem((unsigned char *)®.r0 + (regno - R0) * sizeof(unsigned int), | 544 | if (hex2bin((unsigned char *)®.r0 + (regno - R0) * sizeof(unsigned int), |
551 | val, sizeof(unsigned int)); | 545 | val, sizeof(unsigned int))) |
546 | status = E08; | ||
552 | 547 | ||
553 | } else if (regno == BZ || regno == VR || regno == WZ || regno == DZ) { | 548 | } else if (regno == BZ || regno == VR || regno == WZ || regno == DZ) { |
554 | /* Read-only registers. */ | 549 | /* Read-only registers. */ |
@@ -557,16 +552,19 @@ write_register(int regno, char *val) | |||
557 | } else if (regno == PID) { | 552 | } else if (regno == PID) { |
558 | /* 32-bit register. (Even though we already checked SRS and WZ, we cannot | 553 | /* 32-bit register. (Even though we already checked SRS and WZ, we cannot |
559 | combine this with the EXS - SPC write since SRS and WZ have different size.) */ | 554 | combine this with the EXS - SPC write since SRS and WZ have different size.) */ |
560 | hex2mem((unsigned char *)®.pid, val, sizeof(unsigned int)); | 555 | if (hex2bin((unsigned char *)®.pid, val, sizeof(unsigned int))) |
556 | status = E08; | ||
561 | 557 | ||
562 | } else if (regno == SRS) { | 558 | } else if (regno == SRS) { |
563 | /* 8-bit register. */ | 559 | /* 8-bit register. */ |
564 | hex2mem((unsigned char *)®.srs, val, sizeof(unsigned char)); | 560 | if (hex2bin((unsigned char *)®.srs, val, sizeof(unsigned char))) |
561 | status = E08; | ||
565 | 562 | ||
566 | } else if (regno >= EXS && regno <= SPC) { | 563 | } else if (regno >= EXS && regno <= SPC) { |
567 | /* Consecutive 32-bit registers. */ | 564 | /* Consecutive 32-bit registers. */ |
568 | hex2mem((unsigned char *)®.exs + (regno - EXS) * sizeof(unsigned int), | 565 | if (hex2bin((unsigned char *)®.exs + (regno - EXS) * sizeof(unsigned int), |
569 | val, sizeof(unsigned int)); | 566 | val, sizeof(unsigned int))) |
567 | status = E08; | ||
570 | 568 | ||
571 | } else if (regno == PC) { | 569 | } else if (regno == PC) { |
572 | /* Pseudo-register. Treat as read-only. */ | 570 | /* Pseudo-register. Treat as read-only. */ |
@@ -574,7 +572,9 @@ write_register(int regno, char *val) | |||
574 | 572 | ||
575 | } else if (regno >= S0 && regno <= S15) { | 573 | } else if (regno >= S0 && regno <= S15) { |
576 | /* 32-bit registers. */ | 574 | /* 32-bit registers. */ |
577 | hex2mem((unsigned char *)&sreg.s0_0 + (reg.srs * 16 * sizeof(unsigned int)) + (regno - S0) * sizeof(unsigned int), val, sizeof(unsigned int)); | 575 | if (hex2bin((unsigned char *)&sreg.s0_0 + (reg.srs * 16 * sizeof(unsigned int)) + (regno - S0) * sizeof(unsigned int), |
576 | val, sizeof(unsigned int))) | ||
577 | status = E08; | ||
578 | } else { | 578 | } else { |
579 | /* Non-existing register. */ | 579 | /* Non-existing register. */ |
580 | status = E05; | 580 | status = E05; |
@@ -630,19 +630,6 @@ read_register(char regno, unsigned int *valptr) | |||
630 | } | 630 | } |
631 | 631 | ||
632 | /********************************** Packet I/O ******************************/ | 632 | /********************************** Packet I/O ******************************/ |
633 | /* Returns the integer equivalent of a hexadecimal character. */ | ||
634 | static int | ||
635 | hex(char ch) | ||
636 | { | ||
637 | if ((ch >= 'a') && (ch <= 'f')) | ||
638 | return (ch - 'a' + 10); | ||
639 | if ((ch >= '0') && (ch <= '9')) | ||
640 | return (ch - '0'); | ||
641 | if ((ch >= 'A') && (ch <= 'F')) | ||
642 | return (ch - 'A' + 10); | ||
643 | return -1; | ||
644 | } | ||
645 | |||
646 | /* Convert the memory, pointed to by mem into hexadecimal representation. | 633 | /* Convert the memory, pointed to by mem into hexadecimal representation. |
647 | Put the result in buf, and return a pointer to the last character | 634 | Put the result in buf, and return a pointer to the last character |
648 | in buf (null). */ | 635 | in buf (null). */ |
@@ -689,22 +676,6 @@ mem2hex_nbo(char *buf, unsigned char *mem, int count) | |||
689 | return buf; | 676 | return buf; |
690 | } | 677 | } |
691 | 678 | ||
692 | /* Convert the array, in hexadecimal representation, pointed to by buf into | ||
693 | binary representation. Put the result in mem, and return a pointer to | ||
694 | the character after the last byte written. */ | ||
695 | static unsigned char* | ||
696 | hex2mem(unsigned char *mem, char *buf, int count) | ||
697 | { | ||
698 | int i; | ||
699 | unsigned char ch; | ||
700 | for (i = 0; i < count; i++) { | ||
701 | ch = hex (*buf++) << 4; | ||
702 | ch = ch + hex (*buf++); | ||
703 | *mem++ = ch; | ||
704 | } | ||
705 | return mem; | ||
706 | } | ||
707 | |||
708 | /* Put the content of the array, in binary representation, pointed to by buf | 679 | /* Put the content of the array, in binary representation, pointed to by buf |
709 | into memory pointed to by mem, and return a pointer to the character after | 680 | into memory pointed to by mem, and return a pointer to the character after |
710 | the last byte written. | 681 | the last byte written. |
@@ -763,8 +734,8 @@ getpacket(char *buffer) | |||
763 | buffer[count] = 0; | 734 | buffer[count] = 0; |
764 | 735 | ||
765 | if (ch == '#') { | 736 | if (ch == '#') { |
766 | xmitcsum = hex(getDebugChar()) << 4; | 737 | xmitcsum = hex_to_bin(getDebugChar()) << 4; |
767 | xmitcsum += hex(getDebugChar()); | 738 | xmitcsum += hex_to_bin(getDebugChar()); |
768 | if (checksum != xmitcsum) { | 739 | if (checksum != xmitcsum) { |
769 | /* Wrong checksum */ | 740 | /* Wrong checksum */ |
770 | putDebugChar('-'); | 741 | putDebugChar('-'); |
@@ -1304,14 +1275,17 @@ handle_exception(int sigval) | |||
1304 | /* Write registers. GXX..XX | 1275 | /* Write registers. GXX..XX |
1305 | Each byte of register data is described by two hex digits. | 1276 | Each byte of register data is described by two hex digits. |
1306 | Success: OK | 1277 | Success: OK |
1307 | Failure: void. */ | 1278 | Failure: E08. */ |
1308 | /* General and special registers. */ | 1279 | /* General and special registers. */ |
1309 | hex2mem((char *)®, &input_buffer[1], sizeof(registers)); | 1280 | if (hex2bin((char *)®, &input_buffer[1], sizeof(registers))) |
1281 | gdb_cris_strcpy(output_buffer, error_message[E08]); | ||
1310 | /* Support registers. */ | 1282 | /* Support registers. */ |
1311 | hex2mem((char *)&sreg + (reg.srs * 16 * sizeof(unsigned int)), | 1283 | else if (hex2bin((char *)&sreg + (reg.srs * 16 * sizeof(unsigned int)), |
1312 | &input_buffer[1] + sizeof(registers), | 1284 | &input_buffer[1] + sizeof(registers), |
1313 | 16 * sizeof(unsigned int)); | 1285 | 16 * sizeof(unsigned int))) |
1314 | gdb_cris_strcpy(output_buffer, "OK"); | 1286 | gdb_cris_strcpy(output_buffer, error_message[E08]); |
1287 | else | ||
1288 | gdb_cris_strcpy(output_buffer, "OK"); | ||
1315 | break; | 1289 | break; |
1316 | 1290 | ||
1317 | case 'P': | 1291 | case 'P': |
@@ -1338,6 +1312,10 @@ handle_exception(int sigval) | |||
1338 | /* Do not support non-existing registers. */ | 1312 | /* Do not support non-existing registers. */ |
1339 | gdb_cris_strcpy(output_buffer, error_message[E05]); | 1313 | gdb_cris_strcpy(output_buffer, error_message[E05]); |
1340 | break; | 1314 | break; |
1315 | case E08: | ||
1316 | /* Invalid parameter. */ | ||
1317 | gdb_cris_strcpy(output_buffer, error_message[E08]); | ||
1318 | break; | ||
1341 | default: | 1319 | default: |
1342 | /* Valid register number. */ | 1320 | /* Valid register number. */ |
1343 | gdb_cris_strcpy(output_buffer, "OK"); | 1321 | gdb_cris_strcpy(output_buffer, "OK"); |
@@ -1380,7 +1358,7 @@ handle_exception(int sigval) | |||
1380 | AA..AA is the start address, LLLL is the number of bytes, and | 1358 | AA..AA is the start address, LLLL is the number of bytes, and |
1381 | XX..XX is the hexadecimal data. | 1359 | XX..XX is the hexadecimal data. |
1382 | Success: OK | 1360 | Success: OK |
1383 | Failure: void. */ | 1361 | Failure: E08. */ |
1384 | { | 1362 | { |
1385 | char *lenptr; | 1363 | char *lenptr; |
1386 | char *dataptr; | 1364 | char *dataptr; |
@@ -1389,13 +1367,15 @@ handle_exception(int sigval) | |||
1389 | int len = gdb_cris_strtol(lenptr+1, &dataptr, 16); | 1367 | int len = gdb_cris_strtol(lenptr+1, &dataptr, 16); |
1390 | if (*lenptr == ',' && *dataptr == ':') { | 1368 | if (*lenptr == ',' && *dataptr == ':') { |
1391 | if (input_buffer[0] == 'M') { | 1369 | if (input_buffer[0] == 'M') { |
1392 | hex2mem(addr, dataptr + 1, len); | 1370 | if (hex2bin(addr, dataptr + 1, len)) |
1371 | gdb_cris_strcpy(output_buffer, error_message[E08]); | ||
1372 | else | ||
1373 | gdb_cris_strcpy(output_buffer, "OK"); | ||
1393 | } else /* X */ { | 1374 | } else /* X */ { |
1394 | bin2mem(addr, dataptr + 1, len); | 1375 | bin2mem(addr, dataptr + 1, len); |
1376 | gdb_cris_strcpy(output_buffer, "OK"); | ||
1395 | } | 1377 | } |
1396 | gdb_cris_strcpy(output_buffer, "OK"); | 1378 | } else { |
1397 | } | ||
1398 | else { | ||
1399 | gdb_cris_strcpy(output_buffer, error_message[E06]); | 1379 | gdb_cris_strcpy(output_buffer, error_message[E06]); |
1400 | } | 1380 | } |
1401 | } | 1381 | } |