xref: /qemu/include/hw/nvram/mac_nvram.h (revision 343bd85a40811f0522063e58d565c6965bd81e00)
13cbee15bSj_mayer /*
23cbee15bSj_mayer  * QEMU PowerMac emulation shared definitions and prototypes
33cbee15bSj_mayer  *
43cbee15bSj_mayer  * Copyright (c) 2004-2007 Fabrice Bellard
53cbee15bSj_mayer  * Copyright (c) 2007 Jocelyn Mayer
63cbee15bSj_mayer  *
73cbee15bSj_mayer  * Permission is hereby granted, free of charge, to any person obtaining a copy
83cbee15bSj_mayer  * of this software and associated documentation files (the "Software"), to deal
93cbee15bSj_mayer  * in the Software without restriction, including without limitation the rights
103cbee15bSj_mayer  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
113cbee15bSj_mayer  * copies of the Software, and to permit persons to whom the Software is
123cbee15bSj_mayer  * furnished to do so, subject to the following conditions:
133cbee15bSj_mayer  *
143cbee15bSj_mayer  * The above copyright notice and this permission notice shall be included in
153cbee15bSj_mayer  * all copies or substantial portions of the Software.
163cbee15bSj_mayer  *
173cbee15bSj_mayer  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
183cbee15bSj_mayer  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
193cbee15bSj_mayer  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
203cbee15bSj_mayer  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
213cbee15bSj_mayer  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
223cbee15bSj_mayer  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
233cbee15bSj_mayer  * THE SOFTWARE.
243cbee15bSj_mayer  */
252a6a4076SMarkus Armbruster 
262a6a4076SMarkus Armbruster #ifndef PPC_MAC_H
272a6a4076SMarkus Armbruster #define PPC_MAC_H
283cbee15bSj_mayer 
29022c62cbSPaolo Bonzini #include "exec/memory.h"
3095ed3b7cSAndreas Färber #include "hw/sysbus.h"
3107a7484eSAndreas Färber #include "hw/ide/internal.h"
320d09e41aSPaolo Bonzini #include "hw/input/adb.h"
3309a57347SMark Cave-Ayland #include "hw/misc/mos6522.h"
341e39101cSAvi Kivity 
353cbee15bSj_mayer /* SMP is not enabled, for now */
363cbee15bSj_mayer #define MAX_CPUS 1
373cbee15bSj_mayer 
38bba831e8SPaul Brook #define BIOS_SIZE     (1024 * 1024)
393cbee15bSj_mayer #define NVRAM_SIZE        0x2000
40e5d01b06Saurel32 #define PROM_FILENAME    "openbios-ppc"
41992e5acdSblueswir1 #define PROM_ADDR         0xfff00000
423cbee15bSj_mayer 
433cbee15bSj_mayer #define KERNEL_LOAD_ADDR 0x01000000
44b9e17a34SAlexander Graf #define KERNEL_GAP       0x00100000
453cbee15bSj_mayer 
467fa9ae1aSblueswir1 #define ESCC_CLOCK 3686400
477fa9ae1aSblueswir1 
4809a57347SMark Cave-Ayland 
493cbee15bSj_mayer /* MacIO */
50d037834aSAndreas Färber #define TYPE_OLDWORLD_MACIO "macio-oldworld"
51d037834aSAndreas Färber #define TYPE_NEWWORLD_MACIO "macio-newworld"
5207a7484eSAndreas Färber 
5307a7484eSAndreas Färber #define TYPE_MACIO_IDE "macio-ide"
5407a7484eSAndreas Färber #define MACIO_IDE(obj) OBJECT_CHECK(MACIOIDEState, (obj), TYPE_MACIO_IDE)
5507a7484eSAndreas Färber 
5607a7484eSAndreas Färber typedef struct MACIOIDEState {
5707a7484eSAndreas Färber     /*< private >*/
5807a7484eSAndreas Färber     SysBusDevice parent_obj;
5907a7484eSAndreas Färber     /*< public >*/
600fc84331SMark Cave-Ayland     uint32_t channel;
614f7265ffSBenjamin Herrenschmidt     qemu_irq real_ide_irq;
624f7265ffSBenjamin Herrenschmidt     qemu_irq real_dma_irq;
634f7265ffSBenjamin Herrenschmidt     qemu_irq ide_irq;
6407a7484eSAndreas Färber     qemu_irq dma_irq;
6507a7484eSAndreas Färber 
6607a7484eSAndreas Färber     MemoryRegion mem;
6707a7484eSAndreas Färber     IDEBus bus;
684aa3510fSAlexander Graf     IDEDMA dma;
694aa3510fSAlexander Graf     void *dbdma;
70cae32357SAlexander Graf     bool dma_active;
714f7265ffSBenjamin Herrenschmidt     uint32_t timing_reg;
724f7265ffSBenjamin Herrenschmidt     uint32_t irq_reg;
7307a7484eSAndreas Färber } MACIOIDEState;
7407a7484eSAndreas Färber 
7507a7484eSAndreas Färber void macio_ide_init_drives(MACIOIDEState *ide, DriveInfo **hd_table);
76e451b85fSMark Cave-Ayland void macio_ide_register_dma(MACIOIDEState *ide);
7707a7484eSAndreas Färber 
78d037834aSAndreas Färber void macio_init(PCIDevice *dev,
79343bd85aSMark Cave-Ayland                 MemoryRegion *pic_mem);
803cbee15bSj_mayer 
813cbee15bSj_mayer /* Heathrow PIC */
8223c5e4caSAvi Kivity qemu_irq *heathrow_pic_init(MemoryRegion **pmem,
833cbee15bSj_mayer                             int nb_cpus, qemu_irq **irqs);
843cbee15bSj_mayer 
853cbee15bSj_mayer /* Grackle PCI */
860e655047SAndreas Färber #define TYPE_GRACKLE_PCI_HOST_BRIDGE "grackle-pcihost"
871e39101cSAvi Kivity PCIBus *pci_grackle_init(uint32_t base, qemu_irq *pic,
88aee97b84SAvi Kivity                          MemoryRegion *address_space_mem,
89aee97b84SAvi Kivity                          MemoryRegion *address_space_io);
903cbee15bSj_mayer 
913cbee15bSj_mayer /* UniNorth PCI */
92aee97b84SAvi Kivity PCIBus *pci_pmac_init(qemu_irq *pic,
93aee97b84SAvi Kivity                       MemoryRegion *address_space_mem,
94aee97b84SAvi Kivity                       MemoryRegion *address_space_io);
95aee97b84SAvi Kivity PCIBus *pci_pmac_u3_init(qemu_irq *pic,
96aee97b84SAvi Kivity                          MemoryRegion *address_space_mem,
97aee97b84SAvi Kivity                          MemoryRegion *address_space_io);
983cbee15bSj_mayer 
993cbee15bSj_mayer /* Mac NVRAM */
10095ed3b7cSAndreas Färber #define TYPE_MACIO_NVRAM "macio-nvram"
10195ed3b7cSAndreas Färber #define MACIO_NVRAM(obj) \
10295ed3b7cSAndreas Färber     OBJECT_CHECK(MacIONVRAMState, (obj), TYPE_MACIO_NVRAM)
1033cbee15bSj_mayer 
10495ed3b7cSAndreas Färber typedef struct MacIONVRAMState {
10595ed3b7cSAndreas Färber     /*< private >*/
10695ed3b7cSAndreas Färber     SysBusDevice parent_obj;
10795ed3b7cSAndreas Färber     /*< public >*/
10895ed3b7cSAndreas Färber 
10995ed3b7cSAndreas Färber     uint32_t size;
11095ed3b7cSAndreas Färber     uint32_t it_shift;
11195ed3b7cSAndreas Färber 
11295ed3b7cSAndreas Färber     MemoryRegion mem;
11395ed3b7cSAndreas Färber     uint8_t *data;
11495ed3b7cSAndreas Färber } MacIONVRAMState;
11595ed3b7cSAndreas Färber 
1163cbee15bSj_mayer void pmac_format_nvram_partition (MacIONVRAMState *nvr, int len);
1172a6a4076SMarkus Armbruster #endif /* PPC_MAC_H */
118