mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
Clean up lots of debug output I no longer use.
This commit is contained in:
@@ -68,14 +68,6 @@ con_initialize(EFI_SYSTEM_TABLE *system_table, const CHAR16 *version)
|
||||
con_out->SetAttribute(con_out, EFI_LIGHTGRAY);
|
||||
con_out->OutputString(con_out, (CHAR16 *)L" booting...\r\n\n");
|
||||
|
||||
con_status_begin(L"Setting console display mode: ");
|
||||
con_printf(L"\n %ux%u (%ux%u chars)",
|
||||
gfx_out_proto->Mode->Info->HorizontalResolution,
|
||||
gfx_out_proto->Mode->Info->VerticalResolution,
|
||||
ROWS, COLS);
|
||||
|
||||
con_status_ok();
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -230,34 +222,26 @@ con_status_begin(const CHAR16 *message)
|
||||
void
|
||||
con_status_ok()
|
||||
{
|
||||
UINTN row = con_out->Mode->CursorRow;
|
||||
con_out->SetCursorPosition(con_out, 4, ++row);
|
||||
con_out->SetAttribute(con_out, EFI_LIGHTGRAY);
|
||||
con_out->OutputString(con_out, (CHAR16 *)L"[");
|
||||
con_out->SetAttribute(con_out, EFI_GREEN);
|
||||
con_out->OutputString(con_out, (CHAR16 *)L" ok ");
|
||||
con_out->SetAttribute(con_out, EFI_LIGHTGRAY);
|
||||
con_out->OutputString(con_out, (CHAR16 *)L"]\r");
|
||||
|
||||
con_out->SetCursorPosition(con_out, 0, ++row + 1);
|
||||
con_out->OutputString(con_out, (CHAR16 *)L"]\r\n");
|
||||
}
|
||||
|
||||
void
|
||||
con_status_fail(const CHAR16 *error)
|
||||
{
|
||||
UINTN row = con_out->Mode->CursorRow;
|
||||
con_out->SetCursorPosition(con_out, COLS - 8, row);
|
||||
con_out->SetAttribute(con_out, EFI_LIGHTGRAY);
|
||||
con_out->OutputString(con_out, (CHAR16 *)L"[");
|
||||
con_out->SetAttribute(con_out, EFI_LIGHTRED);
|
||||
con_out->OutputString(con_out, (CHAR16 *)L"failed");
|
||||
con_out->SetAttribute(con_out, EFI_LIGHTGRAY);
|
||||
con_out->OutputString(con_out, (CHAR16 *)L"]\r");
|
||||
con_out->OutputString(con_out, (CHAR16 *)L"]\r\n");
|
||||
|
||||
con_out->SetCursorPosition(con_out, 2, row + 1);
|
||||
con_out->SetAttribute(con_out, EFI_RED);
|
||||
con_out->OutputString(con_out, (CHAR16 *)error);
|
||||
|
||||
con_out->SetCursorPosition(con_out, 0, row + 2);
|
||||
con_out->SetAttribute(con_out, EFI_LIGHTGRAY);
|
||||
con_out->OutputString(con_out, (CHAR16 *)L"\r\n");
|
||||
}
|
||||
|
||||
@@ -65,7 +65,6 @@ loader_load_kernel(
|
||||
bootsvc->AllocatePages(AllocateAnyPages, mem_type, page_count, &addr);
|
||||
}
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, "Allocating kernel pages");
|
||||
con_printf(L"\n Allocating %u pages at 0x%x", page_count, addr);
|
||||
|
||||
buffer = (void *)addr;
|
||||
status = file->Read(file, &buffer_size, buffer);
|
||||
@@ -87,7 +86,6 @@ loader_load_kernel(
|
||||
bootsvc->AllocatePages(AllocateAnyPages, mem_type, page_count, &addr);
|
||||
}
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, "Allocating kernel data pages");
|
||||
con_printf(L"\n Allocating %u pages at 0x%x", page_count, addr);
|
||||
|
||||
*data_length = page_count * 0x1000;
|
||||
*kernel_data = (void *)addr;
|
||||
|
||||
@@ -61,52 +61,28 @@ efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table)
|
||||
EFI_STATUS status;
|
||||
EFI_BOOT_SERVICES *bootsvc = system_table->BootServices;
|
||||
|
||||
// When checking the console initialization error, use
|
||||
// CHECK_EFI_STATUS_OR_RETURN because we can't be sure
|
||||
// if the console was fully set up
|
||||
// When checking console initialization, use CHECK_EFI_STATUS_OR_RETURN
|
||||
// because we can't be sure if the console was fully set up
|
||||
status = con_initialize(system_table, GIT_VERSION);
|
||||
CHECK_EFI_STATUS_OR_RETURN(status, "con_initialize");
|
||||
|
||||
// From here on out, use CHECK_EFI_STATUS_OR_FAIL instead
|
||||
// because the console is now set up
|
||||
// From here on out, we can use CHECK_EFI_STATUS_OR_FAIL instead
|
||||
|
||||
EFI_GUID acpi1_guid = ACPI_TABLE_GUID;
|
||||
EFI_GUID acpi2_guid = {0x8868e871,0xe4f1,0x11d3,{0xbc,0x22,0x00,0x80,0xc7,0x3c,0x88,0x81}};
|
||||
|
||||
con_status_begin(L"Reading configuration tables...");
|
||||
con_printf(L" %d found.\n", system_table->NumberOfTableEntries);
|
||||
|
||||
// Find ACPI tables. Ignore ACPI 1.0 if a 2.0 table is found.
|
||||
//
|
||||
for (size_t i=0; i<system_table->NumberOfTableEntries; ++i) {
|
||||
EFI_CONFIGURATION_TABLE *efi_table = &system_table->ConfigurationTable[i];
|
||||
|
||||
con_printf(L" %d. ", i);
|
||||
|
||||
if (is_guid(&efi_table->VendorGuid, &acpi2_guid)) {
|
||||
char *table = efi_table->VendorTable;
|
||||
con_printf(L" ACPI 2.0 Table.");
|
||||
} else if (is_guid(&efi_table->VendorGuid, &acpi1_guid)) {
|
||||
char *table = efi_table->VendorTable;
|
||||
con_printf(L" ACPI 1.0 Table.");
|
||||
/*
|
||||
} else if (is_guid(&efi_table->VendorGuid, &MpsTableGuid)) {
|
||||
con_printf(L" MPS.");
|
||||
} else if (is_guid(&efi_table->VendorGuid, &SMBIOSTableGuid)) {
|
||||
con_printf(L" SMBIOS.");
|
||||
} else if (is_guid(&efi_table->VendorGuid, &SalSystemTableGuid)) {
|
||||
con_printf(L" SAL.");
|
||||
*/
|
||||
} else {
|
||||
con_printf(L" Other.");
|
||||
}
|
||||
}
|
||||
|
||||
con_printf(L"\n");
|
||||
}
|
||||
con_status_ok();
|
||||
|
||||
|
||||
con_status_begin(L"Computing needed data pages...");
|
||||
UINTN data_length = 0;
|
||||
// Compute necessary number of data pages
|
||||
//
|
||||
size_t data_length = 0;
|
||||
status = memory_get_map_length(bootsvc, &data_length);
|
||||
CHECK_EFI_STATUS_OR_FAIL(status);
|
||||
|
||||
size_t header_size = sizeof(struct popcorn_data);
|
||||
const size_t header_align = alignof(struct popcorn_data);
|
||||
@@ -114,54 +90,33 @@ efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table)
|
||||
header_size += header_align - (header_size % header_align);
|
||||
|
||||
data_length += header_size;
|
||||
con_status_ok();
|
||||
|
||||
con_status_begin(L"Looking for devices...\n");
|
||||
EFI_GUID serial_guid = EFI_SERIAL_IO_PROTOCOL_GUID;
|
||||
size_t num_serial = 0;
|
||||
EFI_HANDLE *serial_handles;
|
||||
status = bootsvc->LocateHandleBuffer(ByProtocol, &serial_guid, NULL, &num_serial, &serial_handles);
|
||||
CHECK_EFI_STATUS_OR_FAIL(status);
|
||||
con_printf(L" %d found.\n", num_serial);
|
||||
|
||||
EFI_GUID ptt_guid = EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID;
|
||||
EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *ptt = NULL;
|
||||
status = bootsvc->LocateProtocol(&ptt_guid, NULL, (void **)&ptt);
|
||||
CHECK_EFI_STATUS_OR_FAIL(status);
|
||||
|
||||
EFI_GUID path_guid = EFI_DEVICE_PATH_PROTOCOL_GUID;
|
||||
for (size_t i=0; i<num_serial; ++i) {
|
||||
EFI_HANDLE handle = serial_handles[i];
|
||||
EFI_DEVICE_PATH_PROTOCOL *path;
|
||||
status = bootsvc->HandleProtocol(handle, &path_guid, (void **)&path);
|
||||
CHECK_EFI_STATUS_OR_FAIL(status);
|
||||
con_printf(L" %s\n", ptt->ConvertDevicePathToText(path, 1, 0));
|
||||
}
|
||||
|
||||
con_status_ok();
|
||||
|
||||
con_status_begin(L"Loading kernel into memory...");
|
||||
// Load the kernel image from disk and check it
|
||||
//
|
||||
void *kernel_image = NULL, *kernel_data = NULL;
|
||||
uint64_t kernel_length = 0;
|
||||
con_printf(L"Loading kernel into memory...\r\n");
|
||||
|
||||
status = loader_load_kernel(bootsvc, &kernel_image, &kernel_length, &kernel_data, &data_length);
|
||||
CHECK_EFI_STATUS_OR_FAIL(status);
|
||||
con_printf(L"\n %u bytes at 0x%x", kernel_length, kernel_image);
|
||||
con_printf(L"\n %u data bytes at 0x%x", data_length, kernel_data);
|
||||
|
||||
con_printf(L" %u bytes at 0x%x\r\n", kernel_length, kernel_image);
|
||||
con_printf(L" %u data bytes at 0x%x\r\n", data_length, kernel_data);
|
||||
|
||||
struct kernel_header *version = (struct kernel_header *)kernel_image;
|
||||
if (version->magic != KERNEL_HEADER_MAGIC) {
|
||||
con_printf(L"\n bad magic %x", version->magic);
|
||||
con_printf(L" bad magic %x\r\n", version->magic);
|
||||
CHECK_EFI_STATUS_OR_FAIL(EFI_CRC_ERROR);
|
||||
}
|
||||
|
||||
con_printf(L"\n Kernel version %d.%d.%d %x%s", version->major, version->minor, version->patch,
|
||||
con_printf(L" Kernel version %d.%d.%d %x%s\r\n", version->major, version->minor, version->patch,
|
||||
version->gitsha & 0x0fffffff, version->gitsha & 0xf0000000 ? "*" : "");
|
||||
con_printf(L"\n Entrypoint 0x%x", version->entrypoint);
|
||||
con_printf(L" Entrypoint 0x%x\r\n", version->entrypoint);
|
||||
|
||||
void (*kernel_main)() = version->entrypoint;
|
||||
|
||||
con_status_ok();
|
||||
|
||||
// Set up the kernel data pages to pass to the kernel
|
||||
//
|
||||
struct popcorn_data *data_header = (struct popcorn_data *)kernel_data;
|
||||
data_header->magic = DATA_HEADER_MAGIC;
|
||||
data_header->version = DATA_HEADER_VERSION;
|
||||
@@ -172,8 +127,8 @@ efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table)
|
||||
data_header->memory_map = (EFI_MEMORY_DESCRIPTOR *)(data_header + 1);
|
||||
data_header->runtime = system_table->RuntimeServices;
|
||||
|
||||
con_status_begin(L"Exiting boot services...");
|
||||
|
||||
// Save the memory map and tell the firmware we're taking control.
|
||||
//
|
||||
struct memory_map map;
|
||||
map.entries = data_header->memory_map;
|
||||
map.length = (data_length - header_size);
|
||||
@@ -184,6 +139,8 @@ efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table)
|
||||
status = bootsvc->ExitBootServices(image_handle, map.key);
|
||||
CHECK_EFI_STATUS_OR_ASSERT(status, 0);
|
||||
|
||||
// Hand control to the kernel
|
||||
//
|
||||
kernel_main(data_header);
|
||||
return EFI_LOAD_ERROR;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user