Write HELLO memory map debug data to serial port

This commit is contained in:
Josh Holtrop 2023-09-04 20:59:38 -04:00
parent 0781962e9f
commit 4500f3cbca
2 changed files with 13 additions and 1 deletions

View File

@ -162,7 +162,10 @@ hello_env = env "hello", use: %w[ldc2 x86_64-w64-mingw32-gcc] do |env|
env.add_builder(CheckThreadLocal) env.add_builder(CheckThreadLocal)
env.add_builder(HulkBinObj) env.add_builder(HulkBinObj)
env["sources"] = glob("src/hello/**/*.d") env["sources"] = glob("src/hello/**/*.d")
env["sources"] += ["src/hulk/writef.d"] env["sources"] += %w[
src/hulk/serial.d
src/hulk/writef.d
]
env["sources"] += glob("uefi-d/source/**/*.d") env["sources"] += glob("uefi-d/source/**/*.d")
env.HulkBinObj("^/hulk_bin.S", hulk_env.expand("^/hulk.bin")) env.HulkBinObj("^/hulk_bin.S", hulk_env.expand("^/hulk.bin"))
env.Object("^/hulk_bin.o", "^/hulk_bin.S") env.Object("^/hulk_bin.o", "^/hulk_bin.S")

View File

@ -11,6 +11,7 @@ import hulk.pagetable;
import hulk.cpu; import hulk.cpu;
import hulk.memory; import hulk.memory;
import ldc.llvmasm; import ldc.llvmasm;
import hulk.serial;
__gshared EFI_SYSTEM_TABLE * st; __gshared EFI_SYSTEM_TABLE * st;
/** HULK binary start address, 4KB-aligned. */ /** HULK binary start address, 4KB-aligned. */
@ -205,6 +206,7 @@ private void get_memory_map(ulong * physical_address_limit, UINTN * memory_map_k
} }
if (descriptor.Type >= efi_to_hulk_memory_map_type.length) if (descriptor.Type >= efi_to_hulk_memory_map_type.length)
{ {
Serial.writefln("Unexpected descriptor type %u", descriptor.Type);
continue; continue;
} }
bootinfo().memory_map[count].base = descriptor.PhysicalStart; bootinfo().memory_map[count].base = descriptor.PhysicalStart;
@ -217,6 +219,7 @@ private void get_memory_map(ulong * physical_address_limit, UINTN * memory_map_k
bootinfo().bss_phys = bootinfo().memory_map[count].base; bootinfo().bss_phys = bootinfo().memory_map[count].base;
bootinfo().memory_map[count].base += hulk_bss_size(); bootinfo().memory_map[count].base += hulk_bss_size();
bootinfo().memory_map[count].size -= hulk_bss_size(); bootinfo().memory_map[count].size -= hulk_bss_size();
Serial.writefln("Locating HULK BSS at %x", bootinfo().bss_phys);
found_bss = true; found_bss = true;
} }
if ((!found_stack) && if ((!found_stack) &&
@ -226,6 +229,7 @@ private void get_memory_map(ulong * physical_address_limit, UINTN * memory_map_k
bootinfo().stack_phys = bootinfo().memory_map[count].base; bootinfo().stack_phys = bootinfo().memory_map[count].base;
bootinfo().memory_map[count].base += hulk_stack_size(); bootinfo().memory_map[count].base += hulk_stack_size();
bootinfo().memory_map[count].size -= hulk_stack_size(); bootinfo().memory_map[count].size -= hulk_stack_size();
Serial.writefln("Locating HULK stack at %x", bootinfo().stack_phys);
found_stack = true; found_stack = true;
} }
if ((!found_fb_buffer1) && if ((!found_fb_buffer1) &&
@ -235,8 +239,13 @@ private void get_memory_map(ulong * physical_address_limit, UINTN * memory_map_k
bootinfo().fb_buffer1_phys = bootinfo().memory_map[count].base; bootinfo().fb_buffer1_phys = bootinfo().memory_map[count].base;
bootinfo().memory_map[count].base += fb_size; bootinfo().memory_map[count].base += fb_size;
bootinfo().memory_map[count].size -= fb_size; bootinfo().memory_map[count].size -= fb_size;
Serial.writefln("Locating HULK FB1 at %x", bootinfo().fb_buffer1_phys);
found_fb_buffer1 = true; found_fb_buffer1 = true;
} }
Serial.writefln("Memory range %x:%x (%u)",
bootinfo().memory_map[count].base,
bootinfo().memory_map[count].base + bootinfo().memory_map[count].size - 1u,
bootinfo().memory_map[count].type);
} }
bootinfo().memory_map_count = count; bootinfo().memory_map_count = count;
if ((!found_bss) || (!found_stack) || (!found_fb_buffer1)) if ((!found_bss) || (!found_stack) || (!found_fb_buffer1))