/[gxemul]/trunk/src/promemul/sh_ipl_g.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/promemul/sh_ipl_g.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 36 - (show annotations)
Mon Oct 8 16:21:34 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 3523 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.1497 2007/03/18 03:41:36 debug Exp $
20070224	Minor update to the initialization of the ns16550 in
		machine_walnut.c, to allow that machine type to boot with the
		new interrupt system (although it is still a dummy machine).
		Adding a wdc at 0x14000000 to machine_landisk.c, and fixing
		the SCIF serial interrupts of the SH4 cpu enough to get
		NetBSD/landisk booting from a disk image :-)  Adding a
		preliminary install instruction skeleton to guestoses.html.
20070306	Adding SH-IPL+G PROM emulation, and also passing the "end"
		symbol in r5 on bootup, for Landisk emulation. This is enough
		to get OpenBSD/landisk to install :)  Adding a preliminary
		install instruction skeleton to the documentation. SuperH
		emulation is still shaky, though :-/
20070307	Fixed a strangeness in memory_sh.c (read/write was never
		returned for any page). (Unknown whether this fixes any actual
		problems, though.)
20070308	dev_ram.c fix: invalidate code translations on writes to
		RAM, emulated as separate devices. Linux/dreamcast gets
		further in the boot process than before, but still bugs out
		in userland.
		Fixing bugs in the "stc.l gbr,@-rN" and "ldc.l @rN+,gbr" SuperH 
		instructions (they should NOT check the MD bit), allowing the
		Linux/dreamcast Live CD to reach userland correctly :-)
20070310	Changing the cpu name "Alpha" in src/useremul.c to "21364" to
		unbreak userland syscall emulation of FreeBSD/Alpha binaries.
20070314	Applying a patch from Michael Yaroslavtsev which fixes the
		previous Linux lib64 patch to the configure script.
20070315	Adding a (dummy) sun4v machine type, and SPARC T1 cpu type.
20070316	Creating a new directory, src/disk, and moving diskimage.c
		to it. Separating out bootblock loading stuff from emul.c into
		new files in src/disk.
		Adding some more SPARC registers.
20070318	Preparing/testing for a minirelease, 0.4.4.1.

==============  RELEASE 0.4.4.1  ==============


1 /*
2 * Copyright (C) 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: sh_ipl_g.c,v 1.2 2007/03/16 18:47:26 debug Exp $
29 *
30 * SH-IPL+G emulation; very basic, only what is needed to get OpenBSD/landisk
31 * booting. (SH-IPL+G stands for SuperH Initial Program Loader + GDB stub.)
32 */
33
34 #include <stdio.h>
35 #include <stdlib.h>
36 #include <string.h>
37 #include <sys/types.h>
38
39 #include "cpu.h"
40 #include "cpu_sh.h"
41 #include "machine.h"
42 #include "memory.h"
43 #include "misc.h"
44 #include "net.h"
45
46
47 #ifdef ENABLE_SH
48
49 #include "sh4_exception.h"
50
51
52 /*
53 * sh_ipl_g_emul_init():
54 */
55 void sh_ipl_g_emul_init(struct machine *machine)
56 {
57 struct cpu *cpu = machine->cpus[0];
58
59 cpu->cd.sh.vbr = 0x8c000000;
60 store_16bit_word(cpu, 0x8c000100, SH_INVALID_INSTR);
61 store_16bit_word(cpu, 0x8c000102, 0x002b); /* rte */
62 store_16bit_word(cpu, 0x8c000104, 0x0009); /* nop */
63 }
64
65
66 /*
67 * sh_ipl_g_promcall():
68 *
69 * SH-IPL+G PROM call emulation.
70 */
71 static int sh_ipl_g_promcall(struct cpu *cpu)
72 {
73 /*
74 * SH-IPL+G call numbers are in R0:
75 *
76 * NOTE: r_bank[0], since this is in a trap handler!
77 */
78 switch (cpu->cd.sh.r_bank[0]) {
79
80 case 4: /* Get memory size. */
81 cpu->cd.sh.r_bank[0] = 64 * 1048576;
82 /* Note: cpu->machine->physical_ram_in_mb * 1048576
83 would be more correct, but physical_ram_in_mb is
84 set to 2 for landisk emulation... */
85 break;
86
87 default:cpu_register_dump(cpu->machine, cpu, 1, 0);
88 printf("\n");
89 fatal("[ SH-IPL+G PROM emulation: unimplemented function 0x%"
90 PRIx32" ]\n", cpu->cd.sh.r_bank[0]);
91 cpu->running = 0;
92 return 0;
93 }
94
95 return 1;
96 }
97
98
99 /*
100 * sh_ipl_g_emul():
101 */
102 int sh_ipl_g_emul(struct cpu *cpu)
103 {
104 /* SH-IPL+G calls are "trapa #63": */
105 if (cpu->cd.sh.expevt == EXPEVT_TRAPA &&
106 cpu->cd.sh.tra == 0xfc) {
107 return sh_ipl_g_promcall(cpu);
108 } else {
109 cpu_register_dump(cpu->machine, cpu, 1, 0);
110 printf("\n");
111 fatal("[ SH-IPL+G PROM emulation: expevt=0x%x, "
112 " tra=0x%x ]\n", (int)cpu->cd.sh.expevt,
113 (int)cpu->cd.sh.tra);
114 cpu->running = 0;
115 return 0;
116 }
117 }
118
119 #endif /* ENABLE_SH */
120

  ViewVC Help
Powered by ViewVC 1.1.26