Michael S. Tsirkin | 049f7ad | 2010-01-14 16:00:14 +0200 | [diff] [blame] | 1 | #ifndef READ_WRITE_HANDLER_H |
| 2 | #define READ_WRITE_HANDLER_H |
| 3 | |
| 4 | #include "qemu-common.h" |
| 5 | #include "ioport.h" |
| 6 | |
| 7 | typedef struct ReadWriteHandler ReadWriteHandler; |
| 8 | |
| 9 | /* len is guaranteed to be one of 1, 2 or 4, addr is guaranteed to fit in an |
| 10 | * appropriate type (io/memory/etc). They do not need to be range checked. */ |
| 11 | typedef void WriteHandlerFunc(ReadWriteHandler *, pcibus_t addr, |
| 12 | uint32_t value, int len); |
| 13 | typedef uint32_t ReadHandlerFunc(ReadWriteHandler *, pcibus_t addr, int len); |
| 14 | |
| 15 | struct ReadWriteHandler { |
| 16 | WriteHandlerFunc *write; |
| 17 | ReadHandlerFunc *read; |
| 18 | }; |
| 19 | |
| 20 | /* Helpers for when we want to use a single routine with length. */ |
| 21 | /* CPU memory handler: both read and write must be present. */ |
| 22 | int cpu_register_io_memory_simple(ReadWriteHandler *); |
| 23 | /* io port handler: can supply only read or write handlers. */ |
| 24 | int register_ioport_simple(ReadWriteHandler *, |
| 25 | pio_addr_t start, int length, int size); |
| 26 | |
| 27 | #endif |