Add host-specific Lua memory
[jpcrr.git] / org / jpc / luaextensions / HostMemory.java
blob35031e990773690f4552b5b2ab39db6b61425392
1 /*
2 JPC-RR: A x86 PC Hardware Emulator
3 Release 1
5 Copyright (C) 2007-2009 Isis Innovation Limited
6 Copyright (C) 2009-2010 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.luaextensions;
32 import mnj.lua.*;
34 import org.jpc.emulator.Clock;
35 import org.jpc.emulator.PC;
36 import org.jpc.emulator.pci.peripheral.VGACard;
37 import org.jpc.emulator.DisplayController;
38 import org.jpc.emulator.EventRecorder;
39 import org.jpc.plugins.LuaPlugin;
41 //Locking this class is used for preventing termination and when terminating.
42 public class HostMemory extends LuaPlugin.LuaResource
44 public void destroy()
48 private HostMemory(LuaPlugin plugin)
50 super(plugin);
53 public static int luaCB_read(Lua l, LuaPlugin plugin)
55 PC p = plugin.getPC();
56 if(p != null) {
57 l.push(p.readHostMemory());
58 return 1;
60 return 0;
63 public static int luaCB_write(Lua l, LuaPlugin plugin)
65 if(l.type(1) != Lua.TSTRING) {
66 l.error("Unexpected types to invoke");
67 return 0;
69 PC p = plugin.getPC();
70 if(p != null)
71 p.writeHostMemory(l.value(1).toString());
72 return 0;