forked from pool/elilo
67 lines
1.7 KiB
Diff
67 lines
1.7 KiB
Diff
|
---
|
||
|
x86_64/system.c | 31 +++++++++++++++++++++++++++++++
|
||
|
1 file changed, 31 insertions(+)
|
||
|
|
||
|
--- a/x86_64/system.c
|
||
|
+++ b/x86_64/system.c
|
||
|
@@ -44,7 +44,9 @@
|
||
|
#include "loader.h"
|
||
|
#include "rmswitch.h"
|
||
|
|
||
|
+#ifndef DEBUG_CREATE_BOOT_PARAMS
|
||
|
#define DEBUG_CREATE_BOOT_PARAMS 0
|
||
|
+#endif
|
||
|
#if DEBUG_CREATE_BOOT_PARAMS
|
||
|
#define DPR(a) do { if (elilo_opt.debug) { Print a; } } while ( 0 )
|
||
|
#else
|
||
|
@@ -100,6 +102,7 @@ UINTN sizeof_init_gdt = sizeof init_gdt;
|
||
|
*/
|
||
|
|
||
|
UINTN high_base_mem = 0x90000;
|
||
|
+VOID *high_base_mem_address = NULL;
|
||
|
|
||
|
/*
|
||
|
* Highest available extended memory address.
|
||
|
@@ -128,6 +131,30 @@ sysdeps_init(EFI_HANDLE dev)
|
||
|
{
|
||
|
DBG_PRT((L"sysdeps_init()\n"));
|
||
|
|
||
|
+ DBG_PRT((L"fix high_base_mem and gdt_addr\n"));
|
||
|
+ while (!high_base_mem_address) {
|
||
|
+ high_base_mem_address = alloc_pages(5, EfiLoaderData,
|
||
|
+ AllocateAddress,
|
||
|
+ (void *)high_base_mem);
|
||
|
+ if (!high_base_mem_address) {
|
||
|
+ if (high_base_mem > (1 << 16)) {
|
||
|
+ high_base_mem -= (1 << 16);
|
||
|
+ } else {
|
||
|
+ /* fall back to previous behavior */
|
||
|
+ high_base_mem = 0x90000;
|
||
|
+ break;
|
||
|
+ }
|
||
|
+ }
|
||
|
+ }
|
||
|
+ if (high_base_mem_address) {
|
||
|
+ VERB_PRT(3, Print(L"high_base_mem="PTR_FMT"\n",
|
||
|
+ high_base_mem_address));
|
||
|
+ gdt_addr.base = high_base_mem + 0x4000;
|
||
|
+ } else {
|
||
|
+ ERR_PRT((L"Failed to allocate high_base_mem, "
|
||
|
+ "stomping over heritage 0x90000.\n"));
|
||
|
+ }
|
||
|
+
|
||
|
/*
|
||
|
* Register our loader(s)...
|
||
|
*/
|
||
|
@@ -624,6 +651,10 @@ sysdeps_create_boot_params(
|
||
|
ERR_PRT((L"bp="PTR_FMT" cmdline="PTR_FMT" initrd="PTR_FMT" cookie="PTR_FMT"",
|
||
|
bp, cmdline, initrd, cookie));
|
||
|
|
||
|
+ if (high_base_mem_address != NULL) {
|
||
|
+ free(high_base_mem_address);
|
||
|
+ high_base_mem_address = NULL;
|
||
|
+ }
|
||
|
if (param_start != NULL) {
|
||
|
free(param_start);
|
||
|
param_start = NULL;
|