diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2013-08-11 19:18:58 +0200 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2013-08-11 19:18:58 +0200 |
commit | 1b1692ff06a563db90e812a4edf8c1434bc4976d (patch) | |
tree | 9e6f3ee07949750bb6f90b4fb81896e2a6649a9c /utils/hwstub/tools/lua/dumper.lua | |
parent | d759bd371050d933a13c3e0b283313f44b7da425 (diff) | |
download | rockbox-1b1692ff06a563db90e812a4edf8c1434bc4976d.tar.gz rockbox-1b1692ff06a563db90e812a4edf8c1434bc4976d.zip |
hwstub: add stmp clkctrl code and generic register dumper
Change-Id: I432853fb4171f07ed23b73dc0499814fe8ce8748
Diffstat (limited to 'utils/hwstub/tools/lua/dumper.lua')
-rw-r--r-- | utils/hwstub/tools/lua/dumper.lua | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/utils/hwstub/tools/lua/dumper.lua b/utils/hwstub/tools/lua/dumper.lua new file mode 100644 index 0000000000..51d9bc7ecc --- /dev/null +++ b/utils/hwstub/tools/lua/dumper.lua | |||
@@ -0,0 +1,38 @@ | |||
1 | DUMPER = {} | ||
2 | |||
3 | local h = HELP:create_topic("DUMPER") | ||
4 | h:add("This table contains some tools to dump the registers from the device to a file.") | ||
5 | |||
6 | local hh = h:create_topic("dump_all") | ||
7 | hh:add("The DUMPER.dump_all(file) function dumps all the registers under HW to a file.") | ||
8 | hh:add("If the argument is a string, the function will interpret it as a path.") | ||
9 | hh:add("Otherwise it will be interpreted as an object returned by io.open") | ||
10 | |||
11 | function DUMPER.dump_all_reg(prefix, hw, f) | ||
12 | for reg, tabl in pairs(hw) do | ||
13 | if type(reg) == "string" and type(tabl) == "table" and tabl.read ~= nil then | ||
14 | f:write(string.format("%s%s = %#08x\n", prefix, tabl.name, tabl.read())) | ||
15 | end | ||
16 | end | ||
17 | end | ||
18 | |||
19 | function DUMPER.dump_all_dev(prefix, hw, f) | ||
20 | for block, tabl in pairs(hw) do | ||
21 | if type(block) == "string" and type(tabl) == "table" then | ||
22 | DUMPER.dump_all_reg(prefix .. block .. ".", tabl, f) | ||
23 | end | ||
24 | end | ||
25 | end | ||
26 | |||
27 | function DUMPER.dump_all(file) | ||
28 | local f = file | ||
29 | if type(file) == "string" then | ||
30 | f = io.open(file, "w") | ||
31 | end | ||
32 | if f == nil then error("Cannot open file or write to nil") end | ||
33 | f:write(string.format("HW = %s\n", HW.name)) | ||
34 | DUMPER.dump_all_dev("HW.", HW, f) | ||
35 | if type(file) == "string" then | ||
36 | io.close(f) | ||
37 | end | ||
38 | end \ No newline at end of file | ||