* better
[mascara-docs.git] / amd64 / bareMetalOS-0.5.2 / pure64.boot0 / src / sysvar.asm
blob255623285982eea82225d54406e32c8b3b63be79
1 ; =============================================================================
2 ; Pure64 -- a 64-bit OS loader written in Assembly for x86-64 systems
3 ; Copyright (C) 2008-2011 Return Infinity -- see LICENSE.TXT
5 ; System Variables
6 ; =============================================================================
9 ;CONFIG
10 cfg_smpinit: db 1 ; By default SMP is enabled. Set to 0 to disable.
11 cfg_vesa: db 0 ; By default VESA is disabled. Set to 1 to enable.
12 cfg_default: db 0 ; By default we don't need a config file so set to 0. If a config file is found set to 1.
13 cfg_e820: db 1 ; By default E820 should be present. Pure64 will set this to 0 if not found/usable.
14 cfg_mbr: db 0 ; Did we boot off of a disk with a proper MBR
16 ; Memory locations
17 E820Map: equ 0x0000000000004000
18 InfoMap: equ 0x0000000000005000
19 SystemVariables: equ 0x0000000000005A00
20 VBEModeInfoBlock equ 0x0000000000005C00
21 hdbuffer: equ 0x0000000000070000 ; 32768 bytes = 0x6000 -> 0xDFFF VERIFY THIS!!!
22 hdbuffer1: equ 0x000000000007E000 ; 512 bytes = 0xE000 -> 0xE1FF VERIFY THIS!!!
24 ; DQ - Starting at offset 0, increments by 0x8
25 os_LocalAPICAddress: equ SystemVariables + 0x00
26 os_IOAPICAddress: equ SystemVariables + 0x08
27 os_ACPITableAddress: equ SystemVariables + 0x10
28 screen_cursor_offset: equ SystemVariables + 0x18
29 hd1_maxlba: equ SystemVariables + 0x20
30 os_Counter: equ SystemVariables + 0x28
32 ; DD - Starting at offset 128, increments by 4
33 hd1_size: equ SystemVariables + 128
34 fat16_FatStart: equ SystemVariables + 132
35 fat16_TotalSectors: equ SystemVariables + 136
36 fat16_DataStart: equ SystemVariables + 140
37 fat16_RootStart: equ SystemVariables + 144
38 fat16_PartitionOffset: equ SystemVariables + 148
40 ; DW - Starting at offset 256, increments by 2
41 cpu_speed: equ SystemVariables + 256
42 cpu_activated: equ SystemVariables + 258
43 cpu_detected: equ SystemVariables + 260
44 mem_amount: equ SystemVariables + 262
45 fat16_BytesPerSector: equ SystemVariables + 264
46 fat16_ReservedSectors: equ SystemVariables + 266
47 fat16_SectorsPerFat: equ SystemVariables + 268
48 fat16_RootDirEnts: equ SystemVariables + 270
50 ; DB - Starting at offset 384, increments by 1
51 hd1_enable: equ SystemVariables + 384
52 hd1_lba48: equ SystemVariables + 385
53 screen_cursor_x: equ SystemVariables + 386
54 screen_cursor_y: equ SystemVariables + 387
55 fat16_SectorsPerCluster: equ SystemVariables + 388
56 fat16_Fats: equ SystemVariables + 389
57 memtempstring: equ SystemVariables + 390
58 speedtempstring: equ SystemVariables + 400
59 cpu_amount_string: equ SystemVariables + 410
60 hdtempstring: equ SystemVariables + 420
62 ;MISC
63 screen_cols: db 80
64 screen_rows: db 25
65 hextable: db '0123456789ABCDEF'
67 ;STRINGS
68 kernelerror: db 'FATAL ERROR: Software not found.', 0
69 kernelname: db 'KERNEL64SYS', 0
70 configname: db 'PURE64 CFG', 0
71 msg_done: db ' Done', 0
72 msg_CPU: db '[CPU: ', 0
73 msg_MEM: db '] [MEM: ', 0
74 msg_HDD: db ' [HDD: ', 0
75 msg_mb: db ' MiB]', 0
76 msg_mhz: db 'MHz x', 0
77 msg_loadingkernel: db 'Loading software...', 0
78 msg_startingkernel: db 'Starting software.', 0
79 msg_noconfig: db '(default config)', 0
80 no64msg: db 'FATAL ERROR: CPU does not support 64-bit mode. Please run on supported hardware.', 0
81 initStartupMsg: db 'Pure64 v0.4.9 - http://www.returninfinity.com', 13, 10, 13, 10, 'Initializing system...', 0
82 msg_date: db '2011/04/05', 0
85 ; Mandatory information for all VBE revisions
86 VBEModeInfoBlock.ModeAttributes equ VBEModeInfoBlock + 0 ; DW - mode attributes
87 VBEModeInfoBlock.WinAAttributes equ VBEModeInfoBlock + 2 ; DB - window A attributes
88 VBEModeInfoBlock.WinBAttributes equ VBEModeInfoBlock + 3 ; DB - window B attributes
89 VBEModeInfoBlock.WinGranularity equ VBEModeInfoBlock + 4 ; DW - window granularity in KB
90 VBEModeInfoBlock.WinSize equ VBEModeInfoBlock + 6 ; DW - window size in KB
91 VBEModeInfoBlock.WinASegment equ VBEModeInfoBlock + 8 ; DW - window A start segment
92 VBEModeInfoBlock.WinBSegment equ VBEModeInfoBlock + 10 ; DW - window B start segment
93 VBEModeInfoBlock.WinFuncPtr equ VBEModeInfoBlock + 12 ; DD - real mode pointer to window function
94 VBEModeInfoBlock.BytesPerScanLine equ VBEModeInfoBlock + 16 ; DW - bytes per scan line
95 ; Mandatory information for VBE 1.2 and above
96 VBEModeInfoBlock.XResolution equ VBEModeInfoBlock + 18 ; DW - horizontal resolution in pixels or characters
97 VBEModeInfoBlock.YResolution equ VBEModeInfoBlock + 20 ; DW - vertical resolution in pixels or characters
98 VBEModeInfoBlock.XCharSize equ VBEModeInfoBlock + 22 ; DB - character cell width in pixels
99 VBEModeInfoBlock.YCharSize equ VBEModeInfoBlock + 23 ; DB - character cell height in pixels
100 VBEModeInfoBlock.NumberOfPlanes equ VBEModeInfoBlock + 24 ; DB - number of memory planes
101 VBEModeInfoBlock.BitsPerPixel equ VBEModeInfoBlock + 25 ; DB - bits per pixel
102 VBEModeInfoBlock.NumberOfBanks equ VBEModeInfoBlock + 26 ; DB - number of banks
103 VBEModeInfoBlock.MemoryModel equ VBEModeInfoBlock + 27 ; DB - memory model type
104 VBEModeInfoBlock.BankSize equ VBEModeInfoBlock + 28 ; DB - bank size in KB
105 VBEModeInfoBlock.NumberOfImagePages equ VBEModeInfoBlock + 29 ; DB - number of image pages
106 VBEModeInfoBlock.Reserved equ VBEModeInfoBlock + 30 ; DB - reserved (0x00 for VBE 1.0-2.0, 0x01 for VBE 3.0)
107 ; Direct Color fields (required for direct/6 and YUV/7 memory models)
108 VBEModeInfoBlock.RedMaskSize equ VBEModeInfoBlock + 31 ; DB - size of direct color red mask in bits
109 VBEModeInfoBlock.RedFieldPosition equ VBEModeInfoBlock + 32 ; DB - bit position of lsb of red mask
110 VBEModeInfoBlock.GreenMaskSize equ VBEModeInfoBlock + 33 ; DB - size of direct color green mask in bits
111 VBEModeInfoBlock.GreenFieldPosition equ VBEModeInfoBlock + 34 ; DB - bit position of lsb of green mask
112 VBEModeInfoBlock.BlueMaskSize equ VBEModeInfoBlock + 35 ; DB - size of direct color blue mask in bits
113 VBEModeInfoBlock.BlueFieldPosition equ VBEModeInfoBlock + 36 ; DB - bit position of lsb of blue mask
114 VBEModeInfoBlock.RsvdMaskSize equ VBEModeInfoBlock + 37 ; DB - size of direct color reserved mask in bits
115 VBEModeInfoBlock.RsvdFieldPosition equ VBEModeInfoBlock + 38 ; DB - bit position of lsb of reserved mask
116 VBEModeInfoBlock.DirectColorModeInfo equ VBEModeInfoBlock + 39 ; DB - direct color mode attributes
117 ; Mandatory information for VBE 2.0 and above
118 VBEModeInfoBlock.PhysBasePtr equ VBEModeInfoBlock + 40 ; DD - physical address for flat memory frame buffer
119 VBEModeInfoBlock.Reserved1 equ VBEModeInfoBlock + 44 ; DD - Reserved - always set to 0
120 VBEModeInfoBlock.Reserved2 equ VBEModeInfoBlock + 48 ; DD - Reserved - always set to 0
121 ; Mandatory information for VBE 3.0 and above
122 ;VBEModeInfoBlock.LinBytesPerScanLine dw 0 ; bytes per scan line for linear modes
123 ;VBEModeInfoBlock.BnkNumberOfImagePages db 0 ; number of images for banked modes
124 ;VBEModeInfoBlock.LinNumberOfImagePages db 0 ; number of images for linear modes
125 ;VBEModeInfoBlock.LinRedMaskSize db 0 ; size of direct color red mask (linear modes)
126 ;VBEModeInfoBlock.LinRedFieldPosition db 0 ; bit position of lsb of red mask (linear modes)
127 ;VBEModeInfoBlock.LinGreenMaskSize db 0 ; size of direct color green mask (linear modes)
128 ;VBEModeInfoBlock.LinGreenFieldPosition db 0 ; bit position of lsb of green mask (linear modes)
129 ;VBEModeInfoBlock.LinBlueMaskSize db 0 ; size of direct color blue mask (linear modes)
130 ;VBEModeInfoBlock.LinBlueFieldPosition db 0 ; bit position of lsb of blue mask (linear modes)
131 ;VBEModeInfoBlock.LinRsvdMaskSize db 0 ; size of direct color reserved mask (linear modes)
132 ;VBEModeInfoBlock.LinRsvdFieldPosition db 0 ; bit position of lsb of reserved mask (linear modes)
133 ;VBEModeInfoBlock.MaxPixelClock dd 0 ; maximum pixel clock (in Hz) for graphics mode
136 ; -----------------------------------------------------------------------------
137 align 16
138 GDTR64: ; Global Descriptors Table Register
139 dw gdt64_end - gdt64 - 1 ; limit of GDT (size minus one)
140 dq 0x0000000000001000 ; linear address of GDT
142 align 16
143 gdt64: ; This structure is copied to 0x0000000000001000
144 SYS64_NULL_SEL equ $-gdt64 ; Null Segment
145 dq 0x0000000000000000
146 SYS64_CODE_SEL equ $-gdt64 ; Code segment, read/execute, nonconforming
147 dq 0x0020980000000000 ; 0x00209A0000000000
148 SYS64_DATA_SEL equ $-gdt64 ; Data segment, read/write, expand down
149 dq 0x0000900000000000 ; 0x0020920000000000
150 gdt64_end:
152 align 16
153 IDTR64: ; Interrupt Descriptor Table Register
154 dw 256*16-1 ; limit of IDT (size minus one) (4096 bytes - 1)
155 dq 0x0000000000000000 ; linear address of IDT
156 ; -----------------------------------------------------------------------------
159 ; =============================================================================
160 ; EOF