[SerialICE] New patch to review for serialice: 85ec5ab Add sample mainboard scripts

Kyösti Mälkki (kyosti.malkki@gmail.com) gerrit at coreboot.org
Sun Oct 28 21:09:09 CET 2012


Kyösti Mälkki (kyosti.malkki at 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 at 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 at 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 at 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 at 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



More information about the SerialICE mailing list