64 bit I/O v3
PATCH 1/1 64 bit I/O v3
This is the third version of adding 64 bit I/O support to QEMU.
This version uses a 4 member structure to hold the mmio callbacks but presents the old 3 element array interface for existing hardware drivers. Only hardware drivers that need 64 bit I/O will need to be converted to the new interface. Sparc32 slavio_timer has been converted to use the new interface and 64 bit accesses to it's 64 bit timer have been verified to work properly using the built in self test for the 64 bit user timer in a sun openboot prom image for an SS5-170.
This patch still has some issues that need to be addressed:
The subpage code has not been converted to a structure so some pointer conversion casts are necessary.
The VGA hack functions still return an array pointer rather than a structure pointer but can be easily changed later along with the hardware driver that uses them.
Please test this on systems other than sparc with DEBUG_UNASSIGNED enabled in exec.c to
see if 64 bit mmio is being performed so those hardware drivers can be converted. They will complain of an unassigned access with a size of 8.
softmmu_template.h +2 -22
@@ -65,17 +65,7 @@ } env->mem_io_vaddr = addr; -#if SHIFT <=2 - res = io_mem_read[index][SHIFT ](io_mem_opaque[index], physaddr); -#else -#ifdef TARGET_WORDS_BIGENDIAN - res = (uint64_t )io_mem_read[index][2 ](io_mem_opaque[index], physaddr) <<32 ; - res |= io_mem_read[index][2 ](io_mem_opaque[index], physaddr +4 ); -#else - res = io_mem_read[index][2 ](io_mem_opaque[index], physaddr); - res |= (uint64_t )io_mem_read[index][2 ](io_mem_opaque[index], physaddr +4 ) <<32 ; -#endif -#endif /* SHIFT > 2 */ + res = io_mem_read[index].SUFFIX (io_mem_opaque[index], physaddr);#ifdef USE_KQEMU env->last_io_time =cpu_get_time_fast ();#endif
@@ -210,17 +200,7 @@ env->mem_io_vaddr = addr; env->mem_io_pc = (unsigned long )retaddr; -#if SHIFT <=2 - io_mem_write[index][SHIFT ](io_mem_opaque[index], physaddr, val); -#else -#ifdef TARGET_WORDS_BIGENDIAN - io_mem_write[index][2 ](io_mem_opaque[index], physaddr, val >>32 ); - io_mem_write[index][2 ](io_mem_opaque[index], physaddr +4 , val); -#else - io_mem_write[index][2 ](io_mem_opaque[index], physaddr, val); - io_mem_write[index][2 ](io_mem_opaque[index], physaddr +4 , val >>32 ); -#endif -#endif /* SHIFT > 2 */ + io_mem_write[index].SUFFIX (io_mem_opaque[index], physaddr, val);#ifdef USE_KQEMU env->last_io_time =cpu_get_time_fast ();#endif
exec.c +231 -80
504 lines not on this page · raw message
exec-all.h +2 -2
@@ -265,8 +265,8 @@TranslationBlock *tb_find_pc (unsigned long pc_ptr); -extern CPUWriteMemoryFunc *io_mem_write[IO_MEM_NB_ENTRIES ][4 ]; -extern CPUReadMemoryFunc *io_mem_read[IO_MEM_NB_ENTRIES ][4 ]; +extern CPUWriteMemoryFuncs io_mem_write[IO_MEM_NB_ENTRIES ]; +extern CPUReadMemoryFuncs io_mem_read[IO_MEM_NB_ENTRIES ];extern void *io_mem_opaque[IO_MEM_NB_ENTRIES ];#include "qemu-lock.h"
slavio_timer.c +66 -4
105 lines not on this page · raw message
cpu-all.h +21 -0
@@ -891,6 +891,23 @@typedef void CPUWriteMemoryFunc (void *opaque,target_phys_addr_t addr,uint32_t value);typedef uint32_t CPUReadMemoryFunc (void *opaque,target_phys_addr_t addr); +typedef void CPUWriteMemoryFunc64 (void *opaque,target_phys_addr_t addr,uint64_t value); +typedef uint64_t CPUReadMemoryFunc64 (void *opaque,target_phys_addr_t addr); + +typedef struct CPUWriteMemoryFuncs { +CPUWriteMemoryFunc *b; +CPUWriteMemoryFunc *w; +CPUWriteMemoryFunc *l; +CPUWriteMemoryFunc64 *q; +}CPUWriteMemoryFuncs ; + +typedef struct CPUReadMemoryFuncs { +CPUReadMemoryFunc *b; +CPUReadMemoryFunc *w; +CPUReadMemoryFunc *l; +CPUReadMemoryFunc64 *q; +}CPUReadMemoryFuncs ; + void cpu_register_physical_memory_offset(target_phys_addr_t start_addr, ram_addr_t size, ram_addr_t phys_offset,
@@ -909,6 +926,10 @@ CPUReadMemoryFunc **mem_read, CPUWriteMemoryFunc **mem_write, void *opaque); +int cpu_register_io_memory64 (int io_index, +CPUReadMemoryFuncs *mem_read, +CPUWriteMemoryFuncs *mem_write, +void *opaque);void cpu_unregister_io_memory (int table_address);CPUWriteMemoryFunc **cpu_get_io_memory_write (int io_index);CPUReadMemoryFunc **cpu_get_io_memory_read (int io_index);
Quoted 17 lines · Robert Reif
This is the third version of adding 64 bit I/O support to QEMU.
int cpu_register_io_memory(int
io_index,
CPUReadMemoryFunc **mem_read, CPUWriteMemoryFunc **mem_write, void *opaque)
{
- int i, subwidth = 0;
+ if (io_index<= 0) {
+io_index=get_free_io_mem_idx();
+ if (io_index== -1)
+ returnio_index;
+ } else {
+ if (io_index>=IO_MEM_NB_ENTRIES)
+ return -1;
+ }
Quoted 15 lines
+ io_mem_read[io_index].b = mem_read[0];
+ io_mem_write[io_index].b = mem_write[0];
+
+ io_mem_read[io_index].w = mem_read[1];
+ io_mem_write[io_index].w = mem_write[1];
+
+ io_mem_read[io_index].l = mem_read[2];
+ io_mem_write[io_index].l = mem_write[2];
+
+ io_mem_read[io_index].q = NULL;
+ io_mem_write[io_index].q = NULL;
+
+ io_mem_opaque[io_index] = opaque;
+ return (io_index<<IO_MEM_SHIFT) |IO_MEM_SUBWIDTH;
+}
I think for 64 bit accesses the default should be emulation using two 32 bit accesses instead of NULL (unassigned).
Quoted 5 lines · Blue Swirl
I think for 64 bit accesses the default should be emulation using two 32 bit accesses instead of NULL (unassigned).
This version adds emulated 64 bit i/o using 32 bit i/o for hardware devices that are not converted over to the new api.
softmmu_template.h +2 -22
@@ -65,17 +65,7 @@ } env->mem_io_vaddr = addr; -#if SHIFT <=2 - res = io_mem_read[index][SHIFT ](io_mem_opaque[index], physaddr); -#else -#ifdef TARGET_WORDS_BIGENDIAN - res = (uint64_t )io_mem_read[index][2 ](io_mem_opaque[index], physaddr) <<32 ; - res |= io_mem_read[index][2 ](io_mem_opaque[index], physaddr +4 ); -#else - res = io_mem_read[index][2 ](io_mem_opaque[index], physaddr); - res |= (uint64_t )io_mem_read[index][2 ](io_mem_opaque[index], physaddr +4 ) <<32 ; -#endif -#endif /* SHIFT > 2 */ + res = io_mem_read[index].SUFFIX (io_mem_opaque[index], physaddr);#ifdef USE_KQEMU env->last_io_time =cpu_get_time_fast ();#endif
@@ -210,17 +200,7 @@ env->mem_io_vaddr = addr; env->mem_io_pc = (unsigned long )retaddr; -#if SHIFT <=2 - io_mem_write[index][SHIFT ](io_mem_opaque[index], physaddr, val); -#else -#ifdef TARGET_WORDS_BIGENDIAN - io_mem_write[index][2 ](io_mem_opaque[index], physaddr, val >>32 ); - io_mem_write[index][2 ](io_mem_opaque[index], physaddr +4 , val); -#else - io_mem_write[index][2 ](io_mem_opaque[index], physaddr, val); - io_mem_write[index][2 ](io_mem_opaque[index], physaddr +4 , val >>32 ); -#endif -#endif /* SHIFT > 2 */ + io_mem_write[index].SUFFIX (io_mem_opaque[index], physaddr, val);#ifdef USE_KQEMU env->last_io_time =cpu_get_time_fast ();#endif
exec.c +270 -73
536 lines not on this page · raw message
exec-all.h +2 -2
@@ -265,8 +265,8 @@TranslationBlock *tb_find_pc (unsigned long pc_ptr); -extern CPUWriteMemoryFunc *io_mem_write[IO_MEM_NB_ENTRIES ][4 ]; -extern CPUReadMemoryFunc *io_mem_read[IO_MEM_NB_ENTRIES ][4 ]; +extern CPUWriteMemoryFuncs io_mem_write[IO_MEM_NB_ENTRIES ]; +extern CPUReadMemoryFuncs io_mem_read[IO_MEM_NB_ENTRIES ];extern void *io_mem_opaque[IO_MEM_NB_ENTRIES ];#include "qemu-lock.h"
slavio_timer.c +66 -4
105 lines not on this page · raw message
cpu-all.h +21 -0
@@ -891,6 +891,23 @@typedef void CPUWriteMemoryFunc (void *opaque,target_phys_addr_t addr,uint32_t value);typedef uint32_t CPUReadMemoryFunc (void *opaque,target_phys_addr_t addr); +typedef void CPUWriteMemoryFunc64 (void *opaque,target_phys_addr_t addr,uint64_t value); +typedef uint64_t CPUReadMemoryFunc64 (void *opaque,target_phys_addr_t addr); + +typedef struct CPUWriteMemoryFuncs { +CPUWriteMemoryFunc *b; +CPUWriteMemoryFunc *w; +CPUWriteMemoryFunc *l; +CPUWriteMemoryFunc64 *q; +}CPUWriteMemoryFuncs ; + +typedef struct CPUReadMemoryFuncs { +CPUReadMemoryFunc *b; +CPUReadMemoryFunc *w; +CPUReadMemoryFunc *l; +CPUReadMemoryFunc64 *q; +}CPUReadMemoryFuncs ; + void cpu_register_physical_memory_offset(target_phys_addr_t start_addr, ram_addr_t size, ram_addr_t phys_offset,
@@ -909,6 +926,10 @@ CPUReadMemoryFunc **mem_read, CPUWriteMemoryFunc **mem_write, void *opaque); +int cpu_register_io_memory64 (int io_index, +CPUReadMemoryFuncs *mem_read, +CPUWriteMemoryFuncs *mem_write, +void *opaque);void cpu_unregister_io_memory (int table_address);CPUWriteMemoryFunc **cpu_get_io_memory_write (int io_index);CPUReadMemoryFunc **cpu_get_io_memory_read (int io_index);