diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c index 91e94a7..9733629 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c +++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c @@ -14,6 +14,39 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "DxeMain.h" +#include +#define PORT 0x3f8 + +static int is_transmit_empty() { + return inb(PORT + 5) & 0x20; +} + +void serial_char(char a) { + outb(a, PORT); + while (is_transmit_empty() == 0); +} + +void serial_string(const char * s) +{ + while(*s) + serial_char(*s++); +} + +void serial_hex(unsigned long x, unsigned digits) +{ + while(digits-- > 0) + { + unsigned d = (x >> (digits * 4)) & 0xF; + if (d >= 0xA) + serial_char(d + 'A' - 0xA); + else + serial_char(d + '0'); + } + serial_char('\r'); + serial_char('\n'); +} + + // // DXE Core Global Variables for Protocols from PEI // @@ -283,7 +318,12 @@ DxeMain ( gDxeCoreRT = AllocateRuntimeCopyPool (sizeof (EFI_RUNTIME_SERVICES), &mEfiRuntimeServicesTableTemplate); ASSERT (gDxeCoreRT != NULL); + + // Set our vendor string and make sure there is at least a few pages + // available in low memory for the SMP trampoline. gDxeCoreST->RuntimeServices = gDxeCoreRT; + gDxeCoreST->FirmwareVendor = L"Heads/NERF"; + gDxeCoreST->FirmwareRevision = 1337; // // Start the Image Services. @@ -297,6 +337,16 @@ DxeMain ( Status = CoreInitializeGcdServices (&HobStart, MemoryBaseAddress, MemoryLength); ASSERT_EFI_ERROR (Status); + // free up the low memory for Linux's SMP trampoline + // otherwise bad things happen... + CoreRemoveMemorySpace (0x10000, 0x10000); + CoreAddMemorySpace( + EfiGcdMemoryTypeSystemMemory, + 0x10000, + 0x10000, + 0 + ); + // // Call constructor for all libraries // @@ -743,6 +794,7 @@ CoreExitBootServices ( // // Disable Timer // + if(gTimer) gTimer->SetTimerPeriod (gTimer, 0); // @@ -780,6 +832,7 @@ CoreExitBootServices ( // // Disable CPU Interrupts // + if(gCpu) gCpu->DisableInterrupt (gCpu); MemoryProtectionExitBootServicesCallback(); diff --git a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c b/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c index a73c4cc..2c08b81 100644 --- a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c +++ b/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c @@ -232,7 +232,7 @@ SetUefiImageMemoryAttributes ( DEBUG ((DEBUG_INFO, "SetUefiImageMemoryAttributes - 0x%016lx - 0x%016lx (0x%016lx)\n", BaseAddress, Length, FinalAttributes)); - ASSERT(gCpu != NULL); + if(gCpu) gCpu->SetMemoryAttributes (gCpu, BaseAddress, Length, FinalAttributes); } index 91e94a7..6b729df 100644 --- /dev/null 2017-09-19 09:53:09.766660422 -0400 +++ ./Makefile 2017-09-20 15:24:01.850433474 -0400 @@ -0,0 +1,35 @@ +# Wrapper around the edk2 "build" script to generate +# the few files that we actually want and avoid rebuilding +# if we don't have to. + +PWD := $(shell pwd) +EDK2_OUTPUT_DIR := $(PWD)/Build/MdeModule/DEBUG_GCC5/X64/MdeModulePkg/Core +EDK2_BIN_DIR := $(PWD)/BaseTools/BinWrappers/PosixLike + +export PATH := $(EDK2_BIN_DIR):$(PATH) +export CONFIG_PATH := $(PWD)/Conf +export EDK_TOOLS_PATH := $(PWD)/BaseTools +export WORKSPACE := $(PWD) + +EDK2_BINS += Dxe/DxeMain/DEBUG/DxeCore.efi +EDK2_BINS += RuntimeDxe/RuntimeDxe/DEBUG/RuntimeDxe.efi + +EDK2_OUTPUTS = $(addprefix $(EDK2_OUTPUT_DIR)/,$(EDK2_BINS)) + +# build takes too long, so we check to see if our executables exist +# before we start a build. run the clean target if they must be rebuilt +all: $(EDK2_OUTPUTS) + ls -Fla $(EDK2_OUTPUTS) + cp -a $(EDK2_OUTPUTS) . + +$(EDK2_OUTPUTS): + build + +build: + build + +clean: + $(RM) $(EDK2_OUTPUTS) + +real-clean: clean + build clean