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