This source file includes following definitions.
- boot
- h_usrInit
- h_usrKernelInit
- h_usrRoot
- ttyRead
- mytty_nextline
- mytty_putc
- ttyWrite
- replaceConsoleDriver
- h_ios_tty_Init
1 #include "lolevel.h"
2 #include "platform.h"
3 #include "core.h"
4
5
6
7
8 extern long wrs_kernel_bss_start;
9 extern long wrs_kernel_bss_end;
10 extern void createHook (void *pNewTcb);
11 extern void deleteHook (void *pTcb);
12 const char * const new_sa = &_end;
13
14 void boot();
15
16
17 void __attribute__((naked,noinline)) h_usrInit();
18 void __attribute__((naked,noinline)) h_usrKernelInit();
19 void __attribute__((naked,noinline)) h_usrRoot();
20
21
22 void boot()
23 {
24 long *canon_data_src = (void*)0xFFAD74A0;
25 long *canon_data_dst = (void*)0x1900;
26 long canon_data_len = 0xEAE0;
27 long *canon_bss_start = (void*)0x103E0;
28 long canon_bss_len = 0x72D40 - 0x103E0;
29
30 long i;
31
32 asm volatile (
33 "MRC p15, 0, R0,c1,c0\n"
34 "ORR R0, R0, #0x1000\n"
35 "ORR R0, R0, #4\n"
36 "ORR R0, R0, #1\n"
37 "MCR p15, 0, R0,c1,c0\n"
38 :::"r0");
39
40
41 for(i=0;i<canon_data_len/4;i++)
42 canon_data_dst[i]=canon_data_src[i];
43
44 for(i=0;i<canon_bss_len/4;i++)
45 canon_bss_start[i]=0;
46
47 asm volatile (
48 "MRC p15, 0, R0,c1,c0\n"
49 "ORR R0, R0, #0x1000\n"
50 "BIC R0, R0, #4\n"
51 "ORR R0, R0, #1\n"
52 "MCR p15, 0, R0,c1,c0\n"
53 :::"r0");
54
55 h_usrInit();
56 }
57
58
59 void h_usrInit()
60 {
61 asm volatile (
62 "STR LR, [SP,#-4]!\n"
63 "BL sub_FF811B20\n"
64 "MOV R0, #2\n"
65 "MOV R1, R0\n"
66 "BL sub_FFABDA10\n"
67 "BL sub_FFAA9FE0\n"
68 "BL sub_FF81125C\n"
69 "BL sub_FF811838\n"
70 "LDR LR, [SP],#4\n"
71 "B h_usrKernelInit\n"
72 );
73
74 }
75
76 void h_usrKernelInit()
77 {
78 asm volatile (
79 " STMFD SP!, {R4,LR}\n"
80 " SUB SP, SP, #8\n"
81 " BL sub_FFABDF10\n"
82 " BL sub_FFAD09D0\n"
83 " LDR R3, =0xF814\n"
84 " LDR R2, =0x70420\n"
85 " LDR R1, [R3]\n"
86 " LDR R0, =0x7270C\n"
87 " MOV R3, #0x100\n"
88 " BL sub_FFACC20C\n"
89 " LDR R3, =0xF7D4\n"
90 " LDR R0, =0xFBF4\n"
91 " LDR R1, [R3]\n"
92 " BL sub_FFACC20C\n"
93 " LDR R3, =0xF890\n"
94 " LDR R0, =0x726E0\n"
95 " LDR R1, [R3]\n"
96 " BL sub_FFACC20C\n"
97 " BL sub_FFAD5550\n"
98 " BL sub_FF811348\n"
99 " MOV R4, #0\n"
100 " MOV R3, R0\n"
101 " MOV R12, #0x800\n"
102 " LDR R0, =h_usrRoot\n"
103 " MOV R1, #0x4000\n"
104
105 );
106 asm volatile (
107 "LDR R2, =new_sa\n"
108 "LDR R2, [R2]\n"
109 );
110 asm volatile (
111 " STR R12, [SP]\n"
112 " STR R4, [SP,#4]\n"
113 " BL sub_FFACDC10\n"
114 " ADD SP, SP, #8\n"
115 " LDMFD SP!, {R4,PC}\n"
116 );
117 }
118
119
120 void h_usrRoot()
121 {
122 asm volatile (
123 " STMFD SP!, {R4,R5,LR}\n"
124 " MOV R5, R0\n"
125 " MOV R4, R1\n"
126 " BL sub_FF811BA0\n"
127 " MOV R1, R4\n"
128 " MOV R0, R5\n"
129 " BL sub_FFAC41F8\n"
130 " MOV R1, R4\n"
131 " MOV R0, R5\n"
132 " BL sub_FFAC4C70\n"
133
134 " BL sub_FF811814\n"
135 " MOV R0, #0x32\n"
136 " BL sub_FFAC66E0\n"
137 " BL sub_FF811BE4\n"
138 " BL sub_FF811BC4\n"
139 " BL sub_FF811C10\n"
140 " BL sub_FFAC5FA0\n"
141 " BL sub_FF811B94\n"
142 );
143 _taskCreateHookAdd(createHook);
144 _taskDeleteHookAdd(deleteHook);
145
146 drv_self_hide();
147
148 asm volatile (
149
150 " LDMFD SP!, {R4,R5,LR}\n"
151 " B sub_FF811408\n"
152 );
153 }
154
155
156 #if CAM_CONSOLE_LOG_ENABLED
157
158 typedef struct {
159 long dev_hdr[4];
160 long opened;
161
162 long fill[64];
163 } MY_DEV;
164
165 #define CONS_W (45)
166 #define CONS_H (128)
167
168 char console_buf[CONS_H][CONS_W];
169 long console_buf_line = 0;
170 long console_buf_line_ptr = 0;
171
172 char cmd[100] = "ShowCameraLog\n\0";
173 int cons_cmd_ptr = -1;
174
175 void mytty_putc(char c);
176
177 int ttyRead(MY_DEV* tty, char* buffer, int nBytes)
178 {
179 int r = 1;
180
181 if (cons_cmd_ptr == -1){
182 msleep(2000);
183 cons_cmd_ptr = 0;
184 }
185
186 mytty_putc('r');
187
188 if (cmd[cons_cmd_ptr] != 0){
189 *buffer = cmd[cons_cmd_ptr];
190 cons_cmd_ptr++;
191 } else {
192 while (cons_cmd_ptr != 0){
193 msleep(10);
194 }
195 *buffer = cmd[cons_cmd_ptr];
196 cons_cmd_ptr++;
197 }
198
199 return r;
200 }
201
202 void mytty_nextline()
203 {
204 int i;
205
206 console_buf_line_ptr=0;
207 console_buf_line++;
208 if (console_buf_line>=CONS_H){
209 console_buf_line = 0;
210 }
211 for (i=0;i<15;i++){
212 int l=i+console_buf_line;
213 if (l>=CONS_H)
214 l-=CONS_H;
215 console_buf[l][0] = 0;
216 }
217 }
218
219 void mytty_putc(char c)
220 {
221 if (c == 0xa){
222 mytty_nextline();
223 } else {
224 if (console_buf_line_ptr>=(CONS_W-1)){
225 mytty_nextline();
226 }
227
228 console_buf[console_buf_line][console_buf_line_ptr++] = c;
229 console_buf[console_buf_line][console_buf_line_ptr] = 0;
230 }
231 }
232
233 int tyWrite = 0xFFACA1E4;
234
235
236 int ttyWrite(MY_DEV* tty, char* buffer, int nBytes)
237 {
238 int i;
239
240 for (i=0;i<nBytes;i++){
241 mytty_putc(buffer[i]);
242 }
243
244 return ((int(*)(void *p, void *p2, int l))tyWrite)(tty, buffer, nBytes);
245
246 }
247
248
249
250
251
252
253
254
255 int *TTY_DRV_NUM = (int*)0x0006F578;
256
257 static void replaceConsoleDriver()
258 {
259
260 int f0 = 0xFFAC9274;
261 int f1 = 0;
262 int f2 = 0xFFAC9274;
263 int f3 = 0xFFAC92B4;
264 int f6 = 0xFFAC92F8;
265 int fRead = (int)&ttyRead;
266 int fWrite = (int)&ttyWrite;
267 int newdriver_id = _iosDrvInstall((void*)f0, (void*)f1, (void*)f2, (void*)f3, (void*)fRead, (void*)fWrite, (void*)f6);
268
269 *TTY_DRV_NUM = newdriver_id;
270 }
271
272 void h_ios_tty_Init()
273 {
274
275
276
277
278
279
280
281
282
283
284
285
286 _iosInit(0x14, 0x32, "/null");
287 replaceConsoleDriver();
288
289
290
291
292
293
294 }
295 #endif
296