From dc1d6a3c61525e9d7e82db0f005be048b5f9c84b Mon Sep 17 00:00:00 2001 From: mintsuki Date: Wed, 3 Nov 2021 01:52:55 +0100 Subject: [PATCH] stivale: Deprecate low memory area --- stage23/protos/stivale.c | 8 ++++++-- stage23/protos/stivale2.c | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/stage23/protos/stivale.c b/stage23/protos/stivale.c index e14e9b7b..585a3501 100644 --- a/stage23/protos/stivale.c +++ b/stage23/protos/stivale.c @@ -302,8 +302,12 @@ void stivale_load(char *config, char *cmdline) { if (bits == 64) pagemap = stivale_build_pagemap(want_5lv, false, NULL, 0, false, 0, 0); - // Reserve 32K at 0x70000 - memmap_alloc_range(0x70000, 0x8000, MEMMAP_USABLE, true, true, false, false); + // Reserve 32K at 0x70000 if possible + if (!memmap_alloc_range(0x70000, 0x8000, MEMMAP_USABLE, true, false, false, false)) { + if ((stivale_hdr.flags & (1 << 4)) == 0) { + panic("stivale: Could not allocate low memory area"); + } + } struct e820_entry_t *mmap_copy = ext_mem_alloc(256 * sizeof(struct e820_entry_t)); diff --git a/stage23/protos/stivale2.c b/stage23/protos/stivale2.c index fd7b61ff..2981b1d4 100644 --- a/stage23/protos/stivale2.c +++ b/stage23/protos/stivale2.c @@ -682,8 +682,12 @@ have_tm_tag:; ext_mem_alloc(sizeof(struct stivale2_struct_tag_memmap) + sizeof(struct e820_entry_t) * 256); - // Reserve 32K at 0x70000 - memmap_alloc_range(0x70000, 0x8000, MEMMAP_USABLE, true, true, false, false); + // Reserve 32K at 0x70000, if possible + if (!memmap_alloc_range(0x70000, 0x8000, MEMMAP_USABLE, true, false, false, false)) { + if ((stivale2_hdr.flags & (1 << 4)) == 0) { + panic("stivale2: Could not allocate low memory area"); + } + } size_t mmap_entries; struct e820_entry_t *mmap = get_memmap(&mmap_entries);