diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2020-07-15 19:40:55 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2020-07-24 21:20:13 +0000 |
commit | 092c340a2062fa98b7387fc5fd63578ddae7d0b6 (patch) | |
tree | 98ec96946eeb2ae709cb0528cc6998e21bb9b290 /firmware/debug.c | |
parent | 17f7cc92c258bc456a27c3e7c5a19c9409851879 (diff) | |
download | rockbox-092c340a2062fa98b7387fc5fd63578ddae7d0b6.tar.gz rockbox-092c340a2062fa98b7387fc5fd63578ddae7d0b6.zip |
[1/4] Remove SH support and all archos targets
This removes all code specific to SH targets
Change-Id: I7980523785d2596e65c06430f4638eec74a06061
Diffstat (limited to 'firmware/debug.c')
-rw-r--r-- | firmware/debug.c | 193 |
1 files changed, 0 insertions, 193 deletions
diff --git a/firmware/debug.c b/firmware/debug.c index bc382335b6..34f89908a3 100644 --- a/firmware/debug.c +++ b/firmware/debug.c | |||
@@ -30,9 +30,6 @@ | |||
30 | 30 | ||
31 | #ifdef DEBUG | 31 | #ifdef DEBUG |
32 | static char debugmembuf[200]; | 32 | static char debugmembuf[200]; |
33 | #if CONFIG_CPU == SH7034 | ||
34 | static char debugbuf[400]; | ||
35 | #endif | ||
36 | #endif | 33 | #endif |
37 | 34 | ||
38 | #include "kernel.h" | 35 | #include "kernel.h" |
@@ -40,194 +37,6 @@ static char debugbuf[400]; | |||
40 | #include "debug.h" | 37 | #include "debug.h" |
41 | 38 | ||
42 | #ifdef DEBUG | 39 | #ifdef DEBUG |
43 | #if CONFIG_CPU == SH7034 /* these are still very SH-oriented */ | ||
44 | void debug_init(void) | ||
45 | { | ||
46 | /* Clear it all! */ | ||
47 | SSR1 &= ~(SCI_RDRF | SCI_ORER | SCI_PER | SCI_FER); | ||
48 | |||
49 | /* This enables the serial Rx interrupt, to be able to exit into the | ||
50 | debugger when you hit CTRL-C */ | ||
51 | SCR1 |= 0x40; | ||
52 | SCR1 &= ~0x80; | ||
53 | IPRE |= 0xf000; /* Set to highest priority */ | ||
54 | } | ||
55 | |||
56 | static int debug_tx_ready(void) | ||
57 | { | ||
58 | return (SSR1 & SCI_TDRE); | ||
59 | } | ||
60 | |||
61 | static void debug_tx_char(char ch) | ||
62 | { | ||
63 | while (!debug_tx_ready()) | ||
64 | { | ||
65 | ; | ||
66 | } | ||
67 | |||
68 | /* | ||
69 | * Write data into TDR and clear TDRE | ||
70 | */ | ||
71 | TDR1 = ch; | ||
72 | SSR1 &= ~SCI_TDRE; | ||
73 | } | ||
74 | |||
75 | static void debug_handle_error(char ssr) | ||
76 | { | ||
77 | (void)ssr; | ||
78 | SSR1 &= ~(SCI_ORER | SCI_PER | SCI_FER); | ||
79 | } | ||
80 | |||
81 | static int debug_rx_ready(void) | ||
82 | { | ||
83 | char ssr; | ||
84 | |||
85 | ssr = SSR1 & ( SCI_PER | SCI_FER | SCI_ORER ); | ||
86 | if ( ssr ) | ||
87 | debug_handle_error ( ssr ); | ||
88 | return SSR1 & SCI_RDRF; | ||
89 | } | ||
90 | |||
91 | static char debug_rx_char(void) | ||
92 | { | ||
93 | char ch; | ||
94 | char ssr; | ||
95 | |||
96 | while (!debug_rx_ready()) | ||
97 | { | ||
98 | ; | ||
99 | } | ||
100 | |||
101 | ch = RDR1; | ||
102 | SSR1 &= ~SCI_RDRF; | ||
103 | |||
104 | ssr = SSR1 & (SCI_PER | SCI_FER | SCI_ORER); | ||
105 | |||
106 | if (ssr) | ||
107 | debug_handle_error (ssr); | ||
108 | |||
109 | return ch; | ||
110 | } | ||
111 | |||
112 | static const char hexchars[] = "0123456789abcdef"; | ||
113 | |||
114 | static char highhex(int x) | ||
115 | { | ||
116 | return hexchars[(x >> 4) & 0xf]; | ||
117 | } | ||
118 | |||
119 | static char lowhex(int x) | ||
120 | { | ||
121 | return hexchars[x & 0xf]; | ||
122 | } | ||
123 | |||
124 | static void putpacket (const char *buffer) | ||
125 | { | ||
126 | register int checksum; | ||
127 | |||
128 | const char *src = buffer; | ||
129 | |||
130 | /* Special debug hack. Shut off the Rx IRQ during I/O to prevent the debug | ||
131 | stub from interrupting the message */ | ||
132 | SCR1 &= ~0x40; | ||
133 | |||
134 | debug_tx_char ('$'); | ||
135 | checksum = 0; | ||
136 | |||
137 | while (*src) | ||
138 | { | ||
139 | int runlen; | ||
140 | |||
141 | /* Do run length encoding */ | ||
142 | for (runlen = 0; runlen < 100; runlen ++) | ||
143 | { | ||
144 | if (src[0] != src[runlen] || runlen == 99) | ||
145 | { | ||
146 | if (runlen > 3) | ||
147 | { | ||
148 | int encode; | ||
149 | /* Got a useful amount */ | ||
150 | debug_tx_char (*src); | ||
151 | checksum += *src; | ||
152 | debug_tx_char ('*'); | ||
153 | checksum += '*'; | ||
154 | checksum += (encode = runlen + ' ' - 4); | ||
155 | debug_tx_char (encode); | ||
156 | src += runlen; | ||
157 | } | ||
158 | else | ||
159 | { | ||
160 | debug_tx_char (*src); | ||
161 | checksum += *src; | ||
162 | src++; | ||
163 | } | ||
164 | break; | ||
165 | } | ||
166 | } | ||
167 | } | ||
168 | |||
169 | |||
170 | debug_tx_char ('#'); | ||
171 | debug_tx_char (highhex(checksum)); | ||
172 | debug_tx_char (lowhex(checksum)); | ||
173 | |||
174 | /* Wait for the '+' */ | ||
175 | debug_rx_char(); | ||
176 | |||
177 | /* Special debug hack. Enable the IRQ again */ | ||
178 | SCR1 |= 0x40; | ||
179 | } | ||
180 | |||
181 | |||
182 | /* convert the memory, pointed to by mem into hex, placing result in buf */ | ||
183 | /* return a pointer to the last char put in buf (null) */ | ||
184 | static char *mem2hex (const char *mem, char *buf, int count) | ||
185 | { | ||
186 | int i; | ||
187 | int ch; | ||
188 | for (i = 0; i < count; i++) | ||
189 | { | ||
190 | ch = *mem++; | ||
191 | *buf++ = highhex (ch); | ||
192 | *buf++ = lowhex (ch); | ||
193 | } | ||
194 | *buf = 0; | ||
195 | return (buf); | ||
196 | } | ||
197 | |||
198 | static void debug(const char *msg) | ||
199 | { | ||
200 | debugbuf[0] = 'O'; | ||
201 | |||
202 | mem2hex(msg, &debugbuf[1], strlen(msg)); | ||
203 | putpacket(debugbuf); | ||
204 | } | ||
205 | #elif defined(HAVE_GDB_API) | ||
206 | static void *get_api_function(int n) | ||
207 | { | ||
208 | struct gdb_api *api = (struct gdb_api *)GDB_API_ADDRESS; | ||
209 | if (api->magic == GDB_API_MAGIC) | ||
210 | return api->func[n]; | ||
211 | else | ||
212 | return NULL; | ||
213 | } | ||
214 | |||
215 | void breakpoint(void) | ||
216 | { | ||
217 | void (*f)(void) = get_api_function(0); | ||
218 | if (f) (*f)(); | ||
219 | } | ||
220 | |||
221 | static void debug(char *msg) | ||
222 | { | ||
223 | void (*f)(char *) = get_api_function(1); | ||
224 | if (f) (*f)(msg); | ||
225 | } | ||
226 | |||
227 | void debug_init(void) | ||
228 | { | ||
229 | } | ||
230 | #else /* !SH7034 && !HAVE_GDB_API */ | ||
231 | void debug_init(void) | 40 | void debug_init(void) |
232 | { | 41 | { |
233 | } | 42 | } |
@@ -236,8 +45,6 @@ static inline void debug(char *msg) | |||
236 | { | 45 | { |
237 | (void)msg; | 46 | (void)msg; |
238 | } | 47 | } |
239 | #endif | ||
240 | |||
241 | #endif /* end of DEBUG section */ | 48 | #endif /* end of DEBUG section */ |
242 | 49 | ||
243 | #ifdef __GNUC__ | 50 | #ifdef __GNUC__ |