[SerialICE] New patch to review for serialice: serialice-lua: Don't hardcode rom_size

Patrick Rudolph (siro@das-labor.org) gerrit at coreboot.org
Mon Apr 25 19:25:26 CEST 2016


Patrick Rudolph (siro at das-labor.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14513

-gerrit

commit 97fbfa0298108a5fcb326de89b7070b2a9683287
Author: Patrick Rudolph <siro at 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 at das-labor.org>
---
 SerialICE/simba/user_env.lua |  4 ----
 qemu-0.15.x/serialice-lua.c  | 10 +++++++++-
 qemu-0.15.x/serialice.c      | 10 ++++++----
 qemu-0.15.x/serialice.h      |  2 +-
 4 files changed, 16 insertions(+), 10 deletions(-)

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..58c74cd 100644
--- a/qemu-0.15.x/serialice-lua.c
+++ b/qemu-0.15.x/serialice-lua.c
@@ -193,7 +193,7 @@ 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;
 
@@ -207,6 +207,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);
 



More information about the SerialICE mailing list