Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/pci_lpc.c
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | |||||
#include "bootrom.h" | #include "bootrom.h" | ||||
#include "config.h" | #include "config.h" | ||||
#include "inout.h" | #include "inout.h" | ||||
#include "pci_emul.h" | #include "pci_emul.h" | ||||
#include "pci_irq.h" | #include "pci_irq.h" | ||||
#include "pci_lpc.h" | #include "pci_lpc.h" | ||||
#include "pci_passthru.h" | #include "pci_passthru.h" | ||||
#include "pctestdev.h" | #include "pctestdev.h" | ||||
#include "tpm_device.h" | |||||
#include "uart_emul.h" | #include "uart_emul.h" | ||||
#define IO_ICU1 0x20 | #define IO_ICU1 0x20 | ||||
#define IO_ICU2 0xA0 | #define IO_ICU2 0xA0 | ||||
SET_DECLARE(lpc_dsdt_set, struct lpc_dsdt); | SET_DECLARE(lpc_dsdt_set, struct lpc_dsdt); | ||||
SET_DECLARE(lpc_sysres_set, struct lpc_sysres); | SET_DECLARE(lpc_sysres_set, struct lpc_sysres); | ||||
Show All 28 Lines | |||||
* <lpc_device_name>[,<options>] | * <lpc_device_name>[,<options>] | ||||
* For e.g. "com1,stdio" or "bootrom,/var/romfile" | * For e.g. "com1,stdio" or "bootrom,/var/romfile" | ||||
*/ | */ | ||||
int | int | ||||
lpc_device_parse(const char *opts) | lpc_device_parse(const char *opts) | ||||
{ | { | ||||
int unit, error; | int unit, error; | ||||
char *str, *cpy, *lpcdev, *node_name; | char *str, *cpy, *lpcdev, *node_name; | ||||
const char *romfile, *varfile; | const char *romfile, *varfile, *tpm_type, *tpm_path; | ||||
error = -1; | error = -1; | ||||
str = cpy = strdup(opts); | str = cpy = strdup(opts); | ||||
lpcdev = strsep(&str, ","); | lpcdev = strsep(&str, ","); | ||||
if (lpcdev != NULL) { | if (lpcdev != NULL) { | ||||
if (strcasecmp(lpcdev, "bootrom") == 0) { | if (strcasecmp(lpcdev, "bootrom") == 0) { | ||||
romfile = strsep(&str, ","); | romfile = strsep(&str, ","); | ||||
if (romfile == NULL) { | if (romfile == NULL) { | ||||
Show All 14 Lines | if (strcasecmp(lpcdev, "bootrom") == 0) { | ||||
pci_parse_legacy_config(find_config_node("lpc"), | pci_parse_legacy_config(find_config_node("lpc"), | ||||
varfile); | varfile); | ||||
} | } | ||||
pci_parse_legacy_config(find_config_node("lpc"), str); | pci_parse_legacy_config(find_config_node("lpc"), str); | ||||
error = 0; | error = 0; | ||||
goto done; | goto done; | ||||
} | } | ||||
if (strcasecmp(lpcdev, "tpm") == 0) { | |||||
nvlist_t *nvl = create_config_node("tpm"); | |||||
tpm_type = strsep(&str, ","); | |||||
if (tpm_type == NULL) { | |||||
errx(4, "invalid tpm type \"%s\"", opts); | |||||
} | |||||
set_config_value_node(nvl, "type", tpm_type); | |||||
tpm_path = strsep(&str, ","); | |||||
if (tpm_path == NULL) { | |||||
errx(4, "invalid tpm path \"%s\"", opts); | |||||
} | |||||
set_config_value_node(nvl, "path", tpm_path); | |||||
pci_parse_legacy_config(find_config_node("tpm"), str); | |||||
set_config_value_node_if_unset(nvl, "version", "2.0"); | |||||
error = 0; | |||||
goto done; | |||||
} | |||||
for (unit = 0; unit < LPC_UART_NUM; unit++) { | for (unit = 0; unit < LPC_UART_NUM; unit++) { | ||||
if (strcasecmp(lpcdev, lpc_uart_names[unit]) == 0) { | if (strcasecmp(lpcdev, lpc_uart_names[unit]) == 0) { | ||||
asprintf(&node_name, "lpc.%s.path", | asprintf(&node_name, "lpc.%s.path", | ||||
lpc_uart_names[unit]); | lpc_uart_names[unit]); | ||||
set_config_value(node_name, str); | set_config_value(node_name, str); | ||||
free(node_name); | free(node_name); | ||||
error = 0; | error = 0; | ||||
goto done; | goto done; | ||||
Show All 17 Lines | |||||
void | void | ||||
lpc_print_supported_devices(void) | lpc_print_supported_devices(void) | ||||
{ | { | ||||
size_t i; | size_t i; | ||||
printf("bootrom\n"); | printf("bootrom\n"); | ||||
for (i = 0; i < LPC_UART_NUM; i++) | for (i = 0; i < LPC_UART_NUM; i++) | ||||
printf("%s\n", lpc_uart_names[i]); | printf("%s\n", lpc_uart_names[i]); | ||||
printf("tpm\n"); | |||||
printf("%s\n", pctestdev_getname()); | printf("%s\n", pctestdev_getname()); | ||||
} | } | ||||
const char * | const char * | ||||
lpc_bootrom(void) | lpc_bootrom(void) | ||||
{ | { | ||||
return (get_config_value("lpc.bootrom")); | return (get_config_value("lpc.bootrom")); | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | lpc_init(struct vmctx *ctx) | ||||
nvl = find_config_node("lpc"); | nvl = find_config_node("lpc"); | ||||
if (nvl != NULL && nvlist_exists(nvl, "bootrom")) { | if (nvl != NULL && nvlist_exists(nvl, "bootrom")) { | ||||
error = bootrom_loadrom(ctx, nvl); | error = bootrom_loadrom(ctx, nvl); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
} | } | ||||
/* COM1 and COM2 */ | /* COM1 and COM2 */ | ||||
markj: Why do we hang the TPM device off of the LPC? arm64 won't have an LPC driver, but there's no… | |||||
Done Inline ActionsI just needed a place to add it. Afaik, some TPMs are attached to the LPC. Where would you like to add this option? corvink: I just needed a place to add it. Afaik, some TPMs are attached to the LPC. Where would you like… | |||||
Done Inline Actionscorvink: @jhb @markj Where should we hang off the TPM device? | |||||
for (unit = 0; unit < LPC_UART_NUM; unit++) { | for (unit = 0; unit < LPC_UART_NUM; unit++) { | ||||
sc = &lpc_uart_softc[unit]; | sc = &lpc_uart_softc[unit]; | ||||
name = lpc_uart_names[unit]; | name = lpc_uart_names[unit]; | ||||
if (uart_legacy_alloc(unit, &sc->iobase, &sc->irq) != 0) { | if (uart_legacy_alloc(unit, &sc->iobase, &sc->irq) != 0) { | ||||
EPRINTLN("Unable to allocate resources for " | EPRINTLN("Unable to allocate resources for " | ||||
"LPC device %s", name); | "LPC device %s", name); | ||||
return (-1); | return (-1); | ||||
▲ Show 20 Lines • Show All 342 Lines • Show Last 20 Lines |
Why do we hang the TPM device off of the LPC? arm64 won't have an LPC driver, but there's no reason to exclude TPM emulation/passthrough on arm64 AFAIK...