64 bit I/O support
PATCH 1/1 64 bit I/O support
This patch is a rebase on current svn of my previous patch .
This patch adds support for 64 bit I/O by essentially replacing an array of 4 function pointers with a structure containing 4 function pointers. The current array contains 4 pointers, one for 8, 16 and 32 bit function pointers which really support only 32 bits and a forth pointer which is unused but I assume is a place holder for a 64 bit function pointer. The current trick of passing 8, 16 or 32 bits in a 32 bit variable doesn't extend to passing 64 bits in a 32 bit bit variable and creating a 64 bit function would require casts to allow being saved in the array so a sutrcture is used that can take different function pointers.
Here are the relevant parts of the patch:
+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;
-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];
The rest of the patch just does the array to structure conversion and adds the 64 bit functions.
The old array function call is supported so no existing drivers need to be modified. They can continue to do 2 32 bit accesses because 2 helper functions have been added to break up the accesses automatically. However, the helper functions should only be used until all drivers are converted to use the structure and then can be removed along with the old array functions api. The replacement of the arrays with structures in the drivers is very straightforward for drivers that don't do 64 bit I/O and the few that do can be cleaned up to remove the work arounds for the lack of true 64 bit I/O by their maintainers.
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 +277 -73
549 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"
cpu-all.h +21 -0
@@ -892,6 +892,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,
@@ -910,6 +927,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 12 lines · Robert Reif
This patch is a rebase on current svn of my previous patch .
This patch adds support for 64 bit I/O by essentially replacing an array of 4 function pointers with a structure containing 4 function pointers. The current array contains 4 pointers, one for 8, 16 and 32 bit function pointers which really support only 32 bits and a forth pointer which is unused but I assume is a place holder for a 64 bit function pointer. The current trick of passing 8, 16 or 32 bits in a 32 bit variable doesn't extend to passing 64 bits in a 32 bit bit variable and creating a 64 bit function would require casts to allow being saved in the array so a sutrcture is used that can take different function pointers.
Having a real 64 bit IO support is really useful for real 64 bit machines (sparc64, alpha...) as the current emulation makes things more complex and is unable to catch some erroneous accesses.
So I strongly support this patch.
Tristan.