64 bit device I/O
RFC 1/1 64 bit device I/O
Here is my second proof of concept attempt at supporting 64 bit device I/O.
This attempt doesn't require changing all devices to add a forth function for 64 bit I/O unless actually needed. Unfortunately it does require an ugly cast when 64 bit is required.
This has been tested only on sparc32 and only the slavio_timer hw device has been converted to support 64 bit I/O.
All other architectures should work as before except when 64 bit I/O is performed. They will now get an unassigned access error because there is no 64 bit callback defined by default. Adding a 64 bit callback and using cpu_register_io_memory64 to register the new callback will fix it. See slavio_timer.c to to see how the new callback is registered.
Comments welcome.
softmmu_template.h +2 -14
@@ -68,13 +68,7 @@#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 + res = ((CPUReadMemoryFunc64 *)(io_mem_read[index][3 ]))(io_mem_opaque[index], physaddr);#endif /* SHIFT > 2 */ #ifdef USE_KQEMU env->last_io_time =cpu_get_time_fast ();
@@ -213,13 +207,7 @@#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 + ((CPUWriteMemoryFunc64 *)(io_mem_write[index][3 ]))(io_mem_opaque[index], physaddr, val);#endif /* SHIFT > 2 */ #ifdef USE_KQEMU env->last_io_time =cpu_get_time_fast ();
exec.c +199 -43
408 lines not on this page · raw message
slavio_timer.c +53 -4
83 lines not on this page · raw message
cpu-all.h +8 -0
@@ -891,6 +891,9 @@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); + void cpu_register_physical_memory_offset(target_phys_addr_t start_addr, ram_addr_t size, ram_addr_t phys_offset,
@@ -909,7 +912,12 @@ CPUReadMemoryFunc **mem_read, CPUWriteMemoryFunc **mem_write, void *opaque); +int cpu_register_io_memory64 (int io_index, +CPUReadMemoryFunc **mem_read, +CPUWriteMemoryFunc **mem_write, +void *opaque);void cpu_unregister_io_memory (int table_address); +void cpu_unregister_io_memory64 (int table_address);CPUWriteMemoryFunc **cpu_get_io_memory_write (int io_index);CPUReadMemoryFunc **cpu_get_io_memory_read (int io_index);
Quoted 18 lines · Robert Reif
Here is my second proof of concept attempt at supporting 64 bit device I/O.
This attempt doesn't require changing all devices to add a forth function for 64 bit I/O unless actually needed. Unfortunately it does require an ugly cast when 64 bit is required.
This has been tested only on sparc32 and only the
slavio_timerhw device has been converted to support 64 bit I/O.All other architectures should work as before except when 64 bit I/O is performed. They will now get an unassigned access error because there is no 64 bit callback defined by default. Adding a 64 bit callback and using
cpu_register_io_memory64to register the new callback will fix it. Seeslavio_timer.cto to see how the new callback is registered.
Quoted 1 line
Comments welcome.
This is a bug fix version of the previous patch.
exec.c subpage_readlen64 had a truncation bug
slavio_timer.c had a timer limit bug
With this patch, a sparc32 SS5-170 openboot image passes the 64bit user timer self test. I have also tested it on sparc32 with an unreleased hw device that does extensive 64 bit i/o.
Please let me know what other ports and hardware configurations perform 64 bit i/o so I can make the necessary changes for inclusion into QEMU.
softmmu_template.h +2 -14
@@ -68,13 +68,7 @@#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 + res = ((CPUReadMemoryFunc64 *)(io_mem_read[index][3 ]))(io_mem_opaque[index], physaddr);#endif /* SHIFT > 2 */ #ifdef USE_KQEMU env->last_io_time =cpu_get_time_fast ();
@@ -213,13 +207,7 @@#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 + ((CPUWriteMemoryFunc64 *)(io_mem_write[index][3 ]))(io_mem_opaque[index], physaddr, val);#endif /* SHIFT > 2 */ #ifdef USE_KQEMU env->last_io_time =cpu_get_time_fast ();
exec.c +204 -48
445 lines not on this page · raw message
slavio_timer.c +66 -4
105 lines not on this page · raw message
cpu-all.h +8 -0
@@ -891,6 +891,9 @@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); + void cpu_register_physical_memory_offset(target_phys_addr_t start_addr, ram_addr_t size, ram_addr_t phys_offset,
@@ -909,7 +912,12 @@ CPUReadMemoryFunc **mem_read, CPUWriteMemoryFunc **mem_write, void *opaque); +int cpu_register_io_memory64 (int io_index, +CPUReadMemoryFunc **mem_read, +CPUWriteMemoryFunc **mem_write, +void *opaque);void cpu_unregister_io_memory (int table_address); +void cpu_unregister_io_memory64 (int table_address);CPUWriteMemoryFunc **cpu_get_io_memory_write (int io_index);CPUReadMemoryFunc **cpu_get_io_memory_read (int io_index);
Quoted 26 lines · Robert Reif
Quoted 18 lines · Robert Reif
Here is my second proof of concept attempt at supporting 64 bit device I/O.
This attempt doesn't require changing all devices to add a forth function for 64 bit I/O unless actually needed. Unfortunately it does require an ugly cast when 64 bit is required.
This has been tested only on sparc32 and only the
slavio_timerhw device has been converted to support 64 bit I/O.All other architectures should work as before except when 64 bit I/O is performed. They will now get an unassigned access error because there is no 64 bit callback defined by default. Adding a 64 bit callback and using
cpu_register_io_memory64to register the new callback will fix it. Seeslavio_timer.cto to see how the new callback is registered.Quoted 2 lines
Comments welcome.
This is a bug fix version of the previous patch.
exec.csubpage_readlen64had a truncation bug
slavio_timer.chad a timer limit bug
Quoted 8 lines
With this patch, a sparc32 SS5-170 openboot image passes the 64bit user timer self test. I have also tested it on sparc32 with an unreleased hw device that does extensive 64 bit i/o.
Please let me know what other ports and hardware configurations perform 64 bit i/o so I can make the necessary changes for inclusion into QEMU.
Sparc64 would use 64 bit IO extensively for most native device registers, but so far there is only the PCI host bridge and even that is not fully implemented. Accessing the registers with 8/16/32 bit operations should trigger a fault.
Quoted 6 lines
+static CPUReadMemoryFunc *unassigned_mem_read[4] = {
unassigned_mem_readb,unassigned_mem_readw,unassigned_mem_readl,
+ (CPUReadMemoryFunc*)unassigned_mem_readq,
};
Would it be better to use a structure with four elements with correct types (including uint8/16_t) instead of the cast? This could also be limited to only cpu_register_io_memory64.
Quoted 6 lines · Blue Swirl
Would it be better to use a structure with four elements with correct types (including uint8/16_t) instead of the cast? This could also be limited to only
cpu_register_io_memory64.
This is what I would prefer and is what the first version of this patch
that I submitted a year ago did: http://landley.net/qemu/2008-01-01.html
The problem is that every hardware driver would need to be changed and some of them would need to be changed drastically because they use the same functions for all three data sizes. No one seemed interested in this approach so I abandoned it.
This approach while uglier requires no changes to the hardware drivers unless they need 64 bit support so I hoped it would be better received.
Quoted 10 lines · Robert Reif
Quoted 6 lines · Blue Swirl
Would it be better to use a structure with four elements with correct types (including uint8/16_t) instead of the cast? This could also be limited to only
cpu_register_io_memory64.This is what I would prefer and is what the first version of this patch
that I submitted a year ago did: http://landley.net/qemu/2008-01-01.html
Quoted 7 lines
The problem is that every hardware driver would need to be changed and some of them would need to be changed drastically because they use the same functions for all three data sizes. No one seemed interested in this approach so I abandoned it.
This approach while uglier requires no changes to the hardware drivers unless they need 64 bit support so I hoped it would be better received.
You might try adding a struct-based 4-function interface, and implementing the array-based 3-function interface on top of that. This way, no immediate changes would be needed for devices, but we could change them incrementally from the old interface to the new interface.
Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.
Quoted 16 lines · Avi Kivity
Quoted 15 lines · Robert Reif
Quoted 6 lines · Blue Swirl
Would it be better to use a structure with four elements with correct types (including uint8/16_t) instead of the cast? This could also be limited to only
cpu_register_io_memory64.This is what I would prefer and is what the first version of this patch
that I submitted a year ago did: http://landley.net/qemu/2008-01-01.htmlThe problem is that every hardware driver would need to be changed and some of them would need to be changed drastically because they use the same functions for all three data sizes. No one seemed interested in this approach so I abandoned it.
Quoted 6 lines
Quoted 2 lines
This approach while uglier requires no changes to the hardware drivers unless they need 64 bit support so I hoped it would be better received.
You might try adding a struct-based 4-function interface, and implementing the array-based 3-function interface on top of that. This way, no immediate changes would be needed for devices, but we could change them incrementally from the old interface to the new interface.
I just tried this by changing exec.c to use a structure internally but still provide an array interface through the old interface and it's a real nice cleanup until you have to deal with subpages. Changing the subpage code over to a structure doesn't really improve it any.
Why is the subpage code now saving so much redundant stuff compared to what it initially started out as. Is it because that one VGA driver is messing with the internals of QEMU?
Quoted 34 lines · Robert Reif
Quoted 11 lines · Avi Kivity
Quoted 9 lines · Robert Reif
Quoted 7 lines · Blue Swirl
Would it be better to use a structure with four elements with correct types (including uint8/16_t) instead of the cast? This could also be limited to only
cpu_register_io_memory64.Quoted 2 lines
Quoted 2 lines
This is what I would prefer and is what the first version of this patch that I submitted a year ago did:
http://landley.net/qemu/2008-01-01.html
Quoted 4 lines
Quoted 4 lines
The problem is that every hardware driver would need to be changed and some of them would need to be changed drastically because they use the same functions for all three data sizes. No one seemed interested in
this
Quoted 7 lines
Quoted 5 lines
approach so I abandoned it.
This approach while uglier requires no changes to the hardware drivers unless they need 64 bit support so I hoped it would be better received.
You might try adding a struct-based 4-function interface, and implementing
the array-based 3-function interface on top of that. This way, no immediate changes would be needed for devices, but we could change them incrementally from the old interface to the new interface.
Quoted 3 lines
Quoted 8 lines
I just tried this by changing
exec.cto use a structure internally but
still provide an array interface through the old interface and it's a real nice cleanup until you have to deal with subpages. Changing the subpage code over to a structure doesn't really improve it any.Why is the subpage code now saving so much redundant stuff compared to what
it initially started out as. Is it because that one VGA driver is messing with the internals of QEMU?
Also CPURead/WriteMemoryFunc structure could be read only, except for these VGA hacks.
Quoted 10 lines · Robert Reif
Quoted 6 lines · Blue Swirl
Would it be better to use a structure with four elements with correct types (including uint8/16_t) instead of the cast? This could also be limited to only
cpu_register_io_memory64.This is what I would prefer and is what the first version of this patch
that I submitted a year ago did: http://landley.net/qemu/2008-01-01.html
Quoted 7 lines
The problem is that every hardware driver would need to be changed and some of them would need to be changed drastically because they use the same functions for all three data sizes. No one seemed interested in this approach so I abandoned it.
This approach while uglier requires no changes to the hardware drivers unless they need 64 bit support so I hoped it would be better received.
You might try adding a struct-based 4-function interface, and implementing the array-based 3-function interface on top of that. This way, no immediate changes would be needed for devices, but we could change them incrementally from the old interface to the new interface.
Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.
Quoted 10 lines
Quoted 3 lines
Would it be better to use a structure with four elements with correct types (including uint8/16_t) instead of the cast? This could also be limited to only
cpu_register_io_memory64.This is what I would prefer and is what the first version of this patch
that I submitted a year ago did: http://landley.net/qemu/2008-01-01.htmlThe problem is that every hardware driver would need to be changed and some of them would need to be changed drastically because they use the same functions for all three data sizes.
You can always use the same prototype for the first 3 functions. In practice there's very little benefit for using types smaller than 32-bit on machines capable of runnit qemu.
Paul