* add p cc
[mascara-docs.git] / amd64 / pure64-0.5.0 / src / sysvar.asm
blob7544603cbc795b0630546928645fe033ab1c00da
1 ; =============================================================================
2 ; Pure64 -- a 64-bit OS loader written in Assembly for x86-64 systems
3 ; Copyright (C) 2008-2012 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_ACPITableAddress: equ SystemVariables + 0x00
26 screen_cursor_offset: equ SystemVariables + 0x08
27 hd1_maxlba: equ SystemVariables + 0x10
28 os_Counter_Timer: equ SystemVariables + 0x18
29 os_Counter_RTC: equ SystemVariables + 0x20
30 os_LocalAPICAddress: equ SystemVariables + 0x28
31 os_IOAPICAddress: equ SystemVariables + 0x30
33 ; DD - Starting at offset 128, increments by 4
34 hd1_size: equ SystemVariables + 128
35 fat16_FatStart: equ SystemVariables + 132
36 fat16_TotalSectors: equ SystemVariables + 136
37 fat16_DataStart: equ SystemVariables + 140
38 fat16_RootStart: equ SystemVariables + 144
39 fat16_PartitionOffset: equ SystemVariables + 148
40 sata_base: equ SystemVariables + 152
41 os_BSP: equ SystemVariables + 156
43 ; DW - Starting at offset 256, increments by 2
44 cpu_speed: equ SystemVariables + 256
45 cpu_activated: equ SystemVariables + 258
46 cpu_detected: equ SystemVariables + 260
47 mem_amount: equ SystemVariables + 262
48 fat16_BytesPerSector: equ SystemVariables + 264
49 fat16_ReservedSectors: equ SystemVariables + 266
50 fat16_SectorsPerFat: equ SystemVariables + 268
51 fat16_RootDirEnts: equ SystemVariables + 270
52 ata_base: equ SystemVariables + 272
54 ; DB - Starting at offset 384, increments by 1
55 hd1_enable: equ SystemVariables + 384
56 hd1_lba48: equ SystemVariables + 385
57 screen_cursor_x: equ SystemVariables + 386
58 screen_cursor_y: equ SystemVariables + 387
59 fat16_SectorsPerCluster: equ SystemVariables + 388
60 fat16_Fats: equ SystemVariables + 389
61 memtempstring: equ SystemVariables + 390
62 speedtempstring: equ SystemVariables + 400
63 cpu_amount_string: equ SystemVariables + 410
64 hdtempstring: equ SystemVariables + 420
65 os_key: equ SystemVariables + 421
66 os_IOAPICCount: equ SystemVariables + 424
68 ;MISC
69 screen_cols: db 80
70 screen_rows: db 25
71 hextable: db '0123456789ABCDEF'
73 ;STRINGS
74 pure64: db 'Pure64 - ', 0
75 kernelerror: db 'ERROR: Software not found.', 0
76 kernelname: db 'KERNEL64SYS', 0
77 configname: db 'PURE64 CFG', 0
78 msg_done: db ' Done', 0
79 msg_CPU: db '[CPU: ', 0
80 msg_mhz: db 'MHz x', 0
81 msg_MEM: db '] [MEM: ', 0
82 msg_mb: db ' MiB]', 0
83 msg_HDD: db ' [HDD: ', 0
84 msg_loadingkernel: db 'Loading software', 0;...', 0
85 msg_startingkernel: db 'Starting software.', 0
86 msg_noconfig: db '(default config)', 0
87 no64msg: db 'ERROR: This computer does not support 64-Bit mode. Press any key to reboot.', 0
88 initStartupMsg: db 'Pure64 v0.5.0 - http://www.returninfinity.com', 13, 10, 13, 10, 'Initializing system... ', 0
89 msg_date: db '2011/12/19', 0
90 hdd_setup_no_drive: db 'No HDD detected', 0
91 hdd_setup_read_error: db 'Error reading HDD', 0
93 ; Mandatory information for all VBE revisions
94 VBEModeInfoBlock.ModeAttributes equ VBEModeInfoBlock + 0 ; DW - mode attributes
95 VBEModeInfoBlock.WinAAttributes equ VBEModeInfoBlock + 2 ; DB - window A attributes
96 VBEModeInfoBlock.WinBAttributes equ VBEModeInfoBlock + 3 ; DB - window B attributes
97 VBEModeInfoBlock.WinGranularity equ VBEModeInfoBlock + 4 ; DW - window granularity in KB
98 VBEModeInfoBlock.WinSize equ VBEModeInfoBlock + 6 ; DW - window size in KB
99 VBEModeInfoBlock.WinASegment equ VBEModeInfoBlock + 8 ; DW - window A start segment
100 VBEModeInfoBlock.WinBSegment equ VBEModeInfoBlock + 10 ; DW - window B start segment
101 VBEModeInfoBlock.WinFuncPtr equ VBEModeInfoBlock + 12 ; DD - real mode pointer to window function
102 VBEModeInfoBlock.BytesPerScanLine equ VBEModeInfoBlock + 16 ; DW - bytes per scan line
103 ; Mandatory information for VBE 1.2 and above
104 VBEModeInfoBlock.XResolution equ VBEModeInfoBlock + 18 ; DW - horizontal resolution in pixels or characters
105 VBEModeInfoBlock.YResolution equ VBEModeInfoBlock + 20 ; DW - vertical resolution in pixels or characters
106 VBEModeInfoBlock.XCharSize equ VBEModeInfoBlock + 22 ; DB - character cell width in pixels
107 VBEModeInfoBlock.YCharSize equ VBEModeInfoBlock + 23 ; DB - character cell height in pixels
108 VBEModeInfoBlock.NumberOfPlanes equ VBEModeInfoBlock + 24 ; DB - number of memory planes
109 VBEModeInfoBlock.BitsPerPixel equ VBEModeInfoBlock + 25 ; DB - bits per pixel
110 VBEModeInfoBlock.NumberOfBanks equ VBEModeInfoBlock + 26 ; DB - number of banks
111 VBEModeInfoBlock.MemoryModel equ VBEModeInfoBlock + 27 ; DB - memory model type
112 VBEModeInfoBlock.BankSize equ VBEModeInfoBlock + 28 ; DB - bank size in KB
113 VBEModeInfoBlock.NumberOfImagePages equ VBEModeInfoBlock + 29 ; DB - number of image pages
114 VBEModeInfoBlock.Reserved equ VBEModeInfoBlock + 30 ; DB - reserved (0x00 for VBE 1.0-2.0, 0x01 for VBE 3.0)
115 ; Direct Color fields (required for direct/6 and YUV/7 memory models)
116 VBEModeInfoBlock.RedMaskSize equ VBEModeInfoBlock + 31 ; DB - size of direct color red mask in bits
117 VBEModeInfoBlock.RedFieldPosition equ VBEModeInfoBlock + 32 ; DB - bit position of lsb of red mask
118 VBEModeInfoBlock.GreenMaskSize equ VBEModeInfoBlock + 33 ; DB - size of direct color green mask in bits
119 VBEModeInfoBlock.GreenFieldPosition equ VBEModeInfoBlock + 34 ; DB - bit position of lsb of green mask
120 VBEModeInfoBlock.BlueMaskSize equ VBEModeInfoBlock + 35 ; DB - size of direct color blue mask in bits
121 VBEModeInfoBlock.BlueFieldPosition equ VBEModeInfoBlock + 36 ; DB - bit position of lsb of blue mask
122 VBEModeInfoBlock.RsvdMaskSize equ VBEModeInfoBlock + 37 ; DB - size of direct color reserved mask in bits
123 VBEModeInfoBlock.RsvdFieldPosition equ VBEModeInfoBlock + 38 ; DB - bit position of lsb of reserved mask
124 VBEModeInfoBlock.DirectColorModeInfo equ VBEModeInfoBlock + 39 ; DB - direct color mode attributes
125 ; Mandatory information for VBE 2.0 and above
126 VBEModeInfoBlock.PhysBasePtr equ VBEModeInfoBlock + 40 ; DD - physical address for flat memory frame buffer
127 VBEModeInfoBlock.Reserved1 equ VBEModeInfoBlock + 44 ; DD - Reserved - always set to 0
128 VBEModeInfoBlock.Reserved2 equ VBEModeInfoBlock + 48 ; DD - Reserved - always set to 0
129 ; Mandatory information for VBE 3.0 and above
130 ;VBEModeInfoBlock.LinBytesPerScanLine dw 0 ; bytes per scan line for linear modes
131 ;VBEModeInfoBlock.BnkNumberOfImagePages db 0 ; number of images for banked modes
132 ;VBEModeInfoBlock.LinNumberOfImagePages db 0 ; number of images for linear modes
133 ;VBEModeInfoBlock.LinRedMaskSize db 0 ; size of direct color red mask (linear modes)
134 ;VBEModeInfoBlock.LinRedFieldPosition db 0 ; bit position of lsb of red mask (linear modes)
135 ;VBEModeInfoBlock.LinGreenMaskSize db 0 ; size of direct color green mask (linear modes)
136 ;VBEModeInfoBlock.LinGreenFieldPosition db 0 ; bit position of lsb of green mask (linear modes)
137 ;VBEModeInfoBlock.LinBlueMaskSize db 0 ; size of direct color blue mask (linear modes)
138 ;VBEModeInfoBlock.LinBlueFieldPosition db 0 ; bit position of lsb of blue mask (linear modes)
139 ;VBEModeInfoBlock.LinRsvdMaskSize db 0 ; size of direct color reserved mask (linear modes)
140 ;VBEModeInfoBlock.LinRsvdFieldPosition db 0 ; bit position of lsb of reserved mask (linear modes)
141 ;VBEModeInfoBlock.MaxPixelClock dd 0 ; maximum pixel clock (in Hz) for graphics mode
144 ; -----------------------------------------------------------------------------
145 align 16
146 GDTR64: ; Global Descriptors Table Register
147 dw gdt64_end - gdt64 - 1 ; limit of GDT (size minus one)
148 dq 0x0000000000001000 ; linear address of GDT
150 gdt64: ; This structure is copied to 0x0000000000001000
151 SYS64_NULL_SEL equ $-gdt64 ; Null Segment
152 dq 0x0000000000000000
153 SYS64_CODE_SEL equ $-gdt64 ; Code segment, read/execute, nonconforming
154 dq 0x0020980000000000 ; 0x00209A0000000000
155 SYS64_DATA_SEL equ $-gdt64 ; Data segment, read/write, expand down
156 dq 0x0000900000000000 ; 0x0020920000000000
157 gdt64_end:
159 IDTR64: ; Interrupt Descriptor Table Register
160 dw 256*16-1 ; limit of IDT (size minus one) (4096 bytes - 1)
161 dq 0x0000000000000000 ; linear address of IDT
162 ; -----------------------------------------------------------------------------
165 ; =============================================================================
166 ; EOF