diff options
Diffstat (limited to 'firmware/target/mips/ingenic_jz47xx/debug-jz4760.c')
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/debug-jz4760.c | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/debug-jz4760.c b/firmware/target/mips/ingenic_jz47xx/debug-jz4760.c index 848fa5343e..ffd9faaf60 100644 --- a/firmware/target/mips/ingenic_jz47xx/debug-jz4760.c +++ b/firmware/target/mips/ingenic_jz47xx/debug-jz4760.c | |||
@@ -169,3 +169,106 @@ bool dbg_hw_info(void) | |||
169 | } | 169 | } |
170 | return true; | 170 | return true; |
171 | } | 171 | } |
172 | |||
173 | #define CFG_UART_BASE UART1_BASE /* Base of the UART channel */ | ||
174 | |||
175 | void serial_putc (const char c) | ||
176 | { | ||
177 | volatile u8 *uart_lsr = (volatile u8 *)(CFG_UART_BASE + OFF_LSR); | ||
178 | volatile u8 *uart_tdr = (volatile u8 *)(CFG_UART_BASE + OFF_TDR); | ||
179 | |||
180 | if (c == '\n') serial_putc ('\r'); | ||
181 | |||
182 | /* Wait for fifo to shift out some bytes */ | ||
183 | while ( !((*uart_lsr & (UARTLSR_TDRQ | UARTLSR_TEMT)) == 0x60) ); | ||
184 | |||
185 | *uart_tdr = (u8)c; | ||
186 | } | ||
187 | |||
188 | void serial_puts (const char *s) | ||
189 | { | ||
190 | while (*s) { | ||
191 | serial_putc (*s++); | ||
192 | } | ||
193 | } | ||
194 | |||
195 | void serial_putsf(const char *format, ...) | ||
196 | { | ||
197 | static char printfbuf[256]; | ||
198 | int len; | ||
199 | unsigned char *ptr; | ||
200 | va_list ap; | ||
201 | va_start(ap, format); | ||
202 | |||
203 | ptr = printfbuf; | ||
204 | len = vsnprintf(ptr, sizeof(printfbuf), format, ap); | ||
205 | va_end(ap); | ||
206 | (void)len; | ||
207 | |||
208 | serial_puts(ptr); | ||
209 | serial_putc('\n'); | ||
210 | } | ||
211 | |||
212 | void serial_put_hex(unsigned int d) | ||
213 | { | ||
214 | char c[12]; | ||
215 | int i; | ||
216 | for(i = 0; i < 8;i++) | ||
217 | { | ||
218 | c[i] = (d >> ((7 - i) * 4)) & 0xf; | ||
219 | if(c[i] < 10) | ||
220 | c[i] += 0x30; | ||
221 | else | ||
222 | c[i] += (0x41 - 10); | ||
223 | } | ||
224 | c[8] = '\n'; | ||
225 | c[9] = 0; | ||
226 | serial_puts(c); | ||
227 | |||
228 | } | ||
229 | void serial_put_dec(unsigned int d) | ||
230 | { | ||
231 | char c[16]; | ||
232 | int i; | ||
233 | int j = 0; | ||
234 | int x = d; | ||
235 | |||
236 | while (x /= 10) | ||
237 | j++; | ||
238 | |||
239 | for (i = j; i >= 0; i--) { | ||
240 | c[i] = d % 10; | ||
241 | c[i] += 0x30; | ||
242 | d /= 10; | ||
243 | } | ||
244 | c[j + 1] = '\n'; | ||
245 | c[j + 2] = 0; | ||
246 | serial_puts(c); | ||
247 | } | ||
248 | |||
249 | void serial_dump_data(unsigned char* data, int len) | ||
250 | { | ||
251 | int i; | ||
252 | for(i=0; i<len; i++) | ||
253 | { | ||
254 | unsigned char a = ((*data)>>4) & 0xf; | ||
255 | if(a < 10) | ||
256 | a += 0x30; | ||
257 | else | ||
258 | a += (0x41 - 10); | ||
259 | serial_putc( a ); | ||
260 | |||
261 | a = (*data) & 0xf; | ||
262 | if(a < 10) | ||
263 | a += 0x30; | ||
264 | else | ||
265 | a += (0x41 - 10); | ||
266 | serial_putc( a ); | ||
267 | |||
268 | serial_putc( ' ' ); | ||
269 | |||
270 | data++; | ||
271 | } | ||
272 | |||
273 | serial_putc( '\n' ); | ||
274 | } | ||