2 JPC-RR: A x86 PC Hardware Emulator
5 Copyright (C) 2007-2009 Isis Innovation Limited
6 Copyright (C) 2009 H. Ilari Liusvaara
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License version 2 as published by
10 the Free Software Foundation.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 Based on JPC x86 PC Hardware emulator,
22 A project from the Physics Dept, The University of Oxford
24 Details about original JPC can be found at:
26 www-jpc.physics.ox.ac.uk
30 package org
.jpc
.emulator
.motherboard
;
33 import org
.jpc
.emulator
.*;
36 * This class provides a <code>Bios</code> implementation for the emulated
37 * machines system bios. The system bios is loaded so that it runs up to address
40 * IO ports <code>0x400-0x403</code> are registered for debugging output. Byte
41 * writes cause ASCII characters to be written to standard output, and word
42 * writes indicate a BIOS panic at the written value line number.
44 * IO port <code>0x8900</code> is registered for system shutdown requests.
45 * Currently this triggers a debugging output, but does not actually shutdown
47 * @author Chris Dennis
49 public class SystemBIOS
extends Bios
implements IOPortCapable
51 private boolean ioportRegistered
;
54 * Loads the system bios from the resource <code>image</code>.
55 * @param image system bios resource name.
56 * @throws java.io.IOException propogated from the resource load.
57 * @throws java.util.MissingResourceException propogated from the resource load
59 public SystemBIOS(String image
) throws IOException
62 ioportRegistered
= false;
65 public void dumpStatusPartial(StatusDumper output
)
67 super.dumpStatusPartial(output
);
68 output
.println("\tioportRegistered " + ioportRegistered
);
71 public void dumpStatus(StatusDumper output
)
73 if(output
.dumped(this))
76 output
.println("#" + output
.objectNumber(this) + ": SystemBIOS:");
77 dumpStatusPartial(output
);
81 public void dumpSRPartial(SRDumper output
) throws IOException
83 super.dumpSRPartial(output
);
84 output
.dumpBoolean(ioportRegistered
);
87 public SystemBIOS(SRLoader input
) throws IOException
90 ioportRegistered
= input
.loadBoolean();
93 public int[] ioPortsRequested()
95 return new int[]{0x400, 0x401, 0x402, 0x403, 0x8900};
98 public void ioPortWriteByte(int address
, int data
)
101 /* Bochs BIOS Messages */
107 System
.err
.println("Emulated: attempted system shutdown");
113 public void ioPortWriteWord(int address
, int data
)
116 /* Bochs BIOS Messages */
119 System
.err
.println("Emulated CRITICAL: panic in rombios.c at line " + data
+ ".");
123 public int ioPortReadByte(int address
)
128 public int ioPortReadWord(int address
)
133 public int ioPortReadLong(int address
)
138 public void ioPortWriteLong(int address
, int data
)
142 protected int loadAddress()
144 return 0x100000 - length();
147 public boolean initialised()
149 return super.initialised() && ioportRegistered
;
152 public void acceptComponent(HardwareComponent component
)
154 super.acceptComponent(component
);
156 if ((component
instanceof IOPortHandler
) && component
.initialised()) {
157 ((IOPortHandler
) component
).registerIOPortCapable(this);
158 ioportRegistered
= true;
165 ioportRegistered
= false;