Be more conservative about setting hw.uart.console
Note when we've found a 8250 PNP node. Only try to set hw.uart.console if we see one (otherwise ignore serial hints). The 8250 is the only one known to have I/O ports, so limit the guessing to when we've positively seen one. And limit this to x86 since that's the only platform where we have I/O ports. Otherwise, we'd set the serial port to something crazy for the platform and fall off the cliff early in boot. Differential Revision: https://reviews.freebsd.org/D16463
This commit is contained in:
parent
858178a142
commit
e78f6dd79f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=336837
@ -82,10 +82,13 @@ bi_getboothowto(char *kargs)
|
|||||||
howto |= RB_SERIAL;
|
howto |= RB_SERIAL;
|
||||||
if (strcmp(console, "nullconsole") == 0)
|
if (strcmp(console, "nullconsole") == 0)
|
||||||
howto |= RB_MUTE;
|
howto |= RB_MUTE;
|
||||||
if (strcmp(console, "efi") == 0) {
|
#if defined(__i386__) || defined(__amd64__)
|
||||||
|
if (strcmp(console, "efi") == 0 &&
|
||||||
|
getenv("efi_8250_uid") != NULL &&
|
||||||
|
getenv("hw.uart.console") == NULL) {
|
||||||
/*
|
/*
|
||||||
* If we found a com port and com speed, we need to tell
|
* If we found a 8250 com port and com speed, we need to
|
||||||
* the kernel where the serial port is, and how
|
* tell the kernel where the serial port is, and how
|
||||||
* fast. Ideally, we'd get the port from ACPI, but that
|
* fast. Ideally, we'd get the port from ACPI, but that
|
||||||
* isn't running in the loader. Do the next best thing
|
* isn't running in the loader. Do the next best thing
|
||||||
* by allowing it to be set by a loader.conf variable,
|
* by allowing it to be set by a loader.conf variable,
|
||||||
@ -93,24 +96,31 @@ bi_getboothowto(char *kargs)
|
|||||||
* comconsole_port if not. PCI support is needed, but
|
* comconsole_port if not. PCI support is needed, but
|
||||||
* for that we'd ideally refactor the
|
* for that we'd ideally refactor the
|
||||||
* libi386/comconsole.c code to have identical behavior.
|
* libi386/comconsole.c code to have identical behavior.
|
||||||
|
* We only try to set the port for cases where we saw
|
||||||
|
* the Serial(x) node when parsing, otherwise
|
||||||
|
* specialized hardware that has Uart nodes will have a
|
||||||
|
* bogus address set.
|
||||||
|
* But if someone specifically setup hw.uart.console,
|
||||||
|
* don't override that.
|
||||||
*/
|
*/
|
||||||
|
speed = -1;
|
||||||
|
port = -1;
|
||||||
tmp = getenv("efi_com_speed");
|
tmp = getenv("efi_com_speed");
|
||||||
if (tmp != NULL) {
|
if (tmp != NULL)
|
||||||
speed = strtol(tmp, NULL, 0);
|
speed = strtol(tmp, NULL, 0);
|
||||||
tmp = getenv("efi_com_port");
|
tmp = getenv("efi_com_port");
|
||||||
if (tmp == NULL)
|
if (tmp == NULL)
|
||||||
tmp = getenv("comconsole_port");
|
tmp = getenv("comconsole_port");
|
||||||
/* XXX fallback to EFI variable set in rc.d? */
|
if (tmp != NULL)
|
||||||
if (tmp != NULL)
|
port = strtol(tmp, NULL, 0);
|
||||||
port = strtol(tmp, NULL, 0);
|
if (speed != -1 && port != -1) {
|
||||||
else
|
|
||||||
port = 0x3f8;
|
|
||||||
snprintf(buf, sizeof(buf), "io:%d,br:%d", port,
|
snprintf(buf, sizeof(buf), "io:%d,br:%d", port,
|
||||||
speed);
|
speed);
|
||||||
env_setenv("hw.uart.console", EV_VOLATILE, buf,
|
env_setenv("hw.uart.console", EV_VOLATILE, buf,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return (howto);
|
return (howto);
|
||||||
|
@ -644,6 +644,15 @@ parse_args(int argc, CHAR16 *argv[])
|
|||||||
return (howto);
|
return (howto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
setenv_int(const char *key, int val)
|
||||||
|
{
|
||||||
|
char buf[20];
|
||||||
|
|
||||||
|
snprintf(buf, sizeof(buf), "%d", val);
|
||||||
|
setenv(key, buf, 1);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse ConOut (the list of consoles active) and see if we can find a
|
* 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
|
* serial port and/or a video port. It would be nice to also walk the
|
||||||
@ -675,15 +684,15 @@ parse_uefi_con_out(void)
|
|||||||
DevicePathSubType(node) == ACPI_DP) {
|
DevicePathSubType(node) == ACPI_DP) {
|
||||||
/* Check for Serial node */
|
/* Check for Serial node */
|
||||||
acpi = (void *)node;
|
acpi = (void *)node;
|
||||||
if (EISA_ID_TO_NUM(acpi->HID) == 0x501)
|
if (EISA_ID_TO_NUM(acpi->HID) == 0x501) {
|
||||||
|
setenv_int("efi_8250_uid", acpi->UID);
|
||||||
com_seen = ++seen;
|
com_seen = ++seen;
|
||||||
|
}
|
||||||
} else if (DevicePathType(node) == MESSAGING_DEVICE_PATH &&
|
} else if (DevicePathType(node) == MESSAGING_DEVICE_PATH &&
|
||||||
DevicePathSubType(node) == MSG_UART_DP) {
|
DevicePathSubType(node) == MSG_UART_DP) {
|
||||||
char bd[16];
|
|
||||||
|
|
||||||
uart = (void *)node;
|
uart = (void *)node;
|
||||||
snprintf(bd, sizeof(bd), "%d", uart->BaudRate);
|
setenv_int("efi_com_speed", uart->BaudRate);
|
||||||
setenv("efi_com_speed", bd, 1);
|
|
||||||
} else if (DevicePathType(node) == ACPI_DEVICE_PATH &&
|
} else if (DevicePathType(node) == ACPI_DEVICE_PATH &&
|
||||||
DevicePathSubType(node) == ACPI_ADR_DP) {
|
DevicePathSubType(node) == ACPI_ADR_DP) {
|
||||||
/* Check for AcpiAdr() Node for video */
|
/* Check for AcpiAdr() Node for video */
|
||||||
|
Loading…
Reference in New Issue
Block a user