summaryrefslogtreecommitdiffstats
path: root/utils/hwstub/tools
diff options
context:
space:
mode:
Diffstat (limited to 'utils/hwstub/tools')
-rw-r--r--utils/hwstub/tools/hwstub_shell.cpp23
-rw-r--r--utils/hwstub/tools/lua/load.lua2
-rw-r--r--utils/hwstub/tools/lua/pp.lua62
3 files changed, 87 insertions, 0 deletions
diff --git a/utils/hwstub/tools/hwstub_shell.cpp b/utils/hwstub/tools/hwstub_shell.cpp
index 61cb617509..cdacd81821 100644
--- a/utils/hwstub/tools/hwstub_shell.cpp
+++ b/utils/hwstub/tools/hwstub_shell.cpp
@@ -44,6 +44,7 @@ struct hwstub_version_desc_t g_hwdev_ver;
struct hwstub_layout_desc_t g_hwdev_layout;
struct hwstub_target_desc_t g_hwdev_target;
struct hwstub_stmp_desc_t g_hwdev_stmp;
+struct hwstub_pp_desc_t g_hwdev_pp;
lua_State *g_lua;
/**
@@ -278,6 +279,8 @@ bool my_lua_import_hwstub()
lua_setfield(g_lua, -2, "UNK");
lua_pushinteger(g_lua, HWSTUB_TARGET_STMP);
lua_setfield(g_lua, -2, "STMP");
+ lua_pushinteger(g_lua, HWSTUB_TARGET_PP);
+ lua_setfield(g_lua, -2, "PP");
lua_pushinteger(g_lua, HWSTUB_TARGET_RK27);
lua_setfield(g_lua, -2, "RK27");
lua_setfield(g_lua, -2, "target");
@@ -293,6 +296,15 @@ bool my_lua_import_hwstub()
lua_setfield(g_lua, -2, "package");
lua_setfield(g_lua, -2, "stmp");
}
+ else if(g_hwdev_target.dID == HWSTUB_TARGET_PP)
+ {
+ lua_newtable(g_lua); // pp
+ lua_pushinteger(g_lua, g_hwdev_pp.wChipID);
+ lua_setfield(g_lua, -2, "chipid");
+ lua_pushlstring(g_lua, (const char *)g_hwdev_pp.bRevision, 2);
+ lua_setfield(g_lua, -2, "rev");
+ lua_setfield(g_lua, -2, "pp");
+ }
lua_pushlightuserdata(g_lua, (void *)&hw_read8);
lua_pushcclosure(g_lua, my_lua_readn, 1);
@@ -791,6 +803,17 @@ int main(int argc, char **argv)
goto Lerr;
}
}
+
+ // get PP specific information
+ if(g_hwdev_target.dID == HWSTUB_TARGET_PP)
+ {
+ ret = hwstub_get_desc(g_hwdev, HWSTUB_DT_PP, &g_hwdev_pp, sizeof(g_hwdev_pp));
+ if(ret != sizeof(g_hwdev_pp))
+ {
+ printf("Cannot get pp: %d\n", ret);
+ goto Lerr;
+ }
+ }
/** Init lua */
// create lua state
diff --git a/utils/hwstub/tools/lua/load.lua b/utils/hwstub/tools/lua/load.lua
index 2875b74f1a..a812f92636 100644
--- a/utils/hwstub/tools/lua/load.lua
+++ b/utils/hwstub/tools/lua/load.lua
@@ -2,6 +2,8 @@ package.path = string.sub(string.gsub(debug.getinfo(1).source, "load.lua", "?.lu
if hwstub.dev.target.id == hwstub.dev.target.STMP then
require "stmp"
+elseif hwstub.dev.target.id == hwstub.dev.target.PP then
+ require "pp"
end
require "dumper"
diff --git a/utils/hwstub/tools/lua/pp.lua b/utils/hwstub/tools/lua/pp.lua
new file mode 100644
index 0000000000..e32a878d01
--- /dev/null
+++ b/utils/hwstub/tools/lua/pp.lua
@@ -0,0 +1,62 @@
+---
+--- Chip Identification
+---
+
+PP = { info = {} }
+
+local h = HELP:create_topic("PP")
+h:add("This table contains the abstraction of the different device blocks for the Portal Player / GoForce")
+h:add("It allows one to use higher-level primitives rather than poking at register directly.")
+h:add("Furthermore, it tries as much as possible to hide the differences between the different PP families.")
+
+local function identify(name, family, desc)
+ PP.chipid = hwstub.dev.pp.chipid
+ PP.info.chip = name
+ PP.info.revision = hwstub.dev.pp.rev
+ PP.desc = desc
+ PP.family = family
+ print("Chip identified as " .. name ..", ROM " .. PP.info.revision)
+ if not hwstub.soc:select(desc) then
+ print("Looking for soc " .. desc .. ": not found. Please load a soc by hand.")
+ end
+end
+
+local hh = h:create_topic("is_pp611x")
+hh:add("PP.is_pp611x() returns true if the chip ID reports a PP611x")
+
+function PP.is_pp611x()
+ return hwstub.dev.pp.chipid >= 0x6110
+end
+
+hh = h:create_topic("is_pp502x")
+hh:add("PP.is_pp502x() returns true if the chip ID reports a PP502x")
+
+function PP.is_pp502x()
+ return hwstub.dev.pp.chipid >= 0x5020 and hwstub.dev.pp.chipid < 0x6100
+end
+
+hh = h:create_topic("is_pp500x")
+hh:add("PP.is_pp500x() returns true if the chip ID reports a PP500x")
+
+function PP.is_pp500x()
+ return hwstub.dev.pp.chipid >= 0x5000 and hwstub.dev.pp.chipid < 0x5010
+end
+
+if PP.is_pp611x() then
+ identify("PP6110x (aka GoForce6110)", "pp6110", "pp6110")
+elseif PP.is_pp502x() then
+ identify("PP502x", "pp502x", "pp502x")
+elseif PP.is_pp500x() then
+ identify("PP500x", "pp500x", "pp500x")
+else
+ print(string.format("Unable to identify this chip as a PP: chipid=0x%x", hwstub.dev.pp.chipid));
+end
+
+hh = h:create_topic("debug")
+hh:add("PP.debug(...) prints some debug output if PP.debug_on is true and does nothing otherwise.")
+
+PP.debug_on = false
+
+function PP.debug(...)
+ if PP.debug_on then print(...) end
+end