bhyve: dynamically register FwCtl ports

Qemu's FwCfg uses the same ports as Bhyve's FwCtl. Static allocated
ports wouldn't allow to switch between Qemu's FwCfg and Bhyve's
FwCtl.

Reviewed by:    markj
MFC after:      2 weeks
Sponsored by:   Beckhoff Automation GmbH & Co. KG
Differential Revision:  https://reviews.freebsd.org/D33496
This commit is contained in:
Corvin Köhne 2022-01-03 14:20:38 +01:00 committed by Emmanuel Vadot
parent 7d55d29508
commit 9fe79f2f2b

View File

@ -540,12 +540,32 @@ fwctl_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
return (0);
}
INOUT_PORT(fwctl_wreg, FWCTL_OUT, IOPORT_F_INOUT, fwctl_handler);
INOUT_PORT(fwctl_rreg, FWCTL_IN, IOPORT_F_IN, fwctl_handler);
void
fwctl_init(void)
{
struct inout_port iop;
int error;
bzero(&iop, sizeof(iop));
iop.name = "fwctl_wreg";
iop.port = FWCTL_OUT;
iop.size = 1;
iop.flags = IOPORT_F_INOUT;
iop.handler = fwctl_handler;
error = register_inout(&iop);
assert(error == 0);
bzero(&iop, sizeof(iop));
iop.name = "fwctl_rreg";
iop.port = FWCTL_IN;
iop.size = 1;
iop.flags = IOPORT_F_IN;
iop.handler = fwctl_handler;
error = register_inout(&iop);
assert(error == 0);
ops[OP_GET_LEN] = &fgetlen_info;
ops[OP_GET] = &fgetval_info;