/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 42 - (show annotations)
Mon Oct 8 16:22:32 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 6498 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.1613 2007/06/15 20:11:26 debug Exp $
20070501	Continuing a little on m88k disassembly (control registers,
		more instructions).
		Adding a dummy mvme88k machine mode.
20070502	Re-adding MIPS load/store alignment exceptions.
20070503	Implementing more of the M88K disassembly code.
20070504	Adding disassembly of some more M88K load/store instructions.
		Implementing some relatively simple M88K instructions (br.n,
		xor[.u] imm, and[.u] imm).
20070505	Implementing M88K three-register and, or, xor, and jmp[.n],
		bsr[.n] including function call trace stuff.
		Applying a patch from Bruce M. Simpson which implements the
		SYSCON_BOARD_CPU_CLOCK_FREQ_ID object of the syscon call in
		the yamon PROM emulation.
20070506	Implementing M88K bb0[.n] and bb1[.n], and skeletons for
		ldcr and stcr (although no control regs are implemented yet).
20070509	Found and fixed the bug which caused Linux for QEMU_MIPS to
		stop working in 0.4.5.1: It was a faulty change to the MIPS
		'sc' and 'scd' instructions I made while going through gcc -W
		warnings on 20070428.
20070510	Updating the Linux/QEMU_MIPS section in guestoses.html to
		use mips-test-0.2.tar.gz instead of 0.1.
		A big thank you to Miod Vallat for sending me M88K manuals.
		Implementing more M88K instructions (addu, subu, div[u], mulu,
		ext[u], clr, set, cmp).
20070511	Fixing bugs in the M88K "and" and "and.u" instructions (found
		by comparing against the manual).
		Implementing more M88K instructions (mask[.u], mak, bcnd (auto-
		generated)) and some more control register details.
		Cleanup: Removing the experimental AVR emulation mode and
		corresponding devices; AVR emulation wasn't really meaningful.
		Implementing autogeneration of most M88K loads/stores. The
		rectangle drawing demo (with -O0) for M88K runs :-)
		Beginning on M88K exception handling.
		More M88K instructions: tb0, tb1, rte, sub, jsr[.n].
		Adding some skeleton MVME PROM ("BUG") emulation.
20070512	Fixing a bug in the M88K cmp instruction.
		Adding the M88K lda (scaled register) instruction.
		Fixing bugs in 64-bit (32-bit pairs) M88K loads/stores.
		Removing the unused tick_hz stuff from the machine struct.
		Implementing the M88K xmem instruction. OpenBSD/mvme88k gets
		far enough to display the Copyright banner :-)
		Implementing subu.co (guess), addu.co, addu.ci, ff0, and ff1.
		Adding a dev_mvme187, for MVME187-specific devices/registers.
		OpenBSD/mvme88k prints more boot messages. :)
20070515	Continuing on MVME187 emulation (adding more devices, beginning
		on the CMMUs, etc).
		Adding the M88K and.c, xor.c, and or.c instructions, and making
		sure that mul, div, etc cause exceptions if executed when SFD1
		is disabled.
20070517	Continuing on M88K and MVME187 emulation in general; moving
		the CMMU registers to the CPU struct, separating dev_pcc2 from
		dev_mvme187, and beginning on memory_m88k.c (BATC and PATC).
		Fixing a bug in 64-bit (32-bit pairs) M88K fast stores.
		Implementing the clock part of dev_mk48txx.
		Implementing the M88K fstcr and xcr instructions.
		Implementing m88k_cpu_tlbdump().
		Beginning on the implementation of a separate address space
		for M88K .usr loads/stores.
20070520	Removing the non-working (skeleton) Sandpoint, SonyNEWS, SHARK
		Dnard, and Zaurus machine modes.
		Experimenting with dyntrans to_be_translated read-ahead. It
		seems to give a very small performance increase for MIPS
		emulation, but a large performance degradation for SuperH. Hm.
