From 6742db6e6819687ab311199bfe76476947ed75ed Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Tue, 15 Apr 2008 13:28:02 +0100 Subject: x86, hvm: I/O emulation handlers return X86EMUL_* return codes. Signed-off-by: Keir Fraser --- xen/arch/x86/hvm/io.c | 61 +++++++++++++++++++-------------------------------- 1 file changed, 23 insertions(+), 38 deletions(-) (limited to 'xen/arch/x86/hvm/io.c') diff --git a/xen/arch/x86/hvm/io.c b/xen/arch/x86/hvm/io.c index 9ff2958ca7..6a8e0885c0 100644 --- a/xen/arch/x86/hvm/io.c +++ b/xen/arch/x86/hvm/io.c @@ -246,74 +246,59 @@ void hvm_io_assist(void) void dpci_ioport_read(uint32_t mport, ioreq_t *p) { - uint64_t i; - uint64_t z_data; - uint64_t length = (p->count * p->size); + int i, sign = p->df ? -1 : 1; + uint32_t data = 0; - for ( i = 0; i < length; i += p->size ) + for ( i = 0; i < p->count; i++ ) { - z_data = ~0ULL; - switch ( p->size ) { case 1: - z_data = (uint64_t)inb(mport); + data = inb(mport); break; case 2: - z_data = (uint64_t)inw(mport); + data = inw(mport); break; case 4: - z_data = (uint64_t)inl(mport); + data = inl(mport); break; default: - gdprintk(XENLOG_ERR, "Error: unable to handle size: %" - PRId64 "\n", p->size); - return; + BUG(); } - p->data = z_data; - if ( p->data_is_ptr && - hvm_copy_to_guest_phys(p->data + i, (void *)&z_data, - (int)p->size) ) - { - gdprintk(XENLOG_ERR, "Error: couldn't copy to hvm phys\n"); - return; - } + if ( p->data_is_ptr ) + (void)hvm_copy_to_guest_phys( + p->data + (sign * i * p->size), &data, p->size); + else + p->data = data; } } void dpci_ioport_write(uint32_t mport, ioreq_t *p) { - uint64_t i; - uint64_t z_data = 0; - uint64_t length = (p->count * p->size); + int i, sign = p->df ? -1 : 1; + uint32_t data; - for ( i = 0; i < length; i += p->size ) + for ( i = 0; i < p->count; i++ ) { - z_data = p->data; - if ( p->data_is_ptr && - hvm_copy_from_guest_phys((void *)&z_data, - p->data + i, (int)p->size) ) - { - gdprintk(XENLOG_ERR, "Error: couldn't copy from hvm phys\n"); - return; - } + data = p->data; + if ( p->data_is_ptr ) + (void)hvm_copy_from_guest_phys( + &data, p->data + (sign * i & p->size), p->size); switch ( p->size ) { case 1: - outb((uint8_t) z_data, mport); + outb(data, mport); break; case 2: - outw((uint16_t) z_data, mport); + outw(data, mport); break; case 4: - outl((uint32_t) z_data, mport); + outl(data, mport); break; default: - gdprintk(XENLOG_ERR, "Error: unable to handle size: %" - PRId64 "\n", p->size); - break; + BUG(); } } } -- cgit v1.2.3