summaryrefslogtreecommitdiff
path: root/utils/hwstub/tools/lua/jz.lua
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2016-02-07 21:46:58 +0000
committerAmaury Pouly <amaury.pouly@gmail.com>2016-04-08 19:38:18 +0200
commitf6c61eb11a13f7a5141a980f56b9a14b3309c449 (patch)
treed1c4a4d992f88e40eacb65d5e046b595fdcb512a /utils/hwstub/tools/lua/jz.lua
parenta2f4c5201d78b9f351834b0512623eeac622280f (diff)
downloadrockbox-f6c61eb11a13f7a5141a980f56b9a14b3309c449.tar.gz
rockbox-f6c61eb11a13f7a5141a980f56b9a14b3309c449.zip
hwstub: port hwstub_shell to the new library
Also use this opportunity to cleanup support for multiple devices: the shell now supports dynamic changes in the device and will call init() everytime a new device is selected, to prepare a new environment. The shell now honors register width on register read/write. The shell also provides access to variants as follows by creating a subtable under the register using the variant type in UPPER case and having the same layout as a register. For example if register HW.GPIO.DIR has variants "set" and "clr", those can be used like this: HW.GPIO.DIR.SET.write(0xff) HW.GPIO.DIR.CLR.write(0xff00) Change-Id: I943947fa98bce875de0cba4338e8b7196a4c1165
Diffstat (limited to 'utils/hwstub/tools/lua/jz.lua')
-rw-r--r--utils/hwstub/tools/lua/jz.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/utils/hwstub/tools/lua/jz.lua b/utils/hwstub/tools/lua/jz.lua
new file mode 100644
index 0000000000..ab2cb8658f
--- /dev/null
+++ b/utils/hwstub/tools/lua/jz.lua
@@ -0,0 +1,26 @@
1---
2--- Chip Identification
3---
4JZ = { info = {} }
5
6local h = HELP:create_topic("JZ")
7h:add("This table contains the abstraction of the different device blocks for the JZ.")
8h:add("It allows one to use higher-level primitives rather than poking at register directly.")
9
10hh = h:create_topic("debug")
11hh:add("STMP.debug(...) prints some debug output if JZ.debug_on is true and does nothing otherwise.")
12
13JZ.debug_on = false
14
15function STMP.debug(...)
16 if STMP.debug_on then print(...) end
17end
18
19-- init
20function JZ.init()
21 local desc = string.format("jz%04x%c", hwstub.dev.jz.chipid, hwstub.dev.jz.rev)
22 desc = desc:lower()
23 if not hwstub.soc:select(desc) then
24 print("Looking for soc " .. desc .. ": not found. Please load a soc by hand.")
25 end
26end