diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2014-04-12 00:08:11 +0200 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2014-04-12 00:11:13 +0200 |
commit | 238be18d0331a7a87e3ea8ea0d24b78e451357cb (patch) | |
tree | 31807bf3fd533d2d0d3d4eb0421b08100cc67c25 /utils/hwstub/tools | |
parent | 910235b49a754fcd18157dbd22e125a32b482c9d (diff) | |
download | rockbox-238be18d0331a7a87e3ea8ea0d24b78e451357cb.tar.gz rockbox-238be18d0331a7a87e3ea8ea0d24b78e451357cb.zip |
hwstub: add proper PP support
- drop support for PP500x: it's very different from other PP and although
it would be possible to support them, I don't have one to test the code
- make sure only the CPU is started
- add PP descriptor to report chip ID and revision
- add code in shell and lua to support pp (no register description yet)
- compile for ARMv4 because PP502x is an ARM7TDMI
Change-Id: I36c4e465dfc2cfdfe7433b2f65cc8f6f0720fe62
Diffstat (limited to 'utils/hwstub/tools')
-rw-r--r-- | utils/hwstub/tools/hwstub_shell.cpp | 23 | ||||
-rw-r--r-- | utils/hwstub/tools/lua/load.lua | 2 | ||||
-rw-r--r-- | utils/hwstub/tools/lua/pp.lua | 62 |
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; | |||
44 | struct hwstub_layout_desc_t g_hwdev_layout; | 44 | struct hwstub_layout_desc_t g_hwdev_layout; |
45 | struct hwstub_target_desc_t g_hwdev_target; | 45 | struct hwstub_target_desc_t g_hwdev_target; |
46 | struct hwstub_stmp_desc_t g_hwdev_stmp; | 46 | struct hwstub_stmp_desc_t g_hwdev_stmp; |
47 | struct hwstub_pp_desc_t g_hwdev_pp; | ||
47 | lua_State *g_lua; | 48 | lua_State *g_lua; |
48 | 49 | ||
49 | /** | 50 | /** |
@@ -278,6 +279,8 @@ bool my_lua_import_hwstub() | |||
278 | lua_setfield(g_lua, -2, "UNK"); | 279 | lua_setfield(g_lua, -2, "UNK"); |
279 | lua_pushinteger(g_lua, HWSTUB_TARGET_STMP); | 280 | lua_pushinteger(g_lua, HWSTUB_TARGET_STMP); |
280 | lua_setfield(g_lua, -2, "STMP"); | 281 | lua_setfield(g_lua, -2, "STMP"); |
282 | lua_pushinteger(g_lua, HWSTUB_TARGET_PP); | ||
283 | lua_setfield(g_lua, -2, "PP"); | ||
281 | lua_pushinteger(g_lua, HWSTUB_TARGET_RK27); | 284 | lua_pushinteger(g_lua, HWSTUB_TARGET_RK27); |
282 | lua_setfield(g_lua, -2, "RK27"); | 285 | lua_setfield(g_lua, -2, "RK27"); |
283 | lua_setfield(g_lua, -2, "target"); | 286 | lua_setfield(g_lua, -2, "target"); |
@@ -293,6 +296,15 @@ bool my_lua_import_hwstub() | |||
293 | lua_setfield(g_lua, -2, "package"); | 296 | lua_setfield(g_lua, -2, "package"); |
294 | lua_setfield(g_lua, -2, "stmp"); | 297 | lua_setfield(g_lua, -2, "stmp"); |
295 | } | 298 | } |
299 | else if(g_hwdev_target.dID == HWSTUB_TARGET_PP) | ||
300 | { | ||
301 | lua_newtable(g_lua); // pp | ||
302 | lua_pushinteger(g_lua, g_hwdev_pp.wChipID); | ||
303 | lua_setfield(g_lua, -2, "chipid"); | ||
304 | lua_pushlstring(g_lua, (const char *)g_hwdev_pp.bRevision, 2); | ||
305 | lua_setfield(g_lua, -2, "rev"); | ||
306 | lua_setfield(g_lua, -2, "pp"); | ||
307 | } | ||
296 | 308 | ||
297 | lua_pushlightuserdata(g_lua, (void *)&hw_read8); | 309 | lua_pushlightuserdata(g_lua, (void *)&hw_read8); |
298 | lua_pushcclosure(g_lua, my_lua_readn, 1); | 310 | lua_pushcclosure(g_lua, my_lua_readn, 1); |
@@ -791,6 +803,17 @@ int main(int argc, char **argv) | |||
791 | goto Lerr; | 803 | goto Lerr; |
792 | } | 804 | } |
793 | } | 805 | } |
806 | |||
807 | // get PP specific information | ||
808 | if(g_hwdev_target.dID == HWSTUB_TARGET_PP) | ||
809 | { | ||
810 | ret = hwstub_get_desc(g_hwdev, HWSTUB_DT_PP, &g_hwdev_pp, sizeof(g_hwdev_pp)); | ||
811 | if(ret != sizeof(g_hwdev_pp)) | ||
812 | { | ||
813 | printf("Cannot get pp: %d\n", ret); | ||
814 | goto Lerr; | ||
815 | } | ||
816 | } | ||
794 | /** Init lua */ | 817 | /** Init lua */ |
795 | 818 | ||
796 | // create lua state | 819 | // 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 | |||
2 | 2 | ||
3 | if hwstub.dev.target.id == hwstub.dev.target.STMP then | 3 | if hwstub.dev.target.id == hwstub.dev.target.STMP then |
4 | require "stmp" | 4 | require "stmp" |
5 | elseif hwstub.dev.target.id == hwstub.dev.target.PP then | ||
6 | require "pp" | ||
5 | end | 7 | end |
6 | 8 | ||
7 | require "dumper" | 9 | 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 @@ | |||
1 | --- | ||
2 | --- Chip Identification | ||
3 | --- | ||
4 | |||
5 | PP = { info = {} } | ||
6 | |||
7 | local h = HELP:create_topic("PP") | ||
8 | h:add("This table contains the abstraction of the different device blocks for the Portal Player / GoForce") | ||
9 | h:add("It allows one to use higher-level primitives rather than poking at register directly.") | ||
10 | h:add("Furthermore, it tries as much as possible to hide the differences between the different PP families.") | ||
11 | |||
12 | local function identify(name, family, desc) | ||
13 | PP.chipid = hwstub.dev.pp.chipid | ||
14 | PP.info.chip = name | ||
15 | PP.info.revision = hwstub.dev.pp.rev | ||
16 | PP.desc = desc | ||
17 | PP.family = family | ||
18 | print("Chip identified as " .. name ..", ROM " .. PP.info.revision) | ||
19 | if not hwstub.soc:select(desc) then | ||
20 | print("Looking for soc " .. desc .. ": not found. Please load a soc by hand.") | ||
21 | end | ||
22 | end | ||
23 | |||
24 | local hh = h:create_topic("is_pp611x") | ||
25 | hh:add("PP.is_pp611x() returns true if the chip ID reports a PP611x") | ||
26 | |||
27 | function PP.is_pp611x() | ||
28 | return hwstub.dev.pp.chipid >= 0x6110 | ||
29 | end | ||
30 | |||
31 | hh = h:create_topic("is_pp502x") | ||
32 | hh:add("PP.is_pp502x() returns true if the chip ID reports a PP502x") | ||
33 | |||
34 | function PP.is_pp502x() | ||
35 | return hwstub.dev.pp.chipid >= 0x5020 and hwstub.dev.pp.chipid < 0x6100 | ||
36 | end | ||
37 | |||
38 | hh = h:create_topic("is_pp500x") | ||
39 | hh:add("PP.is_pp500x() returns true if the chip ID reports a PP500x") | ||
40 | |||
41 | function PP.is_pp500x() | ||
42 | return hwstub.dev.pp.chipid >= 0x5000 and hwstub.dev.pp.chipid < 0x5010 | ||
43 | end | ||
44 | |||
45 | if PP.is_pp611x() then | ||
46 | identify("PP6110x (aka GoForce6110)", "pp6110", "pp6110") | ||
47 | elseif PP.is_pp502x() then | ||
48 | identify("PP502x", "pp502x", "pp502x") | ||
49 | elseif PP.is_pp500x() then | ||
50 | identify("PP500x", "pp500x", "pp500x") | ||
51 | else | ||
52 | print(string.format("Unable to identify this chip as a PP: chipid=0x%x", hwstub.dev.pp.chipid)); | ||
53 | end | ||
54 | |||
55 | hh = h:create_topic("debug") | ||
56 | hh:add("PP.debug(...) prints some debug output if PP.debug_on is true and does nothing otherwise.") | ||
57 | |||
58 | PP.debug_on = false | ||
59 | |||
60 | function PP.debug(...) | ||
61 | if PP.debug_on then print(...) end | ||
62 | end | ||