This source file includes following definitions.
- my_blinker
- boot
- h_usrInit
- h_usrKernelInit
- h_usrRoot
1
2
3
4 #include "lolevel.h"
5 #include "platform.h"
6 #include "core.h"
7 #include "asmsafe.h"
8
9 const char * const new_sa = &_end;
10
11
12 extern long wrs_kernel_bss_start;
13 extern long wrs_kernel_bss_end;
14 extern void createHook (void *pNewTcb);
15 extern void deleteHook (void *pTcb);
16
17
18 void boot();
19
20
21 void __attribute__((naked,noinline)) h_usrInit();
22 void __attribute__((naked,noinline)) h_usrKernelInit();
23 void __attribute__((naked,noinline)) h_usrRoot();
24
25 #define YELLOW_LED 0xC02200B0
26 void __attribute__((naked,noinline)) my_blinker(int n) {
27 asm volatile (
28 " STMFD SP!, {R0-R9,LR}\n"
29 );
30 int i, j;
31 for (j=0; j<n; j++)
32 {
33 *((volatile int *) YELLOW_LED) = 0x46;
34 for (i=0; i<0x200000; i++) { asm volatile ( "nop \n" ); }
35
36 *((volatile int *) YELLOW_LED) = 0x44;
37 for (i=0; i<0x400000; i++) { asm volatile ( "nop \n" ); }
38 }
39 for (i=0; i<0x900000; i++) { asm volatile ( "nop \n" ); }
40 asm volatile (
41 " LDMFD SP!, {R0-R9,PC}\n"
42 );
43 }
44
45 void boot()
46 {
47
48
49 long *canon_data_src = (void*)0xffc33020;
50 long *canon_data_dst = (void*)0x1900;
51 long canon_data_len = 0x18c70 - 0x1900;
52 long *canon_bss_start = (void*)0x18c70;
53 long canon_bss_len = 0xc5d80 - 0x18c70;
54
55 long i;
56
57
58 asm volatile (
59 "MRC p15, 0, R0,c1,c0\n"
60 "ORR R0, R0, #0x1000\n"
61 "ORR R0, R0, #4\n"
62 "ORR R0, R0, #1\n"
63 "MCR p15, 0, R0,c1,c0\n"
64 :::"r0");
65
66 for(i=0;i<canon_data_len/4;i++)
67 canon_data_dst[i]=canon_data_src[i];
68
69 for(i=0;i<canon_bss_len/4;i++)
70 canon_bss_start[i]=0;
71
72
73 asm volatile (
74 "MRC p15, 0, R0,c1,c0\n"
75 "ORR R0, R0, #0x1000\n"
76 "BIC R0, R0, #4\n"
77 "ORR R0, R0, #1\n"
78 "MCR p15, 0, R0,c1,c0\n"
79 :::"r0");
80
81 h_usrInit();
82 }
83
84
85
86 void __attribute__((naked,noinline)) h_usrInit() {
87 asm volatile (
88 " MOV R12, SP \n"
89 " STMFD SP!, {R11,R12,LR,PC} \n"
90 " SUB R11, R12, #4 \n"
91 " SUB SP, SP, #4 \n"
92 " STR R0, [R11, #-0x10] \n"
93 " LDR R0, [R11, #-0x10] \n"
94 " BL sub_FF813ED0 \n"
95 " MOV R0, #1 \n"
96 " MOV R1, #2 \n"
97 " BL sub_FFC15DCC \n"
98 " BL sub_FFBB4890 \n"
99 " BL sub_FF811EA4 \n"
100 " BL sub_FF813B34 \n"
101 " BL h_usrKernelInit \n"
102 " LDMDB R11, {R11,SP,PC} \n"
103 );
104 }
105
106
107
108 void __attribute__((naked,noinline)) h_usrKernelInit() {
109 asm volatile (
110 " MOV R12, SP \n"
111 " STMFD SP!, {R11,R12,LR,PC} \n"
112 " SUB R11, R12, #4 \n"
113 " SUB SP, SP, #8 \n"
114 " BL sub_FFC162CC \n"
115 " BL sub_FFC2C2D0 \n"
116 " LDR R3, =0x17A94 \n"
117 " LDR R0, =0xC5740 \n"
118 " LDR R1, [R3] \n"
119 " LDR R2, =0xBBC00 \n"
120 " MOV R3, #0x100 \n"
121 " BL sub_FFC24A4C \n"
122 " LDR R3, =0x17A54 \n"
123 " LDR R0, =0x18214 \n"
124 " LDR R1, [R3] \n"
125 " BL sub_FFC24A4C \n"
126 " LDR R3, =0x17B10 \n"
127 " LDR R0, =0xC5714 \n"
128 " LDR R1, [R3] \n"
129 " BL sub_FFC24A4C \n"
130 " BL sub_FFC30E50 \n"
131 " BL sub_FF811FE4 \n"
132 " MOV R3, R0 \n"
133 " MOV R2, #0x800 \n"
134 " STR R2, [SP] \n"
135 " MOV R2, #0 \n"
136 " STR R2, [SP, #4] \n"
137 " LDR R0, =h_usrRoot \n"
138 " MOV R1, #0x4000 \n"
139
140 " LDR R2, =new_sa\n"
141 " LDR R2, [R2]\n"
142 " BL sub_FFC28E3C \n"
143 " LDMDB R11, {R11,SP,PC} \n"
144 );
145 }
146
147
148
149 void __attribute__((naked,noinline)) h_usrRoot() {
150 asm volatile (
151 " MOV R12, SP \n"
152 " STMFD SP!, {R11,R12,LR,PC} \n"
153 " SUB R11, R12, #4 \n"
154 " SUB SP, SP, #8 \n"
155 " STR R0, [R11, #-0x10] \n"
156 " STR R1, [R11, #-0x14] \n"
157 " BL sub_FF8140B0 \n"
158 " LDR R0, [R11, #-0x10] \n"
159 " LDR R1, [R11, #-0x14] \n"
160 " BL sub_FFC1C448 \n"
161 " LDR R0, [R11, #-0x10] \n"
162 " LDR R1, [R11, #-0x14] \n"
163 " BL sub_FFC1CEC0 \n"
164 " BL sub_FF813C00 \n"
165 " BL sub_FF813B08 \n"
166 " MOV R0, #0x32 \n"
167 " BL sub_FFC1F444 \n"
168 " BL sub_FF814104 \n"
169 " BL sub_FF8140DC \n"
170 " BL sub_FF814138 \n"
171 " BL sub_FF814050 \n"
172 " BL sub_FFC1ED04 \n"
173 " BL sub_FF81409C \n"
174 );
175
176 _taskCreateHookAdd(createHook);
177 _taskDeleteHookAdd(deleteHook);
178
179 drv_self_hide();
180
181
182 asm volatile (
183 " BL sub_FF812130 \n"
184 " LDMDB R11, {R11,SP,PC} \n"
185 );
186 }