Skip to content

Commit

Permalink
setup, acpi: map BIOS areas where ACPI's RSDP table is located
Browse files Browse the repository at this point in the history
This is needed to get rid of "Low memory" mappings.

Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
  • Loading branch information
wipawel committed Jul 30, 2021
1 parent 4fb9742 commit 015fb7a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
7 changes: 2 additions & 5 deletions common/acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
#include <percpu.h>
#include <string.h>

#define ACPI_RSDP_BIOS_ROM_START 0xE0000
#define ACPI_RSDP_BIOS_ROM_STOP 0xFFFFF

acpi_table_t *acpi_tables[128];
unsigned max_acpi_tables;

Expand Down Expand Up @@ -109,8 +106,8 @@ static rsdp_rev1_t *acpi_find_rsdp(void) {
if (rsdp)
return rsdp;

rsdp = find_rsdp(paddr_to_virt_kern(ACPI_RSDP_BIOS_ROM_START),
paddr_to_virt_kern(ACPI_RSDP_BIOS_ROM_STOP));
rsdp = find_rsdp(paddr_to_virt_kern(BIOS_ACPI_ROM_START),
paddr_to_virt_kern(BIOS_ACPI_ROM_STOP));
if (rsdp)
return rsdp;

Expand Down
14 changes: 14 additions & 0 deletions common/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,19 @@ void zap_boot_mappings(void) {
}
}

static void map_bios_area(void) {
vmap_4k(paddr_to_virt(BDA_ADDR_START), paddr_to_mfn(BDA_ADDR_START), L1_PROT_RO);
kmap_4k(paddr_to_mfn(BDA_ADDR_START), L1_PROT_RO);

uint32_t ebda_addr = get_bios_ebda_addr();
vmap_4k(paddr_to_virt(ebda_addr), paddr_to_mfn(ebda_addr), L1_PROT_RO);
kmap_4k(paddr_to_mfn(ebda_addr), L1_PROT_RO);

for (mfn_t bios_mfn = paddr_to_mfn(BIOS_ACPI_ROM_START);
bios_mfn < paddr_to_mfn(BIOS_ACPI_ROM_STOP); bios_mfn++)
kmap_4k(bios_mfn, L1_PROT_RO);
}

void __noreturn __text_init kernel_start(uint32_t multiboot_magic,
multiboot_info_t *mbi) {
/* Zero-out BSS sections */
Expand Down Expand Up @@ -220,6 +233,7 @@ void __noreturn __text_init kernel_start(uint32_t multiboot_magic,
init_pagetables();

map_multiboot_areas();
map_bios_area();

write_cr3(cr3.paddr);
WRITE_SP(get_free_pages_top(PAGE_ORDER_2M, GFP_KERNEL));
Expand Down
3 changes: 3 additions & 0 deletions include/mm/pmm.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
#define BDA_COM_PORTS_ENTRY 0x400
#define EBDA_ADDR_ENTRY 0x40E

#define BIOS_ACPI_ROM_START 0xE0000
#define BIOS_ACPI_ROM_STOP 0xFFFFF

#define BIOS_ROM_ADDR_START 0xF0000

#ifndef __ASSEMBLY__
Expand Down

0 comments on commit 015fb7a

Please sign in to comment.