diff options
Diffstat (limited to 'firmware/target/mips/ingenic_jz47xx/debug-jz4760.c')
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/debug-jz4760.c | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/debug-jz4760.c b/firmware/target/mips/ingenic_jz47xx/debug-jz4760.c new file mode 100644 index 0000000000..88fc351946 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/debug-jz4760.c | |||
@@ -0,0 +1,146 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2016 by Roman Stolyarov | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "config.h" | ||
23 | #include "system.h" | ||
24 | #include "cpu.h" | ||
25 | #include <stdarg.h> | ||
26 | #include <stdio.h> | ||
27 | #include "lcd.h" | ||
28 | #include "kernel.h" | ||
29 | #include "font.h" | ||
30 | #include "button.h" | ||
31 | #include "timefuncs.h" | ||
32 | |||
33 | #define CFG_UART_BASE UART1_BASE /* Base of the UART channel */ | ||
34 | |||
35 | void serial_putc (const char c) | ||
36 | { | ||
37 | volatile u8 *uart_lsr = (volatile u8 *)(CFG_UART_BASE + OFF_LSR); | ||
38 | volatile u8 *uart_tdr = (volatile u8 *)(CFG_UART_BASE + OFF_TDR); | ||
39 | |||
40 | if (c == '\n') serial_putc ('\r'); | ||
41 | |||
42 | /* Wait for fifo to shift out some bytes */ | ||
43 | while ( !((*uart_lsr & (UARTLSR_TDRQ | UARTLSR_TEMT)) == 0x60) ); | ||
44 | |||
45 | *uart_tdr = (u8)c; | ||
46 | } | ||
47 | |||
48 | void serial_puts (const char *s) | ||
49 | { | ||
50 | while (*s) { | ||
51 | serial_putc (*s++); | ||
52 | } | ||
53 | } | ||
54 | |||
55 | void serial_putsf(const char *format, ...) | ||
56 | { | ||
57 | static char printfbuf[256]; | ||
58 | int len; | ||
59 | unsigned char *ptr; | ||
60 | va_list ap; | ||
61 | va_start(ap, format); | ||
62 | |||
63 | ptr = printfbuf; | ||
64 | len = vsnprintf(ptr, sizeof(printfbuf), format, ap); | ||
65 | va_end(ap); | ||
66 | |||
67 | serial_puts(ptr); | ||
68 | serial_putc('\n'); | ||
69 | } | ||
70 | |||
71 | void serial_put_hex(unsigned int d) | ||
72 | { | ||
73 | char c[12]; | ||
74 | int i; | ||
75 | for(i = 0; i < 8;i++) | ||
76 | { | ||
77 | c[i] = (d >> ((7 - i) * 4)) & 0xf; | ||
78 | if(c[i] < 10) | ||
79 | c[i] += 0x30; | ||
80 | else | ||
81 | c[i] += (0x41 - 10); | ||
82 | } | ||
83 | c[8] = '\n'; | ||
84 | c[9] = 0; | ||
85 | serial_puts(c); | ||
86 | |||
87 | } | ||
88 | |||
89 | void serial_put_dec(unsigned int d) | ||
90 | { | ||
91 | char c[16]; | ||
92 | int i; | ||
93 | int j = 0; | ||
94 | int x = d; | ||
95 | |||
96 | while (x /= 10) | ||
97 | j++; | ||
98 | |||
99 | for (i = j; i >= 0; i--) { | ||
100 | c[i] = d % 10; | ||
101 | c[i] += 0x30; | ||
102 | d /= 10; | ||
103 | } | ||
104 | c[j + 1] = '\n'; | ||
105 | c[j + 2] = 0; | ||
106 | serial_puts(c); | ||
107 | } | ||
108 | |||
109 | void serial_dump_data(unsigned char* data, int len) | ||
110 | { | ||
111 | int i; | ||
112 | for(i=0; i<len; i++) | ||
113 | { | ||
114 | unsigned char a = ((*data)>>4) & 0xf; | ||
115 | if(a < 10) | ||
116 | a += 0x30; | ||
117 | else | ||
118 | a += (0x41 - 10); | ||
119 | serial_putc( a ); | ||
120 | |||
121 | a = (*data) & 0xf; | ||
122 | if(a < 10) | ||
123 | a += 0x30; | ||
124 | else | ||
125 | a += (0x41 - 10); | ||
126 | serial_putc( a ); | ||
127 | |||
128 | serial_putc( ' ' ); | ||
129 | |||
130 | data++; | ||
131 | } | ||
132 | |||
133 | serial_putc( '\n' ); | ||
134 | } | ||
135 | |||
136 | bool dbg_ports(void) | ||
137 | { | ||
138 | serial_puts("dbg_ports\n"); | ||
139 | return false; | ||
140 | } | ||
141 | |||
142 | bool dbg_hw_info(void) | ||
143 | { | ||
144 | serial_puts("dbg_hw_info\n"); | ||
145 | return false; | ||
146 | } | ||