[haiku-commits] BRANCH jessicah-github.efi.master [70e433808f70] src/system/boot/platform/efi

  • From: jessicah-github.efi.master <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 13 Sep 2015 00:01:59 +0200 (CEST)

added 1 changeset to branch 'refs/remotes/jessicah-github/efi.master'
old head: e3db0d1c79831a32b117eac4a0952df4fcb9ca3d
new head: 70e433808f7082477fbe63212108460802f822cb
overview: https://github.com/jessicah/haiku/compare/e3db0d1c7983...70e433808f70

----------------------------------------------------------------------------

70e433808f70: UEFI: fix up debug, trace MMU post-UEFI code.

[ Jessica Hamilton <jessica.l.hamilton@xxxxxxxxx> ]

----------------------------------------------------------------------------

Commit: 70e433808f7082477fbe63212108460802f822cb
Author: Jessica Hamilton <jessica.l.hamilton@xxxxxxxxx>
Date: Sat Sep 12 10:04:25 2015 UTC

----------------------------------------------------------------------------

3 files changed, 28 insertions(+), 11 deletions(-)
src/system/boot/platform/efi/debug.cpp | 3 ---
src/system/boot/platform/efi/mmu.cpp | 25 ++++++++++++++++++++++---
src/system/boot/platform/efi/start.cpp | 11 ++++++-----

----------------------------------------------------------------------------

diff --git a/src/system/boot/platform/efi/debug.cpp
b/src/system/boot/platform/efi/debug.cpp
index 3b8ae99..23ae269 100644
--- a/src/system/boot/platform/efi/debug.cpp
+++ b/src/system/boot/platform/efi/debug.cpp
@@ -74,9 +74,6 @@ dprintf_args(const char *format, va_list args)

syslog_write(buffer, length);
serial_puts(buffer, length);
-
- if (platform_boot_options() & BOOT_OPTION_DEBUG_OUTPUT)
- puts(buffer);
}


