/kernel/branches/Kolibri-acpi/core/apic.inc |
---|
12,9 → 12,9 |
endg |
uglobal |
APIC: dd 0 |
LAPIC_BASE: dd 0 |
IOAPIC_base: dd 0 |
APIC rd 1 |
IOAPIC_base rd 1 |
LAPIC_BASE rd 1 |
endg |
APIC_ID equ 0x20 |
44,17 → 44,15 |
APIC_init: |
mov dword[APIC], 0 |
; jmp .no_apic ; NO APIC |
; bt [cpu_caps], CAPS_APIC |
; jnc .no_apic |
; Check for MP table |
;..... |
mov eax, [acpi_ioapic_base] |
test eax, eax |
jz .no_apic |
call IRQ_mask_all |
; IOAPIC init |
; 0xfec00000 - may be relocated, see chip reference... & MP table |
stdcall map_io_mem, 0xfec00000, 0x20, PG_SW |
stdcall map_io_mem, [acpi_ioapic_base], 0x20, PG_SW |
mov [IOAPIC_base], eax |
mov eax, IOAPIC_VER |
135,11 → 133,11 |
; Check MSR support |
;.... |
; Get LAPIC base address |
mov ecx, 0x1b |
rdmsr ; it may be replaced to |
and ax, 0xf000 ; mov eax, 0xfee00000 |
; mov ecx, 0x1b |
; rdmsr ; it may be replaced to |
; and ax, 0xf000 ; mov eax, 0xfee00000 |
stdcall map_io_mem, eax, 0x1000, PG_SW |
stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_SW |
mov [LAPIC_BASE], eax |
mov esi, eax |
/kernel/branches/Kolibri-acpi/init.inc |
---|
431,4 → 431,122 |
ret |
endp |
uglobal |
align 4 |
acpi_rsdp rd 1 |
acpi_rsdt rd 1 |
acpi_madt rd 1 |
acpi_rsdt_base rd 1 |
acpi_madt_base rd 1 |
acpi_lapic_base rd 1 |
acpi_ioapic_base rd 1 |
endg |
ACPI_HI_RSDP_WINDOW_START equ 0x000E0000 |
ACPI_HI_RSDP_WINDOW_END equ 0x00100000 |
ACPI_RSDP_CHECKSUM_LENGTH equ 20 |
ACPI_MADT_SIGN equ 0x43495041 |
acpi_locate: |
push ebx |
mov ebx, ACPI_HI_RSDP_WINDOW_START |
.check: |
cmp [ebx], dword 0x20445352 |
jne .next |
cmp [ebx+4], dword 0x20525450 |
jne .next |
mov edx, ebx |
mov ecx, ACPI_RSDP_CHECKSUM_LENGTH |
xor eax, eax |
.sum: |
add al, [edx] |
inc edx |
loop .sum |
test al, al |
jnz .next |
mov eax, ebx |
pop ebx |
ret |
.next: |
add ebx, 16 |
cmp ebx, ACPI_HI_RSDP_WINDOW_END |
jb .check |
pop ebx |
xor eax, eax |
ret |
align 4 |
rsdt_find: ;ecx= rsdt edx= SIG |
push ebx |
push esi |
lea ebx, [ecx+36] |
mov esi, [ecx+4] |
add esi, ecx |
.next: |
mov eax, [ebx] |
cmp [eax], edx |
je .done |
add ebx, 4 |
cmp ebx, esi |
jb .next |
xor eax, eax |
pop esi |
pop ebx |
ret |
.done: |
mov eax, [ebx] |
pop esi |
pop ebx |
ret |
align 4 |
check_acpi: |
xchg bx, bx |
call acpi_locate |
test eax, eax |
jz .done |
mov ecx, [eax+16] |
mov edx, ACPI_MADT_SIGN |
mov [acpi_rsdt_base-OS_BASE], ecx |
call rsdt_find |
test eax, eax |
jz .done |
mov [acpi_madt_base-OS_BASE], eax |
mov ecx, [eax+36] |
mov [acpi_lapic_base-OS_BASE], ecx |
lea edx, [eax+44] |
mov ecx, [eax+4] |
add ecx, eax |
.check: |
mov eax, [edx] |
cmp al, 1 |
je .ioapic |
.next: |
movzx eax, ah |
add edx, eax |
cmp edx, ecx |
jb .check |
.done: |
ret |
.ioapic: |
mov eax, [edx+4] |
mov [acpi_ioapic_base-OS_BASE], eax |
ret |
/kernel/branches/Kolibri-acpi/kernel.asm |
---|
258,6 → 258,7 |
call test_cpu |
bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc |
call check_acpi |
call init_BIOS32 |
; MEMORY MODEL |
call mem_test |