diff options
Diffstat (limited to 'utils/hwstub/tools/lua/pp.lua')
-rw-r--r-- | utils/hwstub/tools/lua/pp.lua | 62 |
1 files changed, 62 insertions, 0 deletions
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 | ||