Some coding style fixes
[jpcrr.git] / org / jpc / emulator / memory / codeblock / SpanningProtectedModeCodeBlock.java
blobe99b2f1e37619a288f1d1c6cd76931f1adfc64bf
1 /*
2 JPC-RR: A x86 PC Hardware Emulator
3 Release 1
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.memory.codeblock;
32 import org.jpc.emulator.processor.Processor;
33 import org.jpc.emulator.memory.AddressSpace;
35 /**
37 * @author Chris Dennis
39 class SpanningProtectedModeCodeBlock extends SpanningCodeBlock implements ProtectedModeCodeBlock
41 private ByteSourceWrappedMemory byteSource = new ByteSourceWrappedMemory();
43 private CodeBlockFactory[] factories;
44 private int length;
46 public SpanningProtectedModeCodeBlock(CodeBlockFactory[] factories)
48 this.factories = factories;
51 public int getX86Length()
53 return length;
56 protected CodeBlock decode(Processor cpu)
58 ProtectedModeCodeBlock block = null;
59 AddressSpace memory = cpu.linearMemory;
60 int address = cpu.getInstructionPointer();
61 boolean opSize = cpu.cs.getDefaultSizeFlag();
62 for(int i = 0; (i < factories.length) && (block == null); i++)
63 try {
64 byteSource.set(memory, address);
65 block = factories[i].getProtectedModeCodeBlock(byteSource, opSize);
66 } catch (IllegalStateException e) {
68 length = block.getX86Length();
69 byteSource.set(null, 0);
70 return block;
73 public String toString()
75 return "Spanning Protected Mode CodeBlock";