about summary refs log tree commit diff stats
path: root/tools/iso/kernel.soso/interrupt.asm
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-01-01 18:22:19 -0800
committerKartik Agaram <vc@akkartik.com>2020-01-01 18:42:48 -0800
commit65409d2312e702a48d3cf5b32479d25266bda3c3 (patch)
tree62a7262fce61f2302109246da4536ce6f8e9ef80 /tools/iso/kernel.soso/interrupt.asm
parenta6da50ad30d2e1825575ffef497ab450a8f26e94 (diff)
downloadmu-65409d2312e702a48d3cf5b32479d25266bda3c3.tar.gz
5858
Move script to create a Soso boot image into a sub-directory.

I'm trying to streamline newcomer attention to just a couple of use cases.
Diffstat (limited to 'tools/iso/kernel.soso/interrupt.asm')
-rw-r--r--tools/iso/kernel.soso/interrupt.asm133
1 files changed, 133 insertions, 0 deletions
diff --git a/tools/iso/kernel.soso/interrupt.asm b/tools/iso/kernel.soso/interrupt.asm
new file mode 100644
index 00000000..5610ca55
--- /dev/null
+++ b/tools/iso/kernel.soso/interrupt.asm
@@ -0,0 +1,133 @@
+; NASM macro
+%macro ISR_ERROR_CODE 1
+  global isr%1
+  isr%1:
+    push dword %1         ; push the interrupt number
+    jmp handleISRCommon
+%endmacro
+
+; NASM macro
+%macro ISR_NO_ERROR_CODE 1
+  global isr%1
+  isr%1:
+    push dword 0          ; push a dummy error code just because to keep struct Registers the same as the above macro
+    push dword %1         ; push the interrupt number
+    jmp handleISRCommon
+%endmacro
+
+
+; NASM macro
+%macro IRQ 2
+  global irq%1
+  irq%1:
+    push dword 0          ; push a dummy error code just because to keep struct Registers the same again
+    push dword %2
+    jmp handleIRQCommon
+%endmacro
+        
+ISR_NO_ERROR_CODE  0
+ISR_NO_ERROR_CODE  1
+ISR_NO_ERROR_CODE  2
+ISR_NO_ERROR_CODE  3
+ISR_NO_ERROR_CODE  4
+ISR_NO_ERROR_CODE  5
+ISR_NO_ERROR_CODE  6
+ISR_NO_ERROR_CODE  7
+ISR_ERROR_CODE     8
+ISR_NO_ERROR_CODE  9
+ISR_ERROR_CODE     10
+ISR_ERROR_CODE     11
+ISR_ERROR_CODE     12
+ISR_ERROR_CODE     13
+ISR_ERROR_CODE     14
+ISR_NO_ERROR_CODE  15
+ISR_NO_ERROR_CODE  16
+ISR_NO_ERROR_CODE  17
+ISR_NO_ERROR_CODE  18
+ISR_NO_ERROR_CODE  19
+ISR_NO_ERROR_CODE  20
+ISR_NO_ERROR_CODE  21
+ISR_NO_ERROR_CODE  22
+ISR_NO_ERROR_CODE  23
+ISR_NO_ERROR_CODE  24
+ISR_NO_ERROR_CODE  25
+ISR_NO_ERROR_CODE  26
+ISR_NO_ERROR_CODE  27
+ISR_NO_ERROR_CODE  28
+ISR_NO_ERROR_CODE  29
+ISR_NO_ERROR_CODE  30
+ISR_NO_ERROR_CODE  31
+ISR_NO_ERROR_CODE  128
+
+; IRQ0 is handled by irqTimer below
+
+IRQ   1,    33
+IRQ   2,    34
+IRQ   3,    35
+IRQ   4,    36
+IRQ   5,    37
+IRQ   6,    38
+IRQ   7,    39
+IRQ   8,    40
+IRQ   9,    41
+IRQ  10,    42
+IRQ  11,    43
+IRQ  12,    44
+IRQ  13,    45
+IRQ  14,    46
+IRQ  15,    47
+
+%macro	SAVE_REGS 0
+        pushad
+        push ds ;those registers are 16 bit but they are pushed as 32 bits here
+        push es
+        push fs
+        push gs
+
+        push ebx
+        mov bx, 0x10 ; load the kernel data segment descriptor
+        mov ds, bx
+        mov es, bx
+        mov fs, bx
+        mov gs, bx
+        pop ebx
+%endmacro
+
+%macro	RESTORE_REGS 0
+        pop gs
+        pop fs
+        pop es
+        pop ds
+        popad
+%endmacro
+
+
+extern handleISR
+
+handleISRCommon:
+    SAVE_REGS
+    call handleISR
+    RESTORE_REGS
+    add esp, 8     ; deallocate the error code and the interrupt number
+    iret           ; pops CS, EIP, EFLAGS and also SS, and ESP if privilege change occurs
+
+extern handleIRQ
+
+
+handleIRQCommon:
+    SAVE_REGS
+    call handleIRQ
+    RESTORE_REGS
+    add esp, 8     ; deallocate the error code and the interrupt number
+    iret           ; pops CS, EIP, EFLAGS and also SS, and ESP if privilege change occurs
+
+extern handleTimerIRQ
+global irqTimer
+irqTimer:           ; this does not have int no and error code in the stack, so there is no "add esp, 8"
+        SAVE_REGS
+        call handleTimerIRQ
+        mov al,0x20
+        out 0x20,al
+        RESTORE_REGS
+        iret
+        
alt'>
511db8c ^
e1c5a42 ^













