HV: HV: make io_read_fn_t return true or false

This patch makes io_read_fn_t return true or false instead of void.
Returning true means that the handler in HV process the request completely.
Returning false means that we need to re-inject the request to DM after
processing it in HV.

Tracked-On: #2865
Signed-off-by: Kaige Fu <kaige.fu@intel.com>
This commit is contained in:
Kaige Fu
2019-03-28 16:23:30 +00:00
committed by ACRN System Integration
parent 3b2ad67788
commit 1c0d7f78d0
7 changed files with 54 additions and 31 deletions

View File

@@ -196,7 +196,7 @@ static void dm_emulate_io_complete(struct acrn_vcpu *vcpu)
* @retval -EIO The request spans multiple devices and cannot be emulated.
*/
static int32_t
hv_emulate_pio(const struct acrn_vcpu *vcpu, struct io_request *io_req)
hv_emulate_pio(struct acrn_vcpu *vcpu, struct io_request *io_req)
{
int32_t status = -ENODEV;
uint16_t port, size;
@@ -215,6 +215,8 @@ hv_emulate_pio(const struct acrn_vcpu *vcpu, struct io_request *io_req)
continue;
}
status = 0;
if (pio_req->direction == REQUEST_WRITE) {
if (handler->io_write != NULL) {
if (!(handler->io_write(vm, port, size, pio_req->value))) {
@@ -228,11 +230,16 @@ hv_emulate_pio(const struct acrn_vcpu *vcpu, struct io_request *io_req)
pr_dbg("IO write on port %04x, data %08x", port, pio_req->value);
} else {
if (handler->io_read != NULL) {
pio_req->value = handler->io_read(vm, port, size);
if (!(handler->io_read(vm, vcpu, port, size))) {
/*
* If io_read return false, it indicates that we need continue
* to emulate in DM.
*/
status = -ENODEV;
}
}
pr_dbg("IO read on port %04x, data %08x", port, pio_req->value);
}
status = 0;
break;
}

View File

@@ -121,9 +121,13 @@ static inline uint8_t get_slp_typx(uint32_t pm1_cnt)
return (uint8_t)((pm1_cnt & 0x1fffU) >> BIT_SLP_TYPx);
}
static uint32_t pm1ab_io_read(__unused struct acrn_vm *vm, uint16_t addr, size_t width)
static bool pm1ab_io_read(__unused struct acrn_vm *vm, struct acrn_vcpu *vcpu, uint16_t addr, size_t width)
{
return pio_read(addr, width);
struct pio_request *pio_req = &vcpu->req.reqs.pio;
pio_req->value = pio_read(addr, width);
return true;
}
static inline void enter_s3(struct acrn_vm *vm, uint32_t pm1a_cnt_val, uint32_t pm1b_cnt_val)