xref: /qemu/include/hw/ppc/ppc4xx.h (revision 68b9a2e38d7183f64dddc5faec9a16c70a4f095c)
1 /*
2  * QEMU PowerPC 4xx emulation shared definitions
3  *
4  * Copyright (c) 2007 Jocelyn Mayer
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 
25 #ifndef PPC4XX_H
26 #define PPC4XX_H
27 
28 #include "hw/ppc/ppc.h"
29 #include "exec/memory.h"
30 #include "hw/sysbus.h"
31 
32 typedef struct {
33     MemoryRegion ram;
34     MemoryRegion container; /* used for clipping */
35     hwaddr base;
36     hwaddr size;
37     uint32_t bcr;
38 } Ppc4xxSdramBank;
39 
40 void ppc4xx_sdram_enable(CPUPPCState *env);
41 
42 void ppc4xx_sdram_banks(MemoryRegion *ram, int nr_banks,
43                         MemoryRegion ram_memories[],
44                         hwaddr ram_bases[], hwaddr ram_sizes[],
45                         const ram_addr_t sdram_bank_sizes[]);
46 
47 void ppc4xx_sdram_init (CPUPPCState *env, qemu_irq irq, int nbanks,
48                         MemoryRegion ram_memories[],
49                         hwaddr *ram_bases,
50                         hwaddr *ram_sizes);
51 
52 #define TYPE_PPC4xx_PCI_HOST_BRIDGE "ppc4xx-pcihost"
53 
54 /*
55  * Generic DCR device
56  */
57 #define TYPE_PPC4xx_DCR_DEVICE "ppc4xx-dcr-device"
58 OBJECT_DECLARE_SIMPLE_TYPE(Ppc4xxDcrDeviceState, PPC4xx_DCR_DEVICE);
59 struct Ppc4xxDcrDeviceState {
60     SysBusDevice parent_obj;
61 
62     PowerPCCPU *cpu;
63 };
64 
65 void ppc4xx_dcr_register(Ppc4xxDcrDeviceState *dev, int dcrn, void *opaque,
66                          dcr_read_cb dcr_read, dcr_write_cb dcr_write);
67 bool ppc4xx_dcr_realize(Ppc4xxDcrDeviceState *dev, PowerPCCPU *cpu,
68                         Error **errp);
69 
70 /* Memory Access Layer (MAL) */
71 #define TYPE_PPC4xx_MAL "ppc4xx-mal"
72 OBJECT_DECLARE_SIMPLE_TYPE(Ppc4xxMalState, PPC4xx_MAL);
73 struct Ppc4xxMalState {
74     Ppc4xxDcrDeviceState parent_obj;
75 
76     qemu_irq irqs[4];
77     uint32_t cfg;
78     uint32_t esr;
79     uint32_t ier;
80     uint32_t txcasr;
81     uint32_t txcarr;
82     uint32_t txeobisr;
83     uint32_t txdeir;
84     uint32_t rxcasr;
85     uint32_t rxcarr;
86     uint32_t rxeobisr;
87     uint32_t rxdeir;
88     uint32_t *txctpr;
89     uint32_t *rxctpr;
90     uint32_t *rcbs;
91     uint8_t  txcnum;
92     uint8_t  rxcnum;
93 };
94 
95 /* Peripheral local bus arbitrer */
96 #define TYPE_PPC4xx_PLB "ppc4xx-plb"
97 OBJECT_DECLARE_SIMPLE_TYPE(Ppc4xxPlbState, PPC4xx_PLB);
98 struct Ppc4xxPlbState {
99     Ppc4xxDcrDeviceState parent_obj;
100 
101     uint32_t acr;
102     uint32_t bear;
103     uint32_t besr;
104 };
105 
106 /* Peripheral controller */
107 #define TYPE_PPC4xx_EBC "ppc4xx-ebc"
108 OBJECT_DECLARE_SIMPLE_TYPE(Ppc4xxEbcState, PPC4xx_EBC);
109 struct Ppc4xxEbcState {
110     Ppc4xxDcrDeviceState parent_obj;
111 
112     uint32_t addr;
113     uint32_t bcr[8];
114     uint32_t bap[8];
115     uint32_t bear;
116     uint32_t besr0;
117     uint32_t besr1;
118     uint32_t cfg;
119 };
120 
121 #endif /* PPC4XX_H */
122