]>
Commit | Line | Data |
---|---|---|
9c16fa79 AG |
1 | /* |
2 | * QEMU IndustryPack emulation | |
3 | * | |
4 | * Copyright (C) 2012 Igalia, S.L. | |
5 | * Author: Alberto Garcia <[email protected]> | |
6 | * | |
7 | * This code is licensed under the GNU GPL v2 or (at your option) any | |
8 | * later version. | |
9 | */ | |
10 | ||
11 | #ifndef QEMU_IPACK_H | |
12 | #define QEMU_IPACK_H | |
13 | ||
14 | #include "qdev.h" | |
15 | ||
16 | typedef struct IPackBus IPackBus; | |
17 | ||
18 | #define TYPE_IPACK_BUS "IndustryPack" | |
19 | #define IPACK_BUS(obj) OBJECT_CHECK(IPackBus, (obj), TYPE_IPACK_BUS) | |
20 | ||
21 | struct IPackBus { | |
22 | BusState qbus; | |
23 | /* All fields are private */ | |
24 | uint8_t n_slots; | |
25 | uint8_t free_slot; | |
26 | qemu_irq_handler set_irq; | |
27 | }; | |
28 | ||
29 | typedef struct IPackDevice IPackDevice; | |
30 | typedef struct IPackDeviceClass IPackDeviceClass; | |
31 | ||
32 | #define TYPE_IPACK_DEVICE "ipack-device" | |
33 | #define IPACK_DEVICE(obj) \ | |
34 | OBJECT_CHECK(IPackDevice, (obj), TYPE_IPACK_DEVICE) | |
35 | #define IPACK_DEVICE_CLASS(klass) \ | |
36 | OBJECT_CLASS_CHECK(IPackDeviceClass, (klass), TYPE_IPACK_DEVICE) | |
37 | #define IPACK_DEVICE_GET_CLASS(obj) \ | |
38 | OBJECT_GET_CLASS(IPackDeviceClass, (obj), TYPE_IPACK_DEVICE) | |
39 | ||
40 | struct IPackDeviceClass { | |
41 | DeviceClass parent_class; | |
42 | ||
43 | int (*init)(IPackDevice *dev); | |
44 | int (*exit)(IPackDevice *dev); | |
45 | ||
46 | uint16_t (*io_read)(IPackDevice *dev, uint8_t addr); | |
47 | void (*io_write)(IPackDevice *dev, uint8_t addr, uint16_t val); | |
48 | ||
49 | uint16_t (*id_read)(IPackDevice *dev, uint8_t addr); | |
50 | void (*id_write)(IPackDevice *dev, uint8_t addr, uint16_t val); | |
51 | ||
52 | uint16_t (*int_read)(IPackDevice *dev, uint8_t addr); | |
53 | void (*int_write)(IPackDevice *dev, uint8_t addr, uint16_t val); | |
54 | ||
55 | uint16_t (*mem_read16)(IPackDevice *dev, uint32_t addr); | |
56 | void (*mem_write16)(IPackDevice *dev, uint32_t addr, uint16_t val); | |
57 | ||
58 | uint8_t (*mem_read8)(IPackDevice *dev, uint32_t addr); | |
59 | void (*mem_write8)(IPackDevice *dev, uint32_t addr, uint8_t val); | |
60 | }; | |
61 | ||
62 | struct IPackDevice { | |
63 | DeviceState qdev; | |
64 | int32_t slot; | |
65 | /* IRQ objects for the IndustryPack INT0# and INT1# */ | |
66 | qemu_irq *irq; | |
67 | }; | |
68 | ||
69 | extern const VMStateDescription vmstate_ipack_device; | |
70 | ||
71 | #define VMSTATE_IPACK_DEVICE(_field, _state) \ | |
72 | VMSTATE_STRUCT(_field, _state, 1, vmstate_ipack_device, IPackDevice) | |
73 | ||
74 | IPackDevice *ipack_device_find(IPackBus *bus, int32_t slot); | |
75 | void ipack_bus_new_inplace(IPackBus *bus, DeviceState *parent, | |
76 | const char *name, uint8_t n_slots, | |
77 | qemu_irq_handler handler); | |
78 | ||
79 | #endif |