2013-06-13 00:02:53 +00:00
|
|
|
-- init code for hwstub_tools
|
|
|
|
|
|
|
|
--
|
|
|
|
-- HELP
|
|
|
|
--
|
|
|
|
HELP = hwstub.help
|
|
|
|
|
|
|
|
function HELP:create_topic(name)
|
|
|
|
self[name] = { create_topic = HELP.create_topic, add = HELP.add, get_topic = HELP.get_topic }
|
|
|
|
return self[name]
|
|
|
|
end
|
|
|
|
|
|
|
|
function HELP:get_topic(name)
|
|
|
|
return self[name]
|
|
|
|
end
|
|
|
|
|
|
|
|
function HELP:add(text)
|
|
|
|
table.insert(self, text)
|
|
|
|
end
|
|
|
|
|
|
|
|
do
|
|
|
|
local h = HELP:create_topic("hwstub")
|
|
|
|
h:add("This tool uses a number of well-defined namespaces (tables) to organise its features.")
|
|
|
|
h:add("The hwstub table contains a number of information and functions related to the tool itself.")
|
|
|
|
h:add("Of particular interest are")
|
|
|
|
h:add("* hwstub.host which holds host specific information.")
|
|
|
|
h:add("* hwstub.dev which holds device specific information. See DEV")
|
|
|
|
h:add("* hwstub.help (aka HELP) which holds the help. See HELP.");
|
|
|
|
h:add("* hwstub.soc which holds soc specific information. See HW");
|
|
|
|
|
|
|
|
h = HELP:create_topic("HELP");
|
|
|
|
h:add("This variable redirects to hwstub.help and provides access to the help system.");
|
|
|
|
h:add("You can enhance the help using the following methods on any topic (including HELP itself).");
|
|
|
|
h:add("* t:create_topic(s) to create a new subtopic named s under topic t");
|
|
|
|
h:add("* t:add(s) to add a help line to topic t");
|
|
|
|
h:add("* t:get_topic(s) to get the subtopic s under topic t");
|
|
|
|
|
|
|
|
h = HELP:create_topic("DEV");
|
|
|
|
h:add("This variable redirects to hwstub.dev and provides direct access to the device.");
|
|
|
|
h:add("It contains some information about the device and the following methods.");
|
|
|
|
h:add("* read8/16/32(a) reads a 8/16/32-bit integer at address a");
|
|
|
|
h:add("* write8/16/32(a, v) writes the 8/16/32-bit integer v at address a");
|
2013-07-13 15:38:34 +00:00
|
|
|
h:add("* print_log() prints the device log");
|
2013-06-13 00:02:53 +00:00
|
|
|
|
|
|
|
h = HELP:create_topic("HW");
|
|
|
|
h:add("This variable redirects to the current soc under hwstub.soc and should be changed by calling hwstub:soc:select only.");
|
2013-08-11 17:18:58 +00:00
|
|
|
h:add("The complete register tree can be found under HW in a well organised fashion.");
|
2013-06-13 00:02:53 +00:00
|
|
|
h:add("* HW.dev points to device dev");
|
|
|
|
h:add("* HW.dev[i] points to device devi if there are several copies of the device at different addresses.");
|
|
|
|
h:add("* HW.dev.reg points to the register reg under dev");
|
|
|
|
h:add("* HW.dev.reg[i] points to the register regi if there are several copies.");
|
|
|
|
h:add("* HW.dev.reg.f points to the field f under register reg.");
|
|
|
|
h:add("* HW.dev.reg.f.v gives the value of named value v of field f.");
|
|
|
|
h:add("* All registers can be read using HW.dev.reg.read() and written using HW.dev.reg.write(v).");
|
|
|
|
h:add("* Register with a SCT variant also implement HW.dev.reg.set/clr/tog(v).");
|
|
|
|
h:add("* All register field can be read using HW.dev.reg.f.read() and written using HW.dev.reg.f.write(v).");
|
|
|
|
h:add("* Field writes can either give a integer or a named value to write(v).");
|
|
|
|
h:add("* Register with a SCT variant also implement HW.dev.reg.f.set/clr/tog(v) with the same properties.");
|
|
|
|
h:add("* All devices, registers and fields also have descriptions available such as addresses.");
|
|
|
|
end
|
|
|
|
|
|
|
|
--
|
|
|
|
-- INFO
|
|
|
|
--
|
|
|
|
|
|
|
|
if not hwstub.options.quiet then
|
|
|
|
print("information")
|
|
|
|
print(" hwstub")
|
2014-08-05 16:18:17 +00:00
|
|
|
print(" version: " .. string.format("%d.%d", hwstub.host.version.major,
|
|
|
|
hwstub.host.version.minor))
|
2013-06-13 00:02:53 +00:00
|
|
|
print(" device")
|
|
|
|
print(" version: " .. string.format("%d.%d.%d", hwstub.dev.version.major,
|
|
|
|
hwstub.dev.version.minor, hwstub.dev.version.revision))
|
2013-07-13 15:38:34 +00:00
|
|
|
print(" target")
|
|
|
|
local id_str = string.char(bit32.extract(hwstub.dev.target.id, 0, 8),
|
|
|
|
bit32.extract(hwstub.dev.target.id, 8, 8),
|
|
|
|
bit32.extract(hwstub.dev.target.id, 16, 8),
|
|
|
|
bit32.extract(hwstub.dev.target.id, 24, 8))
|
|
|
|
print(" id: " .. string.format("%#x (%s)", hwstub.dev.target.id, id_str))
|
|
|
|
print(" name: " .. hwstub.dev.target.name)
|
2013-06-13 00:02:53 +00:00
|
|
|
print(" layout")
|
2014-02-03 23:10:41 +00:00
|
|
|
print(" code: " .. string.format("%#x bytes @ %#x",
|
|
|
|
hwstub.dev.layout.code.size, hwstub.dev.layout.code.start))
|
|
|
|
print(" stack: " .. string.format("%#x bytes @ %#x",
|
|
|
|
hwstub.dev.layout.stack.size, hwstub.dev.layout.stack.start))
|
|
|
|
print(" buffer: " .. string.format("%#x bytes @ %#x",
|
|
|
|
hwstub.dev.layout.buffer.size, hwstub.dev.layout.buffer.start))
|
2013-06-13 00:02:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
--
|
|
|
|
-- SOC
|
|
|
|
--
|
|
|
|
function hwstub.soc:select(soc)
|
|
|
|
if self[soc] == nil then return false end
|
|
|
|
print("Selecting soc " .. soc .. ". Redirecting HW to hwstub.soc." .. soc)
|
|
|
|
HW = self[soc]
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
--
|
|
|
|
-- DEV
|
|
|
|
--
|
|
|
|
DEV = hwstub.dev
|
|
|
|
|
2013-12-24 14:24:40 +00:00
|
|
|
--
|
|
|
|
-- Misc
|
|
|
|
--
|
|
|
|
function hwstub.mdelay(msec)
|
|
|
|
hwstub.udelay(msec * 1000)
|
|
|
|
end
|
|
|
|
|
2013-06-13 00:02:53 +00:00
|
|
|
require "lua/load"
|