From acd1c812b5548c8426e093075362b6d4119db6ac Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Wed, 17 Nov 2010 11:50:09 +0200 Subject: Type-safe ioport callbacks The current ioport callbacks are not type-safe, in that they accept an "opaque" pointer as an argument whose type must match the argument to the registration function; this is not checked by the compiler. This patch adds an alternative that is type-safe. Instead of an opaque argument, both registation and the callback use a new IOPort type. The callback then uses container_of() to access its main structures. Currently the old and new methods exist side by side; once the old way is gone, we can also save a bunch of memory since the new method requires one pointer per ioport instead of 6. Acked-by: Anthony Liguori Signed-off-by: Avi Kivity Signed-off-by: Anthony Liguori --- ioport.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'ioport.h') diff --git a/ioport.h b/ioport.h index 3d3c8a3efd..5ae62a3a2c 100644 --- a/ioport.h +++ b/ioport.h @@ -25,6 +25,7 @@ #define IOPORT_H #include "qemu-common.h" +#include "iorange.h" typedef uint32_t pio_addr_t; #define FMT_pioaddr PRIx32 @@ -36,6 +37,7 @@ typedef uint32_t pio_addr_t; typedef void (IOPortWriteFunc)(void *opaque, uint32_t address, uint32_t data); typedef uint32_t (IOPortReadFunc)(void *opaque, uint32_t address); +void ioport_register(IORange *iorange); int register_ioport_read(pio_addr_t start, int length, int size, IOPortReadFunc *func, void *opaque); int register_ioport_write(pio_addr_t start, int length, int size, -- cgit v1.2.3