forked from len0rd/rockbox
hwstub_shell: add support for call and jump
Change-Id: Ie09d0db21831b79255da858bada7382a08ff4eef Reviewed-on: http://gerrit.rockbox.org/1052 Reviewed-by: Marcin Bukat <marcin.bukat@gmail.com> Tested: Marcin Bukat <marcin.bukat@gmail.com>
This commit is contained in:
parent
9439635aa2
commit
e99c036ed1
4 changed files with 54 additions and 0 deletions
27
utils/hwstub/tools/lua/hwlib.lua
Normal file
27
utils/hwstub/tools/lua/hwlib.lua
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
HWLIB = {}
|
||||
|
||||
local h = HELP:create_topic("HWLIB")
|
||||
h:add("This table contains helper functions for use inside hwstub_shell")
|
||||
|
||||
local hh = h:create_topic("load_blob")
|
||||
hh:add("load_blob(filename, address) -- this function loads raw binary blob from the file filename")
|
||||
hh:add(" at specified address in memory. No cache coherency is")
|
||||
hh:add(" guaranteed")
|
||||
|
||||
hh = h:create_topic("printf")
|
||||
hh:add("printf(s,...) -- this function is simple wrapper around string.format to emulate")
|
||||
hh:add(" C printf() function")
|
||||
|
||||
function HWLIB.load_blob(filename, address)
|
||||
local f = assert(io.open(filename, "rb"))
|
||||
local bytes = f:read("*all")
|
||||
for b in string.gmatch(bytes, ".") do
|
||||
DEV.write8(address, string.byte(b))
|
||||
address = address + 1
|
||||
end
|
||||
io.close(f)
|
||||
end
|
||||
|
||||
function HWLIB.printf(s,...)
|
||||
return io.write(s:format(...))
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue