1
0
Fork 0
mirror of https://gitlab.com/bztsrc/bootboot.git synced 2023-02-13 20:54:32 -05:00

More roboust ACPI memory detection

This commit is contained in:
bzt 2019-03-10 14:24:26 +01:00
parent 536ef740d0
commit ae1a94e3d9
10 changed files with 39 additions and 22 deletions

View file

@ -1579,8 +1579,7 @@ gzerr: puts("BOOTBOOT-PANIC: Unable to uncompress\n");
switch(MMapEnt_Type(mmap)) {
case MMAP_USED: uart_puts("reserved"); break;
case MMAP_FREE: uart_puts("free"); break;
case MMAP_ACPIFREE: uart_puts("acpifree"); break;
case MMAP_ACPINVS: uart_puts("acpinvs"); break;
case MMAP_ACPI: uart_puts("acpi"); break;
case MMAP_MMIO: uart_puts("mmio"); break;
default: uart_puts("unknown"); break;
}

Binary file not shown.

Binary file not shown.

View file

@ -70,13 +70,12 @@ typedef struct {
#define MMapEnt_Ptr(a) (a->ptr)
#define MMapEnt_Size(a) (a->size & 0xFFFFFFFFFFFFFFF0)
#define MMapEnt_Type(a) (a->size & 0xF)
#define MMapEnt_IsFree(a) ((a->size&0xF)==1||(a->size&0xF)==2)
#define MMapEnt_IsFree(a) ((a->size&0xF)==1)
#define MMAP_USED 0 /* don't use. Reserved or unknown regions */
#define MMAP_FREE 1 /* usable memory */
#define MMAP_ACPIFREE 2 /* free to use after acpi tables are parsed */
#define MMAP_ACPINVS 3 /* don't use. Acpi non-volatile */
#define MMAP_MMIO 4 /* memory mapped IO region */
#define MMAP_ACPI 2 /* acpi memory, volatile and non-volatile as well */
#define MMAP_MMIO 3 /* memory mapped IO region */
#define INITRD_MAXSIZE 16 /* Mb */

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -511,13 +511,11 @@ getmemmap:
.notfirst: mov al, byte [di+16]
cmp al, 1
je .noov
cmp al, 4
je .isacpi
cmp al, 3
jne @f
mov al, MMAP_ACPIFREE
jmp .noov
@@: cmp al, 4
jne @f
mov al, MMAP_ACPINVS
.isacpi: mov al, MMAP_ACPI
jmp .noov
; everything else reserved
@@: mov al, MMAP_USED
@ -525,7 +523,7 @@ getmemmap:
mov byte [di+8], al
xor ecx, ecx
;is it ACPI area?
cmp al, MMAP_ACPIFREE
cmp al, MMAP_ACPI
jne .notacpi
mov dword [bootboot.acpi_ptr], edi
jmp .entryok
@ -643,13 +641,14 @@ getmemmap:
je .acpi1
.acpi2: mov eax, dword [es:24]
mov dword [bootboot.acpi_ptr], eax
mov eax, dword [es:28]
mov dword [bootboot.acpi_ptr+4], eax
jmp .detsmbi
mov edx, dword [es:28]
mov dword [bootboot.acpi_ptr+4], edx
jmp .chkacpi
; no, fallback to RSDT
.acpi1: mov eax, dword [es:16]
@@: mov dword [bootboot.acpi_ptr], eax
jmp .detsmbi
xor edx, edx
jmp .chkacpi
.acpinotf: xor eax, eax
mov ax, es
inc ax
@ -661,6 +660,27 @@ getmemmap:
jnz .acpinext
mov si, noacpi
jmp real_diefunc
.chkacpi: ; check if memory is marked as ACPI in the memory map
mov esi, bootboot.mmap
mov edi, bootboot.magic
add edi, dword [bootboot.size]
.nextmm: cmp edx, dword [si+4]
jne .skipmm
mov ebx, dword [si]
cmp eax, ebx
jl .skipmm
add ebx, dword [si+8]
and bl, 0F0h
cmp eax, ebx
jge .skipmm
mov al, byte [si+8]
and al, 0F0h
or al, MMAP_ACPI
mov byte [si+8], al
jmp .detsmbi
.skipmm: add si, 16
cmp si, di
jl .nextmm
;detect SMBios tables
.detsmbi: xor eax, eax

View file

@ -74,9 +74,8 @@ end virtual
MMAP_USED equ 0
MMAP_FREE equ 1
MMAP_ACPIFREE equ 2
MMAP_ACPINVS equ 3
MMAP_MMIO equ 4
MMAP_ACPI equ 2
MMAP_MMIO equ 3
INITRD_MAXSIZE equ 16 ; Mb

View file

@ -1712,10 +1712,10 @@ get_memory_map:
mmapent->ptr=mement->PhysicalStart;
mmapent->size=(mement->NumberOfPages*PAGESIZE)+
((mement->Type>0&&mement->Type<5)||mement->Type==7?MMAP_FREE:
(mement->Type==9?MMAP_ACPIFREE:
(mement->Type==10?MMAP_ACPINVS:
(mement->Type==9 || mement->Type==10 || (bootboot->arch.x86_64.acpi_ptr >= mmapent->ptr &&
bootboot->arch.x86_64.acpi_ptr < mmapent->ptr+mement->NumberOfPages*PAGESIZE)?MMAP_ACPI:
(mement->Type==11||mement->Type==12?MMAP_MMIO:
MMAP_USED))));
MMAP_USED)));
// merge continous areas of the same type
if(last!=NULL &&
MMapEnt_Type(last) == MMapEnt_Type(mmapent) &&