d65b795 ^






















528c64d ^

d65b795 ^
528c64d ^




141d41a ^
e1c5a42 ^

b90a54a ^



e1c5a42 ^
8c373fd ^
e1c5a42 ^







8c373fd ^
e1c5a42 ^
8c373fd ^
528c64d ^
8c373fd ^

528c64d ^
8c373fd ^
e1c5a42 ^
528c64d ^















8c373fd ^
528c64d ^








e1c5a42 ^
e1c5a42 ^






528c64d ^
0e0f36f ^
e1c5a42 ^






0e0f36f ^
e1c5a42 ^






ae429cd ^

e1c5a42 ^


e0448d7 ^
e1c5a42 ^
ae429cd ^
e1c5a42 ^





528c64d ^

73fefa7 ^







2b3e09c ^
73fefa7 ^


8c373fd ^




528c64d ^







e0448d7 ^
528c64d ^

e1c5a42 ^



2b3e09c ^
528c64d ^


2b3e09c ^
528c64d ^




73fefa7 ^




8c373fd ^




73fefa7 ^















528c64d ^
e1c5a42 ^

2b3e09c ^
e1c5a42 ^



528c64d ^





e1c5a42 ^
1d27d59 ^


2b3e09c ^
1d27d59 ^
e1c5a42 ^



2b3e09c ^
73fefa7 ^




a9aa343 ^
73fefa7 ^

e1c5a42 ^
224e8fe ^
e1c5a42 ^
















8c373fd ^
e1c5a42 ^







8c373fd ^

e1c5a42 ^

e1c5a42 ^




81ebc6a ^



e1c5a42 ^










73fefa7 ^
e1c5a42 ^

528c64d ^

e1c5a42 ^










73fefa7 ^
e1c5a42 ^
528c64d ^

e1c5a42 ^




44aa822 ^

8c373fd ^
e1c5a42 ^































528c64d ^





2b3e09c ^
528c64d ^




























e1c5a42 ^

2b3e09c ^
e1c5a42 ^


2b3e09c ^
e1c5a42 ^



4335669 ^
e1c5a42 ^






06c784b ^

e1c5a42 ^
06c784b ^
e1c5a42 ^





06c784b ^
e1c5a42 ^



2b3e09c ^
e1c5a42 ^
2b3e09c ^



e1c5a42 ^
35f81e5 ^
e1c5a42 ^


2b3e09c ^
e1c5a42 ^
2b3e09c ^

e1c5a42 ^
35f81e5 ^
e1c5a42 ^




e0448d7 ^
e1c5a42 ^
2b3e09c ^
e1c5a42 ^
35f81e5 ^
e1c5a42 ^




e0448d7 ^
e1c5a42 ^
35f81e5 ^
e1c5a42 ^




2b3e09c ^
e1c5a42 ^
35f81e5 ^
e1c5a42 ^

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
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564