20070522	Disabling correct SuperH ITLB emulation; it does not seem to be
		necessary in order to let SH4 guest OSes run, and it slows down
		userspace code.
		Implementing "samepage" branches for SuperH emulation, and some
		other minor speed hacks.
20070525	Continuing on M88K memory-related stuff: exceptions, memory
		transaction register contents, etc.
		Implementing the M88K subu.ci instruction.
		Removing the non-working (skeleton) Iyonix machine mode.
		OpenBSD/mvme88k reaches userland :-), starts executing
		/sbin/init's instructions, and issues a few syscalls, before
		crashing.
20070526	Fixing bugs in dev_mk48txx, so that OpenBSD/mvme88k detects
		the correct time-of-day.
		Implementing a generic IRQ controller for the test machines
		(dev_irqc), similar to a proposed patch from Petr Stepan.
		Experimenting some more with translation read-ahead.
		Adding an "expect" script for automated OpenBSD/landisk
		install regression/performance tests.
20070527	Adding a dummy mmEye (SH3) machine mode skeleton.
		FINALLY found the strange M88K bug I have been hunting: I had
		not emulated the SNIP value for exceptions occurring in
		branch delay slots correctly.
		Implementing correct exceptions for 64-bit M88K loads/stores.
		Address to symbol lookups are now disabled when M88K is
		running in usermode (because usermode addresses don't have
		anything to do with supervisor addresses).
20070531	Removing the mmEye machine mode skeleton.
20070604	Some minor code cleanup.
20070605	Moving src/useremul.c into a subdir (src/useremul/), and
		cleaning up some more legacy constructs.
		Adding -Wstrict-aliasing and -fstrict-aliasing detection to
		the configure script.
20070606	Adding a check for broken GCC on Solaris to the configure
		script. (GCC 3.4.3 on Solaris cannot handle static variables
		which are initialized to 0 or NULL. :-/)
		Removing the old (non-working) ARC emulation modes: NEC RD94,
		R94, R96, and R98, and the last traces of Olivetti M700 and
		Deskstation Tyne.
		Removing the non-working skeleton WDSC device (dev_wdsc).
20070607	Thinking about how to use the host's cc + ld at runtime to
		generate native code. (See experiments/native_cc_ld_test.i
		for an example.)
20070608	Adding a program counter sampling timer, which could be useful
		for native code generation experiments.
		The KN02_CSR_NRMMOD bit in the DECstation 5000/200 (KN02) CSR
		should always be set, to allow a 5000/200 PROM to boot.
20070609	Moving out breakpoint details from the machine struct into
		a helper struct, and removing the limit on max nr of
		breakpoints.
20070610	Moving out tick functions into a helper struct as well (which
		also gets rid of the max limit).
20070612	FINALLY figured out why Debian/DECstation stopped working when
		translation read-ahead was enabled: in src/memory_rw.c, the
		call to invalidate_code_translation was made also if the
		memory access was an instruction load (if the page was mapped
		as writable); it shouldn't be called in that case.
20070613	Implementing some more MIPS32/64 revision 2 instructions: di,
		ei, ext, dext, dextm, dextu, and ins.
20070614	Implementing an instruction combination for the NetBSD/arm
		idle loop (making the host not use any cpu if NetBSD/arm
		inside the emulator is not using any cpu).
		Increasing the nr of ARM VPH entries from 128 to 384.
20070615	Removing the ENABLE_arch stuff from the configure script, so
		that all included architectures are included in both release
		and development builds.
		Moving memory related helper functions from misc.c to memory.c.
		Adding preliminary instructions for netbooting NetBSD/pmppc to
		guestoses.html; it doesn't work yet, there are weird timeouts.
		Beginning a total rewrite of the userland emulation modes
		(removing all emulation modes, beginning from scratch with
		NetBSD/MIPS and FreeBSD/Alpha only).
