summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2002-04-23 20:21:31 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2002-04-23 20:21:31 +0000
commitf9389fe9fb7a3b1e7285d00a58bc26273c05077b (patch)
tree03001d32f5787bb39571f3071886de0d5bcdfdc0
parentade48b800f7e487d1ba87bba27b70ef18770d190 (diff)
downloadrockbox-f9389fe9fb7a3b1e7285d00a58bc26273c05077b.tar.gz
rockbox-f9389fe9fb7a3b1e7285d00a58bc26273c05077b.zip
Cleanup
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@201 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--gdb/Makefile3
-rw-r--r--gdb/archos.h24
-rw-r--r--gdb/sh-stub.c301
3 files changed, 102 insertions, 226 deletions
diff --git a/gdb/Makefile b/gdb/Makefile
index 2e36a7f80e..f61088effc 100644
--- a/gdb/Makefile
+++ b/gdb/Makefile
@@ -8,14 +8,13 @@
8# 8#
9TARGET = stub 9TARGET = stub
10OBJS = start.o sh-stub.o 10OBJS = start.o sh-stub.o
11#LIBS = -L/home/linus/sh1/lib/gcc-lib/sh-elf/3.0.4 -lgcc
12LIBS = -lgcc 11LIBS = -lgcc
13 12
14.s.o: 13.s.o:
15 sh-elf-as -o $@ $< 14 sh-elf-as -o $@ $<
16 15
17.c.o: 16.c.o:
18 sh-elf-gcc -O -m1 -Wall -c -o $@ $< 17 sh-elf-gcc -O -I../firmware/drivers -m1 -Wall -c -o $@ $<
19 18
20$(TARGET).out: $(TARGET).elf 19$(TARGET).out: $(TARGET).elf
21 sh-elf-objcopy -O binary $(TARGET).elf $(TARGET).out 20 sh-elf-objcopy -O binary $(TARGET).elf $(TARGET).out
diff --git a/gdb/archos.h b/gdb/archos.h
deleted file mode 100644
index c92360e43a..0000000000
--- a/gdb/archos.h
+++ /dev/null
@@ -1,24 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#ifndef ARCHOS_H
20#define ARCHOS_H
21
22#define SYSCLOCK 12000000
23
24#endif
diff --git a/gdb/sh-stub.c b/gdb/sh-stub.c
index c937c84088..6bd5a7ddc4 100644
--- a/gdb/sh-stub.c
+++ b/gdb/sh-stub.c
@@ -164,10 +164,13 @@
164 So 164 So
165 "0* " means the same as "0000". */ 165 "0* " means the same as "0000". */
166 166
167#include "archos.h" 167#include "sh7034.h"
168#include "sh.h"
169#include <string.h> 168#include <string.h>
170#include <setjmp.h> 169#include <setjmp.h>
170#include <signal.h>
171
172/* We need to undefine this from the sh7034.h file */
173#undef GBR
171 174
172/* Hitachi SH architecture instruction encoding masks */ 175/* Hitachi SH architecture instruction encoding masks */
173 176
@@ -197,9 +200,6 @@
197 200
198#define T_BIT_MASK 0x0001 201#define T_BIT_MASK 0x0001
199 202
200#define PBDR (*(volatile unsigned short *)(0x5ffffc2)) /* Port B Data */
201void lcd_printxy( char x, char y, unsigned char* string, int len );
202
203/* 203/*
204 * BUFMAX defines the maximum number of characters in inbound/outbound 204 * BUFMAX defines the maximum number of characters in inbound/outbound
205 * buffers. At least NUMREGBYTES*2 are needed for register packets. 205 * buffers. At least NUMREGBYTES*2 are needed for register packets.
@@ -377,8 +377,6 @@ void start ();
377#define IO_VEC 33 377#define IO_VEC 33
378#define USER_VEC 127 378#define USER_VEC 127
379 379
380
381
382char in_nmi; /* Set when handling an NMI, so we don't reenter */ 380char in_nmi; /* Set when handling an NMI, so we don't reenter */
383int dofault; /* Non zero, bus errors will raise exception */ 381int dofault; /* Non zero, bus errors will raise exception */
384 382
@@ -391,18 +389,18 @@ int remote_debug;
391jmp_buf remcomEnv; 389jmp_buf remcomEnv;
392 390
393enum regnames 391enum regnames
394 { 392{
395 R0, R1, R2, R3, R4, R5, R6, R7, 393 R0, R1, R2, R3, R4, R5, R6, R7,
396 R8, R9, R10, R11, R12, R13, R14, 394 R8, R9, R10, R11, R12, R13, R14,
397 R15, PC, PR, GBR, VBR, MACH, MACL, SR, 395 R15, PC, PR, GBR, VBR, MACH, MACL, SR,
398 TICKS, STALLS, CYCLES, INSTS, PLR 396 TICKS, STALLS, CYCLES, INSTS, PLR
399 }; 397};
400 398
401typedef struct 399typedef struct
402 { 400{
403 short *memAddr; 401 short *memAddr;
404 short oldInstr; 402 short oldInstr;
405 } 403}
406stepData; 404stepData;
407 405
408int registers[NUMREGBYTES / 4]; 406int registers[NUMREGBYTES / 4];
@@ -657,28 +655,28 @@ static int computeSignal (int exceptionVector)
657 switch (exceptionVector) 655 switch (exceptionVector)
658 { 656 {
659 case INVALID_INSN_VEC: 657 case INVALID_INSN_VEC:
660 sigval = 4; 658 sigval = SIGILL;
661 break; 659 break;
662 case INVALID_SLOT_VEC: 660 case INVALID_SLOT_VEC:
663 sigval = 4; 661 sigval = SIGILL;
664 break; 662 break;
665 case CPU_BUS_ERROR_VEC: 663 case CPU_BUS_ERROR_VEC:
666 sigval = 10; 664 sigval = SIGBUS;
667 break; 665 break;
668 case DMA_BUS_ERROR_VEC: 666 case DMA_BUS_ERROR_VEC:
669 sigval = 10; 667 sigval = SIGBUS;
670 break; 668 break;
671 case NMI_VEC: 669 case NMI_VEC:
672 sigval = 2; 670 sigval = SIGINT;
673 break; 671 break;
674 672
675 case TRAP_VEC: 673 case TRAP_VEC:
676 case USER_VEC: 674 case USER_VEC:
677 sigval = 5; 675 sigval = SIGTRAP;
678 break; 676 break;
679 677
680 default: 678 default:
681 sigval = 7; /* "software generated"*/ 679 sigval = SIGEMT; /* "software generated"*/
682 break; 680 break;
683 } 681 }
684 return (sigval); 682 return (sigval);
@@ -763,7 +761,6 @@ void doSStep (void)
763 761
764/* Undo the effect of a previous doSStep. If we single stepped, 762/* Undo the effect of a previous doSStep. If we single stepped,
765 restore the old instruction. */ 763 restore the old instruction. */
766
767void undoSStep (void) 764void undoSStep (void)
768{ 765{
769 if (stepped) 766 if (stepped)
@@ -776,18 +773,13 @@ void undoSStep (void)
776} 773}
777 774
778/* 775/*
779This function does all exception handling. It only does two things - 776 * This function does all exception handling. It only does two things -
780it figures out why it was called and tells gdb, and then it reacts 777 * it figures out why it was called and tells gdb, and then it reacts
781to gdb's requests. 778 * to gdb's requests.
782 779 *
783When in the monitor mode we talk a human on the serial line rather than gdb.
784
785*/ 780*/
786
787void gdb_handle_exception (int exceptionVector) 781void gdb_handle_exception (int exceptionVector)
788{ 782{
789 char buf[32];
790 unsigned int r;
791 int sigval, stepping; 783 int sigval, stepping;
792 int addr, length; 784 int addr, length;
793 char *ptr; 785 char *ptr;
@@ -812,28 +804,13 @@ void gdb_handle_exception (int exceptionVector)
812 registers[PC] -= 2; 804 registers[PC] -= 2;
813 805
814 /* 806 /*
815 * Do the thangs needed to undo 807 * Do the things needed to undo
816 * any stepping we may have done! 808 * any stepping we may have done!
817 */ 809 */
818 undoSStep (); 810 undoSStep ();
819 811
820 stepping = 0; 812 stepping = 0;
821 813
822 buf[0] = highhex(exceptionVector);
823 buf[1] = lowhex(exceptionVector);
824 buf[2] = ':';
825 r = registers[PC];
826 buf[3] = highhex((r >> 24) & 0xff);
827 buf[4] = lowhex((r >> 24) & 0xff);
828 buf[5] = highhex((r >> 16) & 0xff);
829 buf[6] = lowhex((r >> 16) & 0xff);
830 buf[7] = highhex((r >> 8) & 0xff);
831 buf[8] = lowhex((r >> 8) & 0xff);
832 buf[9] = highhex(r & 0xff);
833 buf[10] = lowhex(r & 0xff);
834
835 lcd_printxy(0, 0, buf, 11);
836
837 while (1) 814 while (1)
838 { 815 {
839 remcomOutBuffer[0] = 0; 816 remcomOutBuffer[0] = 0;
@@ -841,96 +818,96 @@ void gdb_handle_exception (int exceptionVector)
841 818
842 switch (*ptr++) 819 switch (*ptr++)
843 { 820 {
844 case '?': 821 case '?':
845 remcomOutBuffer[0] = 'S'; 822 remcomOutBuffer[0] = 'S';
846 remcomOutBuffer[1] = highhex (sigval); 823 remcomOutBuffer[1] = highhex (sigval);
847 remcomOutBuffer[2] = lowhex (sigval); 824 remcomOutBuffer[2] = lowhex (sigval);
848 remcomOutBuffer[3] = 0; 825 remcomOutBuffer[3] = 0;
849 break; 826 break;
850 case 'd': 827 case 'd':
851 remote_debug = !(remote_debug); /* toggle debug flag */ 828 remote_debug = !(remote_debug); /* toggle debug flag */
852 break; 829 break;
853 case 'g': /* return the value of the CPU registers */ 830 case 'g': /* return the value of the CPU registers */
854 mem2hex ((char *) registers, remcomOutBuffer, NUMREGBYTES); 831 mem2hex ((char *) registers, remcomOutBuffer, NUMREGBYTES);
855 break; 832 break;
856 case 'G': /* set the value of the CPU registers - return OK */ 833 case 'G': /* set the value of the CPU registers - return OK */
857 hex2mem (ptr, (char *) registers, NUMREGBYTES); 834 hex2mem (ptr, (char *) registers, NUMREGBYTES);
858 strcpy (remcomOutBuffer, "OK"); 835 strcpy (remcomOutBuffer, "OK");
859 break; 836 break;
860 837
861 /* mAA..AA,LLLL Read LLLL bytes at address AA..AA */ 838 /* mAA..AA,LLLL Read LLLL bytes at address AA..AA */
862 case 'm': 839 case 'm':
863 if (setjmp (remcomEnv) == 0) 840 if (setjmp (remcomEnv) == 0)
864 { 841 {
865 dofault = 0; 842 dofault = 0;
866 /* TRY, TO READ %x,%x. IF SUCCEED, SET PTR = 0 */ 843 /* TRY, TO READ %x,%x. IF SUCCEED, SET PTR = 0 */
867 if (hex2int (&ptr, &addr)) 844 if (hex2int (&ptr, &addr))
868 if (*(ptr++) == ',') 845 if (*(ptr++) == ',')
869 if (hex2int (&ptr, &length)) 846 if (hex2int (&ptr, &length))
847 {
848 ptr = 0;
849 mem2hex ((char *) addr, remcomOutBuffer, length);
850 }
851 if (ptr)
852 strcpy (remcomOutBuffer, "E01");
853 }
854 else
855 strcpy (remcomOutBuffer, "E03");
856
857 /* restore handler for bus error */
858 dofault = 1;
859 break;
860
861 /* MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK */
862 case 'M':
863 if (setjmp (remcomEnv) == 0)
864 {
865 dofault = 0;
866
867 /* TRY, TO READ '%x,%x:'. IF SUCCEED, SET PTR = 0 */
868 if (hex2int (&ptr, &addr))
869 if (*(ptr++) == ',')
870 if (hex2int (&ptr, &length))
871 if (*(ptr++) == ':')
870 { 872 {
873 hex2mem (ptr, (char *) addr, length);
871 ptr = 0; 874 ptr = 0;
872 mem2hex ((char *) addr, remcomOutBuffer, length); 875 strcpy (remcomOutBuffer, "OK");
873 } 876 }
874 if (ptr) 877 if (ptr)
875 strcpy (remcomOutBuffer, "E01"); 878 strcpy (remcomOutBuffer, "E02");
876 } 879 }
877 else 880 else
878 strcpy (remcomOutBuffer, "E03"); 881 strcpy (remcomOutBuffer, "E03");
879
880 /* restore handler for bus error */
881 dofault = 1;
882 break;
883 882
884 /* MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK */ 883 /* restore handler for bus error */
885 case 'M': 884 dofault = 1;
886 if (setjmp (remcomEnv) == 0) 885 break;
887 {
888 dofault = 0;
889
890 /* TRY, TO READ '%x,%x:'. IF SUCCEED, SET PTR = 0 */
891 if (hex2int (&ptr, &addr))
892 if (*(ptr++) == ',')
893 if (hex2int (&ptr, &length))
894 if (*(ptr++) == ':')
895 {
896 hex2mem (ptr, (char *) addr, length);
897 ptr = 0;
898 strcpy (remcomOutBuffer, "OK");
899 }
900 if (ptr)
901 strcpy (remcomOutBuffer, "E02");
902 }
903 else
904 strcpy (remcomOutBuffer, "E03");
905 886
906 /* restore handler for bus error */ 887 /* cAA..AA Continue at address AA..AA(optional) */
907 dofault = 1; 888 /* sAA..AA Step one instruction from AA..AA(optional) */
908 break; 889 case 's':
890 stepping = 1;
891 case 'c':
892 {
893 /* tRY, to read optional parameter, pc unchanged if no parm */
894 if (hex2int (&ptr, &addr))
895 registers[PC] = addr;
909 896
910 /* cAA..AA Continue at address AA..AA(optional) */ 897 if (stepping)
911 /* sAA..AA Step one instruction from AA..AA(optional) */ 898 doSStep ();
912 case 's': 899 }
913 stepping = 1;
914 case 'c':
915 {
916 /* tRY, to read optional parameter, pc unchanged if no parm */
917 if (hex2int (&ptr, &addr))
918 registers[PC] = addr;
919 900
920 if (stepping) 901 return;
921 doSStep (); 902 break;
922 }
923 903
924 return; 904 /* kill the program */
905 case 'k': /* do nothing */
925 break; 906 break;
926 907
927 /* kill the program */ 908 default:
928 case 'k': /* do nothing */ 909 break;
929 break; 910 } /* switch */
930
931 default:
932 break;
933 } /* switch */
934 911
935 /* reply to the request */ 912 /* reply to the request */
936 putpacket (remcomOutBuffer); 913 putpacket (remcomOutBuffer);
@@ -1127,7 +1104,6 @@ void INIT (void)
1127 blink(); 1104 blink();
1128} 1105}
1129 1106
1130
1131void sr() 1107void sr()
1132{ 1108{
1133 /* Calling Reset does the same as pressing the button */ 1109 /* Calling Reset does the same as pressing the button */
@@ -1237,7 +1213,7 @@ void rr()
1237 " mov.l @r1, r1 ! restore R1"); 1213 " mov.l @r1, r1 ! restore R1");
1238} 1214}
1239 1215
1240static __inline__ void code_for_catch_exception(unsigned int n) 1216static inline void code_for_catch_exception(unsigned int n)
1241{ 1217{
1242 asm(" .globl _catch_exception_%O0" : : "X" (n) ); 1218 asm(" .globl _catch_exception_%O0" : : "X" (n) );
1243 asm(" _catch_exception_%O0:" :: "X" (n) ); 1219 asm(" _catch_exception_%O0:" :: "X" (n) );
@@ -1551,78 +1527,3 @@ void handleError (char theSSR)
1551 /* Clear all error bits, otherwise the receiver will stop */ 1527 /* Clear all error bits, otherwise the receiver will stop */
1552 SSR1 &= ~(SCI_ORER | SCI_PER | SCI_FER); 1528 SSR1 &= ~(SCI_ORER | SCI_PER | SCI_FER);
1553} 1529}
1554
1555#define DC 1
1556#define CS1 2
1557#define SDA 4
1558#define SCK 8
1559
1560static const unsigned char ascii2lcd[] = {
1561 0x00,0x01,0x02,0x03,0x00,0x84,0x85,0x89,
1562 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1563 0xec,0xe3,0xe2,0xe1,0xe0,0xdf,0x15,0x00,
1564 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1565 0x24,0x25,0x26,0x37,0x06,0x29,0x2a,0x2b,
1566 0x2c,0x2d,0x2e,0x2f,0x30,0x31,0x32,0x33,
1567 0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,
1568 0x3c,0x3d,0x3e,0x3f,0x40,0x41,0x42,0x43,
1569 0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,
1570 0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0x53,
1571 0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,
1572 0x5c,0x5d,0x5e,0xa9,0x33,0xce,0x00,0x15,
1573 0x00,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,
1574 0x6c,0x6d,0x6e,0x6f,0x70,0x71,0x72,0x73,
1575 0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,
1576 0x7c,0x7d,0x7e,0x24,0x24,0x24,0x24,0x24,
1577 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,
1578 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,
1579 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,
1580 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,
1581 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,
1582 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,
1583 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,
1584 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,
1585 0x45,0x45,0x45,0x45,0x45,0x45,0x24,0x47,
1586 0x49,0x49,0x49,0x49,0x4d,0x4d,0x4d,0x4d,
1587 0x48,0x52,0x53,0x53,0x53,0x53,0x53,0x24,
1588 0x24,0x59,0x59,0x59,0x59,0x5d,0x24,0x24,
1589 0x65,0x65,0x65,0x65,0x65,0x65,0x24,0x67,
1590 0x69,0x69,0x69,0x69,0x6d,0x6d,0x6d,0x6d,
1591 0x73,0x72,0x73,0x73,0x73,0x73,0x73,0x24,
1592 0x24,0x79,0x79,0x79,0x79,0x7d,0x24,0x7d
1593};
1594
1595void lcd_write(int byte, int data)
1596{
1597 int i;
1598 char on,off;
1599
1600 PBDR &= ~CS1; /* enable lcd chip select */
1601
1602 if ( data ) {
1603 on=~(SDA|SCK);
1604 off=SCK|DC;
1605 }
1606 else {
1607 on=~(SDA|SCK|DC);
1608 off=SCK;
1609 }
1610 /* clock out each bit, MSB first */
1611 for (i=0x80;i;i>>=1)
1612 {
1613 PBDR &= on;
1614 if (i & byte)
1615 PBDR |= SDA;
1616 PBDR |= off;
1617 }
1618
1619 PBDR |= CS1; /* disable lcd chip select */
1620}
1621
1622void lcd_printxy( char x, char y, unsigned char* string, int len )
1623{
1624 int i;
1625 lcd_write(0xb0+y*16+x,0);
1626 for (i=0; string[i] && i<len; i++)
1627 lcd_write(ascii2lcd[string[i]],1);
1628}