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
;
32 //Do not even think about adding an import line to this class - especially not import java.net.*!
33 import java
.io
.IOException
;
34 import org
.jpc
.diskimages
.BlockDevice
;
35 import org
.jpc
.diskimages
.GenericBlockDevice
;
37 import org
.jpc
.emulator
.AbstractHardwareComponent
;
40 * Represents the set of disk drive devices associated with this emulator
42 * @author Chris Dennis
44 public class DriveSet
extends AbstractHardwareComponent
47 public static enum BootType
53 public static byte toNumeric(BootType type
)
57 else if(type
== HARD_DRIVE
)
59 else if(type
== CDROM
)
65 public static BootType
fromNumeric(byte type
)
78 private BootType bootType
;
79 private BlockDevice
[] ides
;
81 public void dumpStatusPartial(StatusDumper output
)
83 super.dumpStatusPartial(output
);
84 output
.println("\tbootType " + bootType
);
86 for(int i
=0; i
< ides
.length
; i
++) {
87 output
.println("\tides[" + i
+ "] <object #" + output
.objectNumber(ides
[i
]) + ">");
88 if(ides
[i
] != null) ides
[i
].dumpStatus(output
);
92 public void dumpStatus(StatusDumper output
)
94 if(output
.dumped(this))
97 output
.println("#" + output
.objectNumber(this) + ": DriveSet:");
98 dumpStatusPartial(output
);
102 public void dumpSRPartial(SRDumper output
) throws IOException
104 super.dumpSRPartial(output
);
105 output
.dumpByte(BootType
.toNumeric(bootType
));
106 output
.dumpInt(ides
.length
);
107 for(int i
= 0; i
< ides
.length
; i
++)
108 output
.dumpObject(ides
[i
]);
111 public DriveSet(SRLoader input
) throws IOException
114 bootType
= BootType
.fromNumeric(input
.loadByte());
115 ides
= new BlockDevice
[input
.loadInt()];
116 for(int i
= 0; i
< ides
.length
; i
++)
117 ides
[i
] = (BlockDevice
)input
.loadObject();
121 * Constructs a driveset with all parameters specified.
123 * A drive set can be composed of at most four ide devices and two floppy
125 * @param boot boot device
126 * @param hardDriveA primary master hard disk
127 * @param hardDriveB primary slave hard disk
128 * @param hardDriveC secondary master hard disk
129 * @param hardDriveD secondary slave hard disk
131 public DriveSet(BootType boot
, BlockDevice hardDriveA
, BlockDevice hardDriveB
, BlockDevice hardDriveC
, BlockDevice hardDriveD
)
133 this.bootType
= boot
;
135 ides
= new BlockDevice
[4];
136 ides
[0] = hardDriveA
;
137 ides
[1] = hardDriveB
;
138 ides
[2] = (hardDriveC
== null) ?
new GenericBlockDevice(BlockDevice
.Type
.CDROM
) : hardDriveC
;
139 ides
[3] = hardDriveD
;
143 * Returns the i'th hard drive device.
145 * Devices are numbered from 0 to 3 inclusive in order: primary master,
146 * primary slave, secondary master, secondary slave.
147 * @param index drive index
148 * @return hard drive block device
150 public BlockDevice
getHardDrive(int index
)
155 public void setHardDrive(int index
, BlockDevice device
)
157 ides
[index
] = device
;
161 * Returns the boot type being used by this driveset.
164 public BootType
getBootType()