/[gxemul]/trunk/src/machines/machine_macppc.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/src/machines/machine_macppc.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 26 - (hide annotations)
Mon Oct 8 16:20:10 2007 UTC (16 years, 7 months ago) by dpavlin
File MIME type: text/plain
File size: 6267 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.1264 2006/06/25 11:08:04 debug Exp $
20060624	Replacing the error-prone machine type initialization stuff
		with something more reasonable.
		Finally removing the old "cpu_run" kludge; moving around stuff
		in machine.c and emul.c to better suit the dyntrans system.
		Various minor dyntrans cleanups (renaming translate_address to
		translate_v2p, and experimenting with template physpages).
20060625	Removing the speed hack which separated the vph entries into
		two halves (code vs data); things seem a lot more stable now.
		Minor performance hack: R2000/R3000 cache isolation now only
		clears address translations when going into isolation, not
		when going out of it.
		Fixing the MIPS interrupt problems by letting mtc0 immediately
		cause interrupts.

==============  RELEASE 0.4.0.1  ==============


1 dpavlin 22 /*
2     * Copyright (C) 2005-2006 Anders Gavare. All rights reserved.
3     *
4     * Redistribution and use in source and binary forms, with or without
5     * modification, are permitted provided that the following conditions are met:
6     *
7     * 1. Redistributions of source code must retain the above copyright
8     * notice, this list of conditions and the following disclaimer.
9     * 2. Redistributions in binary form must reproduce the above copyright
10     * notice, this list of conditions and the following disclaimer in the
11     * documentation and/or other materials provided with the distribution.
12     * 3. The name of the author may not be used to endorse or promote products
13     * derived from this software without specific prior written permission.
14     *
15     * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16     * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17     * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18     * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19     * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20     * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21     * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22     * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23     * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24     * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25     * SUCH DAMAGE.
26     *
27     *
28 dpavlin 26 * $Id: machine_macppc.c,v 1.5 2006/06/24 10:19:19 debug Exp $
29 dpavlin 24 *
30     * NOTE: Currently, these are skeletons for generic PowerMac G3, G4, and G5
31     * systems. They do not model real PowerMacs, but should be enough to
32     * begin experimenting with NetBSD/macppc and OpenBSD/macppc.
33 dpavlin 22 */
34    
35     #include <stdio.h>
36     #include <string.h>
37    
38     #include "cpu.h"
39     #include "device.h"
40     #include "devices.h"
41     #include "machine.h"
42     #include "machine_interrupts.h"
43     #include "memory.h"
44     #include "misc.h"
45     #include "of.h"
46    
47    
48     MACHINE_SETUP(macppc)
49     {
50     struct pci_data *pci_data;
51     struct vfb_data *fb;
52     uint64_t b, a;
53     int i;
54    
55     /*
56     * NetBSD/macppc (http://www.netbsd.org/Ports/macppc/)
57     * OpenBSD/macppc (http://www.openbsd.org/macppc.html)
58     */
59     machine->machine_name = "Macintosh (PPC)";
60     if (machine->emulated_hz == 0)
61     machine->emulated_hz = 40000000;
62    
63     machine->md_int.gc_data = dev_gc_init(machine, machine->memory,
64     0xf3000000, 64);
65     machine->md_interrupt = gc_interrupt;
66    
67     pci_data = dev_uninorth_init(machine, machine->memory, 0xe2000000,
68     64 /* isa irq base */, 0 /* pci irq: TODO */);
69    
70     bus_pci_add(machine, pci_data, machine->memory, 0, 12, 0, "dec21143");
71     bus_pci_add(machine, pci_data, machine->memory, 0, 15, 0, "gc_obio");
72    
73     if (machine->use_x11)
74     bus_pci_add(machine, pci_data, machine->memory, 0, 16, 0,
75     "ati_radeon_9200_2");
76    
77     machine->main_console_handle = (size_t)device_add(machine,
78     "z8530 addr=0xf3013000 irq=23 dma_irq=8 addr_mult=0x10");
79    
80     fb = dev_fb_init(machine, machine->memory, 0xf1000000,
81     VFB_GENERIC | VFB_REVERSE_START, 1024,768, 1024,768, 8, "ofb");
82    
83     device_add(machine, "hammerhead addr=0xf2800000");
84    
85     device_add(machine, "adb addr=0xf3016000 irq=1");
86    
87     if (!machine->prom_emulation)
88     return;
89    
90    
91     b = 8 * 1048576; a = b - 0x800;
92    
93     of_emul_init(machine, fb, 0xf1000000, 1024, 768);
94     of_emul_init_uninorth(machine);
95    
96     if (machine->use_x11)
97     of_emul_init_adb(machine);
98     else
99     of_emul_init_zs(machine);
100    
101     /*
102     * r3 = pointer to boot_args (for the Mach kernel).
103     * See http://darwinsource.opendarwin.org/10.3/
104     * BootX-59/bootx.tproj/include.subproj/boot_args.h
105     * for more info.
106     */
107     cpu->cd.ppc.gpr[3] = a;
108     store_16bit_word(cpu, a + 0x0000, 1); /* revision */
109     store_16bit_word(cpu, a + 0x0002, 2); /* version */
110     store_buf(cpu, a + 0x0004, machine->boot_string_argument, 256);
111     /* 26 dram banks; "long base; long size" */
112     store_32bit_word(cpu, a + 0x0104, 0); /* base */
113     store_32bit_word(cpu, a + 0x0108, machine->physical_ram_in_mb
114     * 256); /* size (in pages) */
115     for (i=8; i<26*8; i+= 4)
116     store_32bit_word(cpu, a + 0x0104 + i, 0);
117     a += (0x104 + 26 * 8);
118     /* Video info: */
119     store_32bit_word(cpu, a+0, 0xf1000000); /* video base */
120     store_32bit_word(cpu, a+4, 0); /* display code (?) */
121     store_32bit_word(cpu, a+8, 1024); /* bytes per pixel row */
122     store_32bit_word(cpu, a+12, 1024); /* width */
123     store_32bit_word(cpu, a+16, 768); /* height */
124     store_32bit_word(cpu, a+20, 8); /* pixel depth */
125     a += 24;
126     store_32bit_word(cpu, a+0, 127); /* gestalt number (TODO) */
127     store_32bit_word(cpu, a+4, 0); /* device tree pointer (TODO)*/
128     store_32bit_word(cpu, a+8, 0); /* device tree length */
129     store_32bit_word(cpu, a+12, b); /* last address of kernel data area */
130    
131     /* r4 = "MOSX" (0x4D4F5358) */
132     cpu->cd.ppc.gpr[4] = 0x4D4F5358;
133    
134     /*
135     * r5 = OpenFirmware entry point. NOTE: See
136     * cpu_ppc.c for the rest of this semi-ugly hack.
137     */
138     dev_ram_init(machine, cpu->cd.ppc.of_emul_addr,
139     0x1000, DEV_RAM_RAM, 0x0);
140     store_32bit_word(cpu, cpu->cd.ppc.of_emul_addr,
141     0x44ee0002);
142     cpu->cd.ppc.gpr[5] = cpu->cd.ppc.of_emul_addr;
143    
144     #if 0
145     /* r6 = args */
146     cpu->cd.ppc.gpr[1] -= 516;
147     cpu->cd.ppc.gpr[6] = cpu->cd.ppc.gpr[1] + 4;
148     store_string(cpu, cpu->cd.ppc.gpr[6],
149     machine->boot_string_argument);
150     /* should be something like '/controller/disk/bsd' */
151    
152     /* r7 = length? TODO */
153     cpu->cd.ppc.gpr[7] = 5;
154     #endif
155     }
156    
157    
158     MACHINE_DEFAULT_CPU(macppc)
159     {
160     switch (machine->machine_subtype) {
161 dpavlin 24 case MACHINE_MACPPC_G3:
162 dpavlin 22 machine->cpu_name = strdup("PPC750");
163     break;
164 dpavlin 24 case MACHINE_MACPPC_G4:
165     machine->cpu_name = strdup("MPC7400");
166     break;
167 dpavlin 22 case MACHINE_MACPPC_G5:
168     machine->cpu_name = strdup("PPC970");
169     break;
170     }
171     }
172    
173    
174     MACHINE_DEFAULT_RAM(macppc)
175     {
176     machine->physical_ram_in_mb = 64;
177     }
178    
179    
180     MACHINE_REGISTER(macppc)
181     {
182 dpavlin 26 MR_DEFAULT(macppc, "Macintosh", ARCH_PPC, MACHINE_MACPPC);
183    
184     machine_entry_add_alias(me, "macppc");
185    
186     machine_entry_add_subtype(me, "MacPPC G3", MACHINE_MACPPC_G3,
187     "g3", NULL);
188    
189     machine_entry_add_subtype(me, "MacPPC G4", MACHINE_MACPPC_G4,
190     "g4", NULL);
191    
192     machine_entry_add_subtype(me, "MacPPC G5", MACHINE_MACPPC_G5,
193     "g5", NULL);
194    
195 dpavlin 22 me->set_default_ram = machine_default_ram_macppc;
196     }
197    

  ViewVC Help
Powered by ViewVC 1.1.26