Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/pci_lpc.c
Context not available. | |||||
#include <machine/vmm.h> | #include <machine/vmm.h> | ||||
#include <machine/vmm_snapshot.h> | #include <machine/vmm_snapshot.h> | ||||
#include <err.h> | |||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
Context not available. | |||||
#include "pci_irq.h" | #include "pci_irq.h" | ||||
#include "pci_lpc.h" | #include "pci_lpc.h" | ||||
#include "pctestdev.h" | #include "pctestdev.h" | ||||
#include "tpm2_device.h" | |||||
#include "uart_emul.h" | #include "uart_emul.h" | ||||
#define IO_ICU1 0x20 | #define IO_ICU1 0x20 | ||||
Context not available. | |||||
static bool pctestdev_present; | static bool pctestdev_present; | ||||
static const char *lpc_tpm2_opts; | |||||
static struct tpm2_device *lpc_tpm2; | |||||
/* | /* | ||||
* LPC device configuration is in the following form: | * LPC device configuration is in the following form: | ||||
* <lpc_device_name>[,<options>] | * <lpc_device_name>[,<options>] | ||||
Context not available. | |||||
error = 0; | error = 0; | ||||
goto done; | goto done; | ||||
} | } | ||||
if (strcasecmp(lpcdev, "tpm2") == 0) { | |||||
if (lpc_tpm2_opts != NULL) { | |||||
warnx("%s: only a single TPM allowed", | |||||
__func__); | |||||
error = EINVAL; | |||||
goto done; | |||||
} | |||||
lpc_tpm2_opts = str; | |||||
if (lpc_tpm2_opts == NULL) { | |||||
error = EINVAL; | |||||
goto done; | |||||
} | |||||
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) { | ||||
lpc_uart_softc[unit].opts = str; | lpc_uart_softc[unit].opts = str; | ||||
Context not available. | |||||
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("tpm2\n"); | |||||
printf("%s\n", pctestdev_getname()); | printf("%s\n", pctestdev_getname()); | ||||
} | } | ||||
Context not available. | |||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
} | } | ||||
if (lpc_tpm2_opts != NULL) { | |||||
error = tpm2_device_create(&lpc_tpm2, ctx, lpc_tpm2_opts); | |||||
if (error) { | |||||
warnx( | |||||
"%s: unable to create a TPM device with opts \"%s\" (%d)", | |||||
__func__, lpc_tpm2_opts, error); | |||||
return (error); | |||||
} | |||||
} | |||||
/* COM1 and COM2 */ | /* COM1 and COM2 */ | ||||
for (unit = 0; unit < LPC_UART_NUM; unit++) { | for (unit = 0; unit < LPC_UART_NUM; unit++) { | ||||
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? | |||||
Context not available. | |||||
pci_set_cfgdata8(lpc_bridge, 0x68 + pin, pirq_read(pin + 5)); | pci_set_cfgdata8(lpc_bridge, 0x68 + pin, pirq_read(pin + 5)); | ||||
} | } | ||||
vm_paddr_t | |||||
lpc_tpm2_get_control_address(void) | |||||
{ | |||||
return tpm2_device_get_control_address(lpc_tpm2); | |||||
} | |||||
int | |||||
lpc_tpm2_in_use(void) | |||||
{ | |||||
return (lpc_tpm2 != NULL); | |||||
} | |||||
#ifdef BHYVE_SNAPSHOT | #ifdef BHYVE_SNAPSHOT | ||||
static int | static int | ||||
pci_lpc_snapshot(struct vm_snapshot_meta *meta) | pci_lpc_snapshot(struct vm_snapshot_meta *meta) | ||||
Context not available. |
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...