diff --git a/stand/efi/loader/bootinfo.c b/stand/efi/loader/bootinfo.c index 5afb4c78353..33674f1ccc1 100644 --- a/stand/efi/loader/bootinfo.c +++ b/stand/efi/loader/bootinfo.c @@ -134,6 +134,14 @@ bi_getboothowto(char *kargs) NULL, NULL); } } + if (getenv("efi_com_mmio") != NULL && + getenv("efi_com_speed") != NULL && /* verifies uart mode */ + getenv("hw.uart.console") == NULL) { + snprintf(buf, sizeof(buf), "mm:%s,rs:2", + getenv("efi_com_mmio")); + env_setenv("hw.uart.console", EV_VOLATILE, buf, NULL, + NULL); + } #endif #endif } diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c index ccde939581f..0c6e5de4a03 100644 --- a/stand/efi/loader/main.c +++ b/stand/efi/loader/main.c @@ -723,6 +723,15 @@ setenv_int(const char *key, int val) setenv(key, buf, 1); } +static void +setenv_addr(const char *key, uint64_t addr) +{ + char buf[30]; + + snprintf(buf, sizeof(buf), "0x%llx", addr); + setenv(key, buf, 1); +} + /* * Parse ConOut (the list of consoles active) and see if we can find a * serial port and/or a video port. It would be nice to also walk the @@ -742,6 +751,7 @@ parse_uefi_con_out(void) EFI_DEVICE_PATH *node; ACPI_HID_DEVICE_PATH *acpi; UART_DEVICE_PATH *uart; + VENDOR_DEVICE_PATH *hw; bool pci_pending; how = 0; @@ -805,6 +815,14 @@ parse_uefi_con_out(void) * so only match it if it's last. */ pci_pending = true; + } else if (DevicePathType(node) == HARDWARE_DEVICE_PATH && + DevicePathSubType(node) == HW_VENDOR_DP) { + hw = (void *)node; + + if (DevicePathNodeLength(&hw->Header) == + sizeof(*hw) + sizeof(uint64_t)) { + setenv_addr("efi_com_mmio", *(uint64_t *)(hw + 1)); + } } node = NextDevicePathNode(node); }