Clean up lots of debug output I no longer use.

This commit is contained in:
Justin C. Miller
2018-04-01 15:41:32 -07:00
parent 967018c3ac
commit 913fb202eb
3 changed files with 28 additions and 89 deletions

View File

@@ -68,14 +68,6 @@ con_initialize(EFI_SYSTEM_TABLE *system_table, const CHAR16 *version)
con_out->SetAttribute(con_out, EFI_LIGHTGRAY); con_out->SetAttribute(con_out, EFI_LIGHTGRAY);
con_out->OutputString(con_out, (CHAR16 *)L" booting...\r\n\n"); 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; return status;
} }
@@ -230,34 +222,26 @@ con_status_begin(const CHAR16 *message)
void void
con_status_ok() 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->SetAttribute(con_out, EFI_LIGHTGRAY);
con_out->OutputString(con_out, (CHAR16 *)L"["); con_out->OutputString(con_out, (CHAR16 *)L"[");
con_out->SetAttribute(con_out, EFI_GREEN); con_out->SetAttribute(con_out, EFI_GREEN);
con_out->OutputString(con_out, (CHAR16 *)L" ok "); con_out->OutputString(con_out, (CHAR16 *)L" ok ");
con_out->SetAttribute(con_out, EFI_LIGHTGRAY); 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, 0, ++row + 1);
} }
void void
con_status_fail(const CHAR16 *error) 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->SetAttribute(con_out, EFI_LIGHTGRAY);
con_out->OutputString(con_out, (CHAR16 *)L"["); con_out->OutputString(con_out, (CHAR16 *)L"[");
con_out->SetAttribute(con_out, EFI_LIGHTRED); con_out->SetAttribute(con_out, EFI_LIGHTRED);
con_out->OutputString(con_out, (CHAR16 *)L"failed"); con_out->OutputString(con_out, (CHAR16 *)L"failed");
con_out->SetAttribute(con_out, EFI_LIGHTGRAY); 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->SetAttribute(con_out, EFI_RED);
con_out->OutputString(con_out, (CHAR16 *)error); con_out->OutputString(con_out, (CHAR16 *)error);
con_out->SetCursorPosition(con_out, 0, row + 2);
con_out->SetAttribute(con_out, EFI_LIGHTGRAY); con_out->SetAttribute(con_out, EFI_LIGHTGRAY);
con_out->OutputString(con_out, (CHAR16 *)L"\r\n");
} }

View File

@@ -65,7 +65,6 @@ loader_load_kernel(
bootsvc->AllocatePages(AllocateAnyPages, mem_type, page_count, &addr); bootsvc->AllocatePages(AllocateAnyPages, mem_type, page_count, &addr);
} }
CHECK_EFI_STATUS_OR_RETURN(status, "Allocating kernel pages"); 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; buffer = (void *)addr;
status = file->Read(file, &buffer_size, buffer); status = file->Read(file, &buffer_size, buffer);
@@ -87,7 +86,6 @@ loader_load_kernel(
bootsvc->AllocatePages(AllocateAnyPages, mem_type, page_count, &addr); bootsvc->AllocatePages(AllocateAnyPages, mem_type, page_count, &addr);
} }
CHECK_EFI_STATUS_OR_RETURN(status, "Allocating kernel data pages"); 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; *data_length = page_count * 0x1000;
*kernel_data = (void *)addr; *kernel_data = (void *)addr;

View File

@@ -61,52 +61,28 @@ efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table)
EFI_STATUS status; EFI_STATUS status;
EFI_BOOT_SERVICES *bootsvc = system_table->BootServices; EFI_BOOT_SERVICES *bootsvc = system_table->BootServices;
// When checking the console initialization error, use // When checking console initialization, use CHECK_EFI_STATUS_OR_RETURN
// CHECK_EFI_STATUS_OR_RETURN because we can't be sure // because we can't be sure if the console was fully set up
// if the console was fully set up
status = con_initialize(system_table, GIT_VERSION); status = con_initialize(system_table, GIT_VERSION);
CHECK_EFI_STATUS_OR_RETURN(status, "con_initialize"); CHECK_EFI_STATUS_OR_RETURN(status, "con_initialize");
// From here on out, we can use CHECK_EFI_STATUS_OR_FAIL instead
// From here on out, use CHECK_EFI_STATUS_OR_FAIL instead
// because the console is now set up
EFI_GUID acpi1_guid = ACPI_TABLE_GUID; EFI_GUID acpi1_guid = ACPI_TABLE_GUID;
EFI_GUID acpi2_guid = {0x8868e871,0xe4f1,0x11d3,{0xbc,0x22,0x00,0x80,0xc7,0x3c,0x88,0x81}}; 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) { for (size_t i=0; i<system_table->NumberOfTableEntries; ++i) {
EFI_CONFIGURATION_TABLE *efi_table = &system_table->ConfigurationTable[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"); // Compute necessary number of data pages
} //
con_status_ok(); size_t data_length = 0;
con_status_begin(L"Computing needed data pages...");
UINTN data_length = 0;
status = memory_get_map_length(bootsvc, &data_length); status = memory_get_map_length(bootsvc, &data_length);
CHECK_EFI_STATUS_OR_FAIL(status);
size_t header_size = sizeof(struct popcorn_data); size_t header_size = sizeof(struct popcorn_data);
const size_t header_align = alignof(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); header_size += header_align - (header_size % header_align);
data_length += header_size; data_length += header_size;
con_status_ok();
con_status_begin(L"Looking for devices...\n"); // Load the kernel image from disk and check it
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...");
void *kernel_image = NULL, *kernel_data = NULL; void *kernel_image = NULL, *kernel_data = NULL;
uint64_t kernel_length = 0; 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); status = loader_load_kernel(bootsvc, &kernel_image, &kernel_length, &kernel_data, &data_length);
CHECK_EFI_STATUS_OR_FAIL(status); 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; struct kernel_header *version = (struct kernel_header *)kernel_image;
if (version->magic != KERNEL_HEADER_MAGIC) { 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); 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 ? "*" : ""); 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; 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; struct popcorn_data *data_header = (struct popcorn_data *)kernel_data;
data_header->magic = DATA_HEADER_MAGIC; data_header->magic = DATA_HEADER_MAGIC;
data_header->version = DATA_HEADER_VERSION; 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->memory_map = (EFI_MEMORY_DESCRIPTOR *)(data_header + 1);
data_header->runtime = system_table->RuntimeServices; 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; struct memory_map map;
map.entries = data_header->memory_map; map.entries = data_header->memory_map;
map.length = (data_length - header_size); 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); status = bootsvc->ExitBootServices(image_handle, map.key);
CHECK_EFI_STATUS_OR_ASSERT(status, 0); CHECK_EFI_STATUS_OR_ASSERT(status, 0);
// Hand control to the kernel
//
kernel_main(data_header); kernel_main(data_header);
return EFI_LOAD_ERROR; return EFI_LOAD_ERROR;
} }