pc-testdev: support 8 and 16-bit accesses to 0xe0
This will let us use the testdev to test endianness. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Message-id: 1374501278-31549-17-git-send-email-pbonzini@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
f36a6382b8
commit
b7faba7163
@ -80,13 +80,20 @@ static void test_ioport_write(void *opaque, hwaddr addr, uint64_t data,
|
||||
unsigned len)
|
||||
{
|
||||
PCTestdev *dev = opaque;
|
||||
dev->ioport_data = data;
|
||||
int bits = len * 8;
|
||||
int start_bit = (addr & 3) * 8;
|
||||
uint32_t mask = ((uint32_t)-1 >> (32 - bits)) << start_bit;
|
||||
dev->ioport_data &= ~mask;
|
||||
dev->ioport_data |= data << start_bit;
|
||||
}
|
||||
|
||||
static uint64_t test_ioport_read(void *opaque, hwaddr addr, unsigned len)
|
||||
{
|
||||
PCTestdev *dev = opaque;
|
||||
return dev->ioport_data;
|
||||
int bits = len * 8;
|
||||
int start_bit = (addr & 3) * 8;
|
||||
uint32_t mask = ((uint32_t)-1 >> (32 - bits)) << start_bit;
|
||||
return (dev->ioport_data & mask) >> start_bit;
|
||||
}
|
||||
|
||||
static const MemoryRegionOps test_ioport_ops = {
|
||||
|
Loading…
Reference in New Issue
Block a user