Created
May 27, 2021 06:44
-
-
Save doug65536/da96a0e47b3b9d95eddd6969288b6b37 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool serial_logger_efi_t::init(int port) | |
{ | |
EFI_STATUS status; | |
UINTN serial_port_count = 0; | |
EFI_HANDLE *serial_ports = nullptr; | |
status = efi_systab->BootServices->LocateHandleBuffer( | |
ByProtocol, | |
&efi_serial_io_guid, | |
nullptr, | |
&serial_port_count, | |
&serial_ports); | |
if (EFI_ERROR(status)) { | |
DEBUG(TSTR "LocateHandleBuffer SERIAL_IO_PROTOCOL failed"); | |
return false; | |
} | |
EFI_SERIAL_IO_PROTOCOL *serial_handles[16]; | |
for (size_t i = 0; i < serial_port_count && i < 16; ++i) { | |
status = efi_systab->BootServices->HandleProtocol( | |
serial_ports[i], | |
&efi_serial_io_guid, | |
(VOID**)&serial_handles[i]); | |
if (!EFI_ERROR(status)) { | |
char message[] = "Hello"; | |
UINTN message_len = sizeof(message) - 1; | |
status = serial_handles[i]->Write(serial_handles[i], | |
&message_len, message); | |
if (EFI_ERROR(status)) { | |
// To see in debugger | |
volatile int it_failed _unused = 1; | |
} | |
} else { | |
DEBUG(TSTR "HandleProtocol SERIAL_IO_PROTOCOL failed"); | |
} | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment