mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 16:53:55 -06:00
rwhandler: simplified way to register for mem/io
Some users prefer a single callback with length passed as parameter to using b/w/l callbacks. It would maybe be cleaner to just pass length to existing callbacks but that's a lot of churn. So for now add a wrapper. For convenience use pcibus_t for address so a single callback can be used for pci io and pci memory. I did have to resort to preprocessor to reduce code duplication. It is however slightly more straightforward, and better contained than what we had with pci_host_template.h. Again, it would go away if we just passed len to existing callbacks. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
e73d6e3a02
commit
049f7adbd5
3 changed files with 119 additions and 0 deletions
27
rwhandler.h
Normal file
27
rwhandler.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
#ifndef READ_WRITE_HANDLER_H
|
||||
#define READ_WRITE_HANDLER_H
|
||||
|
||||
#include "qemu-common.h"
|
||||
#include "ioport.h"
|
||||
|
||||
typedef struct ReadWriteHandler ReadWriteHandler;
|
||||
|
||||
/* len is guaranteed to be one of 1, 2 or 4, addr is guaranteed to fit in an
|
||||
* appropriate type (io/memory/etc). They do not need to be range checked. */
|
||||
typedef void WriteHandlerFunc(ReadWriteHandler *, pcibus_t addr,
|
||||
uint32_t value, int len);
|
||||
typedef uint32_t ReadHandlerFunc(ReadWriteHandler *, pcibus_t addr, int len);
|
||||
|
||||
struct ReadWriteHandler {
|
||||
WriteHandlerFunc *write;
|
||||
ReadHandlerFunc *read;
|
||||
};
|
||||
|
||||
/* Helpers for when we want to use a single routine with length. */
|
||||
/* CPU memory handler: both read and write must be present. */
|
||||
int cpu_register_io_memory_simple(ReadWriteHandler *);
|
||||
/* io port handler: can supply only read or write handlers. */
|
||||
int register_ioport_simple(ReadWriteHandler *,
|
||||
pio_addr_t start, int length, int size);
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue