diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2021-11-28 11:41:35 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2021-11-28 11:44:40 +0100 |
commit | 230d7726ce55114c5c32c440c5928f104a085ba6 (patch) | |
tree | 270728ff42aa3e1d6d1f213b5a7271973008041b /i386 | |
parent | 7bb961dfd808df26b9245c999b8cb4e897439019 (diff) | |
download | gnumach-230d7726ce55114c5c32c440c5928f104a085ba6.tar.gz gnumach-230d7726ce55114c5c32c440c5928f104a085ba6.tar.bz2 gnumach-230d7726ce55114c5c32c440c5928f104a085ba6.zip |
memmmap: Use biosmem_addr_available rather than vm_page_lookup_pa
The segment code actually has vm_page entries for reserved pages, and
thus memmmap would reject mapping ACPI pages. Taking the information
from biosmem is much more precise, and indeed knows all hardware quirks
which can now be dropped from memmmap.
Diffstat (limited to 'i386')
-rw-r--r-- | i386/i386at/biosmem.c | 18 | ||||
-rw-r--r-- | i386/i386at/biosmem.h | 6 | ||||
-rw-r--r-- | i386/i386at/mem.c | 18 |
3 files changed, 25 insertions, 17 deletions
diff --git a/i386/i386at/biosmem.c b/i386/i386at/biosmem.c index 9f86b66a..4f0914ca 100644 --- a/i386/i386at/biosmem.c +++ b/i386/i386at/biosmem.c @@ -995,3 +995,21 @@ biosmem_free_usable(void) biosmem_free_usable_entry(start, end); } } + +boolean_t +biosmem_addr_available(phys_addr_t addr) +{ + struct biosmem_map_entry *entry; + unsigned i; + + if (addr < BIOSMEM_BASE) + return FALSE; + + for (i = 0; i < biosmem_map_size; i++) { + entry = &biosmem_map[i]; + + if (addr >= entry->base_addr && addr < entry->base_addr + entry->length) + return entry->type == BIOSMEM_TYPE_AVAILABLE; + } + return FALSE; +} diff --git a/i386/i386at/biosmem.h b/i386/i386at/biosmem.h index 7824c168..76ab23a0 100644 --- a/i386/i386at/biosmem.h +++ b/i386/i386at/biosmem.h @@ -100,4 +100,10 @@ void biosmem_setup(void); */ void biosmem_free_usable(void); +/* + * Tell whether this address is marked as available in the biosmem and thus used + * for usable memory. + */ +boolean_t biosmem_addr_available(phys_addr_t addr); + #endif /* _X86_BIOSMEM_H */ diff --git a/i386/i386at/mem.c b/i386/i386at/mem.c index 61143185..e42e995d 100644 --- a/i386/i386at/mem.c +++ b/i386/i386at/mem.c @@ -36,24 +36,8 @@ dev_t dev; vm_offset_t off; vm_prot_t prot; { - struct vm_page *p; - - if (off == 0) - return 0; - - /* - * The legacy device mappings are included in the page tables and - * need their own test. - */ - if (off >= 0xa0000 && off < 0x100000) - goto out; - - p = vm_page_lookup_pa(off); - - if (p != NULL) { + if (biosmem_addr_available(off)) return -1; - } -out: return i386_btop(off); } |