xref: /qemu/include/hw/misc/macio/macio.h (revision 2af282ec)
1 /*
2  * PowerMac MacIO device emulation
3  *
4  * Copyright (c) 2005-2007 Fabrice Bellard
5  * Copyright (c) 2007 Jocelyn Mayer
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a copy
8  * of this software and associated documentation files (the "Software"), to deal
9  * in the Software without restriction, including without limitation the rights
10  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11  * copies of the Software, and to permit persons to whom the Software is
12  * furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in
15  * all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23  * THE SOFTWARE.
24  */
25 
26 #ifndef MACIO_H
27 #define MACIO_H
28 
29 #include "hw/char/escc.h"
30 #include "hw/ide/internal.h"
31 #include "hw/intc/heathrow_pic.h"
32 #include "hw/misc/macio/cuda.h"
33 #include "hw/misc/macio/gpio.h"
34 #include "hw/misc/macio/pmu.h"
35 #include "hw/ppc/mac.h"
36 #include "hw/ppc/mac_dbdma.h"
37 #include "hw/ppc/openpic.h"
38 
39 /* MacIO virtual bus */
40 #define TYPE_MACIO_BUS "macio-bus"
41 #define MACIO_BUS(obj) OBJECT_CHECK(MacIOBusState, (obj), TYPE_MACIO_BUS)
42 
43 typedef struct MacIOBusState {
44     /*< private >*/
45     BusState parent_obj;
46 } MacIOBusState;
47 
48 /* MacIO IDE */
49 #define TYPE_MACIO_IDE "macio-ide"
50 #define MACIO_IDE(obj) OBJECT_CHECK(MACIOIDEState, (obj), TYPE_MACIO_IDE)
51 
52 typedef struct MACIOIDEState {
53     /*< private >*/
54     SysBusDevice parent_obj;
55     /*< public >*/
56     uint32_t addr;
57     uint32_t channel;
58     qemu_irq real_ide_irq;
59     qemu_irq real_dma_irq;
60     qemu_irq ide_irq;
61     qemu_irq dma_irq;
62 
63     MemoryRegion mem;
64     IDEBus bus;
65     IDEDMA dma;
66     void *dbdma;
67     bool dma_active;
68     uint32_t timing_reg;
69     uint32_t irq_reg;
70 } MACIOIDEState;
71 
72 void macio_ide_init_drives(MACIOIDEState *ide, DriveInfo **hd_table);
73 void macio_ide_register_dma(MACIOIDEState *ide);
74 
75 #define TYPE_MACIO "macio"
76 #define MACIO(obj) OBJECT_CHECK(MacIOState, (obj), TYPE_MACIO)
77 
78 typedef struct MacIOState {
79     /*< private >*/
80     PCIDevice parent;
81     /*< public >*/
82 
83     MacIOBusState macio_bus;
84     MemoryRegion bar;
85     CUDAState cuda;
86     PMUState pmu;
87     DBDMAState dbdma;
88     ESCCState escc;
89     uint64_t frequency;
90 } MacIOState;
91 
92 #define TYPE_OLDWORLD_MACIO "macio-oldworld"
93 #define OLDWORLD_MACIO(obj) \
94     OBJECT_CHECK(OldWorldMacIOState, (obj), TYPE_OLDWORLD_MACIO)
95 
96 typedef struct OldWorldMacIOState {
97     /*< private >*/
98     MacIOState parent_obj;
99     /*< public >*/
100 
101     HeathrowState *pic;
102 
103     MacIONVRAMState nvram;
104     MACIOIDEState ide[2];
105 } OldWorldMacIOState;
106 
107 #define TYPE_NEWWORLD_MACIO "macio-newworld"
108 #define NEWWORLD_MACIO(obj) \
109     OBJECT_CHECK(NewWorldMacIOState, (obj), TYPE_NEWWORLD_MACIO)
110 
111 typedef struct NewWorldMacIOState {
112     /*< private >*/
113     MacIOState parent_obj;
114     /*< public >*/
115 
116     bool has_pmu;
117     bool has_adb;
118     OpenPICState *pic;
119     MACIOIDEState ide[2];
120     MacIOGPIOState gpio;
121 } NewWorldMacIOState;
122 
123 #endif /* MACIO_H */
124