diff --git a/src/system/boot/platform/efi/mmu.cpp
b/src/system/boot/platform/efi/mmu.cpp
index 7548f4e..b658279 100644
--- a/src/system/boot/platform/efi/mmu.cpp
+++ b/src/system/boot/platform/efi/mmu.cpp
@@ -139,10 +139,13 @@ void
mmu_post_efi_setup(UINTN memory_map_size, EFI_MEMORY_DESCRIPTOR *memory_map,
UINTN descriptor_size, UINTN descriptor_version)
{
// Add physical memory to the kernel args and update virtual addresses
for EFI regions..
+ dprintf("entering mmu_post_efi_setup...\n");
addr_t addr = (addr_t)memory_map;
gKernelArgs.num_physical_memory_ranges = 0;
+ dprintf("%ld memory map entries\n", memory_map_size / descriptor_size);
for (UINTN i = 0; i < memory_map_size / descriptor_size; ++i) {
EFI_MEMORY_DESCRIPTOR *entry = (EFI_MEMORY_DESCRIPTOR *)(addr +
i * descriptor_size);
+ dprintf("\nmemory map entry %ld:", i);
switch (entry->Type) {
case EfiLoaderCode:
case EfiLoaderData:
@@ -157,27 +160,40 @@ mmu_post_efi_setup(UINTN memory_map_size,
EFI_MEMORY_DESCRIPTOR *memory_map, UIN
base = 0x100000;
if (end > (512ull * 1024 * 1024 * 1024))
end = 512ull * 1024 * 1024 * 1024;
- if (base >= end)
+ if (base >= end) {
+ dprintf(" [skipped]");
break;
+ }
uint64_t size = end - base;

insert_physical_memory_range(base, size);
+ dprintf(" [physical]");
// LoaderData memory is bootloader allocated memory,
possibly
// containing the kernel or loaded drivers.
- if (entry->Type == EfiLoaderData)
+ if (entry->Type == EfiLoaderData) {
insert_physical_allocated_range(base, size);
+ dprintf(" [allocated]");
+ }
break;
}
case EfiACPIReclaimMemory:
// ACPI reclaim -- physical memory we could actually
use later
gKernelArgs.ignored_physical_memory +=
entry->NumberOfPages * 4096;
+ dprintf(" [acpi (ignored)]");
break;
case EfiRuntimeServicesCode:
case EfiRuntimeServicesData:
+ case EfiACPIMemoryNVS:
+ case EfiPalCode:
entry->VirtualStart = entry->PhysicalStart +
0xFFFFFF0000000000ull;
+ dprintf(" [runtime remapped]");
+ break;
+ default:
+ dprintf(" >>> unknown entry type (%x) <<< ",
entry->Type);
break;
}
}
+ dprintf("\nmemory ranges setup done\n");

// Sort the address ranges.
sort_address_ranges(gKernelArgs.physical_memory_range,
@@ -186,11 +202,14 @@ mmu_post_efi_setup(UINTN memory_map_size,
EFI_MEMORY_DESCRIPTOR *memory_map, UIN
gKernelArgs.num_physical_allocated_ranges);
sort_address_ranges(gKernelArgs.virtual_allocated_range,
gKernelArgs.num_virtual_allocated_ranges);
+ dprintf("sorted the address ranges...\n");

// Switch EFI to virtual mode, using the kernel pmap.
// Something involving ConvertPointer might need to be done after this?
//
http://wiki.phoenix.com/wiki/index.php/EFI_RUNTIME_SERVICES#SetVirtualAddressMap.28.29
- kRuntimeServices->SetVirtualAddressMap(memory_map_size,
descriptor_size, descriptor_version, memory_map);
+ dprintf("setting up the virtual address map...\n");
+ EFI_STATUS status =
kRuntimeServices->SetVirtualAddressMap(memory_map_size, descriptor_size,
descriptor_version, memory_map);
+ dprintf("status = %lx\n", status);
}

// As far as I know, EFI uses identity mapped memory, and we already have
paging enabled
diff --git a/src/system/boot/platform/efi/start.cpp
b/src/system/boot/platform/efi/start.cpp
index 58e049d..cc78c03 100644
--- a/src/system/boot/platform/efi/start.cpp
+++ b/src/system/boot/platform/efi/start.cpp
@@ -250,7 +250,6 @@ platform_start_kernel(void)
// A changing memory map shouldn't affect the generated page tables, as
// they only needed to know about the maximum address, not any specific
entry.
dprintf("Calling ExitBootServices. So long, EFI!\n");
-puts("Calling ExitBootServices");
while (1) {
if (kBootServices->ExitBootServices(kImage, map_key) ==
EFI_SUCCESS) {
break;
@@ -269,15 +268,17 @@ puts("Calling ExitBootServices");

// Switch to BIOS serial output
serial_switch_to_bios();
- dprintf("can we still serial debug?\n");
+ dprintf("welcome to legacy serial debugging! :p\n");

// Update EFI, generate final kernel physical memory map, etc.
+ dprintf("mmu_post_efi_setup...\n");
mmu_post_efi_setup(memory_map_size, memory_map, descriptor_size,
descriptor_version);

-puts("smp_boot_other cpus");
+ dprintf("smp_boot_other_cpus...\n");
smp_boot_other_cpus(final_pml4, (uint32_t)(uint64_t)&gLongGDTR,
gLongKernelEntry);
-puts("efi_enter_kernel");
+
// Enter the kernel!
+ dprintf("efi_enter_kernel...\n");
efi_enter_kernel(final_pml4,
gLongKernelEntry,
gKernelArgs.cpu_kstack[0].start +
gKernelArgs.cpu_kstack[0].size);
@@ -331,7 +332,7 @@ efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *systemTable)
serial_enable();
// interrupts_init();
console_init();
- sBootOptions |= BOOT_OPTION_DEBUG_OUTPUT;
+ //sBootOptions |= BOOT_OPTION_DEBUG_OUTPUT;
cpu_init();
// mmu_init();
debug_init_post_mmu();


Other related posts:

  • » [haiku-commits] BRANCH jessicah-github.efi.master [70e433808f70] src/system/boot/platform/efi - jessicah-github . efi . master