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
6 ; =============================================================================
11 lodsd ; OEMID (First 4 bytes)
12 lodsw ; OEMID (Last 2 bytes)
13 lodsb ; Grab the Revision value (0 is v1.0, 1 is v2.0, 2 is v3.0, etc)
15 mov [0x000B8098], al ; Print the ACPI version number
18 je foundACPIv1
; If AL is 0 then the system is using ACPI v1.0
19 jmp foundACPIv2
; Otherwise it is v2.0 or higher
23 lodsd ; Grab the 32 bit physical address of the RSDT (Offset 16).
24 mov rsi
, rax
; RSI now points to the RSDT
25 lodsd ; Grab the Signiture
26 cmp eax, 'RSDT' ; Make sure the signiture is valid
27 jne novalidacpi
; Not the same? Bail out
29 mov [os_ACPITableAddress
], rsi
; Save the RSDT Table Address
33 add rsi
, 28 ; Skip to the Entry offset
34 sub eax, 36 ; EAX holds the table size. Subtract the preamble
35 shr eax, 2 ; Divide by 4
36 mov rdx
, rax
; RDX is the entry count
38 foundACPIv1_nextentry:
44 jmp foundACPIv1_nextentry
49 lodsq
; Grab the 64 bit physical address of the XSDT (Offset 24).
50 mov rsi
, rax
; RSI now points to the XSDT
51 lodsd ; Grab the Signiture
52 cmp eax, 'XSDT' ; Make sure the signiture is valid
53 jne novalidacpi
; Not the same? Bail out
55 mov [os_ACPITableAddress
], rsi
; Save the XSDT Table Address
59 add rsi
, 28 ; Skip to the start of the Entries (offset 36)
60 sub eax, 36 ; EAX holds the table size. Subtract the preamble
61 shr eax, 3 ; Divide by 8
62 mov rdx
, rax
; RDX is the entry count
64 foundACPIv2_nextentry:
69 jne foundACPIv2_nextentry
72 mov al, '3' ; Search for the APIC table
97 lodsd ; Length of MADT in bytes
102 lodsd ; OEMID (First 4 bytes)
103 lodsw ; OEMID (Last 2 bytes)
107 lodsd ; Creator Revision
109 lodsd ; Local APIC Address
110 mov [os_LocalAPICAddress
], rax
; Save the Address of the Local APIC
113 mov rdi
, 0x0000000000005800
117 jge init_smp_acpi_done
118 lodsb ; APIC Structure Type
126 inc word [cpu_detected
]
128 lodsb ; Length (will be set to 8)
130 lodsb ; ACPI Processor ID
137 jmp readAPICstructures
; Read the next structure
141 lodsb ; Length (will be set to 12)
146 lodsd ; IO APIC Address
147 mov [os_IOAPICAddress
], rax
148 lodsd ; System Vector Base
149 jmp readAPICstructures
; Read the next structure
153 lodsb ; We have a type that we ignore, read the next byte
156 sub rsi
, 2 ; For the two bytes just read
157 jmp readAPICstructures
; Read the next structure
166 ; =============================================================================