Patrick Rudolph (siro@das-labor.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14513
-gerrit
commit 88648a02736d136a99b71acd88a2c7c07b746a87 Author: Patrick Rudolph siro@das-labor.org Date: Mon Apr 25 17:16:13 2016 +0200
serialice-lua: Don't hardcode rom_size
Read bios filesize and use it instead of hardcoding it to 4MiB.
Change-Id: I0f7aa9e9ba5e2368d93dda59fb9ce6e9e470dc0c Signed-off-by: Patrick Rudolph siro@das-labor.org --- SerialICE/simba/replay.lua | 19 +++++++++++++++---- SerialICE/simba/user_env.lua | 4 ---- qemu-0.15.x/serialice-lua.c | 11 ++++++++++- qemu-0.15.x/serialice.c | 10 ++++++---- qemu-0.15.x/serialice.h | 2 +- 5 files changed, 32 insertions(+), 14 deletions(-)
diff --git a/SerialICE/simba/replay.lua b/SerialICE/simba/replay.lua index e7a2868..7f3ac57 100644 --- a/SerialICE/simba/replay.lua +++ b/SerialICE/simba/replay.lua @@ -8,6 +8,8 @@ function SerialICE_system_reset() end
SerialICE_mainboard = "undetected" +rom_size = 0 +rom_base = 0
regs = { eax, ebc, ecx, edx, cs=0, eip=0, ds, es, ss, gs, fs, } ids = { parent, this, flags} @@ -169,15 +171,24 @@ end
function parse_headers() while true do - local found = false + local found_mb = false + local found_rom = false line = io.read("*line") - if not found then + if not found_mb then local board - found, _, board = string.find(line, "SerialICE: Mainboard...:%s+(.+)") - if found then + found_mb, _, board = string.find(line, "SerialICE: Mainboard...:%s+(.+)") + if found_mb then SerialICE_mainboard = board end end + if not found_rom then + local romsize + found_rom, _, romsize = string.find(line, "SerialICE: ROM size:%s+(.+)") + if found_rom then + rom_size = tonumber(romsize, 16) + rom_base = 0x100000000 - tonumber(romsize, 16) + end + end if string.find(line, "LUA script initialized.") then return end diff --git a/SerialICE/simba/user_env.lua b/SerialICE/simba/user_env.lua index ff9f64d..51da977 100644 --- a/SerialICE/simba/user_env.lua +++ b/SerialICE/simba/user_env.lua @@ -25,10 +25,6 @@ cache_nvram = false -- SMSC 0x07, Winbond 0x06 ? DEFAULT_SUPERIO_LDN_REGISTER = 0x07
--- FIXME: Use bios file image size here. -rom_size = 4 * 1024 * 1024 -rom_base = 0x100000000 - rom_size - -- We refrain from backing up most of memory in Qemu because Qemu would -- need lots of ram on the host and firmware usually does not intensively -- use high memory anyways. diff --git a/qemu-0.15.x/serialice-lua.c b/qemu-0.15.x/serialice-lua.c index f6c4c31..883690b 100644 --- a/qemu-0.15.x/serialice-lua.c +++ b/qemu-0.15.x/serialice-lua.c @@ -193,11 +193,12 @@ static int serialice_lua_registers(void) return 0; }
-const SerialICE_filter * serialice_lua_init(const char *serialice_lua_script) +const SerialICE_filter * serialice_lua_init(const char *serialice_lua_script, int bios_size) { int status;
printf("SerialICE: LUA init...\n"); + printf("SerialICE: ROM size: %x\n", bios_size);
/* Create a LUA context and load LUA libraries */ L = luaL_newstate(); @@ -207,6 +208,14 @@ const SerialICE_filter * serialice_lua_init(const char *serialice_lua_script) lua_register(L, "SerialICE_register_physical", serialice_register_physical); lua_register(L, "SerialICE_system_reset", serialice_system_reset);
+ /* Set global variable rom_size */ + lua_pushinteger(L, bios_size); + lua_setglobal(L, "rom_size"); + + /* Set global variable rom_base */ + lua_pushinteger(L, 0x100000000ULL - bios_size); + lua_setglobal(L, "rom_base"); + /* Set global variable SerialICE_mainboard */ lua_pushstring(L, serialice_mainboard); lua_setglobal(L, "SerialICE_mainboard"); diff --git a/qemu-0.15.x/serialice.c b/qemu-0.15.x/serialice.c index 793951f..9062ca1 100644 --- a/qemu-0.15.x/serialice.c +++ b/qemu-0.15.x/serialice.c @@ -193,7 +193,7 @@ void serialice_io_write(uint16_t port, unsigned int size, uint32 data) // ************************************************************************** // initialization and exit
-static void serialice_init(void) +static void serialice_init(int bios_size) { dumb_screen();
@@ -203,7 +203,7 @@ static void serialice_init(void) target->mainboard();
printf("SerialICE: LUA init...\n"); - filter = serialice_lua_init(SERIALICE_LUA_SCRIPT); + filter = serialice_lua_init(SERIALICE_LUA_SCRIPT, bios_size);
/* Let the rest of Qemu know we're alive */ serialice_active = 1; @@ -254,8 +254,6 @@ static void pc_init_serialice(ram_addr_t ram_size, qemu_register_reset((QEMUResetHandler *) cpu_reset, env); }
- /* Must not happen before CPUs are initialized */ - serialice_init();
/* BIOS load */ if (bios_name == NULL) @@ -269,6 +267,10 @@ static void pc_init_serialice(ram_addr_t ram_size, if (bios_size <= 0 || (bios_size % 65536) != 0) { goto bios_error; } + + /* Must not happen before CPUs are initialized */ + serialice_init(bios_size); + bios_offset = qemu_ram_alloc(NULL, "serialice_bios", bios_size); ret = load_image(filename, qemu_get_ram_ptr(bios_offset)); if (ret != bios_size) { diff --git a/qemu-0.15.x/serialice.h b/qemu-0.15.x/serialice.h index 23e3af6..7ff932f 100644 --- a/qemu-0.15.x/serialice.h +++ b/qemu-0.15.x/serialice.h @@ -96,7 +96,7 @@ typedef struct { void (*cpuid_post) (cpuid_regs_t * res); } SerialICE_filter;
-const SerialICE_filter *serialice_lua_init(const char *serialice_lua_script); +const SerialICE_filter *serialice_lua_init(const char *serialice_lua_script, int bios_size); void serialice_lua_exit(void); const char *serialice_lua_execute(const char *cmd);