diff options
-rw-r--r-- | gdb/Makefile | 24 | ||||
-rw-r--r-- | gdb/README | 27 | ||||
-rw-r--r-- | gdb/setjmp.S | 59 | ||||
-rw-r--r-- | gdb/sh-stub.c | 40 |
4 files changed, 135 insertions, 15 deletions
diff --git a/gdb/Makefile b/gdb/Makefile index 518217fc70..21c0cf8341 100644 --- a/gdb/Makefile +++ b/gdb/Makefile | |||
@@ -6,25 +6,37 @@ | |||
6 | # \/ \/ \/ \/ \/ | 6 | # \/ \/ \/ \/ \/ |
7 | # $Id$ | 7 | # $Id$ |
8 | # | 8 | # |
9 | |||
10 | ifdef RECORDER | ||
11 | EXTRA = -DRECORDER | ||
12 | EXT = ajz | ||
13 | else | ||
14 | EXT = mod | ||
15 | endif | ||
16 | |||
9 | TARGET = stub | 17 | TARGET = stub |
10 | OBJS = start.o sh-stub.o | 18 | OBJS = start.o sh-stub.o setjmp.o |
11 | LIBS = -lgcc | 19 | LIBS = -lgcc |
12 | 20 | ||
13 | .s.o: | 21 | .s.o: |
14 | sh-elf-as -o $@ $< | 22 | sh-elf-as -o $@ $< |
15 | 23 | ||
16 | .c.o: | 24 | .c.o: |
17 | sh-elf-gcc -O -I../firmware/drivers -m1 -Wall -Wstrict-prototypes -c -o $@ $< | 25 | sh-elf-gcc -O $(EXTRA) -I../firmware/export -I../firmware/include -m1 -Wall -Wstrict-prototypes -c -o $@ $< |
26 | |||
27 | .S.o: | ||
28 | sh-elf-gcc -O -I../firmware/export -I../firmware/include -m1 -Wall -Wstrict-prototypes -c -o $@ $< | ||
18 | 29 | ||
19 | archos.mod: $(TARGET).elf | 30 | $(TARGET).$(EXT): $(TARGET).elf |
20 | sh-elf-objcopy -O binary $(TARGET).elf $(TARGET).out | 31 | sh-elf-objcopy -O binary $(TARGET).elf $(TARGET).out |
21 | ../tools/scramble $(TARGET).out archos.mod | 32 | ../tools/scramble $(TARGET).out $(TARGET).$(EXT) |
22 | 33 | ||
23 | $(TARGET).elf: $(OBJS) | 34 | $(TARGET).elf: $(OBJS) |
24 | sh-elf-gcc -nostartfiles $(OBJS) -lgcc -Wl,-Map,$(TARGET).map -o $(TARGET).elf -Tlinker.cfg | 35 | sh-elf-gcc -nostartfiles $(OBJS) -nostdlib -Wl,-Map,$(TARGET).map -o $(TARGET).elf -Tlinker.cfg |
25 | 36 | ||
26 | clean: | 37 | clean: |
27 | rm $(OBJS) $(TARGET).map $(TARGET).elf $(TARGET).out archos.mod | 38 | rm $(OBJS) $(TARGET).map $(TARGET).elf $(TARGET).out $(TARGET).mod $(TARGET).ajz |
28 | 39 | ||
29 | start.o: start.s | 40 | start.o: start.s |
30 | sh-stub.o: sh-stub.c | 41 | sh-stub.o: sh-stub.c |
42 | setjmp.o: setjmp.S | ||
diff --git a/gdb/README b/gdb/README index 751fb22946..e61c930ea8 100644 --- a/gdb/README +++ b/gdb/README | |||
@@ -23,14 +23,23 @@ To debug using the serial port on the Jukebox, you need to do the following: | |||
23 | 2) Build or download a GDB SH1 cross debugger | 23 | 2) Build or download a GDB SH1 cross debugger |
24 | 24 | ||
25 | 3) Compile the GDB stub from the CVS "gdb" archive | 25 | 3) Compile the GDB stub from the CVS "gdb" archive |
26 | For Player models, just type: | ||
27 | # make | ||
28 | |||
29 | For Recorder, type | ||
30 | #make RECORDER=1 | ||
26 | 31 | ||
27 | 4) Copy the newly built ARCHOS.MOD to the Jukebox. | 32 | 4) Copy the newly built ARCHOS.MOD to the Jukebox. |
28 | 33 | ||
29 | 5) Start the Jukebox and fire up the GDB with the elf file you want to debug | 34 | 5) Start the Jukebox and fire up the GDB with the elf file you want to debug |
30 | as an argument along with the baud rate: | 35 | as an argument along with the baud rate: |
31 | 36 | ||
37 | For Player: | ||
32 | # sh-elf-gdb -b 38400 test.elf | 38 | # sh-elf-gdb -b 38400 test.elf |
33 | 39 | ||
40 | For Recorder: | ||
41 | # sh-elf-gdb -b 115200 test.elf | ||
42 | |||
34 | 6) In GDB, type: | 43 | 6) In GDB, type: |
35 | 44 | ||
36 | (gdb) target remote /dev/ttyS0 | 45 | (gdb) target remote /dev/ttyS0 |
@@ -58,13 +67,13 @@ To debug using the serial port on the Jukebox, you need to do the following: | |||
58 | 67 | ||
59 | 8) You're set. Now try to set a breakpoint and run: | 68 | 8) You're set. Now try to set a breakpoint and run: |
60 | 69 | ||
61 | (gdb) b 22 | 70 | (gdb) b main |
62 | Breakpoint 1 at 0x90182c6: file led.c, line 14. | 71 | Breakpoint 1 at 0x9011b2a: file main.c, line 192. |
63 | (gdb) c | 72 | (gdb) c |
64 | Continuing. | 73 | Continuing. |
65 | 74 | ||
66 | Breakpoint 2, main () at led.c:15 | 75 | Breakpoint 1, main () at main.c:192 |
67 | 15 SSR1 &= ~(SCI_RDRF | SCI_ORER | SCI_PER | SCI_FER); | 76 | 192 app_main(); |
68 | (gdb) | 77 | (gdb) |
69 | 78 | ||
70 | Good luck! | 79 | Good luck! |
@@ -73,8 +82,14 @@ To debug using the serial port on the Jukebox, you need to do the following: | |||
73 | Technical details: | 82 | Technical details: |
74 | 83 | ||
75 | As for now, the GDB stub occupies the memory from 0x900000 up to | 84 | As for now, the GDB stub occupies the memory from 0x900000 up to |
76 | 0x9018000. This will change. | 85 | 0x9018000. |
77 | 86 | ||
78 | Compile and link your test program at 0x9018000 and up, and it will work. | 87 | Compile and link your test program at 0x9018000 and up, and it will work. |
79 | 88 | ||
80 | The baud rate is 38400, and the settings are 8N1. | 89 | The baud rate is 38400 for Player, 115200 for Recorder, and the settings |
90 | are 8N1. | ||
91 | |||
92 | Note that you may have to change the ATA I/O address in the ATA_CONTROL | ||
93 | macro in sh-stub.c. go to Menu->Debug (keep out)->View HW info to find out. | ||
94 | |||
95 | Linus Nielsen Feltzing | ||
diff --git a/gdb/setjmp.S b/gdb/setjmp.S new file mode 100644 index 0000000000..28a6ce2f43 --- /dev/null +++ b/gdb/setjmp.S | |||
@@ -0,0 +1,59 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Red Hat Inc | ||
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 | .type _setjmp,@function | ||
20 | .global _setjmp | ||
21 | _setjmp: | ||
22 | add #(9*4),r4 | ||
23 | |||
24 | sts.l pr,@-r4 | ||
25 | |||
26 | mov.l r15,@-r4 | ||
27 | mov.l r14,@-r4 | ||
28 | mov.l r13,@-r4 | ||
29 | mov.l r12,@-r4 | ||
30 | |||
31 | mov.l r11,@-r4 | ||
32 | mov.l r10,@-r4 | ||
33 | mov.l r9,@-r4 | ||
34 | mov.l r8,@-r4 | ||
35 | |||
36 | rts | ||
37 | mov #0,r0 | ||
38 | |||
39 | .type _longjmp,@function | ||
40 | .global _longjmp | ||
41 | _longjmp: | ||
42 | mov.l @r4+,r8 | ||
43 | mov.l @r4+,r9 | ||
44 | mov.l @r4+,r10 | ||
45 | mov.l @r4+,r11 | ||
46 | |||
47 | mov.l @r4+,r12 | ||
48 | mov.l @r4+,r13 | ||
49 | mov.l @r4+,r14 | ||
50 | mov.l @r4+,r15 | ||
51 | |||
52 | lds.l @r4+,pr | ||
53 | |||
54 | mov r5,r0 | ||
55 | tst r0,r0 | ||
56 | bf retr4 | ||
57 | movt r0 | ||
58 | retr4: rts | ||
59 | nop | ||
diff --git a/gdb/sh-stub.c b/gdb/sh-stub.c index 7a717e0ac5..61c63596bc 100644 --- a/gdb/sh-stub.c +++ b/gdb/sh-stub.c | |||
@@ -166,8 +166,11 @@ | |||
166 | 166 | ||
167 | #include "sh7034.h" | 167 | #include "sh7034.h" |
168 | #include <string.h> | 168 | #include <string.h> |
169 | #include <setjmp.h> | 169 | |
170 | #include <signal.h> | 170 | typedef int jmp_buf[20]; |
171 | |||
172 | void longjmp(jmp_buf __jmpb, int __retval); | ||
173 | int setjmp(jmp_buf __jmpb); | ||
171 | 174 | ||
172 | /* We need to undefine this from the sh7034.h file */ | 175 | /* We need to undefine this from the sh7034.h file */ |
173 | #undef GBR | 176 | #undef GBR |
@@ -411,7 +414,12 @@ static char remcomOutBuffer[BUFMAX]; | |||
411 | 414 | ||
412 | #define ATA_NSECTOR (*((volatile unsigned char*)0x06100102)) | 415 | #define ATA_NSECTOR (*((volatile unsigned char*)0x06100102)) |
413 | #define ATA_COMMAND (*((volatile unsigned char*)0x06100107)) | 416 | #define ATA_COMMAND (*((volatile unsigned char*)0x06100107)) |
417 | |||
418 | #ifdef RECORDER | ||
419 | #define ATA_CONTROL (*((volatile unsigned char*)0x06200206)) | ||
420 | #else | ||
414 | #define ATA_CONTROL (*((volatile unsigned char*)0x06200306)) | 421 | #define ATA_CONTROL (*((volatile unsigned char*)0x06200306)) |
422 | #endif | ||
415 | #define ATA_ALT_STATUS ATA_CONTROL | 423 | #define ATA_ALT_STATUS ATA_CONTROL |
416 | 424 | ||
417 | #define STATUS_BSY 0x80 | 425 | #define STATUS_BSY 0x80 |
@@ -690,6 +698,12 @@ void handle_buserror (void) | |||
690 | longjmp (remcomEnv, 1); | 698 | longjmp (remcomEnv, 1); |
691 | } | 699 | } |
692 | 700 | ||
701 | #define SIGINT 2 /* interrupt */ | ||
702 | #define SIGILL 4 /* illegal instruction (not reset when caught) */ | ||
703 | #define SIGTRAP 5 /* trace trap (not reset when caught) */ | ||
704 | #define SIGEMT 7 /* EMT instruction */ | ||
705 | #define SIGBUS 10 /* bus error */ | ||
706 | |||
693 | /* | 707 | /* |
694 | * this function takes the SH-1 exception number and attempts to | 708 | * this function takes the SH-1 exception number and attempts to |
695 | * translate this number into a unix compatible signal value | 709 | * translate this number into a unix compatible signal value |
@@ -1509,8 +1523,13 @@ void init_serial (void) | |||
1509 | /* Set communication to be async, 8-bit data, | 1523 | /* Set communication to be async, 8-bit data, |
1510 | no parity, 1 stop bit and use internal clock */ | 1524 | no parity, 1 stop bit and use internal clock */ |
1511 | SMR1 = 0; | 1525 | SMR1 = 0; |
1512 | /* BRR1 = SYSCLOCK / (9600 * 32) - 1;*/ | 1526 | |
1527 | #ifdef RECORDER | ||
1528 | #warning 115200 | ||
1529 | BRR1 = 2; /* 115200 */ | ||
1530 | #else | ||
1513 | BRR1 = 9; /* 38400 */ | 1531 | BRR1 = 9; /* 38400 */ |
1532 | #endif | ||
1514 | 1533 | ||
1515 | SCR1 &= ~(SCI_CKE1 | SCI_CKE0); | 1534 | SCR1 &= ~(SCI_CKE1 | SCI_CKE0); |
1516 | 1535 | ||
@@ -1575,3 +1594,18 @@ void handleError (char theSSR) | |||
1575 | /* Clear all error bits, otherwise the receiver will stop */ | 1594 | /* Clear all error bits, otherwise the receiver will stop */ |
1576 | SSR1 &= ~(SCI_ORER | SCI_PER | SCI_FER); | 1595 | SSR1 &= ~(SCI_ORER | SCI_PER | SCI_FER); |
1577 | } | 1596 | } |
1597 | |||
1598 | void *memcpy(void *dest, const void *src0, size_t n) | ||
1599 | { | ||
1600 | char *dst = (char *) dest; | ||
1601 | char *src = (char *) src0; | ||
1602 | |||
1603 | void *save = dest; | ||
1604 | |||
1605 | while(n--) | ||
1606 | { | ||
1607 | *dst++ = *src++; | ||
1608 | } | ||
1609 | |||
1610 | return save; | ||
1611 | } | ||