xref: /qemu/include/hw/misc/macio/macio.h (revision db1015e92e04835c9eb50c29625fe566d1202dbd)
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/pci/pci.h"
31 #include "hw/ide/internal.h"
32 #include "hw/intc/heathrow_pic.h"
33 #include "hw/misc/macio/cuda.h"
34 #include "hw/misc/macio/gpio.h"
35 #include "hw/misc/macio/pmu.h"
36 #include "hw/ppc/mac.h"
37 #include "hw/ppc/mac_dbdma.h"
38 #include "hw/ppc/openpic.h"
39 #include "qom/object.h"
40 
41 /* MacIO virtual bus */
42 #define TYPE_MACIO_BUS "macio-bus"
43 typedef struct MacIOBusState MacIOBusState;
44 #define MACIO_BUS(obj) OBJECT_CHECK(MacIOBusState, (obj), TYPE_MACIO_BUS)
45 
46 struct MacIOBusState {
47     /*< private >*/
48     BusState parent_obj;
49 };
50 
51 /* MacIO IDE */
52 #define TYPE_MACIO_IDE "macio-ide"
53 typedef struct MACIOIDEState MACIOIDEState;
54 #define MACIO_IDE(obj) OBJECT_CHECK(MACIOIDEState, (obj), TYPE_MACIO_IDE)
55 
56 struct MACIOIDEState {
57     /*< private >*/
58     SysBusDevice parent_obj;
59     /*< public >*/
60     uint32_t addr;
61     uint32_t channel;
62     qemu_irq real_ide_irq;
63     qemu_irq real_dma_irq;
64     qemu_irq ide_irq;
65     qemu_irq dma_irq;
66 
67     MemoryRegion mem;
68     IDEBus bus;
69     IDEDMA dma;
70     void *dbdma;
71     bool dma_active;
72     uint32_t timing_reg;
73     uint32_t irq_reg;
74 };
75 
76 void macio_ide_init_drives(MACIOIDEState *ide, DriveInfo **hd_table);
77 void macio_ide_register_dma(MACIOIDEState *ide);
78 
79 #define TYPE_MACIO "macio"
80 typedef struct MacIOState MacIOState;
81 #define MACIO(obj) OBJECT_CHECK(MacIOState, (obj), TYPE_MACIO)
82 
83 struct MacIOState {
84     /*< private >*/
85     PCIDevice parent;
86     /*< public >*/
87 
88     MacIOBusState macio_bus;
89     MemoryRegion bar;
90     CUDAState cuda;
91     PMUState pmu;
92     DBDMAState dbdma;
93     ESCCState escc;
94     uint64_t frequency;
95 };
96 
97 #define TYPE_OLDWORLD_MACIO "macio-oldworld"
98 typedef struct OldWorldMacIOState OldWorldMacIOState;
99 #define OLDWORLD_MACIO(obj) \
100     OBJECT_CHECK(OldWorldMacIOState, (obj), TYPE_OLDWORLD_MACIO)
101 
102 struct OldWorldMacIOState {
103     /*< private >*/
104     MacIOState parent_obj;
105     /*< public >*/
106 
107     HeathrowState *pic;
108 
109     MacIONVRAMState nvram;
110     MACIOIDEState ide[2];
111 };
112 
113 #define TYPE_NEWWORLD_MACIO "macio-newworld"
114 typedef struct NewWorldMacIOState NewWorldMacIOState;
115 #define NEWWORLD_MACIO(obj) \
116     OBJECT_CHECK(NewWorldMacIOState, (obj), TYPE_NEWWORLD_MACIO)
117 
118 struct NewWorldMacIOState {
119     /*< private >*/
120     MacIOState parent_obj;
121     /*< public >*/
122 
123     bool has_pmu;
124     bool has_adb;
125     OpenPICState *pic;
126     MACIOIDEState ide[2];
127     MacIOGPIOState gpio;
128 };
129 
130 #endif /* MACIO_H */
131