-
Notifications
You must be signed in to change notification settings - Fork 0
/
kernel.inc
10187 lines (9745 loc) · 285 KB
/
kernel.inc
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
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
; User Memory Map (World view)
; +----------------------+
; | | 000000000H (prevent dereference 0H)
; |----------------------|
; | |
; | User Runnable Code |
; | |
; |----------------------| Program break (extend on brk by page unit)
; | |
; | |
; | |
; | |
; | |
; | |
; | |
; | User Space |
; | |
; | |
; | |
; | |
; | |
; | |
; | |
; |----------------------| Stack expand on page fault
; | User Stack |
; |----------------------|
; | User Shell Arguments | IPC for argument
; ////////////////////////
; | | 0C0000000H (principally for interrupts/syscall)
; | |
; | |
; | |
; | |
; | |
; | |
; | |
; | Kernel Space |
; | |
; | |
; | |
; | |
; | |
; | |
; |----------------------|
; | IO APIC Registers |
; |----------------------|
; | Local APIC Registers | Used by Legacy APIC, xAPIC (x2APIC use MSR)
; |----------------------|
; | VDSO Runnable Code | Used by sigret syscall and sysenter
; ////////////////////////
; | Video Framebuffer | 16Mb to sastify all kind of resolution
; ////////////////////////
; | Temporary Mappings | (duplicate PD/PT when address > 020H (only if PAE))
; |``````````````````````| Recursive mapping (used for mmap without changing cr3)
; |``````````````````````| 0FFC00000H (without PAE)
; |``````````````````````| 0FF600000H (with PAE)
; | Recursive Mappings |
; +----------------------+
; Kernel Memory Map (kernel does not necessary switch to this mapping on all interrupts/syscall)
; +-----------------------+
; |```````````````````````| 000000000H (managing physical address directly)
; |```````````````````````|
; |```````````````````````| 000100000H (reserved for devices, bios, memory map io, ...)
; | |
; | |
; | |
; | |
; | Identity Mappings |
; | |
; | |
; | |
; | |
; | |
; | |
; | |
; /////////////////////////
; | | 0C0000000H (memory here can be fragmented)
; | Virtual Space | Here Virtual Space = Kernel Space in all process
; | | (All PDE are used to provide this consistency)
; /////////////////////////
; | Zero PE | 0FFC00000H
; +-----------------------+
; Some PAE terminology
; I don't want to waste 1G address space, so I make the paging structure kind of mutually recursive
; In the PDPT table, I have added an extra slot that point to the PDPT itself, the fifth slot technique
; But for it to work, I must write to some reserved bit in the PDPTE. So a PDPTE are in "pure" form when all of it's reserved bit are zero
; Some paging terminology
; The sensitive mapping include two thing:
; Temporary mapping:
; 1th gen mapping is only useful for clearing a new physicall page when PA != VA
; 2th gen mapping is necessary to copy submapping because pointer can be 36-bit and register are ony 32-bit
; A maximum of 2 PDE temporary is used because otherwise it's a waste a linear address
; Recursive mapping are useful to modify the mapping without changing the PDBR
; Sensitive mapping (temporary mapping and recursive mapping) must be contiguous in the addressing space and are located at the end
; One property of the recursive mapping must be enforced. The recursive mapping must be linear
; It's must walk all PTE first, PDE, and PDPTE (PAE) last in that order
; PSE page are an exception that must be taken into account (No PSE PDE must be treated like a PTE (because of PAT which is not always present))
; Recursive level mean what [ebx] point to (PTE,PDE,PDPTE)?
_KERNEL_VIRTUAL = 0C0000000H
; 1th generation paging
_TEMP_1_INDEX = (_TABLE_ENTRY_COUNT - 3H)
_TEMP_2_INDEX = (_TABLE_ENTRY_COUNT - 2H)
_PAGE_DIRECTORY_INDEX = (_TABLE_ENTRY_COUNT - 1H)
_RECURSIVE_VIRTUAL = (_PAGE_DIRECTORY_INDEX shl _PAGE_DIRECTORY_SHIFT)
_PAGE_DIRECTORY_LINEAR = (_RECURSIVE_VIRTUAL or (_PAGE_DIRECTORY_INDEX shl _PAGE_TABLE_SHIFT))
_TEMP_MASK = (_PAGE_TABLE_MASK or _PAGE_OFFSET_MASK)
irp _kind*, _TEMP_1,_TEMP_2
{
_kind#_LINEAR_PTE = (_kind#_INDEX shl _PAGE_DIRECTORY_SHIFT)
_kind#_LINEAR_PDE = (_RECURSIVE_VIRTUAL or (_kind#_INDEX shl _PAGE_TABLE_SHIFT))
_kind#_LINEAR_ITSELF = (_PAGE_DIRECTORY_LINEAR or (_kind#_INDEX shl 2H))
}
_KERNEL_VIRTUAL_INDEX = (_KERNEL_VIRTUAL shr _PAGE_DIRECTORY_SHIFT)
_KERNEL_VIRTUAL_COUNT = ((_TABLE_ENTRY_COUNT - _KERNEL_VIRTUAL_INDEX) - 1H)
_PAGE_DIRECTORY_ITSELF = (_PAGE_DIRECTORY_LINEAR or (_PAGE_DIRECTORY_INDEX shl 2H))
_IO_APIC = (_LOCAL_APIC - _PAGE_FRAME_SIZE)
_LOCAL_APIC = (_USER_VDSO_VIRTUAL - _PAGE_FRAME_SIZE)
_USER_VDSO_VIRTUAL = (_FRAME_BUFFER_START - (_PSE_PAGE_FRAME_SIZE shl 1H))
_FRAME_BUFFER_START = (_SENSITIVE_TEMPORARY_START - (_REGEN_4MB_PAGE * _PSE_PAGE_FRAME_SIZE))
_SENSITIVE_TEMPORARY_START = _TEMP_1_LINEAR_PTE
_SENSITIVE_RECURSIVE_START = _RECURSIVE_VIRTUAL
assert (_SENSITIVE_TEMPORARY_START < _SENSITIVE_RECURSIVE_START)
; 2th generation paging
_PDPT_INDEX_KERNEL = 3H
_PDPT_INDEX_RECURSIVE = 4H
_PAE_TEMP_1_INDEX = (_PAE_TABLE_ENTRY_COUNT - 7H)
_PAE_TEMP_2_INDEX = (_PAE_TABLE_ENTRY_COUNT - 6H)
_PTE_INDEX_RECURSIVE_1 = (_PAE_TABLE_ENTRY_COUNT - 5H)
_PTE_INDEX_RECURSIVE_2 = (_PAE_TABLE_ENTRY_COUNT - 4H)
_PTE_INDEX_RECURSIVE_3 = (_PAE_TABLE_ENTRY_COUNT - 3H)
_PTE_INDEX_RECURSIVE_KERNEL = (_PAE_TABLE_ENTRY_COUNT - 2H)
_PAE_PAGE_DIRECTORY_POINTER_INDEX = (_PAE_TABLE_ENTRY_COUNT - 1H)
_PAE_RECURSIVE_VIRTUAL = ((_PDPT_INDEX_KERNEL shl _PAE_PAGE_DIRECTORY_POINTER_SHIFT) or (_PAE_PAGE_DIRECTORY_POINTER_INDEX shl _PAE_PAGE_DIRECTORY_SHIFT))
_PAE_PDPT_RECURSIVE_VIRTUAL = (_PAE_RECURSIVE_VIRTUAL or (_PDPT_INDEX_RECURSIVE shl _PAGE_TABLE_SHIFT))
_PAE_PTE_RECURSIVE_BASE = ((_PDPT_INDEX_KERNEL shl _PAE_PAGE_DIRECTORY_POINTER_SHIFT) or (_PTE_INDEX_RECURSIVE_1 shl _PAE_PAGE_DIRECTORY_SHIFT))
_PAE_PTE_RECURSIVE_BASE_ITSELF = (_PAE_RECURSIVE_VIRTUAL or (_PDPT_INDEX_KERNEL shl _PAGE_TABLE_SHIFT) or (_PTE_INDEX_RECURSIVE_1 shl 3H))
_PAE_KERNEL_PAGE_DIRECTORY = (_PAE_RECURSIVE_VIRTUAL or (_PDPT_INDEX_KERNEL shl _PAGE_TABLE_SHIFT))
_PAE_TEMP_MASK = (_PAE_PAGE_TABLE_MASK or _PAGE_OFFSET_MASK)
irp _kind*, TEMP_1,TEMP_2
{
_PAE_#_kind#_LINEAR_PTE = ((_PDPT_INDEX_KERNEL shl _PAE_PAGE_DIRECTORY_POINTER_SHIFT) or (_PAE_#_kind#_INDEX shl _PAE_PAGE_DIRECTORY_SHIFT))
_PAE_#_kind#_LINEAR_PDE = ((_PDPT_INDEX_KERNEL shl _PAE_PAGE_DIRECTORY_POINTER_SHIFT) or (_PTE_INDEX_RECURSIVE_KERNEL shl _PAE_PAGE_DIRECTORY_SHIFT)\
or (_PAE_#_kind#_INDEX shl _PAGE_TABLE_SHIFT))
_PAE_#_kind#_LINEAR_ITSELF = (_PAE_KERNEL_PAGE_DIRECTORY + (_PAE_#_kind#_INDEX shl 3H))
}
_PAE_IO_APIC = (_PAE_LOCAL_APIC - _PAGE_FRAME_SIZE)
_PAE_LOCAL_APIC = (_PAE_USER_VDSO_VIRTUAL - _PAGE_FRAME_SIZE)
_PAE_USER_VDSO_VIRTUAL = (_PAE_FRAME_BUFFER_START - (_PAE_PSE_PAGE_FRAME_SIZE shl 1H))
_PAE_FRAME_BUFFER_START = (_PAE_SENSITIVE_TEMPORARY_START - _PAE_PSE_PAGE_FRAME_SIZE - (_REGEN_4MB_PAGE * _PSE_PAGE_FRAME_SIZE)) ; need to align on _PSE_OFFSET_MASK
_PAE_SENSITIVE_TEMPORARY_START = _PAE_TEMP_1_LINEAR_PTE
_PAE_SENSITIVE_RECURSIVE_START = _PAE_PTE_RECURSIVE_BASE
assert (_PAE_SENSITIVE_TEMPORARY_START < _PAE_SENSITIVE_RECURSIVE_START)
assert ((_IO_APIC = _PAE_IO_APIC) & (_LOCAL_APIC = _PAE_LOCAL_APIC) & (_USER_VDSO_VIRTUAL = _PAE_USER_VDSO_VIRTUAL))
define _TELETYPE_COUNT 8H
_PAE_TELETYPE_START = 0H ; (_PAE_SENSITIVE_START - (_TELETYPE_COUNT shl ((bsf _PAE_TABLE_ENTRY_COUNT) + _PAGE_TABLE_SHIFT)))
_USER_CODE_VIRTUAL = 8563000H
_USER_SHELL_ARGUMENT_VIRTUAL = (_KERNEL_VIRTUAL - _PAGE_FRAME_SIZE)
_USER_STACK_VIRTUAL = (_USER_SHELL_ARGUMENT_VIRTUAL - _PAGE_FRAME_SIZE)
_KERNEL_STACK_SIZE = _PAGE_FRAME_SIZE
_CODE_KERNEL = (_kernel_code_segment.selector + _RPL0)
_DATA_KERNEL = (_kernel_data_segment.selector + _RPL0)
_CODE_USER = (_user_code_segment.selector + _RPL3)
_DATA_USER = (_user_data_segment.selector + _RPL3)
_TSS = _tss_segment.selector
_CALL_GATE = _call_gate.selector
_TSS_VM86 = _tss_vm86_segment.selector
_kernel_physical:
struct _linked _prev*, _next*
.prev: dd (_prev)
.next: dd (_next)
ends
struct _x86_register _edi*, _esi*, _ebp*, _ebx*, _edx*, _ecx*, _eax*, _ds*, _es*, _fs*, _gs*,\
_trap*, _error*, _eip*, _cs*, _eflags*, _esp*, _ss*
.edi: dd (_edi)
.esi: dd (_esi)
.ebp: dd (_ebp)
dd 0H
.ebx: dd (_ebx)
.edx: dd (_edx)
.ecx: dd (_ecx)
.eax: dd (_eax)
.ds: dw (_ds)
dw 0H
.es: dw (_es)
dw 0H
.fs: dw (_fs)
dw 0H
.gs: dw (_gs)
dw 0H
.trap: dd (_trap)
.error: dd (_error)
.eip: dd (_eip)
.cs: dw (_cs)
dw 0H
.eflags: dd (_eflags)
.esp: dd (_esp)
.ss: dw (_ss)
dw 0H
ends
struct _vm86_x86_register _edi*, _esi*, _ebp*, _ebx*, _edx*, _ecx*, _eax*, __ds*, __es*, __fs*, __gs*,\
_trap*, _error*, _eip*, _cs*, _eflags*, _esp*, _ss*, _es*, _ds*, _fs*, _gs*
.register _x86_register _edi, _esi, _ebp, _ebx, _edx, _ecx, _eax,\
__ds, __es, __fs, __gs, _trap, _error, _eip, _cs, _eflags, _esp, _ss
.es: dw (_es)
dw 0H
.ds: dw (_ds)
dw 0H
.fs: dw (_fs)
dw 0H
.gs: dw (_gs)
dw 0H
ends
struct _debug_context _active*, _dr0*, _dr1*, _dr2*, _dr3*, _dr6*, _dr7*
.active: db (_active)
.dr0: dd (_dr0)
.dr1: dd (_dr1)
.dr2: dd (_dr2)
.dr3: dd (_dr3)
.dr6: dd (_dr6)
.dr7: dd (_dr7)
ends
struct _float_context _active*, _save*
.active: db (_active)
.save: dd (_save) ; either by fxsave or xsave
ends
_current: dd 0H
_scheduler: dd 0H
_initproc: dd 0H
_process_list: dd 0H
_process_group: dd 0H
_session_list: dd 0H
_process_dead: dd 0H
_process_lock: db 0H ; XXX
struct _page_descriptor _lower*, _upper*, _count*, _lba*, _lock*, _prev*, _next*
.lower: dd (_lower) ; physical address low 32-bit
.upper: dd (_upper) ; physical address high 32-bit (only if PAE)
.count: dd (_count)
.lba: dd (_lba)
.lock: db (_lock)
align 4H
.list _linked (_prev), (_next)
ends
struct _process_group_descriptor _sid*, _pgid*, _leader*, _prclist*, _stopped*, _orphaned*, _prev_sess, _next_sess, _prev*, _next*
.sid: dd (_sid)
.pgid: dd (_pgid)
.leader: dd (_leader)
.prclist: dd (_prclist)
.stopped: dd (_stopped) ; count of stopped process in the group
.orphaned: db (_orphaned)
align 4H
.sess _linked (_prev_sess), (_next_sess)
.list _linked (_prev), (_next)
ends
struct _session_descriptor _sid*, _leader*, _grplist*, _teletype*, _attach*, _prev*, _next*
.sid: dd (_sid)
.leader: dd (_leader)
.grplist: dd (_grplist)
.teletype: dd (_teletype)
.attach: db (_attach)
align 4H
.list _linked (_prev), (_next)
ends
struct _cpuid _pae*, _maxphyaddr*, _nx*, _pse*, _pse36*, _pge*, _pat*, _popcnt*, _msr*, _xcr0*, _xsave*, _xsaves*,\
_osxsave*, _apic*, _x2apic*, _direoi*, _sep*, _mtrr*, _wc*, _clflush*, _fixmtrr*, _varmtrr*, _smrr*, _fpu*,\
_mmx*, _vme*, _de*, _smap*, _smep*, _avx*, _sse*, _sse2*, _sse3*, _ssse3*, _sse41*, _sse42*, _aes*, _pclmulqdq*,\
_fxsr*, _fsgsbase*, _rdseed*, _sha*, _umip*, _pcid*, _bmi1*, _bmi2*, _vmx*, _mce*, _mca*, _htt*, _acpi*, _lproc*, _linsz*
.pae: db (_pae)
.maxphyaddr:db (_maxphyaddr)
.nx: db (_nx)
.pse: db (_pse)
.pse36: db (_pse36)
.pge: db (_pge)
.pat: db (_pat)
.popcnt: db (_popcnt)
.msr: db (_msr)
.xcr0: db (_xcr0)
.xsave: db (_xsave) ; user xsave
.xsaves: db (_xsaves) ; supervisor xsave
.osxsave: db (_osxsave)
.apic: db (_apic)
.x2apic: db (_x2apic)
.direoi: db (_direoi)
.sep: db (_sep)
.mtrr: db (_mtrr)
.wc: db (_wc)
.clflush: db (_clflush)
.fixmtrr: db (_fixmtrr)
.varmtrr: db (_varmtrr)
.smrr: db (_smrr)
.fpu: db (_fpu)
.mmx: db (_mmx)
.vme: db (_vme)
.de: db (_de)
.avx: db (_avx)
.sse: db (_sse)
.sse2: db (_sse2)
.sse3: db (_sse3)
.ssse3: db (_ssse3)
.sse41: db (_sse41)
.sse42: db (_sse42)
.aes: db (_aes)
.pclmulqdq: db (_pclmulqdq)
.fxsr: db (_fxsr)
.fsgsbase: db (_fsgsbase)
.smep: db (_smep)
.smap: db (_smap)
.rdseed: db (_rdseed)
.sha: db (_sha)
.umip: db (_umip)
.pcid: db (_pcid)
.bmi1: db (_bmi1)
.bmi2: db (_bmi2)
.vmx: db (_vmx)
.mce: db (_mce)
.mca: db (_mca)
.htt: db (_htt)
.acpi: db (_acpi)
.lproc: db (_lproc)
.linsz: db (_linsz)
ends
assert (_cpuid.sizeof <= 07FH)
_singleton _cpuid 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H,\
0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H
_memory_size: dd 0H
_kernel_mapping: dd 0H
_kernel_vdso: dq 0H
_page_descriptor_head: dd 0H
irp _kind*, io,local
{
_#_kind#_apic_base: dd 0H
_#_kind#_apic_mtrr_alloc: db 0H
_#_kind#_apic_mtrr_phys: dd 0H
_#_kind#_apic_mtrr_mask: dd 0H
}
irp _kind*, io_apic,processor { _#_kind#_count: db 0H }
include "fonts.inc"
include "bitmap.inc"
_TELETYPE_TEXT_VIDEO = 00B8000H
_TELETYPE_TEXT_DEFAULT = 00720H
_TELETYPE_VIDEO_FRAME_START = _TELETYPE_GRAPHIC_320x200_VIDEO
_TELETYPE_VIDEO_FRAME_END = _TELETYPE_VIDEO_FRAME_START + 20000H
_TELETYPE_GRAPHIC_320x200_VIDEO = 00A0000H
_TELETYPE_GRAPHIC_320x200_WIDTH = 140H
_TELETYPE_GRAPHIC_320x200_HEIGHT = 0C8H
_TELETYPE_GRAPHIC_320x200_SCANLINE = 140H
_TELETYPE_GRAPHIC_320x200_PITCH = 8H
_TELETYPE_GRAPHIC_320x200_RESOLUTION = 013H
_TELETYPE_GRAPHIC_XORED = 080H
_TELETYPE_NULL_POSITION = (not 0H)
_TELETYPE_REGEN = 10000H
_MAX_COLOR = 010H
enum _VGA_BLACK, _VGA_BLUE, _VGA_GREEN, _VGA_CYAN, _VGA_RED, _VGA_MAGENTA, _VGA_BROWN, _VGA_LIGHT_GRAY, _VGA_DARK_GRAY,\
_VGA_LIGHT_BLUE, _VGA_LIGHT_GREEN, _VGA_LIGHT_CYAN, _VGA_LIGHT_RED, _VGA_LIGHT_MAGENTA, _VGA_YELLOW, _VGA_WHITE
_RGB_BLACK = _VGA_BLACK
_RGB_BLUE = 00000AAH
_RGB_GREEN = 000AA00H
_RGB_CYAN = 000AAAAH
_RGB_RED = 0AA0000H
_RGB_MAGENTA = 0AA00AAH
_RGB_BROWN = 0AA5500H
_RGB_LIGHT_GRAY = 0AAAAAAH
_RGB_DARK_GRAY = 0555555H
_RGB_LIGHT_BLUE = 05555FFH
_RGB_LIGHT_GREEN = 055FF55H
_RGB_LIGHT_CYAN = 055FFFFH
_RGB_LIGHT_RED = 0FF5555H
_RGB_LIGHT_MAGENTA = 0FF55FFH
_RGB_YELLOW = 0FFFF55H
_RGB_WHITE = 0FFFFFFH
enum _TELETYPE_TEXT_40x25:1H, _TELETYPE_TEXT_80x25:3H, _TELETYPE_GRAPHIC_40x25:013H
enum & IGNBRK, BRKINT, IGNPAR, PARMRK, INPCK, ISTRIP, INLCR, IGNCR, ICRNL, IUCLC, IXON, IXANY, IXOFF, IMAXBEL, IUTF8
enum & OPOST, OLCUC, ONLCR, OCRNL
enum & CBAUD, CS8, CBAUDEX
enum & ISIG, ICANON, XCASE, ECHO, ECHOE, ECHOK, ECHONL, NOFLSH, TOSTOP, ECHOCTL, ECHOPRT, ECHOKE, FLUSHO, PENDIN, IEXTEN, EXTPROC
struct _termios _iflag*, _oflag*, _cflag*, _lflag*, _vmin*, _veol*, _vintr*, _vquit*, _verase*, _vkill*, _veof*, _vstart*,\
_vstop*, _vsusp*, _vlnext*, _vwerase*, _vreprint*
.iflag: dw (_iflag)
.oflag: dw (_oflag)
.cflag: dw (_cflag)
.lflag: dw (_lflag)
.vmin: dw (_vmin)
.veol: db (_veol)
.vintr: db (_vintr)
.vquit: db (_vquit)
.verase: db (_verase)
.vkill: db (_vkill)
.veof: db (_veof)
.vstart: db (_vstart)
.vstop: db (_vstop)
.vsusp: db (_vsusp)
.vlnext: db (_vlnext)
.vwerase: db (_vwerase)
.vreprint: db (_vreprint)
ends
_DEFAULT_IFLAG = (ICRNL or IXON)
_DEFAULT_OFLAG = (OPOST or ONLCR)
_DEFAULT_CFLAG = (CS8)
_DEFAULT_LFLAG = (ISIG or ICANON or ECHO or ECHOE or ECHOK or ECHONL or ECHOCTL or ECHOKE or IEXTEN)
_default_termios _termios _DEFAULT_IFLAG, _DEFAULT_OFLAG, 0DEADH, _DEFAULT_LFLAG, 0H, 0H, 3H, 01CH, 07FH, 015H, 4H, 011H, 013H, 01AH, 016H, 017H, 012H
_TELETYPE_INPUT = _PAGE_FRAME_SIZE
assert (_TELETYPE_INPUT = _PAGE_FRAME_SIZE)
struct _teletype _input*, _regen*, _video*, _index*, _ceidx*, _gfxpos*, _gfxwdth*, _gfxhght*, _position*, _width*, _height*, _eoi*, _mode*, _init*, _id*,\
_fonts_source*, _fonts_width*, _fonts_height*, _fonts_btposw*, _fonts_btposh*, _scroll*, _cursor*, _tabulation*,\
_xlinear*, _ylinear*, _xgrid*, _ygrid*, _backgnd*, _foregnd*,\
_iflag*, _oflag*, _cflag*, _lflag*, _vmin*, _veol*, _vintr*, _vquit*, _verase*, _vkill*, _veof*, _vstart*, _vstop*, _vsusp*, _vlnext*, _vwerase*, _vreprint*
.input: dd (_input)
.regen: dd (_regen)
.video: dd (_video)
.index: dw (_index)
.ceidx: dw (_ceidx) ; cannonical end of input index
.gfxpos: dd (_gfxpos)
.gfxwdth: db (_gfxwdth)
.gfxhght: db (_gfxhght)
.position: dw (_position)
.width: db (_width) ; needed to see if the cursor is located on the last column of the current row
.height: db (_height) ; needed for cursor to be redrawn in graphic mode
.fonts _fonts (_fonts_source), (_fonts_width), (_fonts_height), (_fonts_btposw), (_fonts_btposh)
.scroll: dd (_scroll)
.xlinear: dw (_xlinear)
.ylinear: dw (_ylinear)
.xsaved: dw 0H
.ysaved: dw 0H
.xgrid: dw (_xgrid)
.ygrid: dw (_ygrid)
.backgnd: dd (_backgnd) ; background color
.foregnd: dd (_foregnd) ; foreground color
.cursor: db (_cursor)
.tabulation:db (_tabulation)
.vdfrbf: db 0H
.legacy: db 0H
.sesdesc: dd 0H ; session attached to this teletype
.grpdesc: dd 0H ; foreground group
.control: db 0H ; is a controlling terminal
.fground: db 0H ; have a foreground group which signal are send
.attach: dd 0H ; (_attach)
.eoi: db (_eoi) ; only useful with _TELETYPE_ICANON, 0H to indicate the user has not typed enter (does not take into account ^V^J)
.vbe: db 0H
.mode: db (_mode)
.init: db (_init)
.id: db (_id)
.idxstp: dw (0H)
.termios _termios _iflag, _oflag, _cflag, _lflag, _vmin, _veol, _vintr, _vquit, _verase, _vkill, _veof, _vstart, _vstop, _vsusp, _vlnext, _vwerase, _vreprint
ends
align 4H
_teletype_table:
rept _TELETYPE_COUNT i:1H { dd _tty#i }
_teletype_table_end:
rept _TELETYPE_COUNT i:1H
{
_TTY#i = (i - 1H)
_tty#i _teletype 0H, 0H, _TELETYPE_TEXT_VIDEO, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, _TELETYPE_TEXT_80x25, 0H, (i - 1H),\
0H, 0H, 0H, 0H, 0H, 0H, -1H, 4H, 0H, 0H, 0H, 0H, (i - 1H), 0FF00H, ICRNL,\
OPOST, 0H, (ICANON or ECHO or ECHOE or ECHONL), 0H, 0H, 3H, 01CH, 07FH, 015H, 4H, 011H, 013H, 01AH, 016H, 017H, 012H
}
_current_teletype: dd 0H
_vbe_frame_amount: dd 0H
_current_modeinfo _mode_info_block 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H,\
0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H
struct _kbdste _extended*, _scroll_lock*, _right_ctrl*, _left_ctrl*, _right_shift*,\
_left_shift*, _right_alt*, _left_alt*, _caps_lock*, _num_lock*
.extended: db (_extended)
.scroll_lock: db (_scroll_lock)
.right_ctrl: db (_right_ctrl)
.left_ctrl: db (_left_ctrl)
.right_shift: db (_right_shift)
.left_shift: db (_left_shift)
.right_alt: db (_right_alt)
.left_alt: db (_left_alt)
.caps_lock: db (_caps_lock)
.num_lock: db (_num_lock)
ends
_current_keyboard _kbdste 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H, 0H
_PROCESS_STRING = 020H
_PROCESS_CHANNEL = 0H
_PROCESS_POLICY = 0H
_PROCESS_NICE = 5H
_PROCESS_WAITABLE = (not 0H)
_PROCESS_ZOMBIES = (not 0H)
_PROCESS_STACKPF = 020H ; 32 page by default allowed to be allocated on page fault
struct _signal_context _handler*, _sigframe*, _newfrm*, _assign*, _nested*
.handler: dd (_handler)
.sigframe: dd (_sigframe)
.newfrm: db (_newfrm)
.assign: db (_assign)
.nested: db (_nested)
align 010H
ends
assert (_signal_context.sizeof = 010H)
struct _socket _filde*, _lock*, _bind*, _port*, _buffer*, _cursor*, _stand*, _prev*, _next*
.filde: dd (_filde)
.lock: db (_lock)
.bind: db (_bind)
.port: dw (_port)
.buffer: dd (_buffer)
.cursor: dd (_cursor)
.stand: dd (_stand)
.list _linked (_prev), (_next)
ends
include "signal_enum.inc"
_PROCESS_SIGNALS_BITMAP = ((_SIGNALS + (_BITMAP_UNIT - 1H)) and (not (_BITMAP_UNIT - 1H)))
_PORT_RANGE = (_PORT_AVAILABLE shr 3H)
enum _PROCESS_RUN, _PROCESS_ZOMBIE, _PROCESS_SLEEP, _PROCESS_STOP, _PROCESS_DEAD, _PROCESS_THREAD
struct _process _state*, _pid*, _uid*, _pgid*, _sid*, _tid*, _mnbrk*, _break*, _ustck*, _mapping*, _parent*, _childs*, _socket*, _sockno*, _sesdesc*, _grpdesc*,\
_siblings_prev*, _siblings_next*, _pgroup_prev*, _pgroup_next*, _stackpf*, _pfcount*, _sigcnt*, _signst*, _sigstp*, _tty*, _waitable*, _jststp*, _jstcnt*,\
_vm86*, _vmflgs*, _lwreal*, _hgreal*, _mapreal*, _lckreal*, _vif*, _vip*, _extcde*, _extsig*, _fground_prev*, _fground_next*, _priority*, _increment*, _intprec*, _channel*,\
_kstack*, _vstack*, _pgstck*, _retframe*, _vmframe*, _context*, _list_prev*, _list_next*, _name*
.state: dd (_state)
.pid: dd (_pid)
.uid: dd (_uid)
.pgid: dd (_pgid)
.sid: dd (_sid)
.tid: dd (_tid)
.mnbrk: dd (_mnbrk) ; the minimum value of program break
.break: dd (_break) ; program break
.ustck: dd (_ustck) ; always decrement never increment
.mapping: dd (_mapping)
.parent: dd (_parent)
.childs: dd (_childs)
.socket: dd (_socket)
.sockno: dd (_sockno)
.sesdesc: dd (_sesdesc)
.grpdesc: dd (_grpdesc)
.siblings _linked _siblings_prev, _siblings_next
.pgroup _linked _pgroup_prev, _pgroup_next
.stackpf: dd (_stackpf) ; max allowed stack page fault (-1 for page fault until stack meet the program break)
.pfcount: dd (_pfcount) ; how many this process has performed a page fault
.sigmask _bitmap _PROCESS_SIGNALS_BITMAP
.pending _bitmap _PROCESS_SIGNALS_BITMAP
.signals: dd ((_SIGNALS+1H) shl (bsf _signal_context.sizeof)) dup 0H
.sigcnt: dd (_sigcnt) ; count of received signal even if it's blocked with sigmask
.signst: db (_signst) ; signal nested counter
.sigstp: db (_sigstp) ; signal that caused a stop
.ports _bitmap _PORT_RANGE
.waitable: db (_waitable)
.vm86: db (_vm86)
.vmflgs: dd (_vmflgs)
.lwreal: dd (_lwreal)
.hgreal: dd (_hgreal)
.mapreal: db (_mapreal)
.lckreal: db (_lckreal)
.vif: db (_vif)
.vip: db (_vip)
.daemon: db 0H ; if it's attached to a TTY
.allzmbs: db 0H ; if all children of this process are zombie ? 0H if the process has not children
.tty: dd (_tty)
;.jststp: dw (_jststp)
;.jstcnt: dw (_jstcnt)
.refresh: db 0H ; need to refresh the PSE page framebuffer because the resolution has changed
.seslead: db 0H
.grplead: db 0H
.panic: db 0H
;.fsave:
;.fxsave: dd (0H)
;.extwhy: dd (0H)
.fltctx _float_context 0H, 0H
.dbgctx _debug_context 0H, 0H, 0H, 0H, 0H, 0H, 0H
.align: db 0H
.extcde: dd (_extcde)
.extsig: db (_extsig)
;.fground _linked _fground_prev, _fground_next
.priority: dd (_priority)
.increment: dd (_increment)
.intprec: db (_intprec)
.channel: dd (_channel)
.kstack: dd (_kstack) ; kernel task stack (in TSS.esp0)
.vstack: dd (_vstack)
.pgstck: dd (_pgstck) ; page wher the stack reside
.retframe: dd (_retframe) ; point into kernel task stack where user register reside
.vmframe: dd (_vmframe) ; virtual 8086 task stack
.context: dd (_context) ; point into kernel task stack where a saved eip reside (context switch entry point)
.list _linked _list_prev, _list_next
.name string _name
times (_PROCESS_STRING - .name.sizeof) db 0H ; XXX
ends
struct _pci_configuration_header _vendor_id*, _device_id*, _command_register*, _status_register*, _revision_id*,\
_class_code*, _cache_line_size*, _latency_timer*, _header_type*, _bist*
.vendor_id: dw (_vendor_id)
.device_id: dw (_device_id)
.command_register: dw (_command_register)
.status_register: dw (_status_register)
.revision_id: db (_revision_id)
.class_code: dw ((_class_code) and 0FFFFH)
db ((_class_code) shr 010H)
.cache_line_size: db (_cache_line_size)
.latency_timer: db (_latency_timer)
.header_type: db (_header_type)
.bist: db (_bist)
ends
struct _pci_header_device _vendor_id*, _device_id*, _command_register*, _status_register*, _revision_id*,\
_class_code*, _cache_line_size*, _latency_timer*, _bist*, _bar0*, _bar1*, _bar2*, _bar3*, _bar4*, _bar5*,\
_cardbus_cis*, _subsystem_vendor_id*, _subsystem_id*, _expansion_rom*, _capabilities*, _interrupt_line*,\
_interrupt_pin*, _min_gnt*, _max_lat*
.header _pci_configuration_header _vendor_id, _device_id, _command_register, _status_register,\
_revision_id, _class_code, _cache_line_size, _latency_timer, _PCI_HEADER_DEVICE, _bist
.bar0: dd (_bar0)
.bar1: dd (_bar1)
.bar2: dd (_bar2)
.bar3: dd (_bar3)
.bar4: dd (_bar4)
.bar5: dd (_bar5)
.cardbus_cis: dd (_cardbus_cis)
.subsystem_vendor_id: dw (_subsystem_vendor_id)
.subsystem_id: dw (_subsystem_id)
.expansion_rom: dd (_expansion_rom)
.capabilities: db (_capabilities)
.reserved: db 7H dup 0H
.interrupt_line: db (_interrupt_line)
.interrupt_pin: db (_interrupt_pin)
.min_gnt: db (_min_gnt)
.max_lat: db (_max_lat)
ends
_frame _bitmap ((200000000H shr 00CH) shr 3H)
_pid_table _bitmap 080H
_kernel_entry:
cli
call _idt_reset
mov al, _INTEL_RESERVED_INT
call _8259_enable
call _configure_8253
test byte [_singleton.xsave], 1H
jz _kernel_entry_xsave
test byte [_singleton.sse], 1H
jz _kernel_entry_xsave
test byte [_singleton.xsaves], 1H
jz _kernel_entry_rfbm
xor edx, edx
xor eax, eax
mov ecx, _IA32_XSS
wrmsr
_kernel_entry_rfbm:
xor ecx, ecx
mov cl, _XCR0
xgetbv
or al, _XCR0_SSE
test byte [_singleton.avx], 1H
jz _kernel_entry_xcr0_write
or al, _XCR0_AVX
_kernel_entry_xcr0_write:
xsetbv
_kernel_entry_xsave:
test byte [_singleton.pae], 1H
jz _kernel_entry_efer
test byte [_singleton.nx], 1H
jz _kernel_entry_efer
mov ecx, _EFER
rdmsr
or eax, _EFER_NXE
wrmsr
_kernel_entry_efer:
_load_descriptor_table gdt, _GDT
_load_descriptor_table idt, _IDT
mov ax, _TSS
ltr ax
xor ax, ax
lldt ax
jmp far _CODE_KERNEL:_kernel_entry_setup
_kernel_entry_setup:
mov ax, _DATA_KERNEL
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
finit
test byte [_singleton.sse], 1H
jz _kernel_entry_default
ldmxcsr dword [_default_mxcsr]
_kernel_entry_default:
call _kernel_enable_nmi
;call _debug_force_reset
xor eax, eax
mov al, _DEBUG_RW_INST_READ
xor ebx, ebx
xor ecx, ecx
;call _debug_memory_range
xor eax, eax
xor edx, edx
mov ecx, _KERNEL_GS_BASE
call _write_msr
mov ecx, _IA32_MISC_ENABLE
call _read_msr
jc _kernel_entry_smp
or al, (_MISC_FAST_STRING_ENABLE or _MISC_ENABLE_THERMAL_MONITOR)
wrmsr
;sub esp, 2H
;fnstcw word [esp]
;and word [esp], (not _FCW_ZM)
;fldcw word [esp]
;fldz
;fld1
;fdiv st0, st1
;fwait
;mov edi, _fpu_init
;fxsave [edi]
;mov eax, _local_apic_base
;xor ecx, ecx
;xor edx, edx
;monitor eax, ecx, edx
;xor eax, eax
;xor ecx, ecx
;mwait eax, ecx
;mov eax, cr4
;or eax, _CR4_SMAP
;mov cr4, eax
;clac
;mov al, byte [esp]
;mov byte [esp], 0H
;stac
_kernel_entry_smp:
;mov eax, _extract_primary_apic_information
;call _parse_mp_conftable_entry
mov eax, _frame
mov ebx, dword [_frame.next]
mov ecx, ((_KERNEL_IDENTITY * _PSE_PAGE_FRAME_SIZE) shr _PAGE_TABLE_SHIFT)
xor edx, edx
mov edi, _BITMAP_RESET
call _bitmap_update
jc _panic
call _pdpt_read_write_current
mov eax, cr3
and eax, (not _PAGE_OFFSET_MASK)
mov dword [_kernel_mapping], eax
call _initialize_multitasking
jc _panic
;xor ebx, ebx
;mov bl, _SCHEDULER_PID
;call _syscall_daemon
;xor ebx, ebx
;mov bl, _INIT_PID
;call _syscall_daemon
call _teletype_initialize
jc _panic
;xor eax, eax
;call _refresh_apic_registers_set
;jc _panic
;call _soft_enable_apic
call _create_vdso
jc _panic
match,DEBUG
{
cmp dword [_io_apic_count], 0H
jz _kernel_entry_uniprocessor
mov eax, _configure_io_apic_rt
mov edi, [_PAE_LOCAL_APIC+_LOCAL_APIC_ID_REGISTER]
xor ebp, ebp
call _parse_mp_conftable_entry
_kernel_entry_uniprocessor:
mov eax, dword [_rsdp_descriptor_base]
mov ebx, dword [eax+_rsdp_descriptor.rsdt_address]
mov edx, _MADT
call _acpi_find_sdt_table
mov ecx, dword [ebx+_madt_header.common.length]
sub ecx, _madt_header.sizeof
lea ebx, [ebx+_madt_header.sizeof]
_abc_loop:
mov dl, byte [ebx+_madt_prefix.type]
cmp dl, _MADT_PROCESSOR_LOCAL_APIC
jz _abc_preprocessor
cmp dl, _MADT_IO_APIC
jz _abc_io_apic
_abc_preprocessor:
inc byte [_processor_count]
jmp _abc_update
_abc_io_apic:
inc byte [_io_apic_count]
mov edx, dword [ebx+_madt_io_apic.io_apic_address]
mov dword [_io_apic_base], edx
xor eax, eax
mov al, _REFRESH_ONLY_IO_APIC
call _refresh_apic_registers_set
call _io_apic_reset_rt
call _io_apic_irq_connect
call _8259_disable
;call _soft_disable_apic
;mov dword [_LOCAL_APIC+_SPURIOUS_INTERRUPT_VECTOR_REGISTER], 0H
;mov eax, dword [_LOCAL_APIC+_SPURIOUS_INTERRUPT_VECTOR_REGISTER]
;mov eax, dword [_LOCAL_APIC+_LVT_LINT0]
;xor eax, _LVT_LINT_MASKED
;mov dword [_LOCAL_APIC+_LVT_LINT0], eax
;mov eax, dword [_LOCAL_APIC+_LVT_LINT0]
mov ecx, _IA32_APIC_BASE
rdmsr
or eax, (_APIC_BASE_EN or _APIC_BASE_EXTD)
wrmsr
sub esp, _pci_configuration_header.sizeof
xor eax, eax
xor ebx, ebx
xor ecx, ecx
mov esi, esp
call _pci_read_configuration_header
call _set_cr0_am
mov eax, _EFLAGS_AC
call _set_eflags
mov dword [1H], 5H
mov eax, 0H
mov ebx, 01FH
mov ecx, 7H
xor edx, edx
mov edi, 0H
call _pci_write_configuration_space
mov ebx, _LOCAL_APIC_ACCESS_WRITE
mov ecx, _LVT_ERROR
mov eax, _APIC_ERROR_ENTRY
call _local_apic_access_register
mov eax, _APIC_ERROR_ENTRY
mov edx, (_apic_error_gate or _SWAP_IDT_ASSIGN_GATE)
call _set_and_swap_idt_vector
;mov ecx,
xor eax, eax
cpuid
mov eax, 0BH
xor ecx, ecx
cpuid
;mov dword [_LOCAL_APIC+_LOGICAL_DESTINATION_REGISTER], (0DAH shl 018H)
;mov eax, 1H
;cpuid
;mov dword [_LOCAL_APIC+_ERROR_STATUS_REGISTER], 1H
;mov eax, dword [_LOCAL_APIC+_ERROR_STATUS_REGISTER]
;mov al, byte [_singleton.x2apic]
mov ecx, (_LOCAL_APIC_BASE_MSR + _LOGICAL_DESTINATION_REGISTER_MSR)
rdmsr
jmp $
mov ecx, (_LOCAL_APIC_BASE_MSR + _LVT_ERROR_MSR)
rdmsr
mov edx, 5H
wrmsr
mov ecx, (_LOCAL_APIC_BASE_MSR + _INTERRUPT_COMMAND_REGISTER_MSR)
xor edx, edx
mov eax, (_ICR_SELF or _ICR_LEVEL_ASSERT or 3H)
wrmsr
;mov ecx, _SELF_IPI
;xor eax, eax
;xor edx, edx
;mov al, 0H
sti
nop
nop
mov ecx, (_LOCAL_APIC_BASE_MSR + _LVT_ERROR_MSR)
rdmsr
mov ecx, (_LOCAL_APIC_BASE_MSR + _ERROR_STATUS_REGISTER_MSR)
xor eax, eax
wrmsr
rdmsr
xor eax, eax
wrmsr
rdmsr
;wrmsr
;mov ecx, (_LOCAL_APIC_BASE_MSR + _ERROR_STATUS_REGISTER_MSR)
;xor eax, eax
;xor edx, edx
;wrmsr
;rdmsr
jmp $
mov al, byte [_singleton.acpi]
mov ecx, 19CH
rdmsr
mov dword [_IO_APIC+_INDEX_REGISTER], _IO_APIC_RT_LOW_1
mov eax, dword [_IO_APIC+_DATA_REGISTER]
mov dword [_IO_APIC+_INDEX_REGISTER], _IO_APIC_RT_LOW_2
mov eax, dword [_IO_APIC+_DATA_REGISTER]
;sti
;jmp $
jmp __next
;_oo_loop:
; mov al, _IO_APIC_RT_HIGH_2
; mov byte [_PAE_IO_APIC+_INDEX_REGISTER], al
; mov eax, dword [_PAE_IO_APIC+_DATA_REGISTER]
; test eax, 1 shl 12
; jz _oo_loop
; nop
_abc_update:
movzx eax, byte [ebx+_madt_prefix.length]
sub ecx, eax
add ebx, eax
test ecx, ecx
jnz _abc_loop
__next:
mov dword [_PAE_LOCAL_APIC+_LOCAL_EOI_REGISTER], 0H
call _8259_disable
mov byte [_PAE_IO_APIC+_INDEX_REGISTER], _REDIRECTION_TABLE_BASE
mov eax, dword [_PAE_IO_APIC+_DATA_REGISTER]
mov byte [_PAE_IO_APIC+_INDEX_REGISTER], _REDIRECTION_TABLE_BASE+1H
mov eax, dword [_PAE_IO_APIC+_DATA_REGISTER]
sti
jmp $
jmp $
mov word [0DEADH], 0FEEBH
mov al, _RESET_CODE_BYTE
out _CMOS_SELECT, al
mov al, _BIOS_JUMP_EOI
out _CMOS_PORT, al
mov dword [_WARN_RESET_VECTOR], 0DEADH
call _reboot_system
jmp $
mov eax, _next
;mov word [_interrupt_stub_49], 0E0FFH
mov edx, dword [_PAE_LOCAL_APIC+_LOCAL_APIC_ID_REGISTER]
shl edx, (_ICR_XAPIC_DESTINATION_SHIFT - 020H)
mov dword [_PAE_LOCAL_APIC+_INTERRUPT_COMMAND_REGISTER_HIGH], edx