summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyösti Mälkki <kyosti.malkki@gmail.com>2013-03-03 14:07:18 +0200
committerStefan Reinauer <stefan.reinauer@coreboot.org>2013-03-11 18:55:41 +0100
commita5a5176c137e22eee9a08e697db15e1665533afb (patch)
tree6f016d1ad812c0aa7a5f9604d29f07779fc9587d
parente663d0803584e301261c8e1a10bd51768e0816c9 (diff)
Refactor logging functions
This adds root_info() and resource_info() functions to add informational lines (tagged with I...) in the log. This also fixes index and cs:eip values printed for these lines. Change-Id: Ib83140037ef4e910f2828783fd7505eac74fac2f Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: http://review.coreboot.org/2579 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
-rw-r--r--SerialICE/simba/hooks.lua61
-rw-r--r--SerialICE/simba/output.lua34
-rw-r--r--SerialICE/simba/pci_cfg.lua6
-rw-r--r--SerialICE/simba/serialice.lua6
4 files changed, 53 insertions, 54 deletions
diff --git a/SerialICE/simba/hooks.lua b/SerialICE/simba/hooks.lua
index 72e1a55..01aea65 100644
--- a/SerialICE/simba/hooks.lua
+++ b/SerialICE/simba/hooks.lua
@@ -1,10 +1,13 @@
-function new_list()
- return { list = nil }
+froot = { id = 0, name = "SerialICE" }
+fresource = { id = 1, name = "Resource" }
+
+function new_hooks(str)
+ return { list = nil, name = str }
end
-next_filter_id = 1
+next_filter_id = 2
next_action_id = 1
current_parent_id = 0
@@ -19,16 +22,15 @@ function new_parent_action()
end
-io_hooks = new_list()
-mem_hooks = new_list()
-
-cpumsr_hooks = new_list()
-cpuid_hooks = new_list()
+io_hooks = new_hooks("IO")
+mem_hooks = new_hooks("MEM")
+cpumsr_hooks = new_hooks("CPU MSR")
+cpuid_hooks = new_hooks("CPUID")
function enable_hook(list, filter)
if not filter then
- printks(froot, "Enable_hook called with filter==nil\n")
+ root_info("Attempted to call enable_hook() with filter==nil\n")
return
end
@@ -40,37 +42,27 @@ function enable_hook(list, filter)
end
if not found then
filter.id = next_filter_id
+ filter.list = list
next_filter_id = next_filter_id + 1
list.list = { next = list.list, hook = filter }
end
- if (list == io_hooks) then
- printks(fresource, "[%04x] IO [%04x-%04x] = %s\n",
- filter.id, filter.base, filter.base + filter.size - 1, filter.name)
- elseif (list == mem_hooks) then
- printks(fresource, "[%04x] MEM [%08x-%08x] = %s\n",
- filter.id, filter.base, filter.base + filter.size - 1, filter.name)
- else
- printks(fresource, "[%04x] %s\n", filter.id, filter.name)
- end
+ update_hook(filter)
filter.enable = true
end
-function disable_hook(list, filter)
- if not filter then
- return
- end
- local l = list.list
- local found = false
- while l and not found do
- found = (l.hook == filter)
- l = l.next
+function disable_hook(f)
+ if f.id and f.enable and f.enable == true then
+ resource_info(f, "disabled")
end
- if found then
- printks(froot, "id=%04x disabled\n", filter.id)
- filter.enable = false
+ f.enable = false
+end
+
+function update_hook(f)
+ if f.list == io_hooks or f.list == mem_hooks then
+ resource_info(f, "[%04x-%04x] = %s",
+ f.base, f.base + f.size - 1, f.name)
else
- printks(filter, "disabled\n")
- filter.enable = false
+ resource_info(f, "%s", f.name)
end
end
@@ -157,7 +149,7 @@ function generic_io_bar(bar)
if (bar.f.base ~= 0) then
enable_hook(io_hooks, bar.f)
else
- disable_hook(io_hooks, bar.f)
+ disable_hook(bar.f)
end
end
@@ -176,7 +168,7 @@ function generic_mmio_bar(bar)
if bar.f.base ~= 0 then
enable_hook(mem_hooks, bar.f)
else
- disable_hook(mem_hooks, bar.f)
+ disable_hook(bar.f)
end
end
@@ -233,6 +225,7 @@ function pre_action(action, dir_wr, addr, size, data)
action.dropped = false
action.to_hw = false
action.to_qemu = false
+ action.info_only = false
action.write = dir_wr
action.addr = addr
diff --git a/SerialICE/simba/output.lua b/SerialICE/simba/output.lua
index fac895d..a01e074 100644
--- a/SerialICE/simba/output.lua
+++ b/SerialICE/simba/output.lua
@@ -1,14 +1,4 @@
-
-froot = {
- id = 0,
- name = "SerialICE",
-}
-
-fresource = {
- name = "Resource",
-}
-
-- -------------------------------------------------------------------
-- logging functions
@@ -24,6 +14,8 @@ function printk(f, action, fmt, ...)
local str = ""
if action.undefined or action.f or action == cpu_action then
str = str .. "R"
+ elseif action.info_only then
+ str = str .. "I"
else
str = str .. "."
end
@@ -58,10 +50,24 @@ function printk(f, action, fmt, ...)
end
end
-function printks(f, fmt, ...)
- print_address(0,0,"I...",0,0)
- printf("%s: ", f.name)
- printf(fmt, ...)
+info_action = {}
+
+function print_info(f, str)
+ pre_action(info_action)
+ info_action.info_only = true
+ info_action.parent_id = current_parent_id
+ info_action.my_id = next_action_id
+ printk(f, info_action, "%s", str)
+end
+
+function root_info(fmt, ...)
+ print_info(froot, string.format(fmt, ...))
+end
+
+function resource_info(f, fmt, ...)
+ print_info(fresource,
+ string.format("[%04x] %s ", f.id, f.list.name) ..
+ string.format(fmt, ...) .. "\n")
end
function trim (s)
diff --git a/SerialICE/simba/pci_cfg.lua b/SerialICE/simba/pci_cfg.lua
index d874e9f..e7bdf65 100644
--- a/SerialICE/simba/pci_cfg.lua
+++ b/SerialICE/simba/pci_cfg.lua
@@ -8,11 +8,11 @@ pci_cfg_action = {}
PCI_CFG_READ = false
PCI_CFG_WRITE = true
-pci_cfg_hooks = new_list()
+pci_cfg_hooks = new_hooks("PCI")
function add_pci_cfg_hook(dev, reg, size, func)
local bdfr = bit32.bor(dev.pci_dev, reg)
- local name = string.format("PCI %x:%02x.%x [%04x]",
+ local name = string.format("%x:%02x.%x [%03x]",
bit32.band(0xff,bit32.rshift(bdfr, 20)), bit32.band(0x1f,bit32.rshift(bdfr, 15)),
bit32.band(0x7,bit32.rshift(bdfr, 12)), bit32.band(0xfff,bdfr))
local filter = {
@@ -327,6 +327,6 @@ end
function pcie_mm_disable(dev, reg, base, size)
if dev.bar and dev.bar[reg] and dev.bar[reg].f then
- disable_hook(mem_hooks, dev.bar[reg].f)
+ disable_hook(dev.bar[reg].f)
end
end
diff --git a/SerialICE/simba/serialice.lua b/SerialICE/simba/serialice.lua
index 61e2fd1..82a2b03 100644
--- a/SerialICE/simba/serialice.lua
+++ b/SerialICE/simba/serialice.lua
@@ -98,16 +98,16 @@ if mainboard_script then
io.close(mainboard_script)
assert(mainboard_lua, ferr)
mainboard_lua()
- printks(froot, "Mainboard script %s initialized.\n", mainboard_file)
+ root_info("Mainboard script %s initialized.\n", mainboard_file)
do_minimal_setup()
do_mainboard_setup()
else
- printks(froot, "Mainboard script %s not found.\n", mainboard_file)
+ root_info("Mainboard script %s not found.\n", mainboard_file)
do_minimal_setup()
do_default_setup()
end
-printks(froot, "LUA script initialized.\n")
+root_info("LUA script initialized.\n")
return true