Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/fwctl.c
Show First 20 Lines • Show All 466 Lines • ▼ Show 20 Lines | fwctl_inb(void) | ||||
} | } | ||||
return (retval); | return (retval); | ||||
} | } | ||||
static void | static void | ||||
fwctl_outw(uint16_t val) | fwctl_outw(uint16_t val) | ||||
{ | { | ||||
switch (be_state) { | |||||
case IDENT_WAIT: | |||||
if (val == 0) { | if (val == 0) { | ||||
be_state = IDENT_SEND; | be_state = IDENT_SEND; | ||||
ident_idx = 0; | ident_idx = 0; | ||||
} | } | ||||
break; | |||||
default: | |||||
/* ignore */ | |||||
break; | |||||
} | } | ||||
} | |||||
static uint32_t | static uint32_t | ||||
fwctl_inl(void) | fwctl_inl(void) | ||||
{ | { | ||||
uint32_t retval; | uint32_t retval; | ||||
switch (be_state) { | switch (be_state) { | ||||
case RESP: | case RESP: | ||||
Show All 38 Lines | if (in) { | ||||
if (bytes == 2) | if (bytes == 2) | ||||
fwctl_outw(*eax); | fwctl_outw(*eax); | ||||
else if (bytes == 4) | else if (bytes == 4) | ||||
fwctl_outl(*eax); | fwctl_outl(*eax); | ||||
} | } | ||||
return (0); | 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) | 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_LEN] = &fgetlen_info; | ||||
ops[OP_GET] = &fgetval_info; | ops[OP_GET] = &fgetval_info; | ||||
be_state = IDENT_WAIT; | be_state = IDENT_WAIT; | ||||
return (0); | |||||
} | } |