Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/1651
-gerrit
commit 85ec5ab0b6cfdb8da5d311e55b237f5e5179414c
Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Date: Sun Oct 28 09:51:43 2012 +0200
Add sample mainboard scripts
Scripts are written by replaying old logfiles from these platforms,
they may or may not work when used live.
Change-Id: I6510d9c82625eb6315cfd92d4a4b961a61e555a3
Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
---
SerialICE/simba/aopen_dxpl_plus.lua | 143 ++++++++++++++++++++++++++++
SerialICE/simba/asrock_775i65g.lua | 11 +++
SerialICE/simba/asus_p4p800_vm.lua | 83 +++++++++++++++++
SerialICE/simba/conroexfire_esata2.lua | 87 +++++++++++++++++
SerialICE/simba/intel_d845gbv2.lua | 93 +++++++++++++++++++
SerialICE/simba/intel_d946gzis.lua | 78 ++++++++++++++++
SerialICE/simba/serialice.lua | 15 ++-
SerialICE/simba/via_epia_m_850.lua | 165 +++++++++++++++++++++++++++++++++
8 files changed, 673 insertions(+), 2 deletions(-)
diff --git a/SerialICE/simba/aopen_dxpl_plus.lua b/SerialICE/simba/aopen_dxpl_plus.lua
new file mode 100644
index 0000000..bc5459c
--- /dev/null
+++ b/SerialICE/simba/aopen_dxpl_plus.lua
@@ -0,0 +1,143 @@
+-- SerialICE
+--
+-- Copyright (c) 2012 Kyösti Mälkki <kyosti.malkki(a)gmail.com>
+--
+-- Permission is hereby granted, free of charge, to any person obtaining a copy
+-- of this software and associated documentation files (the "Software"), to deal
+-- in the Software without restriction, including without limitation the rights
+-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+-- copies of the Software, and to permit persons to whom the Software is
+-- furnished to do so, subject to the following conditions:
+--
+-- The above copyright notice and this permission notice shall be included in
+-- all copies or substantial portions of the Software.
+--
+-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+-- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+-- THE SOFTWARE.
+--
+
+dofile("i82801.lua")
+dofile("intel_bars.lua")
+
+-- **********************************************************
+--
+
+function mainboard_io_read(f, action)
+ -- Some timer loop
+ if ( action.addr == 0x61 ) then
+ if ( regs.eip == 0x1634 ) then
+ regs.ecx = 0x01
+ return fake_action(f, action, 0x20)
+ end
+ if ( regs.eip == 0x163a ) then
+ regs.ecx = 0x01
+ return fake_action(f, action, 0x30)
+ end
+ end
+
+ -- IO slowdown
+ if action.addr == 0xed then
+ ignore_action(f, action)
+ return drop_action(f, action, 0)
+ end
+
+ if action.addr == 0xcfb then
+ ignore_action(f, action)
+ return drop_action(f, action, 0)
+ end
+
+ return skip_filter(f, action)
+end
+
+
+function mainboard_io_write(f, action)
+
+ -- Catch RAM controller ready.
+ if action.addr == 0x80 and action.data == 0x2c and not ram_enabled() then
+ enable_ram()
+ end
+
+ if action.addr == 0xcfb then
+ ignore_action(f, action)
+ return drop_action(f, action, 0)
+ end
+
+ if action.addr == 0xed then
+ if ( regs.eip == 0x1792 ) then
+ regs.ecx = 0x01
+ end
+if false then
+ -- SIPI delay
+ if ( regs.eip == 0xb3bc or regs.eip == 0xb3bf ) then
+ regs.ecx = 0x01
+ end
+ if ( regs.eip == 0xb4ad or regs.eip == 0xb4af ) then
+ regs.ecx = 0x01
+ end
+end
+ ignore_action(f, action)
+ return drop_action(f, action, action.data)
+ end
+
+ return skip_filter(f, action)
+end
+
+function mainboard_io_pre(f, action)
+ if action.write then
+ return mainboard_io_write(f, action)
+ else
+ return mainboard_io_read(f, action)
+ end
+end
+
+function mainboard_io_post(f, action)
+ if action.addr == 0xed or action.addr == 0xcfb then
+ return true
+ end
+
+ -- If KBD controller returns status=0xff, clear 0x02.
+ if action.addr == 0x64 and not action.write and action.size == 1 then
+ if action.data == 0xff then
+ -- tag these but give out correct data
+ fake_action(f, action, action.data)
+ end
+ end
+end
+
+filter_mainboard = {
+ id = -1,
+ name = "AOpen",
+ pre = mainboard_io_pre,
+ post = mainboard_io_post,
+ hide = hide_mainboard_io,
+ base = 0x0,
+ size = 0x10000
+}
+
+
+function do_mainboard_setup()
+ enable_hook(io_hooks, filter_pci_io_cfg)
+ enable_hook(mem_hooks, filter_lapic)
+ enable_hook(mem_hooks, filter_ioapic)
+
+ enable_hook(cpumsr_hooks, filter_intel_microcode)
+ enable_hook(cpuid_hooks, filter_multiprocessor)
+
+ -- I have a hook to detect RAM initialisation from
+ -- a POST code I can skip this here
+ --enable_ram()
+
+ enable_hook_pc80()
+ enable_hook_superio(0x2e, 0x07)
+ --enable_hook(io_hooks, filter_com1)
+ enable_hook_i82801dx()
+ northbridge_e7505()
+
+ -- Apply mainboard hooks last, so they are the first ones to check
+ enable_hook(io_hooks, filter_mainboard)
+end
diff --git a/SerialICE/simba/asrock_775i65g.lua b/SerialICE/simba/asrock_775i65g.lua
new file mode 100644
index 0000000..7021554
--- /dev/null
+++ b/SerialICE/simba/asrock_775i65g.lua
@@ -0,0 +1,11 @@
+
+dofile("i82801.lua")
+
+function do_mainboard_setup()
+ do_default_setup()
+
+ enable_hook_i82801dx()
+
+ -- Apply mainboard hooks last, so they are the first ones to check
+ --enable_hook(io_hooks, filter_mainboard)
+end
diff --git a/SerialICE/simba/asus_p4p800_vm.lua b/SerialICE/simba/asus_p4p800_vm.lua
new file mode 100644
index 0000000..aad1932
--- /dev/null
+++ b/SerialICE/simba/asus_p4p800_vm.lua
@@ -0,0 +1,83 @@
+
+
+function mainboard_io_read(f, action)
+ -- Some timer loop
+ if ( action.addr == 0x61 ) then
+ if ( regs.eip == 0x1634 ) then
+ regs.ecx = 0x01
+ return fake_action(f, action, 0x20)
+ end
+ if ( regs.eip == 0x163a ) then
+ regs.ecx = 0x01
+ return fake_action(f, action, 0x30)
+ end
+ end
+
+ -- IO slowdown
+ if action.addr == 0xed then
+ ignore_action(f, action)
+ return drop_action(f, action, 0)
+ end
+
+ if action.addr == 0xcfb then
+ ignore_action(f, action)
+ return drop_action(f, action, 0)
+ end
+
+ return skip_filter(f, action)
+end
+
+
+function mainboard_io_write(f, action)
+
+
+ if action.addr == 0xcfb then
+ ignore_action(f, action)
+ return drop_action(f, action, 0)
+ end
+
+ if action.addr == 0xe1 then
+ ignore_action(f, action)
+ return drop_action(f, action, action.data)
+ end
+
+ return skip_filter(f, action)
+end
+
+function mainboard_io_pre(f, action)
+ if action.write then
+ return mainboard_io_write(f, action)
+ else
+ return mainboard_io_read(f, action)
+ end
+end
+
+function mainboard_io_post(f, action)
+ if action.addr == 0xe1 or action.addr == 0xed or action.addr == 0xcfb then
+ return true
+ end
+ if action.addr == 0x80 and not action.write then
+ return true
+ end
+end
+
+filter_mainboard = {
+ id = -1,
+ name = "test",
+ pre = mainboard_io_pre,
+ post = mainboard_io_post,
+ hide = hide_mainboard_io,
+ base = 0x0,
+ size = 0x10000
+}
+
+dofile("i82801.lua")
+
+function do_mainboard_setup()
+ do_default_setup()
+
+ enable_hook_i82801dx()
+
+ -- Apply mainboard hooks last, so they are the first ones to check
+ enable_hook(io_hooks, filter_mainboard)
+end
diff --git a/SerialICE/simba/conroexfire_esata2.lua b/SerialICE/simba/conroexfire_esata2.lua
new file mode 100644
index 0000000..5f8b198
--- /dev/null
+++ b/SerialICE/simba/conroexfire_esata2.lua
@@ -0,0 +1,87 @@
+
+
+
+function mainboard_io_read(f, action)
+ -- Some timer loop
+ if ( action.addr == 0x61 ) then
+ if ( regs.eip == 0x1634 ) then
+ regs.ecx = 0x01
+ return fake_action(f, action, 0x20)
+ end
+ if ( regs.eip == 0x163a ) then
+ regs.ecx = 0x01
+ return fake_action(f, action, 0x30)
+ end
+ end
+
+ -- IO slowdown
+ if action.addr == 0xed then
+ ignore_action(f, action)
+ return drop_action(f, action, 0)
+ end
+
+ if action.addr == 0xcfb then
+ ignore_action(f, action)
+ return drop_action(f, action, 0)
+ end
+
+ return skip_filter(f, action)
+end
+
+
+function mainboard_io_write(f, action)
+
+
+ if action.addr == 0xcfb then
+ ignore_action(f, action)
+ return drop_action(f, action, 0)
+ end
+
+ if action.addr == 0xe1 then
+ ignore_action(f, action)
+ return drop_action(f, action, action.data)
+ end
+
+ return skip_filter(f, action)
+end
+
+function mainboard_io_pre(f, action)
+ if action.write then
+ return mainboard_io_write(f, action)
+ else
+ return mainboard_io_read(f, action)
+ end
+end
+
+function mainboard_io_post(f, action)
+ if action.addr == 0xe1 or action.addr == 0xed or action.addr == 0xcfb then
+ return true
+ end
+ if action.addr == 0x80 and not action.write then
+ return true
+ end
+end
+
+filter_mainboard = {
+ id = -1,
+ name = "test",
+ pre = mainboard_io_pre,
+ post = mainboard_io_post,
+ hide = hide_mainboard_io,
+ base = 0x0,
+ size = 0x10000
+}
+
+dofile("i82801.lua")
+dofile("intel_bars.lua")
+
+function do_mainboard_setup()
+ do_default_setup()
+
+ enable_hook_i82801gx()
+
+ northbridge_i945()
+
+ -- Apply mainboard hooks last, so they are the first ones to check
+ enable_hook(io_hooks, filter_mainboard)
+end
diff --git a/SerialICE/simba/intel_d845gbv2.lua b/SerialICE/simba/intel_d845gbv2.lua
new file mode 100644
index 0000000..43921ee
--- /dev/null
+++ b/SerialICE/simba/intel_d845gbv2.lua
@@ -0,0 +1,93 @@
+
+
+function mainboard_io_read(f, action)
+ -- Some timer loop
+ if ( action.addr == 0x61 ) then
+ end
+
+ -- IO slowdown
+ if action.addr == 0xed then
+ ignore_action(f, action)
+ return drop_action(f, action, 0)
+ end
+
+ if action.addr == 0xcfb then
+ ignore_action(f, action)
+ return drop_action(f, action, 0)
+ end
+
+ return skip_filter(f, action)
+end
+
+
+function mainboard_io_write(f, action)
+
+ -- Catch RAM controller ready.
+ if action.addr == 0x80 and action.data == 0xd5 and not ram_enabled() then
+ -- enable_ram()
+ end
+
+ if action.addr == 0xcfb then
+ ignore_action(f, action)
+ return drop_action(f, action, 0)
+ end
+
+ if action.addr == 0xe1 then
+ ignore_action(f, action)
+ return drop_action(f, action, action.data)
+ end
+
+ return skip_filter(f, action)
+end
+
+function mainboard_io_pre(f, action)
+ if action.write then
+ return mainboard_io_write(f, action)
+ else
+ return mainboard_io_read(f, action)
+ end
+end
+
+function mainboard_io_post(f, action)
+ if action.addr == 0xe1 or action.addr == 0xed or action.addr == 0xcfb then
+ return true
+ end
+ if action.addr == 0x80 and not action.write then
+ return true
+ end
+end
+
+filter_mainboard = {
+ id = -1,
+ name = "GEBV2",
+ pre = mainboard_io_pre,
+ post = mainboard_io_post,
+ hide = hide_mainboard_io,
+ base = 0x0,
+ size = 0x10000
+}
+
+dofile("i82801.lua")
+
+function do_mainboard_setup()
+ new_car_region(0xfef00000, 0x800)
+
+ enable_hook(io_hooks, filter_pci_io_cfg)
+ enable_hook(mem_hooks, filter_lapic)
+ enable_hook(mem_hooks, filter_ioapic)
+
+ enable_hook(cpumsr_hooks, filter_intel_microcode)
+ enable_hook(cpuid_hooks, filter_multiprocessor)
+
+ -- I have a hook to detect RAM initialisation from
+ -- a POST code I can skip this here
+ enable_ram()
+
+ enable_hook_pc80()
+ enable_hook_superio(0x2e, 0x07)
+ --enable_hook(io_hooks, filter_com1)
+ enable_hook_i82801dx()
+
+ -- Apply mainboard hooks last, so they are the first ones to check
+ enable_hook(io_hooks, filter_mainboard)
+end
diff --git a/SerialICE/simba/intel_d946gzis.lua b/SerialICE/simba/intel_d946gzis.lua
new file mode 100644
index 0000000..ea46ba3
--- /dev/null
+++ b/SerialICE/simba/intel_d946gzis.lua
@@ -0,0 +1,78 @@
+
+
+
+function mainboard_io_read(f, action)
+ -- IO slowdown
+ if action.addr == 0xed then
+ ignore_action(f, action)
+ return drop_action(f, action, 0)
+ end
+
+ if action.addr == 0xcfb then
+ ignore_action(f, action)
+ return drop_action(f, action, 0)
+ end
+
+ return skip_filter(f, action)
+end
+
+
+function mainboard_io_write(f, action)
+
+
+ if action.addr == 0xcfb then
+ ignore_action(f, action)
+ return drop_action(f, action, 0)
+ end
+
+ if action.addr == 0xe1 then
+ ignore_action(f, action)
+ return drop_action(f, action, action.data)
+ end
+
+ return skip_filter(f, action)
+end
+
+function mainboard_io_pre(f, action)
+ if action.write then
+ return mainboard_io_write(f, action)
+ else
+ return mainboard_io_read(f, action)
+ end
+end
+
+function mainboard_io_post(f, action)
+ if action.addr == 0xe1 or action.addr == 0xed or action.addr == 0xcfb then
+ return true
+ end
+ if action.addr == 0x80 and not action.write then
+ return true
+ end
+end
+
+filter_mainboard = {
+ id = -1,
+ name = "test",
+ pre = mainboard_io_pre,
+ post = mainboard_io_post,
+ hide = hide_mainboard_io,
+ base = 0x0,
+ size = 0x10000
+}
+
+dofile("i82801.lua")
+dofile("intel_bars.lua")
+
+function do_mainboard_setup()
+ do_default_setup()
+
+ enable_hook_i82801gx()
+ enable_hook(cpumsr_hooks, filter_intel_microcode)
+ enable_hook(cpuid_hooks, filter_multiprocessor)
+ northbridge_i946()
+
+ new_car_region(0xfef00000,0x2000)
+
+ -- Apply mainboard hooks last, so they are the first ones to check
+ enable_hook(io_hooks, filter_mainboard)
+end
diff --git a/SerialICE/simba/serialice.lua b/SerialICE/simba/serialice.lua
index 9d2f672..9eb287d 100644
--- a/SerialICE/simba/serialice.lua
+++ b/SerialICE/simba/serialice.lua
@@ -36,6 +36,7 @@ hide_i8254_io = true
hide_i8259_io = true
hide_superio_cfg = true
hide_smbus_io = true
+hide_mainboard_io = true
-- Set to "true" to log every memory and IO access
log_everything = false
@@ -90,8 +91,18 @@ function do_default_setup()
end
end
-do_minimal_setup()
-do_default_setup()
+mainboard_file = string.format("%s.lua", string.lower(string.gsub(SerialICE_mainboard, "[ -]", "_")))
+local mainboard_lua = loadfile(mainboard_file)
+if (mainboard_lua) then
+ mainboard_lua()
+ printks(froot, "Mainboard script %s initialized.\n", mainboard_file)
+ do_minimal_setup()
+ do_mainboard_setup()
+else
+ printks(froot, "Mainboard script %s not found.\n", mainboard_file)
+ do_minimal_setup()
+ do_default_setup()
+end
printks(froot, "LUA script initialized.\n")
diff --git a/SerialICE/simba/via_epia_m_850.lua b/SerialICE/simba/via_epia_m_850.lua
new file mode 100644
index 0000000..e4649c4
--- /dev/null
+++ b/SerialICE/simba/via_epia_m_850.lua
@@ -0,0 +1,165 @@
+-- SerialICE
+--
+-- Copyright (c) 2012 Kyösti Mälkki <kyosti.malkki(a)gmail.com>
+--
+-- Permission is hereby granted, free of charge, to any person obtaining a copy
+-- of this software and associated documentation files (the "Software"), to deal
+-- in the Software without restriction, including without limitation the rights
+-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+-- copies of the Software, and to permit persons to whom the Software is
+-- furnished to do so, subject to the following conditions:
+--
+-- The above copyright notice and this permission notice shall be included in
+-- all copies or substantial portions of the Software.
+--
+-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+-- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+-- THE SOFTWARE.
+--
+
+
+-- **********************************************************
+--
+
+function mainboard_io_read(f, action)
+
+ -- IO slowdown
+ if action.addr == 0xed then
+ ignore_action(f, action)
+ return drop_action(f, action, 0)
+ end
+
+ -- IO slowdown
+ if action.addr == 0xeb then
+ ignore_action(f, action)
+ return drop_action(f, action, 0)
+ end
+
+ if action.addr == 0xcfb then
+ ignore_action(f, action)
+ return drop_action(f, action, 0)
+ end
+
+ return skip_filter(f, action)
+end
+
+
+function mainboard_io_write(f, action)
+
+ -- Catch RAM controller ready.
+ if action.addr == 0x80 and action.data == 0x2c and not ram_enabled() then
+ enable_ram()
+ end
+
+-- if action.addr == 0xcfb then
+-- ignore_action(f, action)
+-- return drop_action(f, action, 0)
+-- end
+
+ if action.addr == 0xeb then
+ ignore_action(f, action)
+ return drop_action(f, action, action.data)
+ end
+
+ if action.addr == 0xed then
+ ignore_action(f, action)
+ return drop_action(f, action, action.data)
+ end
+
+ return skip_filter(f, action)
+end
+
+function mainboard_io_pre(f, action)
+ if action.write then
+ return mainboard_io_write(f, action)
+ else
+ return mainboard_io_read(f, action)
+ end
+end
+
+function mainboard_io_post(f, action)
+ if action.addr == 0xeb or action.addr == 0xed then
+ return true
+ end
+
+ -- If KBD controller returns status=0xff, clear 0x02.
+ if action.addr == 0x64 and not action.write and action.size == 1 then
+ if action.data == 0xff then
+ -- tag these but give out correct data
+ fake_action(f, action, action.data)
+ end
+ end
+end
+
+filter_mainboard = {
+ id = -1,
+ name = "VIA",
+ pre = mainboard_io_pre,
+ post = mainboard_io_post,
+ hide = hide_mainboard_io,
+ base = 0x0,
+ size = 0x10000
+}
+
+
+
+-- MOVE THIS TO CHIPSET FILE
+
+dofile("intel_smbus.lua")
+dofile("via_bars.lua")
+
+function smbus_bar_hook(dev, reg, base)
+ intel_smbus_setup(base, 0x20)
+end
+
+dev_sb_lpc = {
+ pci_dev = pci_bdf(0x0,0x1f,0x3,0x0),
+ name = "Smbus",
+ bar = {},
+}
+
+dev_power = {
+ pci_dev = pci_bdf(0x0,0x11,0x0,0x0),
+ name = "SYS",
+ bar = {},
+ acpi = { f = nil },
+ tco = { f = nil },
+}
+
+function pm_io_bar(dev, reg, base)
+ dev.acpi.name = "ACPI"
+ dev.acpi.base = base
+ dev.acpi.size = 0x60
+ generic_io_bar(dev.acpi)
+end
+
+
+
+-- ****************
+
+function do_mainboard_setup()
+ enable_hook(io_hooks, filter_pci_io_cfg)
+ enable_hook(mem_hooks, filter_lapic)
+ enable_hook(mem_hooks, filter_ioapic)
+
+ enable_hook(cpumsr_hooks, filter_intel_microcode)
+ enable_hook(cpuid_hooks, filter_multiprocessor)
+
+ -- I have a hook to detect RAM initialisation from
+ -- a POST code I can skip this here
+ --enable_ram()
+
+ enable_hook_pc80()
+ enable_hook_superio(0x4e, 0x07)
+
+ northbridge_vx900()
+ pci_cfg16_hook(dev_power, 0x88, "PM", pm_io_bar)
+ pci_cfg16_hook(dev_power, 0xd0, "SMBus", smbus_bar_hook)
+
+ -- Apply mainboard hooks last, so they are the first ones to check
+ enable_hook(io_hooks, filter_mainboard)
+end
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/1648
-gerrit
commit 562525ed1cfe0bab64520605d057fc4448a39d68
Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Date: Sun Oct 28 11:54:51 2012 +0200
Add APIC memory spaces
To be precise, the base addresses of APICs are actually configurable
in either PCI config space or an MSR. For now, this decodes at
the commonly used and fixed base address for both IOAPIC and LAPIC.
For LAPIC, Startup-IPI is replaced with INIT IPI to prevent AP CPUs
from attempting to execute code from Flash.
Change-Id: Icdbb8cd460bba440b466860f7e92f8a83cdb9d00
Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
---
SerialICE/simba/mmio.lua | 40 ++++++++++++++++++++++++++++++++++++++++
SerialICE/simba/serialice.lua | 3 +++
2 files changed, 43 insertions(+)
diff --git a/SerialICE/simba/mmio.lua b/SerialICE/simba/mmio.lua
new file mode 100644
index 0000000..695315f
--- /dev/null
+++ b/SerialICE/simba/mmio.lua
@@ -0,0 +1,40 @@
+
+-- **********************************************************
+--
+-- Vendor independent X86 memory mapped IO
+
+-- Local APIC
+-- We should avoid that someone wakes up cores
+-- on the target system that go wild.
+function mem_lapic(f, action)
+ if bit32.band(action.addr, f.size-1) == 0x300 then
+ -- replace Start-Up IPI with Init IPI
+ if action.write and bit32.band(action.data, 0xf0f00) == 0xc0600 then
+ return fake_action(f, action, 0xc0500)
+ end
+ end
+ return handle_action(f, action)
+end
+
+filter_lapic = {
+ id = -1,
+ name = "LAPIC",
+ pre = mem_lapic,
+ post = mem_base_post,
+ hide = true,
+ base = 0xfee00000,
+ size = 0x00010000,
+}
+
+-- IOAPIC
+filter_ioapic = {
+ id = -1,
+ name = "IOAPIC",
+ pre = mem_target_only,
+ post = mem_base_post,
+ hide = true,
+ base = 0xfec00000,
+ size = 0x00010000,
+}
+
+
diff --git a/SerialICE/simba/serialice.lua b/SerialICE/simba/serialice.lua
index 3700589..08625d6 100644
--- a/SerialICE/simba/serialice.lua
+++ b/SerialICE/simba/serialice.lua
@@ -64,6 +64,7 @@ dofile("cpu.lua")
dofile("pci_cfg.lua")
dofile("pc80.lua")
dofile("superio.lua")
+dofile("mmio.lua")
function do_minimal_setup()
enable_hook(io_hooks, filter_io_fallback)
@@ -76,6 +77,8 @@ end
function do_default_setup()
enable_ram()
+ enable_hook(mem_hooks, filter_lapic)
+ enable_hook(mem_hooks, filter_ioapic)
enable_hook(io_hooks, filter_pci_io_cfg)
enable_hook_pc80()
enable_hook_superio(0x2e, DEFAULT_SUPERIO_LDN_REGISTER)
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/1644
-gerrit
commit eeb22786e622d85091719d3b8d0b62865913424f
Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Date: Sun Oct 28 11:01:47 2012 +0200
Add log replayer
If you create the log from serialice with log_everything=true,
you can modify the filters and pipe the logfile through the replayer
without having to run Qemu again. This mostly works with old logfiles
created with the single-file script too.
$ cat qemu_logfile.txt | lua replay.lua
Change-Id: I80f94f6cdb13b1f52188f4b9560ec040fb831fe8
Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
---
SerialICE/simba/replay.lua | 186 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 186 insertions(+)
diff --git a/SerialICE/simba/replay.lua b/SerialICE/simba/replay.lua
new file mode 100644
index 0000000..fcfabf3
--- /dev/null
+++ b/SerialICE/simba/replay.lua
@@ -0,0 +1,186 @@
+
+
+function SerialICE_register_physical()
+end
+
+function SerialICE_system_reset()
+end
+
+SerialICE_mainboard = "undetected"
+
+regs = { eax, ebc, ecx, edx, cs=0, eip=0, ds, es, ss, gs, fs, }
+ids = { parent, this, }
+
+function replay_io(dir_wr, addr, size, data)
+ pre_action(io_action, dir_wr, addr, size, data)
+ walk_pre_hooks(io_hooks, io_action)
+ io_action.data = data
+ post_action(io_action, data)
+ walk_post_hooks(io_hooks, io_action)
+end
+
+function replay_mem(dir_wr, addr, size, data)
+ pre_action(mem_action, dir_wr, addr, size, data)
+ walk_pre_hooks(mem_hooks, mem_action)
+ mem_action.data = data
+ post_action(mem_action, data)
+ walk_post_hooks(mem_hooks, mem_action)
+end
+
+function replay_unknown(str)
+ local dummy = {}
+ pre_action(dummy, false, 0, 0, 0)
+ post_action(dummy, 0)
+ io.write(string.format("[%04x:%04x] %04x.%04x %s\n",
+ regs.cs, regs.eip, ids.parent, ids.this, str))
+end
+
+function parse_cpu(line)
+ if string.find(line, "CPUID") then
+ replay_unknown(line)
+ return true
+ end
+ if string.find(line, "CPU MSR") then
+ replay_unknown(line)
+ return true
+ end
+ return false
+end
+
+
+function parse_io(line)
+ local io_op = "IO[^:]*:?%s+%a+%s+(%x+)%s+(<?=>?)%s+(%x+)"
+ local found, addr, dir, data
+ found, _, addr, dir, data = string.find(line, io_op)
+ if not found then
+ return false
+ end
+ local naddr = tonumber(addr, 16)
+ local ndata = tonumber(data, 16)
+ local nsize = string.len(data)/2
+ if string.find("<=", dir) then
+ replay_io(true, naddr, nsize, ndata)
+ else
+ replay_io(false, naddr, nsize, ndata)
+ end
+ return true
+end
+
+function parse_mem(line)
+ local mem_op = "MEM[^:]*:?%s+%a+%s+(%x+)%s+(<?=>?)%s+(%x+)"
+ local found, addr, dir, data
+ found, _, addr, dir, data = string.find(line, mem_op)
+ if not found then
+ return false
+ end
+ local naddr = tonumber(addr, 16)
+ local ndata = tonumber(data, 16)
+ local nsize = string.len(data)/2
+ if string.find("<=", dir) then
+ replay_mem(true, naddr, nsize, ndata)
+ else
+ replay_mem(false, naddr, nsize, ndata)
+ end
+ return true
+end
+
+-- Old script already parsed PCI config, synthesize those IOs back.
+function parse_pci(line)
+ local found, bus, dev, fn, reg, dir, data
+ local pci_cfg = "PCI:?%s+(%x):(%x+).(%x+)%s+R.(%x+)%s+(<?=>?)%s+(%x+)"
+ found, _, bus, dev, fn, reg, dir, data = string.find(line, pci_cfg)
+ if not found then
+ local pci_cfg_empty = "PCI:?%s+(%x):(%x+).(%x+)%s+R.(%x+)"
+ if string.find(line, pci_cfg_empty) then
+ return true
+ end
+ return false
+ end
+
+ local nreg = bit32.band(0xfc, tonumber(reg,16))
+ local noff = bit32.band(0x03, tonumber(reg,16))
+ local ndata = tonumber(data,16)
+ local nsize = string.len(data)/2
+
+ replay_io(true, 0xcf8, 4, pci_bdf(tonumber(bus,16), tonumber(dev,16), tonumber(fn,16), nreg))
+ if string.find("<=", dir) then
+ replay_io(true, 0xcfc + noff, nsize, ndata)
+ else
+ replay_io(false, 0xcfc + noff, nsize, ndata)
+ end
+ return true
+end
+
+function parse_headers()
+ while true do
+ local found = false
+ line = io.read("*line")
+ if not found then
+ local board
+ found, _, board = string.find(line, "SerialICE: Mainboard...:%s+(.+)")
+ if found then
+ SerialICE_mainboard = board
+ end
+ end
+-- io.write(line)
+-- io.write("\n")
+ if string.find(line, "LUA script initialized.") then
+ return
+ end
+ end
+end
+
+function parse_file()
+ while true do
+ local iplog = false
+ local found = false
+ local line, str, cs, eip, a, b
+
+ line = io.read("*line")
+ if not line then
+ return
+ end
+
+ regs.cs = 0
+ regs.eip = 0
+ ids.parent = 0
+ ids.this = 0
+ iplog, _, cs, eip, a, b, str = string.find(line, "%[(%x+):(%x+)%]%s+(%x+)[%.:](%x+)...(.*)")
+ if iplog then
+ regs.cs = tonumber(cs, 16)
+ regs.eip = tonumber(eip, 16)
+ ids.parent = tonumber(a, 16)
+ ids.this = tonumber(b, 16)
+ end
+
+ if not iplog then
+ str = line
+ end
+
+ if not found then
+ found = parse_io(str)
+ end
+ if not found then
+ found = parse_pci(str)
+ end
+ if not found then
+ found = parse_mem(str)
+ end
+ if not found then
+ found = parse_cpu(str)
+ end
+ if not found then
+ --replay_unknown(str)
+ end
+ end
+end
+
+parse_headers()
+
+dofile("serialice.lua")
+
+parse_file()
+
+
+
+
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/1643
-gerrit
commit 8b3bcef891346f02b3945f700d734ef1af695aeb
Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Date: Sun Oct 28 14:00:19 2012 +0200
Add CPUID and CPU MSR filters
MSR filter prevents microcode update on the target.
CPUID filter fakes CPU is single-core.
Change-Id: I26479bae215dafe0b1bc114951e04c927423759e
Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
---
SerialICE/simba/cpu.lua | 54 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/SerialICE/simba/cpu.lua b/SerialICE/simba/cpu.lua
index 00162ae..be04825 100644
--- a/SerialICE/simba/cpu.lua
+++ b/SerialICE/simba/cpu.lua
@@ -75,3 +75,57 @@ filter_cpuid_fallback = {
post = cpuid_post,
}
+
+
+function multicore_pre(f, action)
+ return skip_filter(f, action)
+end
+
+function multicore_post(f, action)
+ local rout = action.rout
+ local rin = action.rin
+ -- Set number of cores to 1 on Core Duo and Atom to trick the
+ -- firmware into not trying to wake up non-BSP nodes.
+ if not action.write and rin.eax == 0x01 then
+ rout.ebx = bit32.band(0xff00ffff, rout.ebx);
+ rout.ebx = bit32.bor(0x00010000, rout.ebx);
+ fake_action(f, action, 0)
+ end
+ return skip_filter(f, action)
+end
+
+filter_multiprocessor = {
+ id = -1,
+ name = "Multiprocessor Count",
+ pre = multicore_pre,
+ post = multicore_post,
+}
+
+-- Intel CPU microcode update
+function intel_microcode_pre(f, action)
+ if action.rin.ecx == 0x79 then
+ --action.dropped = true
+ --action.rout.edx = 0
+ --action.rout.eax = 0xffff0000
+ return drop_action(f, action)
+ end
+ return skip_filter(f, action)
+end
+
+-- Intel CPU microcode revision check
+-- Fakes microcode revision of my 0x6f6 Core 2 Duo Mobile
+function intel_microcode_post(f, action)
+ if action.rin.ecx == 0x8b then
+ action.rout.edx = 0xc7
+ action.rout.eax = 0
+ return fake_action(f, action, 0)
+ end
+ return skip_filter(f, action)
+end
+
+filter_intel_microcode = {
+ id = -1,
+ name = "Microcode Update",
+ pre = intel_microcode_pre,
+ post = intel_microcode_post,
+}