version 1.1.1.1, 2018/04/24 16:48:33
|
version 1.1.1.2, 2018/04/24 16:52:55
|
Line 14
|
Line 14
|
/* Bitbanded IO. Each word corresponds to a single bit. */ |
/* Bitbanded IO. Each word corresponds to a single bit. */ |
|
|
/* Get the byte address of the real memory for a bitband acess. */ |
/* Get the byte address of the real memory for a bitband acess. */ |
static inline uint32_t bitband_addr(uint32_t addr) |
static inline uint32_t bitband_addr(void * opaque, uint32_t addr) |
{ |
{ |
uint32_t res; |
uint32_t res; |
|
|
res = addr & 0xe0000000; |
res = *(uint32_t *)opaque; |
res |= (addr & 0x1ffffff) >> 5; |
res |= (addr & 0x1ffffff) >> 5; |
return res; |
return res; |
|
|
Line 27 static inline uint32_t bitband_addr(uint
|
Line 27 static inline uint32_t bitband_addr(uint
|
static uint32_t bitband_readb(void *opaque, target_phys_addr_t offset) |
static uint32_t bitband_readb(void *opaque, target_phys_addr_t offset) |
{ |
{ |
uint8_t v; |
uint8_t v; |
cpu_physical_memory_read(bitband_addr(offset), &v, 1); |
cpu_physical_memory_read(bitband_addr(opaque, offset), &v, 1); |
return (v & (1 << ((offset >> 2) & 7))) != 0; |
return (v & (1 << ((offset >> 2) & 7))) != 0; |
} |
} |
|
|
Line 37 static void bitband_writeb(void *opaque,
|
Line 37 static void bitband_writeb(void *opaque,
|
uint32_t addr; |
uint32_t addr; |
uint8_t mask; |
uint8_t mask; |
uint8_t v; |
uint8_t v; |
addr = bitband_addr(offset); |
addr = bitband_addr(opaque, offset); |
mask = (1 << ((offset >> 2) & 7)); |
mask = (1 << ((offset >> 2) & 7)); |
cpu_physical_memory_read(addr, &v, 1); |
cpu_physical_memory_read(addr, &v, 1); |
if (value & 1) |
if (value & 1) |
Line 52 static uint32_t bitband_readw(void *opaq
|
Line 52 static uint32_t bitband_readw(void *opaq
|
uint32_t addr; |
uint32_t addr; |
uint16_t mask; |
uint16_t mask; |
uint16_t v; |
uint16_t v; |
addr = bitband_addr(offset) & ~1; |
addr = bitband_addr(opaque, offset) & ~1; |
mask = (1 << ((offset >> 2) & 15)); |
mask = (1 << ((offset >> 2) & 15)); |
mask = tswap16(mask); |
mask = tswap16(mask); |
cpu_physical_memory_read(addr, (uint8_t *)&v, 2); |
cpu_physical_memory_read(addr, (uint8_t *)&v, 2); |
Line 65 static void bitband_writew(void *opaque,
|
Line 65 static void bitband_writew(void *opaque,
|
uint32_t addr; |
uint32_t addr; |
uint16_t mask; |
uint16_t mask; |
uint16_t v; |
uint16_t v; |
addr = bitband_addr(offset) & ~1; |
addr = bitband_addr(opaque, offset) & ~1; |
mask = (1 << ((offset >> 2) & 15)); |
mask = (1 << ((offset >> 2) & 15)); |
mask = tswap16(mask); |
mask = tswap16(mask); |
cpu_physical_memory_read(addr, (uint8_t *)&v, 2); |
cpu_physical_memory_read(addr, (uint8_t *)&v, 2); |
Line 81 static uint32_t bitband_readl(void *opaq
|
Line 81 static uint32_t bitband_readl(void *opaq
|
uint32_t addr; |
uint32_t addr; |
uint32_t mask; |
uint32_t mask; |
uint32_t v; |
uint32_t v; |
addr = bitband_addr(offset) & ~3; |
addr = bitband_addr(opaque, offset) & ~3; |
mask = (1 << ((offset >> 2) & 31)); |
mask = (1 << ((offset >> 2) & 31)); |
mask = tswap32(mask); |
mask = tswap32(mask); |
cpu_physical_memory_read(addr, (uint8_t *)&v, 4); |
cpu_physical_memory_read(addr, (uint8_t *)&v, 4); |
Line 94 static void bitband_writel(void *opaque,
|
Line 94 static void bitband_writel(void *opaque,
|
uint32_t addr; |
uint32_t addr; |
uint32_t mask; |
uint32_t mask; |
uint32_t v; |
uint32_t v; |
addr = bitband_addr(offset) & ~3; |
addr = bitband_addr(opaque, offset) & ~3; |
mask = (1 << ((offset >> 2) & 31)); |
mask = (1 << ((offset >> 2) & 31)); |
mask = tswap32(mask); |
mask = tswap32(mask); |
cpu_physical_memory_read(addr, (uint8_t *)&v, 4); |
cpu_physical_memory_read(addr, (uint8_t *)&v, 4); |
Line 120 static CPUWriteMemoryFunc *bitband_write
|
Line 120 static CPUWriteMemoryFunc *bitband_write
|
static void armv7m_bitband_init(void) |
static void armv7m_bitband_init(void) |
{ |
{ |
int iomemtype; |
int iomemtype; |
|
static uint32_t bitband1_offset = 0x20000000; |
|
static uint32_t bitband2_offset = 0x40000000; |
|
|
iomemtype = cpu_register_io_memory(0, bitband_readfn, bitband_writefn, |
iomemtype = cpu_register_io_memory(0, bitband_readfn, bitband_writefn, |
NULL); |
&bitband1_offset); |
cpu_register_physical_memory(0x22000000, 0x02000000, iomemtype); |
cpu_register_physical_memory(0x22000000, 0x02000000, iomemtype); |
|
iomemtype = cpu_register_io_memory(0, bitband_readfn, bitband_writefn, |
|
&bitband2_offset); |
cpu_register_physical_memory(0x42000000, 0x02000000, iomemtype); |
cpu_register_physical_memory(0x42000000, 0x02000000, iomemtype); |
} |
} |
|
|
Line 203 qemu_irq *armv7m_init(int flash_size, in
|
Line 207 qemu_irq *armv7m_init(int flash_size, in
|
|
|
return pic; |
return pic; |
} |
} |
|
|