Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/pci_uart.c
Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | pci_uart_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, | ||||
assert(baridx == 0); | assert(baridx == 0); | ||||
assert(size == 1); | assert(size == 1); | ||||
val = uart_read(pi->pi_arg, offset); | val = uart_read(pi->pi_arg, offset); | ||||
return (val); | return (val); | ||||
} | } | ||||
static int | static int | ||||
pci_uart_legacy_config(nvlist_t *nvl, const char *opts) | pci_uart_legacy_config(config_node_t *node, const char *opts) | ||||
{ | { | ||||
if (opts != NULL) | if (opts != NULL) | ||||
set_config_value_node(nvl, "path", opts); | set_config_value_node(node, "path", opts); | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
pci_uart_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) | pci_uart_init(struct vmctx *ctx, struct pci_devinst *pi, config_node_t *node) | ||||
{ | { | ||||
struct uart_softc *sc; | struct uart_softc *sc; | ||||
const char *device; | const char *device; | ||||
pci_emul_alloc_bar(pi, 0, PCIBAR_IO, UART_IO_BAR_SIZE); | pci_emul_alloc_bar(pi, 0, PCIBAR_IO, UART_IO_BAR_SIZE); | ||||
pci_lintr_request(pi); | pci_lintr_request(pi); | ||||
/* initialize config space */ | /* initialize config space */ | ||||
pci_set_cfgdata16(pi, PCIR_DEVICE, COM_DEV); | pci_set_cfgdata16(pi, PCIR_DEVICE, COM_DEV); | ||||
pci_set_cfgdata16(pi, PCIR_VENDOR, COM_VENDOR); | pci_set_cfgdata16(pi, PCIR_VENDOR, COM_VENDOR); | ||||
pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_SIMPLECOMM); | pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_SIMPLECOMM); | ||||
sc = uart_init(pci_uart_intr_assert, pci_uart_intr_deassert, pi); | sc = uart_init(pci_uart_intr_assert, pci_uart_intr_deassert, pi); | ||||
pi->pi_arg = sc; | pi->pi_arg = sc; | ||||
device = get_config_value_node(nvl, "path"); | device = get_config_value_node(node, "path"); | ||||
if (uart_set_backend(sc, device) != 0) { | if (uart_set_backend(sc, device) != 0) { | ||||
EPRINTLN("Unable to initialize backend '%s' for " | EPRINTLN("Unable to initialize backend '%s' for " | ||||
"pci uart at %d:%d", device, pi->pi_slot, pi->pi_func); | "pci uart at %d:%d", device, pi->pi_slot, pi->pi_func); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
Show All 9 Lines |