-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.s
460 lines (456 loc) · 11.1 KB
/
main.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
.text
.file "main.c"
.globl get_next_virtual_adress ! -- Begin function get_next_virtual_adress
.p2align 2
.type get_next_virtual_adress,@function
get_next_virtual_adress: ! @get_next_virtual_adress
.Lget_next_virtual_adress$local:
.cfi_startproc
! %bb.0:
st fp, [-- GP]
add GP, 0x8
sub GP, 0x18
ld 0[ fp], GPR3
mov hi(actuel_adress), GPR3
or GPR3, lo(actuel_adress)
ld 0[ GPR3], GPR9
ld 4[ GPR3], GPR3
sub fp, 0x10
or GPR12, 0x4
st GPR3, 0[ GPR12]
st GPR9, -16[ fp]
bt .LBB0_1
st GPR0, -20[ fp]
.LBB0_1: ! =>This Inner Loop Header: Depth=1
ld -20[ fp], GPR3
ld 0[ fp], GPR9
sha GPR9, -0x1f, GPR12
sh GPR12, -0x1d, GPR12
add GPR9, GPR12
sha GPR9, -0x3, GPR9
sub.f GPR3, GPR9, r0
bge .LBB0_4
nop
bt .LBB0_2
nop
.LBB0_2: ! in Loop: Header=BB0_1 Depth=1
mov hi(actuel_adress), GPR3
or GPR3, lo(actuel_adress)
ld 0[ GPR3], GPR9
ld 4[ GPR3], GPR12
add GPR12, 0x1
sub.f GPR13, GPR12, r0
sult GPR12
add GPR9, GPR12
st GPR13, 4[ GPR3]
bt .LBB0_3
st GPR9, 0[ GPR3]
.LBB0_3: ! in Loop: Header=BB0_1 Depth=1
ld -20[ fp], GPR3
add GPR3, 0x1
bt .LBB0_1
st GPR3, -20[ fp]
.LBB0_4:
sub fp, 0x10
or GPR3, 0x4
ld 0[ GPR3], GPR9
ld -16[ fp], rv
ld -4[fp], pc ! return
add fp, 0x0
ld -8[ fp], fp
.Lfunc_end0:
.size get_next_virtual_adress, .Lfunc_end0-get_next_virtual_adress
.cfi_endproc
! -- End function
.globl init_pagination ! -- Begin function init_pagination
.p2align 2
.type init_pagination,@function
init_pagination: ! @init_pagination
.Linit_pagination$local:
.cfi_startproc
! %bb.0:
st fp, [-- GP]
add GP, 0x8
sub GP, 0x30
mov 0x10, GPR3
st GPR3, 0[ GP]
add SP, 0x10
st rca, [-- GP]
bt get_next_virtual_adress
nop
mov hi(pag_config), GPR3
or GPR3, lo(pag_config)
st GPR12, -40[ fp]
st GPR9, 0[ GPR12]
ld 0[ GPR12], GPR3
mov 0x14, GPR9
st.h GPR9, 2[ GPR3]
ld 0[ GPR12], GPR3
mov 0x1, GPR9
st.b GPR9, 1[ GPR3]
ld 0[ GPR12], GPR3
st.b GPR9, 0[ GPR3]
mov 0xa0, GPR3
st GPR3, 0[ GP]
add SP, 0x10
st rca, [-- GP]
bt get_next_virtual_adress
nop
mov hi(pages), GPR3
or GPR3, lo(pages)
st GPR9, 0[ GPR3]
ld 0[ GPR3], GPR3
ld -40[ fp], GPR9
ld 0[ GPR9], GPR9
st GPR3, 12[ GPR9]
st GPR0, 8[ GPR9]
bt .LBB1_1
st GPR0, -12[ fp]
.LBB1_1: ! =>This Inner Loop Header: Depth=1
ld -12[ fp], GPR3
sub.f GPR3, 0x13, r0
bgt .LBB1_4
nop
bt .LBB1_2
nop
.LBB1_2: ! in Loop: Header=BB1_1 Depth=1
uld.b -32[ fp], GPR3
mov 0xe1, GPR9
and GPR3, GPR9
or GPR3, 0x6
st.b GPR3, -32[ fp]
sub fp, 0x20
st GPR3, -36[ fp]
or GPR3, 0x1
uld.b 0[ GPR3], GPR9
mov 0xf0, GPR12
and GPR9, GPR12
st.b GPR9, 0[ GPR3]
mov 0x1, GPR3
st GPR3, 0[ GP]
add SP, 0x10
st rca, [-- GP]
bt get_next_virtual_adress
nop
st GPR9, -20[ fp]
st rv, -24[ fp]
mov hi(pages), GPR3
or GPR3, lo(pages)
ld 0[ GPR3], GPR9
ld -12[ fp], GPR12
sh GPR12, 0x3, GPR12
add GPR9, GPR12
ld -20[ fp], GPR12
st GPR12, 20[ GPR9]
ld -24[ fp], GPR12
st GPR12, 16[ GPR9]
ld -36[ fp], GPR12
or GPR12, 0x4
ld 0[ GPR12], GPR12
st GPR12, 12[ GPR9]
ld -32[ fp], GPR12
st GPR12, 8[ GPR9]
ld 0[ GPR3], GPR9
ld -12[ fp], GPR12
sh GPR12, 0x3, GPR12
uld.h [ GPR9 add GPR12], GPR13
mov 0xfff0, GPR14
and GPR13, GPR14
or GPR13, 0x3
st.h GPR13, [ GPR9 add GPR12]
ld 0[ GPR3], GPR9
ld -12[ fp], GPR12
sh GPR12, 0x3, GPR12
add GPR9, GPR12
uld.h 0[ GPR13], GPR13
or GPR13, 0x100
st.h GPR13, [ GPR9 add GPR12]
ld 0[ GPR3], GPR3
ld -12[ fp], GPR9
sh GPR9, 0x3, GPR9
uld.h [ GPR3 add GPR9], GPR12
mov 0xff0f, GPR13
and GPR12, GPR13
bt .LBB1_3
st.h GPR12, [ GPR3 add GPR9]
.LBB1_3: ! in Loop: Header=BB1_1 Depth=1
ld -12[ fp], GPR3
add GPR3, 0x1
bt .LBB1_1
st GPR3, -12[ fp]
.LBB1_4:
mov hi(pag_config), GPR3
or GPR3, lo(pag_config)
ld 0[ GPR3], GPR3
st GPR3, 4[ GP]
mov hi(.L.str), GPR3
or GPR3, lo(.L.str)
st GPR3, 0[ GP]
add SP, 0x10
st rca, [-- GP]
bt chiara_asm
nop
ld -4[fp], pc ! return
add fp, 0x0
ld -8[ fp], fp
.Lfunc_end1:
.size init_pagination, .Lfunc_end1-init_pagination
.cfi_endproc
! -- End function
.globl chiara_handle_bad_opcode ! -- Begin function chiara_handle_bad_opcode
.p2align 2
.type chiara_handle_bad_opcode,@function
chiara_handle_bad_opcode: ! @chiara_handle_bad_opcode
.Lchiara_handle_bad_opcode$local:
.cfi_startproc
! %bb.0:
st fp, [-- GP]
add GP, 0x8
sub GP, 0x8
ld -4[fp], pc ! return
add fp, 0x0
ld -8[ fp], fp
.Lfunc_end2:
.size chiara_handle_bad_opcode, .Lfunc_end2-chiara_handle_bad_opcode
.cfi_endproc
! -- End function
.globl chiara_handle_no_stack_pointer ! -- Begin function chiara_handle_no_stack_pointer
.p2align 2
.type chiara_handle_no_stack_pointer,@function
chiara_handle_no_stack_pointer: ! @chiara_handle_no_stack_pointer
.Lchiara_handle_no_stack_pointer$local:
.cfi_startproc
! %bb.0:
st fp, [-- GP]
add GP, 0x8
sub GP, 0x8
ld -4[fp], pc ! return
add fp, 0x0
ld -8[ fp], fp
.Lfunc_end3:
.size chiara_handle_no_stack_pointer, .Lfunc_end3-chiara_handle_no_stack_pointer
.cfi_endproc
! -- End function
.globl chiara_handle_bad_permissions ! -- Begin function chiara_handle_bad_permissions
.p2align 2
.type chiara_handle_bad_permissions,@function
chiara_handle_bad_permissions: ! @chiara_handle_bad_permissions
.Lchiara_handle_bad_permissions$local:
.cfi_startproc
! %bb.0:
st fp, [-- GP]
add GP, 0x8
sub GP, 0x8
ld -4[fp], pc ! return
add fp, 0x0
ld -8[ fp], fp
.Lfunc_end4:
.size chiara_handle_bad_permissions, .Lfunc_end4-chiara_handle_bad_permissions
.cfi_endproc
! -- End function
.globl chiara_handle_bad_adress ! -- Begin function chiara_handle_bad_adress
.p2align 2
.type chiara_handle_bad_adress,@function
chiara_handle_bad_adress: ! @chiara_handle_bad_adress
.Lchiara_handle_bad_adress$local:
.cfi_startproc
! %bb.0:
st fp, [-- GP]
add GP, 0x8
sub GP, 0x8
ld -4[fp], pc ! return
add fp, 0x0
ld -8[ fp], fp
.Lfunc_end5:
.size chiara_handle_bad_adress, .Lfunc_end5-chiara_handle_bad_adress
.cfi_endproc
! -- End function
.globl init_interrupts ! -- Begin function init_interrupts
.p2align 2
.type init_interrupts,@function
init_interrupts: ! @init_interrupts
.Linit_interrupts$local:
.cfi_startproc
! %bb.0:
st fp, [-- GP]
add GP, 0x8
sub GP, 0x18
mov 0xff0, GPR3
st GPR3, 0[ GP]
add SP, 0x10
st rca, [-- GP]
bt get_next_virtual_adress
nop
mov hi(chiara64_interrupt), GPR3
or GPR3, lo(chiara64_interrupt)
st GPR9, 0[ GPR3]
ld 0[ GPR3], GPR9
uld.b 0[ GPR9], GPR12
or GPR12, 0x1
st.b GPR12, 0[ GPR9]
ld 0[ GPR3], GPR9
mov hi(chiara_handle_no_stack_pointer), GPR12
or GPR12, lo(chiara_handle_no_stack_pointer)
st GPR12, 12[ GPR9]
st GPR0, 8[ GPR9]
ld 0[ GPR3], GPR9
uld.b 16[ GPR9], GPR12
or GPR12, 0x1
st.b GPR12, 16[ GPR9]
ld 0[ GPR3], GPR9
mov hi(chiara_handle_bad_permissions), GPR12
or GPR12, lo(chiara_handle_bad_permissions)
st GPR12, 28[ GPR9]
st GPR0, 24[ GPR9]
ld 0[ GPR3], GPR9
uld.b 32[ GPR9], GPR12
or GPR12, 0x1
st.b GPR12, 32[ GPR9]
ld 0[ GPR3], GPR9
mov hi(chiara_handle_bad_opcode), GPR12
or GPR12, lo(chiara_handle_bad_opcode)
st GPR12, 44[ GPR9]
st GPR0, 40[ GPR9]
ld 0[ GPR3], GPR9
uld.b 48[ GPR9], GPR12
or GPR12, 0x1
st.b GPR12, 48[ GPR9]
ld 0[ GPR3], GPR3
mov hi(chiara_handle_bad_adress), GPR9
or GPR9, lo(chiara_handle_bad_adress)
st GPR9, 60[ GPR3]
st GPR0, 56[ GPR3]
mov 0x4, GPR3
bt .LBB6_1
st GPR3, -12[ fp]
.LBB6_1: ! =>This Inner Loop Header: Depth=1
ld -12[ fp], GPR3
sub.f GPR3, 0xfe, r0
bgt .LBB6_4
nop
bt .LBB6_2
nop
.LBB6_2: ! in Loop: Header=BB6_1 Depth=1
mov hi(chiara64_interrupt), GPR3
or GPR3, lo(chiara64_interrupt)
ld 0[ GPR3], GPR9
ld -12[ fp], GPR12
sh GPR12, 0x4, GPR12
uld.b [ GPR9 add GPR12], GPR13
mov 0xfe, GPR14
and GPR13, GPR14
st.b GPR13, [ GPR9 add GPR12]
ld 0[ GPR3], GPR3
ld -12[ fp], GPR9
sh GPR9, 0x4, GPR9
add GPR3, GPR9
st GPR0, 12[ GPR3]
bt .LBB6_3
st GPR0, 8[ GPR3]
.LBB6_3: ! in Loop: Header=BB6_1 Depth=1
ld -12[ fp], GPR3
add GPR3, 0x1
bt .LBB6_1
st GPR3, -12[ fp]
.LBB6_4:
mov hi(chiara64_interrupt), GPR3
or GPR3, lo(chiara64_interrupt)
ld 0[ GPR3], GPR3
st GPR3, 4[ GP]
mov hi(.L.str.1), GPR3
or GPR3, lo(.L.str.1)
st GPR3, 0[ GP]
add SP, 0x10
st rca, [-- GP]
bt chiara_asm
nop
ld -4[fp], pc ! return
add fp, 0x0
ld -8[ fp], fp
.Lfunc_end6:
.size init_interrupts, .Lfunc_end6-init_interrupts
.cfi_endproc
! -- End function
.globl init_restraint_mode ! -- Begin function init_restraint_mode
.p2align 2
.type init_restraint_mode,@function
init_restraint_mode: ! @init_restraint_mode
.Linit_restraint_mode$local:
.cfi_startproc
! %bb.0:
st fp, [-- GP]
add GP, 0x8
sub GP, 0x10
mov hi(.L.str.2), GPR3
or GPR3, lo(.L.str.2)
st GPR3, 0[ GP]
add SP, 0x10
st rca, [-- GP]
bt chiara_asm
nop
ld -4[fp], pc ! return
add fp, 0x0
ld -8[ fp], fp
.Lfunc_end7:
.size init_restraint_mode, .Lfunc_end7-init_restraint_mode
.cfi_endproc
! -- End function
.globl main ! -- Begin function main
.p2align 2
.type main,@function
main: ! @main
.Lmain$local:
.cfi_startproc
! %bb.0:
st fp, [-- GP]
add GP, 0x8
sub GP, 0x8
add SP, 0x10
st rca, [-- GP]
bt init_pagination
nop
add SP, 0x10
st rca, [-- GP]
bt init_interrupts
nop
add SP, 0x10
st rca, [-- GP]
bt init_restraint_mode
nop
or GPR0, 0x0
ld -4[fp], pc ! return
add fp, 0x0
ld -8[ fp], fp
.Lfunc_end8:
.size main, .Lfunc_end8-main
.cfi_endproc
! -- End function
.type actuel_adress,@object ! @actuel_adress
.data
.globl actuel_adress
.p2align 3
actuel_adress:
.Lactuel_adress$local:
.quad 4096 ! 0x1000
.size actuel_adress, 8
.type pag_config,@object ! @pag_config
.comm pag_config,4,8
.type pages,@object ! @pages
.comm pages,4,8
.type .L.str,@object ! @.str
.section .rodata.str1.1,"aMS",@progbits,1
.L.str:
.asciz "prcfg PAG,%x"
.size .L.str, 13
.type chiara64_interrupt,@object ! @chiara64_interrupt
.comm chiara64_interrupt,4,8
.type .L.str.1,@object ! @.str.1
.L.str.1:
.asciz "prcfg INT,%x"
.size .L.str.1, 13
.type .L.str.2,@object ! @.str.2
.L.str.2:
.asciz "prcfg EXEC,2"
.size .L.str.2, 13
.ident "clang version 7.0.1-8+deb10u2 (tags/RELEASE_701/final)"
.section ".note.GNU-stack","",@progbits