Kyösti Mälkki (kyosti.malkki@gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2598
-gerrit
commit fcd8a6c3c5080464a16bcf939dc31bc9210b319a Author: Kyösti Mälkki kyosti.malkki@gmail.com Date: Wed Mar 6 20:19:27 2013 +0200
Refactor matching filters to actions
Each hooks list has some criteria when an action matches a filter.
For memory and IO, the action address must be within the range of an enabled filter.
For CPUID and MSR, the filter must be enabled, and the filter internally checks the index parameters.
Change-Id: I6f035a0a39d1f94dc77e1b1dc16459b071ca871a Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- SerialICE/simba/hooks.lua | 56 ++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 30 deletions(-)
diff --git a/SerialICE/simba/hooks.lua b/SerialICE/simba/hooks.lua index 4a0d529..8877cd7 100644 --- a/SerialICE/simba/hooks.lua +++ b/SerialICE/simba/hooks.lua @@ -3,8 +3,8 @@ froot = { id = 0, name = "SerialICE" } fresource = { id = 1, name = "Resource" }
-function new_hooks(str) - return { list = nil, name = str } +function new_hooks(str, rule) + return { list = nil, name = str, match_filter = rule } end
next_filter_id = 2 @@ -21,12 +21,22 @@ function new_parent_action() current_parent_id = action_id() end
+function filter_in_range(f, action) + if f.enable and action.addr >= f.base and action.addr < f.base + f.size then + return true + end + return false +end + +function filter_enabled(f, action) + return f.enable +end
-io_hooks = new_hooks("IO") -mem_hooks = new_hooks("MEM") +io_hooks = new_hooks("IO", filter_in_range) +mem_hooks = new_hooks("MEM", filter_in_range)
-cpumsr_hooks = new_hooks("CPU MSR") -cpuid_hooks = new_hooks("CPUID") +cpumsr_hooks = new_hooks("CPU MSR", filter_enabled) +cpuid_hooks = new_hooks("CPUID", filter_enabled)
function enable_hook(list, filter) if not filter then @@ -76,21 +86,14 @@ function walk_pre_hooks(list, action) local l = list.list local f = nil
- local no_base_check = true - if list == io_hooks or list == mem_hooks then - no_base_check = false - end - while l and not logged do f = l.hook - if no_base_check or action.addr >= f.base and action.addr < f.base + f.size then - if f.enable and f.pre then - if f.pre(f, action) then - if not f.raw then - action.logged_pre = f - end - logged = true + if list.match_filter(f, action) then + if f.pre and f.pre(f, action) then + if not f.raw then + action.logged_pre = f end + logged = true end end l = l.next @@ -113,21 +116,14 @@ function walk_post_hooks(list, action) local l = list.list local f = nil
- local no_base_check = true - if list == io_hooks or list == mem_hooks then - no_base_check = false - end - while l and not logged do f = l.hook - if no_base_check or action.addr >= f.base and action.addr < f.base + f.size then - if f.enable and f.post then - if f.post(f, action) then - if not f.raw then - action.logged_post = f - end - logged = false + if list.match_filter(f, action) then + if f.post and f.post(f, action) then + if not f.raw then + action.logged_post = f end + logged = false end end l = l.next