4 #include <palacios/vmm_types.h>
7 struct vm_device_io_hook;
8 struct vm_device_mem_hook;
12 // This structure defines an abstract io and/or memory-mapped device
13 // It currently does not define the interaction with actual hardware
19 int (*init_device)(struct vm_device *dev, struct vm_guest *vm);
20 int (*deinit_device)(struct vm_device *dev);
23 int (*reset_device)(struct vm_device *dev);
25 int (*start_device)(struct vm_device *dev);
26 int (*stop_device)(struct vm_device *dev);
30 // To understand how to register these callbacks
33 // Note that callbacks like these are only called
34 // when the port/memory is hooked as EMULATED
39 // If your device is I/O mapped, this function will
40 // be called on an I/O read
43 int (*read_io_port)(ushort_t port_read,
46 struct vm_device *dev);
49 // If your device is I/O mapped, this function will
50 // be called on an I/O write
53 int (*write_io_port)(ushort_t port_written,
56 struct vm_device *dev);
60 // If your device is memory mapped, this function will
61 // be called on an memory read
64 int (*read_mapped_memory)(void *address_read,
67 struct vm_device *dev);
70 // If your device is memory mapped, this function will
71 // be called on an memory read
74 int (*write_mapped_memory)(void *address_written,
77 struct vm_device *dev);
80 //int (*save_device)(struct vm_device *dev, struct *iostream);
81 //int (*restore_device)(struct vm_device *dev, struct *iostream);
83 struct guest_info *vm;
87 // Do not touch anything below this!
89 struct vm_device *next, *prev;
91 struct vm_device_io_hook *io_hooks;
92 struct vm_device_mem_hook *mem_hooks;