aboutsummaryrefslogtreecommitdiffstats
path: root/arch/cris
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert@linux-m68k.org>2013-02-11 14:37:19 -0500
committerGeert Uytterhoeven <geert@linux-m68k.org>2013-06-16 07:47:22 -0400
commit4bf01dda083bd3a0d2e8e6e6287a42355852b6cb (patch)
tree5177e7b84ec3850bd6d82be187f26c8acdc1341f /arch/cris
parent4bb77a9dface5f3b8ee97f2857dc693bbc94120a (diff)
cris/kgdb: Kill forward declarations for static functions
Move some functions around and kill forward declarations for static functions. This fixes: arch/cris/arch-v10/kernel/kgdb.c:255:13: warning: 'copy_registers_from_stack' declared 'static' but never defined [-Wunused-function] arch/cris/arch-v10/kernel/kgdb.c:259:13: warning: 'copy_registers_to_stack' declared 'static' but never defined [-Wunused-function] arch/cris/arch-v10/kernel/kgdb.c:267:12: warning: 'write_stack_register' declared 'static' but never defined [-Wunused-function] Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Diffstat (limited to 'arch/cris')
-rw-r--r--arch/cris/arch-v10/kernel/kgdb.c406
1 files changed, 165 insertions, 241 deletions
diff --git a/arch/cris/arch-v10/kernel/kgdb.c b/arch/cris/arch-v10/kernel/kgdb.c
index 6b64567e63ed..3c852b3141c6 100644
--- a/arch/cris/arch-v10/kernel/kgdb.c
+++ b/arch/cris/arch-v10/kernel/kgdb.c
@@ -230,46 +230,6 @@ struct register_image
230 unsigned int usp; /* 0x66 User mode stack pointer */ 230 unsigned int usp; /* 0x66 User mode stack pointer */
231} registers; 231} registers;
232 232
233/************** Prototypes for local library functions ***********************/
234
235/* Copy of strcpy from libc. */
236static char *gdb_cris_strcpy (char *s1, const char *s2);
237
238/* Copy of strlen from libc. */
239static int gdb_cris_strlen (const char *s);
240
241/* Copy of memchr from libc. */
242static void *gdb_cris_memchr (const void *s, int c, int n);
243
244/* Copy of strtol from libc. Does only support base 16. */
245static int gdb_cris_strtol (const char *s, char **endptr, int base);
246
247/********************** Prototypes for local functions. **********************/
248/* Copy the content of a register image into another. The size n is
249 the size of the register image. Due to struct assignment generation of
250 memcpy in libc. */
251static void copy_registers (registers *dptr, registers *sptr, int n);
252
253/* Copy the stored registers from the stack. Put the register contents
254 of thread thread_id in the struct reg. */
255static void copy_registers_from_stack (int thread_id, registers *reg);
256
257/* Copy the registers to the stack. Put the register contents of thread
258 thread_id from struct reg to the stack. */
259static void copy_registers_to_stack (int thread_id, registers *reg);
260
261/* Write a value to a specified register regno in the register image
262 of the current thread. */
263static int write_register (int regno, char *val);
264
265/* Write a value to a specified register in the stack of a thread other
266 than the current thread. */
267static int write_stack_register(int thread_id, int regno, char *valptr);
268
269/* Read a value from a specified register in the register image. Returns the
270 status of the read operation. The register value is returned in valptr. */
271static int read_register (char regno, unsigned int *valptr);
272
273/* Serial port, reads one character. ETRAX 100 specific. from debugport.c */ 233/* Serial port, reads one character. ETRAX 100 specific. from debugport.c */
274int getDebugChar (void); 234int getDebugChar (void);
275 235
@@ -278,42 +238,6 @@ void putDebugChar (int val);
278 238
279void enableDebugIRQ (void); 239void enableDebugIRQ (void);
280 240
281/* Returns the integer equivalent of a hexadecimal character. */
282static int hex (char ch);
283
284/* Convert the memory, pointed to by mem into hexadecimal representation.
285 Put the result in buf, and return a pointer to the last character
286 in buf (null). */
287static char *mem2hex (char *buf, unsigned char *mem, int count);
288
289/* Convert the array, in hexadecimal representation, pointed to by buf into
290 binary representation. Put the result in mem, and return a pointer to
291 the character after the last byte written. */
292static unsigned char *hex2mem (unsigned char *mem, char *buf, int count);
293
294/* Put the content of the array, in binary representation, pointed to by buf
295 into memory pointed to by mem, and return a pointer to
296 the character after the last byte written. */
297static unsigned char *bin2mem (unsigned char *mem, unsigned char *buf, int count);
298
299/* Await the sequence $<data>#<checksum> and store <data> in the array buffer
300 returned. */
301static void getpacket (char *buffer);
302
303/* Send $<data>#<checksum> from the <data> in the array buffer. */
304static void putpacket (char *buffer);
305
306/* Build and send a response packet in order to inform the host the
307 stub is stopped. */
308static void stub_is_stopped (int sigval);
309
310/* All expected commands are sent from remote.c. Send a response according
311 to the description in remote.c. */
312static void handle_exception (int sigval);
313
314/* Performs a complete re-start from scratch. ETRAX specific. */
315static void kill_restart (void);
316
317/******************** Prototypes for global functions. ***********************/ 241/******************** Prototypes for global functions. ***********************/
318 242
319/* The string str is prepended with the GDB printout token and sent. */ 243/* The string str is prepended with the GDB printout token and sent. */
@@ -500,164 +424,6 @@ gdb_cris_strtol (const char *s, char **endptr, int base)
500 return x; 424 return x;
501} 425}
502 426
503/********************************* Register image ****************************/
504/* Copy the content of a register image into another. The size n is
505 the size of the register image. Due to struct assignment generation of
506 memcpy in libc. */
507static void
508copy_registers (registers *dptr, registers *sptr, int n)
509{
510 unsigned char *dreg;
511 unsigned char *sreg;
512
513 for (dreg = (unsigned char*)dptr, sreg = (unsigned char*)sptr; n > 0; n--)
514 *dreg++ = *sreg++;
515}
516
517#ifdef PROCESS_SUPPORT
518/* Copy the stored registers from the stack. Put the register contents
519 of thread thread_id in the struct reg. */
520static void
521copy_registers_from_stack (int thread_id, registers *regptr)
522{
523 int j;
524 stack_registers *s = (stack_registers *)stack_list[thread_id];
525 unsigned int *d = (unsigned int *)regptr;
526
527 for (j = 13; j >= 0; j--)
528 *d++ = s->r[j];
529 regptr->sp = (unsigned int)stack_list[thread_id];
530 regptr->pc = s->pc;
531 regptr->dccr = s->dccr;
532 regptr->srp = s->srp;
533}
534
535/* Copy the registers to the stack. Put the register contents of thread
536 thread_id from struct reg to the stack. */
537static void
538copy_registers_to_stack (int thread_id, registers *regptr)
539{
540 int i;
541 stack_registers *d = (stack_registers *)stack_list[thread_id];
542 unsigned int *s = (unsigned int *)regptr;
543
544 for (i = 0; i < 14; i++) {
545 d->r[i] = *s++;
546 }
547 d->pc = regptr->pc;
548 d->dccr = regptr->dccr;
549 d->srp = regptr->srp;
550}
551#endif
552
553/* Write a value to a specified register in the register image of the current
554 thread. Returns status code SUCCESS, E02 or E05. */
555static int
556write_register (int regno, char *val)
557{
558 int status = SUCCESS;
559 registers *current_reg = &reg;
560
561 if (regno >= R0 && regno <= PC) {
562 /* 32-bit register with simple offset. */
563 hex2mem ((unsigned char *)current_reg + regno * sizeof(unsigned int),
564 val, sizeof(unsigned int));
565 }
566 else if (regno == P0 || regno == VR || regno == P4 || regno == P8) {
567 /* Do not support read-only registers. */
568 status = E02;
569 }
570 else if (regno == CCR) {
571 /* 16 bit register with complex offset. (P4 is read-only, P6 is not implemented,
572 and P7 (MOF) is 32 bits in ETRAX 100LX. */
573 hex2mem ((unsigned char *)&(current_reg->ccr) + (regno-CCR) * sizeof(unsigned short),
574 val, sizeof(unsigned short));
575 }
576 else if (regno >= MOF && regno <= USP) {
577 /* 32 bit register with complex offset. (P8 has been taken care of.) */
578 hex2mem ((unsigned char *)&(current_reg->ibr) + (regno-IBR) * sizeof(unsigned int),
579 val, sizeof(unsigned int));
580 }
581 else {
582 /* Do not support nonexisting or unimplemented registers (P2, P3, and P6). */
583 status = E05;
584 }
585 return status;
586}
587
588#ifdef PROCESS_SUPPORT
589/* Write a value to a specified register in the stack of a thread other
590 than the current thread. Returns status code SUCCESS or E07. */
591static int
592write_stack_register (int thread_id, int regno, char *valptr)
593{
594 int status = SUCCESS;
595 stack_registers *d = (stack_registers *)stack_list[thread_id];
596 unsigned int val;
597
598 hex2mem ((unsigned char *)&val, valptr, sizeof(unsigned int));
599 if (regno >= R0 && regno < SP) {
600 d->r[regno] = val;
601 }
602 else if (regno == SP) {
603 stack_list[thread_id] = val;
604 }
605 else if (regno == PC) {
606 d->pc = val;
607 }
608 else if (regno == SRP) {
609 d->srp = val;
610 }
611 else if (regno == DCCR) {
612 d->dccr = val;
613 }
614 else {
615 /* Do not support registers in the current thread. */
616 status = E07;
617 }
618 return status;
619}
620#endif
621
622/* Read a value from a specified register in the register image. Returns the
623 value in the register or -1 for non-implemented registers.
624 Should check consistency_status after a call which may be E05 after changes
625 in the implementation. */
626static int
627read_register (char regno, unsigned int *valptr)
628{
629 registers *current_reg = &reg;
630
631 if (regno >= R0 && regno <= PC) {
632 /* 32-bit register with simple offset. */
633 *valptr = *(unsigned int *)((char *)current_reg + regno * sizeof(unsigned int));
634 return SUCCESS;
635 }
636 else if (regno == P0 || regno == VR) {
637 /* 8 bit register with complex offset. */
638 *valptr = (unsigned int)(*(unsigned char *)
639 ((char *)&(current_reg->p0) + (regno-P0) * sizeof(char)));
640 return SUCCESS;
641 }
642 else if (regno == P4 || regno == CCR) {
643 /* 16 bit register with complex offset. */
644 *valptr = (unsigned int)(*(unsigned short *)
645 ((char *)&(current_reg->p4) + (regno-P4) * sizeof(unsigned short)));
646 return SUCCESS;
647 }
648 else if (regno >= MOF && regno <= USP) {
649 /* 32 bit register with complex offset. */
650 *valptr = *(unsigned int *)((char *)&(current_reg->p8)
651 + (regno-P8) * sizeof(unsigned int));
652 return SUCCESS;
653 }
654 else {
655 /* Do not support nonexisting or unimplemented registers (P2, P3, and P6). */
656 consistency_status = E05;
657 return E05;
658 }
659}
660
661/********************************** Packet I/O ******************************/ 427/********************************** Packet I/O ******************************/
662/* Returns the integer equivalent of a hexadecimal character. */ 428/* Returns the integer equivalent of a hexadecimal character. */
663static int 429static int
@@ -843,6 +609,164 @@ putDebugString (const unsigned char *str, int length)
843 putpacket(remcomOutBuffer); 609 putpacket(remcomOutBuffer);
844} 610}
845 611
612/********************************* Register image ****************************/
613/* Copy the content of a register image into another. The size n is
614 the size of the register image. Due to struct assignment generation of
615 memcpy in libc. */
616static void
617copy_registers (registers *dptr, registers *sptr, int n)
618{
619 unsigned char *dreg;
620 unsigned char *sreg;
621
622 for (dreg = (unsigned char*)dptr, sreg = (unsigned char*)sptr; n > 0; n--)
623 *dreg++ = *sreg++;
624}
625
626#ifdef PROCESS_SUPPORT
627/* Copy the stored registers from the stack. Put the register contents
628 of thread thread_id in the struct reg. */
629static void
630copy_registers_from_stack (int thread_id, registers *regptr)
631{
632 int j;
633 stack_registers *s = (stack_registers *)stack_list[thread_id];
634 unsigned int *d = (unsigned int *)regptr;
635
636 for (j = 13; j >= 0; j--)
637 *d++ = s->r[j];
638 regptr->sp = (unsigned int)stack_list[thread_id];
639 regptr->pc = s->pc;
640 regptr->dccr = s->dccr;
641 regptr->srp = s->srp;
642}
643
644/* Copy the registers to the stack. Put the register contents of thread
645 thread_id from struct reg to the stack. */
646static void
647copy_registers_to_stack (int thread_id, registers *regptr)
648{
649 int i;
650 stack_registers *d = (stack_registers *)stack_list[thread_id];
651 unsigned int *s = (unsigned int *)regptr;
652
653 for (i = 0; i < 14; i++) {
654 d->r[i] = *s++;
655 }
656 d->pc = regptr->pc;
657 d->dccr = regptr->dccr;
658 d->srp = regptr->srp;
659}
660#endif
661
662/* Write a value to a specified register in the register image of the current
663 thread. Returns status code SUCCESS, E02 or E05. */
664static int
665write_register (int regno, char *val)
666{
667 int status = SUCCESS;
668 registers *current_reg = &reg;
669
670 if (regno >= R0 && regno <= PC) {
671 /* 32-bit register with simple offset. */
672 hex2mem ((unsigned char *)current_reg + regno * sizeof(unsigned int),
673 val, sizeof(unsigned int));
674 }
675 else if (regno == P0 || regno == VR || regno == P4 || regno == P8) {
676 /* Do not support read-only registers. */
677 status = E02;
678 }
679 else if (regno == CCR) {
680 /* 16 bit register with complex offset. (P4 is read-only, P6 is not implemented,
681 and P7 (MOF) is 32 bits in ETRAX 100LX. */
682 hex2mem ((unsigned char *)&(current_reg->ccr) + (regno-CCR) * sizeof(unsigned short),
683 val, sizeof(unsigned short));
684 }
685 else if (regno >= MOF && regno <= USP) {
686 /* 32 bit register with complex offset. (P8 has been taken care of.) */
687 hex2mem ((unsigned char *)&(current_reg->ibr) + (regno-IBR) * sizeof(unsigned int),
688 val, sizeof(unsigned int));
689 }
690 else {
691 /* Do not support nonexisting or unimplemented registers (P2, P3, and P6). */
692 status = E05;
693 }
694 return status;
695}
696
697#ifdef PROCESS_SUPPORT
698/* Write a value to a specified register in the stack of a thread other
699 than the current thread. Returns status code SUCCESS or E07. */
700static int
701write_stack_register (int thread_id, int regno, char *valptr)
702{
703 int status = SUCCESS;
704 stack_registers *d = (stack_registers *)stack_list[thread_id];
705 unsigned int val;
706
707 hex2mem ((unsigned char *)&val, valptr, sizeof(unsigned int));
708 if (regno >= R0 && regno < SP) {
709 d->r[regno] = val;
710 }
711 else if (regno == SP) {
712 stack_list[thread_id] = val;
713 }
714 else if (regno == PC) {
715 d->pc = val;
716 }
717 else if (regno == SRP) {
718 d->srp = val;
719 }
720 else if (regno == DCCR) {
721 d->dccr = val;
722 }
723 else {
724 /* Do not support registers in the current thread. */
725 status = E07;
726 }
727 return status;
728}
729#endif
730
731/* Read a value from a specified register in the register image. Returns the
732 value in the register or -1 for non-implemented registers.
733 Should check consistency_status after a call which may be E05 after changes
734 in the implementation. */
735static int
736read_register (char regno, unsigned int *valptr)
737{
738 registers *current_reg = &reg;
739
740 if (regno >= R0 && regno <= PC) {
741 /* 32-bit register with simple offset. */
742 *valptr = *(unsigned int *)((char *)current_reg + regno * sizeof(unsigned int));
743 return SUCCESS;
744 }
745 else if (regno == P0 || regno == VR) {
746 /* 8 bit register with complex offset. */
747 *valptr = (unsigned int)(*(unsigned char *)
748 ((char *)&(current_reg->p0) + (regno-P0) * sizeof(char)));
749 return SUCCESS;
750 }
751 else if (regno == P4 || regno == CCR) {
752 /* 16 bit register with complex offset. */
753 *valptr = (unsigned int)(*(unsigned short *)
754 ((char *)&(current_reg->p4) + (regno-P4) * sizeof(unsigned short)));
755 return SUCCESS;
756 }
757 else if (regno >= MOF && regno <= USP) {
758 /* 32 bit register with complex offset. */
759 *valptr = *(unsigned int *)((char *)&(current_reg->p8)
760 + (regno-P8) * sizeof(unsigned int));
761 return SUCCESS;
762 }
763 else {
764 /* Do not support nonexisting or unimplemented registers (P2, P3, and P6). */
765 consistency_status = E05;
766 return E05;
767 }
768}
769
846/********************************** Handle exceptions ************************/ 770/********************************** Handle exceptions ************************/
847/* Build and send a response packet in order to inform the host the 771/* Build and send a response packet in order to inform the host the
848 stub is stopped. TAAn...:r...;n...:r...;n...:r...; 772 stub is stopped. TAAn...:r...;n...:r...;n...:r...;
@@ -916,6 +840,13 @@ stub_is_stopped(int sigval)
916 putpacket (remcomOutBuffer); 840 putpacket (remcomOutBuffer);
917} 841}
918 842
843/* Performs a complete re-start from scratch. */
844static void
845kill_restart (void)
846{
847 machine_restart("");
848}
849
919/* All expected commands are sent from remote.c. Send a response according 850/* All expected commands are sent from remote.c. Send a response according
920 to the description in remote.c. */ 851 to the description in remote.c. */
921static void 852static void
@@ -1252,13 +1183,6 @@ handle_exception (int sigval)
1252 } 1183 }
1253} 1184}
1254 1185
1255/* Performs a complete re-start from scratch. */
1256static void
1257kill_restart ()
1258{
1259 machine_restart("");
1260}
1261
1262/********************************** Breakpoint *******************************/ 1186/********************************** Breakpoint *******************************/
1263/* The hook for both a static (compiled) and a dynamic breakpoint set by GDB. 1187/* The hook for both a static (compiled) and a dynamic breakpoint set by GDB.
1264 An internal stack is used by the stub. The register image of the caller is 1188 An internal stack is used by the stub. The register image of the caller is