diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2008-04-15 13:28:02 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2008-04-15 13:28:02 +0100 |
commit | 6742db6e6819687ab311199bfe76476947ed75ed (patch) | |
tree | 3736ca574aebcce589b9769d62aeb96bc19b0176 /xen/arch/x86/hvm/io.c | |
parent | ef3c86eb818614eb5a4bdd7c0c82b1e1346dd60e (diff) | |
download | xen-6742db6e6819687ab311199bfe76476947ed75ed.tar.gz xen-6742db6e6819687ab311199bfe76476947ed75ed.tar.bz2 xen-6742db6e6819687ab311199bfe76476947ed75ed.zip |
x86, hvm: I/O emulation handlers return X86EMUL_* return codes.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
Diffstat (limited to 'xen/arch/x86/hvm/io.c')
-rw-r--r-- | xen/arch/x86/hvm/io.c | 61 |
1 files changed, 23 insertions, 38 deletions
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(); } } } |