diff options
author | mlarkin <mlarkin@openbsd.org> | 2017-03-25 22:36:53 +0000 |
---|---|---|
committer | mlarkin <mlarkin@openbsd.org> | 2017-03-25 22:36:53 +0000 |
commit | b966d91a0c4c148f4a70f543b2f2de3db0cdb93a (patch) | |
tree | 9fe8363a215f92e1dd28bf7cba779d0ae4bbd666 /usr.sbin/vmd/pci.c | |
parent | Recognise vmm in dmesg to install "vmm-firmware" (the SeaBIOS package). (diff) | |
download | wireguard-openbsd-b966d91a0c4c148f4a70f543b2f2de3db0cdb93a.tar.xz wireguard-openbsd-b966d91a0c4c148f4a70f543b2f2de3db0cdb93a.zip |
Last bits needed to get seabios + alpine linux working. This is enough
to get started and let more people help finding and fixing bugs.
ok kettenis, deraadt
Diffstat (limited to 'usr.sbin/vmd/pci.c')
-rw-r--r-- | usr.sbin/vmd/pci.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/usr.sbin/vmd/pci.c b/usr.sbin/vmd/pci.c index f106747b8de..5bc1c5eedfd 100644 --- a/usr.sbin/vmd/pci.c +++ b/usr.sbin/vmd/pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pci.c,v 1.14 2017/03/25 15:47:37 mlarkin Exp $ */ +/* $OpenBSD: pci.c,v 1.15 2017/03/25 22:36:53 mlarkin Exp $ */ /* * Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org> @@ -215,7 +215,7 @@ pci_handle_address_reg(struct vm_run_params *vrp) * The guest wrote to the address register. */ if (vei->vei.vei_dir == VEI_DIR_OUT) { - pci.pci_addr_reg = get_input_data(vei); + get_input_data(vei, &pci.pci_addr_reg); } else { /* * vei_dir == VEI_DIR_IN : in instruction @@ -346,8 +346,7 @@ pci_handle_data_reg(struct vm_run_params *vrp) /* XXX - discard writes to reassign IRQs / pins */ if (o != 0x3c) - pci.pci_devices[d].pd_cfg_space[o / 4] = - get_input_data(vei); + get_input_data(vei, &pci.pci_devices[d].pd_cfg_space[o / 4]); /* IOBAR registers must have bit 0 set */ if (o == 0x10) @@ -360,6 +359,26 @@ pci_handle_data_reg(struct vm_run_params *vrp) * The guest read from the config space location determined by * the current value in the address register. */ - set_return_data(vei, pci.pci_devices[d].pd_cfg_space[o / 4]); + if (d > pci.pci_dev_ct || b > 0 || f > 0) + set_return_data(vei, 0xFFFFFFFF); + else { + switch (sz) { + case 4: + set_return_data(vei, pci.pci_devices[d].pd_cfg_space[o / 4]); + break; + case 2: + if (ofs == 0) + set_return_data(vei, + pci.pci_devices[d].pd_cfg_space[o / 4]); + else + set_return_data(vei, + pci.pci_devices[d].pd_cfg_space[o / 4] >> 16); + break; + case 1: + set_return_data(vei, + pci.pci_devices[d].pd_cfg_space[o / 4] >> (ofs * 3)); + break; + } + } } } |