stand: eficom: Only set baudrate when it changes
Only set the baudrate when it is different than what the device has reported. In addition, pass in the args to effect no change to the other parameters to the serial port. Some EFI firmware gets cranky when you set them to the same value, so avoid doing so (we likely can remove the HyperV workaround with this fix, but I kept it in place). Add comments to the code for why we do this too. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D40010
This commit is contained in:
parent
cb2da74905
commit
8c3d6917c1
@ -41,6 +41,7 @@ static EFI_GUID serial = SERIAL_IO_PROTOCOL;
|
|||||||
#define PNP0501 0x501 /* 16550A-compatible COM port */
|
#define PNP0501 0x501 /* 16550A-compatible COM port */
|
||||||
|
|
||||||
struct serial {
|
struct serial {
|
||||||
|
uint64_t newbaudrate;
|
||||||
uint64_t baudrate;
|
uint64_t baudrate;
|
||||||
uint32_t timeout;
|
uint32_t timeout;
|
||||||
uint32_t receivefifodepth;
|
uint32_t receivefifodepth;
|
||||||
@ -300,6 +301,7 @@ comc_probe(struct console *sc)
|
|||||||
if (EFI_ERROR(status)) {
|
if (EFI_ERROR(status)) {
|
||||||
comc_port->sio = NULL;
|
comc_port->sio = NULL;
|
||||||
} else {
|
} else {
|
||||||
|
comc_port->newbaudrate =
|
||||||
comc_port->baudrate = comc_port->sio->Mode->BaudRate;
|
comc_port->baudrate = comc_port->sio->Mode->BaudRate;
|
||||||
comc_port->timeout = comc_port->sio->Mode->Timeout;
|
comc_port->timeout = comc_port->sio->Mode->Timeout;
|
||||||
comc_port->receivefifodepth =
|
comc_port->receivefifodepth =
|
||||||
@ -322,7 +324,7 @@ comc_probe(struct console *sc)
|
|||||||
env = getenv("comconsole_speed");
|
env = getenv("comconsole_speed");
|
||||||
|
|
||||||
if (comc_parse_intval(env, &val) == CMD_OK)
|
if (comc_parse_intval(env, &val) == CMD_OK)
|
||||||
comc_port->baudrate = val;
|
comc_port->newbaudrate = val;
|
||||||
|
|
||||||
if (env != NULL)
|
if (env != NULL)
|
||||||
unsetenv("efi_com_speed");
|
unsetenv("efi_com_speed");
|
||||||
@ -497,9 +499,8 @@ comc_speed_set(struct env_var *ev, int flags, const void *value)
|
|||||||
if (comc_parse_intval(value, &speed) != CMD_OK)
|
if (comc_parse_intval(value, &speed) != CMD_OK)
|
||||||
return (CMD_ERROR);
|
return (CMD_ERROR);
|
||||||
|
|
||||||
comc_port->baudrate = speed;
|
comc_port->newbaudrate = speed;
|
||||||
(void) comc_setup();
|
if (comc_setup())
|
||||||
|
|
||||||
env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL);
|
env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL);
|
||||||
|
|
||||||
return (CMD_OK);
|
return (CMD_OK);
|
||||||
@ -525,20 +526,24 @@ comc_setup(void)
|
|||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (comc_port->sio->SetAttributes != NULL) {
|
/*
|
||||||
|
* Avoid setting the baud rate on Hyper-V. Also, only set the baud rate
|
||||||
|
* if the baud rate has changed from the default. And pass in '0' or
|
||||||
|
* DefaultFoo when we're not changing those values. Some EFI
|
||||||
|
* implementations get cranky when you set things to the values reported
|
||||||
|
* back even when they are unchanged.
|
||||||
|
*/
|
||||||
|
if (comc_port->sio->SetAttributes != NULL &&
|
||||||
|
comc_port->newbaudrate != comc_port->baudrate) {
|
||||||
ev = getenv("smbios.bios.version");
|
ev = getenv("smbios.bios.version");
|
||||||
if (ev != NULL && strncmp(ev, "Hyper-V", 7) == 0) {
|
if (ev != NULL && strncmp(ev, "Hyper-V", 7) != 0) {
|
||||||
status = comc_port->sio->SetAttributes(comc_port->sio,
|
status = comc_port->sio->SetAttributes(comc_port->sio,
|
||||||
0, 0, 0, DefaultParity, 0, DefaultStopBits);
|
comc_port->newbaudrate, 0, 0, DefaultParity, 0,
|
||||||
} else {
|
DefaultStopBits);
|
||||||
status = comc_port->sio->SetAttributes(comc_port->sio,
|
|
||||||
comc_port->baudrate, comc_port->receivefifodepth,
|
|
||||||
comc_port->timeout, comc_port->parity,
|
|
||||||
comc_port->databits, comc_port->stopbits);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (EFI_ERROR(status))
|
if (EFI_ERROR(status))
|
||||||
return (false);
|
return (false);
|
||||||
|
comc_port->baudrate = comc_port->newbaudrate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef EFI_FORCE_RTS
|
#ifdef EFI_FORCE_RTS
|
||||||
|
Loading…
Reference in New Issue
Block a user