1- ; =============================================================================
2- ; System Variables
3- ; =============================================================================
4-
5-
6- ;CONFIG
7- cfg_smpinit: db 1 ; By default SMP is enabled. Set to 0 to disable.
8-
9- ; Memory locations
10- InfoMap: equ 0x0000000000005000
11-
12- ;;;;;;;;;;;;;;; info de video la tengo en 2 lugares para consultar: InfoMap y VBEModeInfoBlock
13- ;;;;;;;;;;;;;;;; Info de video desde 0x5080
14- ;;;;;;;;;;;;;;;; 0x5080 = qword, framebuffer
15- ;;;;;;;;;;;;;;;; 0x5088 = word, screen x
16- ;;;;;;;;;;;;;;;; 0x508A = word, screen y
17- ;;;;;;;;;;;;;;;; 0x508C = word, ppsl
18- ;;;;;;;;;;;;;;;; 0x508E = word, bits ppx
19-
20- IM_DetectedCoreIDs: equ 0x0000000000005100 ; 1 byte per entry - Each byte is the APIC ID of a core
21- IM_PCIE: equ 0x0000000000005400 ; 16 bytes per entry
22- IM_IOAPICAddress: equ 0x0000000000005600 ; 16 bytes per entry
23- IM_IOAPICIntSource: equ 0x0000000000005700 ; 8 bytes per entry
1+ ;;==============================================================================
2+ ;; System Variables
3+ ;;==============================================================================
4+
5+
6+ cfg_smpinit: db 1 ; By default SMP is enabled. Set to 0 to disable.
7+
8+ ;; Memory locations
9+ ;; Info de video en 2 lugares para consultar: InfoMap y VBEModeInfoBlock.
10+ ;; Info de video desde 0x5080
11+ ;; 0x5080 = qword, framebuffer
12+ ;; 0x5088 = word, screen x
13+ ;; 0x508A = word, screen y
14+ ;; 0x508C = word, ppsl
15+ ;; 0x508E = word, bits ppx
16+
17+ InfoMap: equ 0x0000000000005000
18+ IM_DetectedCoreIDs: equ 0x0000000000005100 ;; 1 byte per entry. Each is the API
19+ ;; C ID of a core.
20+ IM_PCIE: equ 0x0000000000005400 ;; 16 bytes per entry
21+ IM_IOAPICAddress: equ 0x0000000000005600 ;; 16 bytes per entry
22+ IM_IOAPICIntSource: equ 0x0000000000005700 ;; 8 bytes per entry
2423SystemVariables: equ 0x0000000000005800
25- IM_ActivedCoreIDs: equ 0x0000000000005E00 ; 1 byte per entry - 1 if the core was activated
26-
24+ IM_ActivedCoreIDs: equ 0x0000000000005E00 ;; 1by per entry. 1 = 1 core active.
2725
2826
29- ;;; cuando bootea uefi, la info de video durante uefi la mete aqui\
30- ;;; y de esta manera:
31- ;;;[0x00005F00] ; Frame buffer base
32- ;;;[0x00005F08] ; Frame buffer size (bytes)
33- ;;;[0x00005F10] ; Screen X
34- ;;;;[0x00005F12] ; Screen Y
35- ;;;;[0x00005F14] ; PixelsPerScanLine
36- ;;; luego, durante el bootloader, la mantiene aqui, pero lo copia al infoMap 0x5080
37- VBEModeInfoBlock: equ 0x0000000000005F00 ; 256 bytes
27+ ;; Cuando bootea uefi, la info de video durante uefi la mete aqui:
28+ ;; [0x00005F00] ;; Frame buffer base
29+ ;; [0x00005F08] ;; Frame buffer size (bytes)
30+ ;; [0x00005F10] ;; Screen X
31+ ;; [0x00005F12] ;; Screen Y
32+ ;; [0x00005F14] ;; PixelsPerScanLine
33+ ;; Luego, durante el bootloader, la mantiene aqui, pero tambien copia al infoMap
34+ ;; 0x5080
3835
36+ VBEModeInfoBlock: equ 0x0000000000005F00 ;; 256 bytes.
3937
40-
41- ; DQ - Starting at offset 0, increments by 0x8
38+ ;; DQ - Starting at offset 0, increments by 0x8
4239p_ACPITableAddress: equ SystemVariables + 0x00
4340p_LocalAPICAddress: equ SystemVariables + 0x10
4441p_Counter_Timer: equ SystemVariables + 0x18
4542p_Counter_RTC: equ SystemVariables + 0x20
4643p_HPET_Address: equ SystemVariables + 0x28
4744
48- ; DD - Starting at offset 0x80, increments by 4
49- p_BSP: equ SystemVariables + 0x80
50- p_mem_amount: equ SystemVariables + 0x84 ; in MiB
45+ ;; DD - Starting at offset 0x80, increments by 4
46+ p_BSP: equ SystemVariables + 0x80
47+ p_mem_amount: equ SystemVariables + 0x84 ;; MiB
5148p_HPET_Frequency: equ SystemVariables + 0x88
5249
53- ; DW - Starting at offset 0x100, increments by 2
50+ ;; DW - Starting at offset 0x100, increments by 2
5451p_cpu_speed: equ SystemVariables + 0x100
5552p_cpu_activated: equ SystemVariables + 0x102
5653p_cpu_detected: equ SystemVariables + 0x104
@@ -60,51 +57,55 @@ p_IAPC_BOOT_ARCH: equ SystemVariables + 0x10A
6057
6158; DB - Starting at offset 0x180, increments by 1
6259p_IOAPICCount: equ SystemVariables + 0x180
63- p_BootMode: equ SystemVariables + 0x181 ; 'U' for UEFI, otherwise BIOS
60+ p_BootMode: equ SystemVariables + 0x181 ; ; 'U' for UEFI, otherwise BIOS
6461p_IOAPICIntSourceC: equ SystemVariables + 0x182
65- p_x2APIC: equ SystemVariables + 0x183
62+ p_x2APIC: equ SystemVariables + 0x183
6663p_HPET_Timers: equ SystemVariables + 0x184
67- p_BootDisk: equ SystemVariables + 0x185 ; 'F' for Floppy drive
68- p_1GPages: equ SystemVariables + 0x186 ; 1 if 1GB pages are supported
64+ p_BootDisk: equ SystemVariables + 0x185 ; ; 'F' for Floppy drive
65+ p_1GPages: equ SystemVariables + 0x186 ; ; 1 if 1GB pages are supported
6966
7067align 16
71- GDTR32: ; Global Descriptors Table Register
72- dw gdt32_end - gdt32 - 1 ; limit of GDT (size minus one)
73- dq gdt32 ; linear address of GDT
68+ GDTR32: ; ; Global Descriptors Table Register
69+ dw gdt32_end - gdt32 - 1 ;; Limit.
70+ dq gdt32 ;; Linear address of GDT
7471
7572align 16
7673gdt32:
77- SYS32_NULL_SEL equ $ - gdt32 ; Null Segment
78- dq 0x0000000000000000
79- SYS32_CODE_SEL equ $ - gdt32 ; 32-bit code descriptor
80- dq 0x00CF9A000000FFFF ; 55 Granularity 4KiB, 54 Size 32bit, 47 Present, 44 Code/Data, 43 Executable, 41 Readable
81- SYS32_DATA_SEL equ $ - gdt32 ; 32-bit data descriptor
82- dq 0x00CF92000000FFFF ; 55 Granularity 4KiB, 54 Size 32bit, 47 Present, 44 Code/Data, 41 Writeable
74+ SYS32_NULL_SEL: equ $ - gdt32 ;; Null Segment
75+ dq 0x0000000000000000
76+ SYS32_CODE_SEL: equ $ - gdt32 ;; 32-bit code descriptor
77+ dq 0x00CF9A000000FFFF ;; 55 Granularity 4KiB, 54 Size 32bit, 4
78+ ;; 7 Present, 44 Code/Data, 43 Executabl
79+ ;; e, 41 Readable.
80+ SYS32_DATA_SEL: equ $ - gdt32 ;; 32-bit data descriptor
81+ dq 0x00CF92000000FFFF ;; 55 Granularity 4KiB, 54 Size 32bit, 4
82+ ;; 7 Present, 44 Code/Data, 41 Writeable
8383gdt32_end:
8484
8585align 16
86- tGDTR64: ; Global Descriptors Table Register
87- dw gdt64_end - gdt64 - 1 ; limit of GDT (size minus one)
88- dq gdt64 ; linear address of GDT
86+
87+ tGDTR64: ;; Global Descriptors Table Register
88+ dw gdt64_end - gdt64 - 1 ;; Limit.
89+ dq gdt64 ;; linear address of GDT
8990
9091align 16
91- GDTR64: ; Global Descriptors Table Register
92- dw gdt64_end - gdt64 - 1 ; limit of GDT (size minus one)
93- dq 0x0000000000001000 ; linear address of GDT
94-
95- gdt64: ; This structure is copied to 0x0000000000001000
96- SYS64_NULL_SEL equ $ - gdt64 ; Null Segment
97- dq 0x0000000000000000
98- SYS64_CODE_SEL equ $ - gdt64 ; Code segment, read/execute, nonconforming
99- dq 0x00209A0000000000 ; 53 Long mode code, 47 Present, 44 Code/Data, 43 Executable, 41 Readable
100- SYS64_DATA_SEL equ $ - gdt64 ; Data segment, read/write, expand down
101- dq 0x0000920000000000 ; 47 Present, 44 Code/Data, 41 Writable
92+ GDTR64: ;; Global Descriptors Table Register
93+ dw gdt64_end - gdt64 - 1 ;; Limit.
94+ dq 0x0000000000001000 ;; linear address of GDT
95+
96+ gdt64: ;; Struct copied to 0x0000000000001000
97+ SYS64_NULL_SEL: equ $ - gdt64 ;; Null Segment
98+ dq 0x0000000000000000
99+ SYS64_CODE_SEL: equ $ - gdt64 ;; Code segment, read/execute, nonconfor
100+ ;; ming
101+ dq 0x00209A0000000000 ;; 53 Long mode code, 47 Present, 44 Cod
102+ ;; e/Data, 43 Executable, 41 Readable
103+ SYS64_DATA_SEL: equ $ - gdt64 ;; Data segment, read/write, expand down
104+ dq 0x0000920000000000 ;; 47 Present, 44 Code/Data, 41 Writable
102105gdt64_end:
103106
104- IDTR64: ; Interrupt Descriptor Table Register
105- dw 256 * 16 - 1 ; limit of IDT (size minus one) ( 4096 bytes - 1)
106- dq 0x0000000000000000 ; linear address of IDT
107+ IDTR64: ; ; Interrupt Descriptor Table Register
108+ dw 256 * 16 - 1 ;; Limit = 4096 - 1
109+ dq 0x0000000000000000 ; ; linear address of IDT
107110
108111
109- ; =============================================================================
110- ; EOF
0 commit comments