diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c --- a/usr.sbin/bhyve/bhyverun.c +++ b/usr.sbin/bhyve/bhyverun.c @@ -1535,8 +1535,13 @@ assert(error == 0); } - if (lpc_bootrom()) - fwctl_init(); + if (lpc_bootrom()) { + error = fwctl_init(); + if (error) { + perror("bhyve fwctl initialization error"); + exit(4); + } + } /* * Change the proc title to include the VM name. diff --git a/usr.sbin/bhyve/fwctl.h b/usr.sbin/bhyve/fwctl.h --- a/usr.sbin/bhyve/fwctl.h +++ b/usr.sbin/bhyve/fwctl.h @@ -51,6 +51,6 @@ }; \ DATA_SET(ctl_set, __CONCAT(__ctl, __LINE__)) -void fwctl_init(void); +int fwctl_init(void); #endif /* _FWCTL_H_ */ diff --git a/usr.sbin/bhyve/fwctl.c b/usr.sbin/bhyve/fwctl.c --- a/usr.sbin/bhyve/fwctl.c +++ b/usr.sbin/bhyve/fwctl.c @@ -538,15 +538,39 @@ 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 +int 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; + + if ((error = register_inout(&iop)) != 0) { + return (error); + } + + bzero(&iop, sizeof(iop)); + iop.name = "fwctl_rreg"; + iop.port = FWCTL_IN; + iop.size = 1; + iop.flags = IOPORT_F_IN; + iop.handler = fwctl_handler; + + if ((error = register_inout(&iop)) != 0) { + return (error); + } ops[OP_GET_LEN] = &fgetlen_info; ops[OP_GET] = &fgetval_info; be_state = IDENT_WAIT; + + return (0); }