git-svn-id: svn://kolibrios.org@2218 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2011-09-21 09:13:47 +00:00
parent 9447e850cf
commit e06410d094
3 changed files with 122 additions and 2 deletions

View File

@ -171,9 +171,14 @@ proc map_io_mem stdcall, base:dword, size:dword, flags:dword
push ebx push ebx
push edi push edi
mov eax, [size] mov eax, [size]
add eax, [base]
add eax, 4095 add eax, 4095
and eax, -4096 and eax, -4096
mov ecx, [base]
and ecx, -4096
sub eax, ecx
mov [size], eax mov [size], eax
stdcall alloc_kernel_space, eax stdcall alloc_kernel_space, eax
test eax, eax test eax, eax
jz .fail jz .fail
@ -189,9 +194,7 @@ proc map_io_mem stdcall, base:dword, size:dword, flags:dword
or edx, [flags] or edx, [flags]
@@: @@:
mov [page_tabs+eax*4], edx mov [page_tabs+eax*4], edx
; push eax
invlpg [ebx] invlpg [ebx]
; pop eax
inc eax inc eax
add ebx, edi add ebx, edi
add edx, edi add edx, edi

View File

@ -431,4 +431,120 @@ proc test_cpu
ret ret
endp 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:
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

View File

@ -258,6 +258,7 @@ B32:
call test_cpu call test_cpu
bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc
call check_acpi
call init_BIOS32 call init_BIOS32
; MEMORY MODEL ; MEMORY MODEL
call mem_test call mem_test