20070616	After fixing a bug in the DEC21143 NIC (the TDSTAT_OWN bit was
		only cleared for the last segment when transmitting, not all
		segments), NetBSD/pmppc boots with root-on-nfs without the
		timeouts. Updating guestoses.html.
		Removing the skeleton PSP (Playstation Portable) mode.
		Moving X11-related stuff in the machine struct into a helper
		struct.
		Cleanup of out-of-memory checks, to use a new CHECK_ALLOCATION
		macro (which prints a meaningful error message).
		Adding a COMMENT to each machine and device (for automagic
		.index comment generation).
		Doing regression testing for the next release.

==============  RELEASE 0.4.6  ==============


1 /*
2 * Copyright (C) 2005-2007 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 * $Id: machine_macppc.c,v 1.16 2007/06/15 18:08:10 debug Exp $
29 *
30 * COMMENT: Generic PowerPC-based Macintosh machines
31 *
32 * See also:
33 *
34 * NetBSD/macppc (http://www.netbsd.org/ports/macppc/)
35 * OpenBSD/macppc (http://www.openbsd.org/macppc.html)
36 *
37 * Currently, these are skeletons for generic PowerMac G3, G4, and G5 systems.
38 * They do not model real PowerMacs, but should be enough to begin
39 * experimenting with running NetBSD/macppc and OpenBSD/macppc.
40 */
41
42 #include <stdio.h>
43 #include <stdlib.h>
44 #include <string.h>
45
46 #include "bus_pci.h"
47 #include "cpu.h"
48 #include "device.h"
49 #include "devices.h"
50 #include "machine.h"
51 #include "memory.h"
52 #include "misc.h"
53 #include "of.h"
54
55
56 MACHINE_SETUP(macppc)
57 {
58 char tmpstr[300];
59 struct pci_data *pci_data;
60 struct vfb_data *fb;
61 uint64_t b, a;
62 int i;
63
64 machine->machine_name = "Macintosh (PPC)";
65 if (machine->emulated_hz == 0)
66 machine->emulated_hz = 40000000;
67
68 device_add(machine, "gc addr=0xf3000000");
69
70 pci_data = dev_uninorth_init(machine, machine->memory, 0xe2000000,
71 64 /* isa irq base */, 0 /* pci irq: TODO */);
72
73 /* bus_pci_add(
74 machine, pci_data, machine->memory, 0, 12, 0, "dec21143"); */
75 bus_pci_add(machine, pci_data, machine->memory, 0, 15, 0, "gc_obio");
76
77 if (machine->x11_md.in_use)
78 bus_pci_add(machine, pci_data, machine->memory, 0, 16, 0,
79 "ati_radeon_9200_2");
80
81 snprintf(tmpstr, sizeof(tmpstr), "z8530 addr=0xf3013000 irq="
82 "%s.cpu[%i].gc.lo.23 addr_mult=0x10",
83 machine->path, machine->bootstrap_cpu);
84 machine->main_console_handle = (size_t)device_add(machine, tmpstr);
85
86 fb = dev_fb_init(machine, machine->memory, 0xf1000000,
87 VFB_GENERIC | VFB_REVERSE_START, 1024,768, 1024,768, 8, "ofb");
88
89 device_add(machine, "hammerhead addr=0xf2800000");
90
91 snprintf(tmpstr, sizeof(tmpstr), "adb addr=0xf3016000 irq="
92 "%s.cpu[%i].gc.lo.1", machine->path, machine->bootstrap_cpu);
93 device_add(machine, tmpstr);
94
95 if (!machine->prom_emulation)
96 return;
97
98
99 b = 8 * 1048576; a = b - 0x800;
100
101 of_emul_init(machine, fb, 0xf1000000, 1024, 768);
102 of_emul_init_uninorth(machine);
103
104 if (machine->x11_md.in_use)
105 of_emul_init_adb(machine);
106 else
107 of_emul_init_zs(machine);
108
109 /*
110 * r3 = pointer to boot_args (for the Mach kernel).
111 * See http://darwinsource.opendarwin.org/10.3/
112 * BootX-59/bootx.tproj/include.subproj/boot_args.h
113 * for more info.
114 */
115 cpu->cd.ppc.gpr[3] = a;
116 store_16bit_word(cpu, a + 0x0000, 1); /* revision */
117 store_16bit_word(cpu, a + 0x0002, 2); /* version */
118 store_buf(cpu, a + 0x0004, machine->boot_string_argument, 256);
119 /* 26 dram banks; "long base; long size" */
120 store_32bit_word(cpu, a + 0x0104, 0); /* base */
121 store_32bit_word(cpu, a + 0x0108, machine->physical_ram_in_mb
122 * 256); /* size (in pages) */
123 for (i=8; i<26*8; i+= 4)
124 store_32bit_word(cpu, a + 0x0104 + i, 0);
125 a += (0x104 + 26 * 8);
126 /* Video info: */
127 store_32bit_word(cpu, a+0, 0xf1000000); /* video base */
128 store_32bit_word(cpu, a+4, 0); /* display code (?) */
129 store_32bit_word(cpu, a+8, 1024); /* bytes per pixel row */
130 store_32bit_word(cpu, a+12, 1024); /* width */
131 store_32bit_word(cpu, a+16, 768); /* height */
132 store_32bit_word(cpu, a+20, 8); /* pixel depth */
133 a += 24;
134 store_32bit_word(cpu, a+0, 127); /* gestalt number (TODO) */
135 store_32bit_word(cpu, a+4, 0); /* device tree pointer (TODO)*/
136 store_32bit_word(cpu, a+8, 0); /* device tree length */
137 store_32bit_word(cpu, a+12, b); /* last address of kernel data area */
138
139 /* r4 = "MOSX" (0x4D4F5358) */
140 cpu->cd.ppc.gpr[4] = 0x4D4F5358;
141
142 /*
143 * r5 = OpenFirmware entry point. NOTE: See
144 * cpu_ppc.c for the rest of this semi-ugly hack.
145 */
146 dev_ram_init(machine, cpu->cd.ppc.of_emul_addr,
147 0x1000, DEV_RAM_RAM, 0x0);
148 store_32bit_word(cpu, cpu->cd.ppc.of_emul_addr,
149 0x44ee0002);
150 cpu->cd.ppc.gpr[5] = cpu->cd.ppc.of_emul_addr;
151
152 #if 0
153 /* r6 = args */
154 cpu->cd.ppc.gpr[1] -= 516;
155 cpu->cd.ppc.gpr[6] = cpu->cd.ppc.gpr[1] + 4;
156 store_string(cpu, cpu->cd.ppc.gpr[6],
157 machine->boot_string_argument);
158 /* should be something like '/controller/disk/bsd' */
159
160 /* r7 = length? TODO */
161 cpu->cd.ppc.gpr[7] = 5;
162 #endif
163 }
164
165
166 MACHINE_DEFAULT_CPU(macppc)
167 {
168 switch (machine->machine_subtype) {
169 case MACHINE_MACPPC_G3:
170 machine->cpu_name = strdup("PPC750");
171 break;
172 case MACHINE_MACPPC_G4:
173 machine->cpu_name = strdup("MPC7400");
174 break;
175 case MACHINE_MACPPC_G5:
176 machine->cpu_name = strdup("PPC970");
177 break;
178 }
179 }
180
181
182 MACHINE_DEFAULT_RAM(macppc)
183 {
184 machine->physical_ram_in_mb = 64;
185 }
186
187
188 MACHINE_REGISTER(macppc)
189 {
190 MR_DEFAULT(macppc, "Macintosh", ARCH_PPC, MACHINE_MACPPC);
191
192 machine_entry_add_alias(me, "macppc");
193
194 machine_entry_add_subtype(me, "MacPPC G3", MACHINE_MACPPC_G3,
195 "g3", NULL);
196
197 machine_entry_add_subtype(me, "MacPPC G4", MACHINE_MACPPC_G4,
198 "g4", NULL);
199
200 machine_entry_add_subtype(me, "MacPPC G5", MACHINE_MACPPC_G5,
201 "g5", NULL);
202
203 me->set_default_ram = machine_default_ram_macppc;
204 }
205

  ViewVC Help
Powered by ViewVC 1.1.26