summaryrefslogtreecommitdiff
path: root/utils/hwstub/tools/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'utils/hwstub/tools/init.lua')
-rw-r--r--utils/hwstub/tools/init.lua86
1 files changed, 24 insertions, 62 deletions
diff --git a/utils/hwstub/tools/init.lua b/utils/hwstub/tools/init.lua
index 323f36957d..8ab69c890a 100644
--- a/utils/hwstub/tools/init.lua
+++ b/utils/hwstub/tools/init.lua
@@ -1,71 +1,11 @@
1-- init code for hwstub_tools 1-- init code for hwstub_tools
2 2
3-- 3--
4-- HELP
5--
6HELP = hwstub.help
7
8function HELP:create_topic(name)
9 self[name] = { create_topic = HELP.create_topic, add = HELP.add, get_topic = HELP.get_topic }
10 return self[name]
11end
12
13function HELP:get_topic(name)
14 return self[name]
15end
16
17function HELP:add(text)
18 table.insert(self, text)
19end
20
21do
22 local h = HELP:create_topic("hwstub")
23 h:add("This tool uses a number of well-defined namespaces (tables) to organise its features.")
24 h:add("The hwstub table contains a number of information and functions related to the tool itself.")
25 h:add("Of particular interest are")
26 h:add("* hwstub.host which holds host specific information.")
27 h:add("* hwstub.dev which holds device specific information. See DEV")
28 h:add("* hwstub.help (aka HELP) which holds the help. See HELP.");
29 h:add("* hwstub.soc which holds soc specific information. See HW");
30
31 h = HELP:create_topic("HELP");
32 h:add("This variable redirects to hwstub.help and provides access to the help system.");
33 h:add("You can enhance the help using the following methods on any topic (including HELP itself).");
34 h:add("* t:create_topic(s) to create a new subtopic named s under topic t");
35 h:add("* t:add(s) to add a help line to topic t");
36 h:add("* t:get_topic(s) to get the subtopic s under topic t");
37
38 h = HELP:create_topic("DEV");
39 h:add("This variable redirects to hwstub.dev and provides direct access to the device.");
40 h:add("It contains some information about the device and the following methods.");
41 h:add("* read8/16/32(a) reads a 8/16/32-bit integer at address a atomically");
42 h:add("* write8/16/32(a, v) writes the 8/16/32-bit integer v at address a atomically");
43 h:add("* jump(a) jump to specified address");
44 h:add("* call(a) call function at specified address and return to hwstub");
45 h:add("* print_log() prints the device log");
46
47 h = HELP:create_topic("HW");
48 h:add("This variable redirects to the current soc under hwstub.soc and should be changed by calling hwstub:soc:select only.");
49 h:add("The complete register tree can be found under HW in a well organised fashion.");
50 h:add("* HW.dev points to device dev");
51 h:add("* HW.dev[i] points to device devi if there are several copies of the device at different addresses.");
52 h:add("* HW.dev.reg points to the register reg under dev");
53 h:add("* HW.dev.reg[i] points to the register regi if there are several copies.");
54 h:add("* HW.dev.reg.f points to the field f under register reg.");
55 h:add("* HW.dev.reg.f.v gives the value of named value v of field f.");
56 h:add("* All registers can be read using HW.dev.reg.read() and written using HW.dev.reg.write(v).");
57 h:add("* Register with a SCT variant also implement HW.dev.reg.set/clr/tog(v).");
58 h:add("* All register field can be read using HW.dev.reg.f.read() and written using HW.dev.reg.f.write(v).");
59 h:add("* Field writes can either give a integer or a named value to write(v).");
60 h:add("* Register with a SCT variant also implement HW.dev.reg.f.set/clr/tog(v) with the same properties.");
61 h:add("* All devices, registers and fields also have descriptions available such as addresses.");
62end
63
64--
65-- INFO 4-- INFO
66-- 5--
67 6
68if not hwstub.options.quiet then 7function hwstub.info()
8--- if not hwstub.options.quiet then
69 print("information") 9 print("information")
70 print(" hwstub") 10 print(" hwstub")
71 print(" version: " .. string.format("%d.%d", hwstub.host.version.major, 11 print(" version: " .. string.format("%d.%d", hwstub.host.version.major,
@@ -87,6 +27,20 @@ if not hwstub.options.quiet then
87 hwstub.dev.layout.stack.size, hwstub.dev.layout.stack.start)) 27 hwstub.dev.layout.stack.size, hwstub.dev.layout.stack.start))
88 print(" buffer: " .. string.format("%#x bytes @ %#x", 28 print(" buffer: " .. string.format("%#x bytes @ %#x",
89 hwstub.dev.layout.buffer.size, hwstub.dev.layout.buffer.start)) 29 hwstub.dev.layout.buffer.size, hwstub.dev.layout.buffer.start))
30 if hwstub.dev.target.id == hwstub.dev.target.STMP then
31 print(" stmp")
32 print(" chipid: " .. string.format("%x", hwstub.dev.stmp.chipid))
33 print(" rev: " .. string.format("%d", hwstub.dev.stmp.rev))
34 print(" package: " .. string.format("%d", hwstub.dev.stmp.package))
35 elseif hwstub.dev.target.id == hwstub.dev.target.PP then
36 print(" pp")
37 print(" chipid: " .. string.format("%x", hwstub.dev.pp.chipid))
38 print(" rev: " .. string.format("%d", hwstub.dev.pp.rev))
39 elseif hwstub.dev.target.id == hwstub.dev.target.JZ then
40 print(" jz")
41 print(" chipid: " .. string.format("%x", hwstub.dev.jz.chipid))
42 print(" revision: " .. string.format("%c", hwstub.dev.jz.rev))
43 end
90end 44end
91 45
92-- 46--
@@ -111,4 +65,12 @@ function hwstub.mdelay(msec)
111 hwstub.udelay(msec * 1000) 65 hwstub.udelay(msec * 1000)
112end 66end
113 67
68require "lua/help"
114require "lua/load" 69require "lua/load"
70
71function init()
72 LOAD.init()
73end
74
75-- first time init
76init()