[SerialICE] Patch set updated for serialice: d56fc16 Port to lua 5.3

Lubomir Rintel (lkundrak@v3.sk) gerrit at coreboot.org
Wed Mar 25 20:55:13 CET 2015


Lubomir Rintel (lkundrak at v3.sk) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8524

-gerrit

commit d56fc16901c97d2d86b92bbf01d2c187807f4a06
Author: Lubomir Rintel <lkundrak at v3.sk>
Date:   Wed Feb 11 09:14:40 2015 +0100

    Port to lua 5.3
    
    It uses integers natively and removes the bit32 library.
    The intsize patch is no longer needed.
    
    Tested on a Thinkpad X60 and X61 (not yet merged, Change-Id:
    I105c69ae53b3735fd60e7461f8f64078e8fef15c)
    
    Change-Id: I9db21b37aaae167fe7f6ebbefc20ea21a872553a
    Signed-off-by: Lubomir Rintel <lkundrak at v3.sk>
---
 SerialICE/patches/lua-5.2.0-intsize.diff | 20 ---------
 SerialICE/patches/lua-5.2.0-shared.diff  | 42 -------------------
 SerialICE/patches/lua-5.2.0-x64-fix.diff | 12 ------
 SerialICE/simba/chipset/i82801.lua       |  6 +--
 SerialICE/simba/chipset/intel_bars.lua   | 14 +++----
 SerialICE/simba/chipset/intel_smbus.lua  | 38 ++++++++---------
 SerialICE/simba/chipset/pc80.lua         | 72 ++++++++++++++++----------------
 SerialICE/simba/chipset/smbus_host.lua   | 14 +++----
 SerialICE/simba/chipset/superio.lua      |  4 +-
 SerialICE/simba/chipset/via_bars.lua     |  8 ++--
 SerialICE/simba/core_io.lua              |  4 +-
 SerialICE/simba/cpu.lua                  | 10 ++---
 SerialICE/simba/hooks.lua                | 10 ++---
 SerialICE/simba/mmio.lua                 |  4 +-
 SerialICE/simba/pci_cfg.lua              | 48 ++++++++++-----------
 SerialICE/simba/replay.lua               |  4 +-
 qemu-0.15.x/configure                    | 28 +++----------
 qemu-0.15.x/serialice-lua.c              |  2 +-
 18 files changed, 125 insertions(+), 215 deletions(-)

diff --git a/SerialICE/patches/lua-5.2.0-intsize.diff b/SerialICE/patches/lua-5.2.0-intsize.diff
deleted file mode 100644
index e29ffae..0000000
--- a/SerialICE/patches/lua-5.2.0-intsize.diff
+++ /dev/null
@@ -1,20 +0,0 @@
-diff -ur lua-5.2.0/src/luaconf.h lua-5.2.0-shared/src/luaconf.h
---- lua-5.2.0/src/luaconf.h	2011-12-06 17:58:36.000000000 +0100
-+++ lua-5.2.0-shared/src/luaconf.h	2012-06-12 22:25:20.179943819 +0200
-@@ -10,6 +10,7 @@
- 
- #include <limits.h>
- #include <stddef.h>
-+#include <stdint.h>
- 
- 
- /*
-@@ -444,7 +445,7 @@
- ** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
- ** machines, ptrdiff_t gives a good choice between int or long.)
- */
--#define LUA_INTEGER	ptrdiff_t
-+#define LUA_INTEGER	int64_t
- 
- /*
- @@ LUA_UNSIGNED is the integral type used by lua_pushunsigned/lua_tounsigned.
diff --git a/SerialICE/patches/lua-5.2.0-shared.diff b/SerialICE/patches/lua-5.2.0-shared.diff
deleted file mode 100644
index 4b8aaaf..0000000
--- a/SerialICE/patches/lua-5.2.0-shared.diff
+++ /dev/null
@@ -1,42 +0,0 @@
-diff -ur lua-5.2.0/Makefile lua-5.2.0-shared/Makefile
---- lua-5.2.0/Makefile	2011-11-16 00:38:12.000000000 +0100
-+++ lua-5.2.0-shared/Makefile	2012-06-12 21:42:25.953250340 +0200
-@@ -41,7 +41,7 @@
- # What to install.
- TO_BIN= lua luac
- TO_INC= lua.h luaconf.h lualib.h lauxlib.h lua.hpp
--TO_LIB= liblua.a
-+TO_LIB= liblua.a liblua.so
- TO_MAN= lua.1 luac.1
- 
- # Lua version and release.
-diff -ur lua-5.2.0/src/Makefile lua-5.2.0-shared/src/Makefile
---- lua-5.2.0/src/Makefile	2011-09-19 14:45:14.000000000 +0200
-+++ lua-5.2.0-shared/src/Makefile	2012-06-12 21:44:17.476584177 +0200
-@@ -29,6 +29,7 @@
- PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
- 
- LUA_A=	liblua.a
-+LUA_SO= liblua.so
- CORE_O=	lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \
- 	lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \
- 	ltm.o lundump.o lvm.o lzio.o
-@@ -43,7 +44,7 @@
- LUAC_O=	luac.o
- 
- ALL_O= $(BASE_O) $(LUA_O) $(LUAC_O)
--ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T)
-+ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) $(LUA_SO)
- ALL_A= $(LUA_A)
- 
- # Targets start here.
-@@ -59,6 +60,9 @@
- 	$(AR) $@ $?
- 	$(RANLIB) $@
- 
-+$(LUA_SO): $(CORE_O) $(LIB_O)
-+	$(CC) -o $@ -shared $? -lm -ldl
-+
- $(LUA_T): $(LUA_O) $(LUA_A)
- 	$(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
- 
diff --git a/SerialICE/patches/lua-5.2.0-x64-fix.diff b/SerialICE/patches/lua-5.2.0-x64-fix.diff
deleted file mode 100644
index d649f7a..0000000
--- a/SerialICE/patches/lua-5.2.0-x64-fix.diff
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -ur lua-5.2.0/src/Makefile lua-5.2.0-shared/src/Makefile
---- lua-5.2.0/src/Makefile	2011-09-19 14:45:14.000000000 +0200
-+++ lua-5.2.0-shared/src/Makefile	2012-06-12 22:24:16.973276561 +0200
-@@ -103,7 +103,7 @@
- generic: $(ALL)
- 
- linux:
--	$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl -lreadline -lncurses"
-+	$(MAKE) $(ALL) SYSCFLAGS="-fPIC -DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl -lreadline -lncurses"
- 
- macosx:
- 	$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_MACOSX" SYSLIBS="-lreadline"
diff --git a/SerialICE/simba/chipset/i82801.lua b/SerialICE/simba/chipset/i82801.lua
index 24da007..40be0f9 100644
--- a/SerialICE/simba/chipset/i82801.lua
+++ b/SerialICE/simba/chipset/i82801.lua
@@ -44,11 +44,11 @@ function pm_io_bar(f, action)
 end
 
 function lpc_io_bar(f, action)
-	local base = bit32.band(action.data, 0xffff)
-	local mask = bit32.bor(bit32.rshift(action.data, 16), 3)
+	local base = (action.data & 0xffff)
+	local mask = (action.data >> 16) | 3
 	local size = mask + 1
 
-	base = bit32.band(base, bit32.bnot(mask))
+	base = (base & ~mask)
 
 	add_bar(f.dev, f.reg, "LPC", size)
 	f.dev.bar[f.reg].val = base
diff --git a/SerialICE/simba/chipset/intel_bars.lua b/SerialICE/simba/chipset/intel_bars.lua
index 0841a23..63feb23 100644
--- a/SerialICE/simba/chipset/intel_bars.lua
+++ b/SerialICE/simba/chipset/intel_bars.lua
@@ -35,7 +35,7 @@ dev_i915 = {
 }
 
 function i915_pcie_bar(f, action)
-	local baseaddr = bit32.band(action.data, 0xf0000000)
+	local baseaddr = (action.data & 0xf0000000)
 	local size = 256*1024*1024
 
 	-- enable is 0:00.0 [054] .31
@@ -58,26 +58,26 @@ end
 
 function i945_pcie_bar(f, action)
 	local base = action.data
-	local sizebits = bit32.band(bit32.rshift(base, 1), 0x3)
+	local sizebits = (base >> 1) & 0x3
 	local baseaddr = 0
 	local size = 0
 
 	if sizebits == 0 then
 		size = 256*1024*1024
-		baseaddr = bit32.band(base, 0xf0000000)
+		baseaddr = (base & 0xf0000000)
 	elseif sizebits == 1 then
 		size = 128*1024*1024
-		baseaddr = bit32.band(base, 0xf8000000)
+		baseaddr = (base & 0xf8000000)
 	elseif sizebits == 2 then
 		size = 64*1024*1024
-		baseaddr = bit32.band(base, 0xfc000000)
+		baseaddr = (base & 0xfc000000)
 	else
 		-- undefined, really
-		baseaddr = bit32.band(base, 0xfe000000)
+		baseaddr = (base & 0xfe000000)
 		size = 32*1024*1024
 	end
 
-	if bit32.band(base, 1) ~= 0 then
+	if (base & 1) ~= 0 then
 		pcie_mm_enable(f.dev, f.reg, baseaddr, size)
 	else
 		pcie_mm_disable(f.dev, f.reg, baseaddr, size)
diff --git a/SerialICE/simba/chipset/intel_smbus.lua b/SerialICE/simba/chipset/intel_smbus.lua
index 1c2606d..c2156f8 100644
--- a/SerialICE/simba/chipset/intel_smbus.lua
+++ b/SerialICE/simba/chipset/intel_smbus.lua
@@ -31,7 +31,7 @@ I801_PEC_EN		= 0x80
 
 
 local function intel_smbus_get_protocol(f)
-	local proto = bit32.band(f.reg.control, 0x1c)
+	local proto = (f.reg.control & 0x1c)
 
 	if proto == I801_QUICK then
 		return SMBUS_QUICK
@@ -73,7 +73,7 @@ local function intel_smbus_host_status(f, action)
 			if not smbus.passive(f) then
 				f.reg.status = 0x0
 			end
-			if bit32.band(f.reg.status, 0x40) ~= 0 then
+			if (f.reg.status & 0x40) ~= 0 then
 			       printk(f, action, "Host may be busy, ignoring.\n")
 			end
 			smbus.get_resource(f)
@@ -83,19 +83,19 @@ local function intel_smbus_host_status(f, action)
 
 		elseif smbus.state(f, HOST_STARTED) then
 			if not smbus.passive(f) then
-				f.reg.status = bit32.band(f.reg.status, 0xFE)
+				f.reg.status = (f.reg.status & 0xFE)
 				if f.reg.busy_count > 0 then
 					f.reg.busy_count = f.reg.busy_count - 1
-					f.reg.status = bit32.bor(f.reg.status, 0x01)
+					f.reg.status = (f.reg.status | 0x01)
 				end
-				if bit32.band(f.reg.status, 0x02) == 0 then
+				if (f.reg.status & 0x02) == 0 then
 					smbus_transaction(host)
 				end
 			end
 
-			local irq = bit32.band(f.reg.status, 0x02) ~= 0
-			local failures = bit32.band(f.reg.status, 0x1c) ~= 0
-			local host_busy = bit32.band(f.reg.status, 0x01) ~= 0
+			local irq = (f.reg.status & 0x02) ~= 0
+			local failures = (f.reg.status & 0x1c) ~= 0
+			local host_busy = (f.reg.status & 0x01) ~= 0
 
 			if irq and not host_busy then
 				smbus.done(f)
@@ -107,17 +107,17 @@ local function intel_smbus_host_status(f, action)
 
 		if not smbus.passive(f) then
 			action.data = f.reg.status;
-			f.reg.status = bit32.bor(f.reg.status, 0x40)
+			f.reg.status = (f.reg.status | 0x40)
 		end
 	else
 
 		if not smbus.passive(f) then
-			f.reg.status = bit32.band(f.reg.status, bit32.bnot(action.data))
+			f.reg.status = (f.reg.status & ~action.data)
 		end
 
-		local ack_irq = bit32.band(action.data, 0x02) ~= 0
-		local release_host = bit32.band(action.data, 0x40) ~= 0
-		local failures = bit32.band(action.data, 0x1c) ~= 0
+		local ack_irq = (action.data & 0x02) ~= 0
+		local release_host = (action.data & 0x40) ~= 0
+		local failures = (action.data & 0x1c) ~= 0
 		if release_host then
 			smbus.put_resource(f)
 		end
@@ -137,18 +137,18 @@ local function intel_smbus_host_control(f, action)
 	if not action.write then
 		f.reg.block_ptr=0;
 		if not smbus.passive(f) then
-			action.data = bit32.band(f.reg.control, bit32.bnot(0x40))
+			action.data = (f.reg.control & ~0x40)
 		end
 
 	else
 
 		f.reg.control = action.data;
-		if bit32.band(f.reg.control, 0x80) ~= 0 then
+		if (f.reg.control & 0x80) ~= 0 then
 			printk(f, action, "No PEC simulation\n")
 		end
 
-		local abort = bit32.band(f.reg.control, 0x02) ~= 0
-		local start = bit32.band(f.reg.control, 0x40) ~= 0
+		local abort = (f.reg.control & 0x02) ~= 0
+		local start = (f.reg.control & 0x40) ~= 0
 		if abort then
 			smbus.abort(f)
 		end
@@ -171,7 +171,7 @@ local function intel_smbus_block_data(f, action)
 end
 
 local function intel_smbus_host_access(f, action)
-	local reg = bit32.band(action.addr, (f.size-1))
+	local reg = action.addr & (f.size-1)
 
 	-- mirror hw register both ways
 	local data_write = 0
@@ -246,7 +246,7 @@ local intel_smbus_host = {
 
 function intel_smbus_setup(base, size)
 	local f = intel_smbus_host
-	f.base = bit32.band(base, bit32.bnot(size-1))
+	f.base = (base & ~(size-1))
 	f.size = size
 	if not f.reg then
 		f.reg = { control = 0, status = 0, busy_count = 0, block_ptr = 0, aux_ctl = 0, aux_sts = 0 }
diff --git a/SerialICE/simba/chipset/pc80.lua b/SerialICE/simba/chipset/pc80.lua
index 35d01e3..454bdda 100644
--- a/SerialICE/simba/chipset/pc80.lua
+++ b/SerialICE/simba/chipset/pc80.lua
@@ -25,9 +25,9 @@ filter_debugport = {
 -- i8259 PIC
 
 function i8259_pre(f, action)
-	local master = (bit32.rshift(0x05, action.addr) == 0x1)
-	local slave = (bit32.rshift(0x05, action.addr) == 0x5)
-	local reg = bit32.band(0x03, action.addr)
+	local master = ((0x05 >> action.addr) == 0x1)
+	local slave = ((0x05 >> action.addr) == 0x5)
+	local reg = (0x03 & action.addr)
 	if reg == 0 or reg == 1 then
 		return handle_action(f, action)
 	end
@@ -35,7 +35,7 @@ function i8259_pre(f, action)
 end
 
 function i8259_post(f,action)
-	local reg = bit32.band(0x03, action.addr)
+	local reg = (0x03 & action.addr)
 	if reg == 0 or reg == 1 then
 		return true
 	end
@@ -133,37 +133,37 @@ function i8254_pre(f, action)
 		return handle_action(f, action)
 	end
 
-	local reg = bit32.band(0x03, action.addr)
+	local reg = (0x03 & action.addr)
 	if reg >= 0x0 and reg < 0x03 then
 		local counter_n = 0
 		local counter_p = 0
 		if f.counter[reg].lsb then
 			f.counter[reg].lsb = f.counter[reg].after_lsb
 			counter_n = action.data
-			counter_p = bit32.band(0xff00, f.counter[reg].init)
+			counter_p = (0xff00 & f.counter[reg].init)
 		else
-			counter_n = bit32.lshift(action.data, 8)
-			counter_p = bit32.band(0x00ff, f.counter[reg].init)
+			counter_n = (action.data << 8)
+			counter_p = (0x00ff & f.counter[reg].init)
 		end
-		f.counter[reg].init = bit32.bor(counter_n, counter_p)
+		f.counter[reg].init = (counter_n | counter_p)
 	elseif reg == 0x03 then
-		local reg2 = bit32.rshift(action.data, 6)
-		local rwsel = bit32.band(0x3, bit32.rshift(action.data, 4))
+		local reg2 = (action.data >> 6)
+		local rwsel = 0x3 & (action.data >> 4)
 		if reg2 == 0x3 then
-			if bit32.band(0x10, action.data) == 0 then
-				f.counter[0].readback = (bit32.band(0x2, action.data) ~= 0)
-				f.counter[1].readback = (bit32.band(0x4, action.data) ~= 0)
-				f.counter[2].readback = (bit32.band(0x8, action.data) ~= 0)
+			if (0x10 & action.data) == 0 then
+				f.counter[0].readback = ((0x2 & action.data) ~= 0)
+				f.counter[1].readback = ((0x4 & action.data) ~= 0)
+				f.counter[2].readback = ((0x8 & action.data) ~= 0)
 			end
-			if bit32.band(0x20, action.data) == 0 then
-				f.counter[0].latch = (bit32.band(0x2, action.data) ~= 0)
-				f.counter[1].latch = (bit32.band(0x4, action.data) ~= 0)
-				f.counter[2].latch = (bit32.band(0x8, action.data) ~= 0)
+			if (0x20 & action.data) == 0 then
+				f.counter[0].latch = ((0x2 & action.data) ~= 0)
+				f.counter[1].latch = ((0x4 & action.data) ~= 0)
+				f.counter[2].latch = ((0x8 & action.data) ~= 0)
 			end
 		elseif rwsel == 0x0 then
 			f.counter[reg2].latch = true
 		else
-			f.counter[reg2].mode = bit32.band(0xf, action.data)
+			f.counter[reg2].mode = (0xf & action.data)
 			if rwsel == 0x1 then
 				f.counter[reg2].lsb = true
 				f.counter[reg2].after_lsb = true
@@ -180,17 +180,17 @@ function i8254_pre(f, action)
 end
 
 function i8254_post(f, action)
-	local reg = bit32.band(0x03, action.addr)
+	local reg = (0x03 & action.addr)
 	if reg >= 0x0 and reg < 0x03 then
 		if action.write then
-			local mode = bit32.band(0x0f, f.counter[reg].mode);
+			local mode = (0x0f & f.counter[reg].mode);
 			local modestr = "Mode" .. mode
 			if mode == 0x4 then
 				modestr = "Square Wave"
 			elseif mode == 0x6 then
 				modestr = "Rate Generator"
 			end
-			if bit32.band(0x01, mode) ~= 0 then
+			if (0x01 & mode) ~= 0 then
 				modestr = modestr .. " (BCD)"
 			end
 
@@ -262,15 +262,15 @@ filter_i8254_b = {
 function i8042_write(f, action)
 	if action.addr == 0x60 then
 		f.reg.data = action.data
-		f.reg.sts = bit32.band(f.reg.sts, 0xf7)
+		f.reg.sts = (f.reg.sts & 0xf7)
 		if (f.reg.cmd == 0xd1) then
-			f.reg.A20 = (bit32.band(0x02, action.data) == 0x02)
+			f.reg.A20 = ((0x02 & action.data) == 0x02)
 		end
 		return handle_action(f, action)
 	end
 	if action.addr == 0x64 then
 		f.reg.cmd = action.data
-		f.reg.sts = bit32.bor(f.reg.sts, 0x0a)
+		f.reg.sts = (f.reg.sts | 0x0a)
 		return handle_action(f, action)
 	end
 	return skip_filter(f, action)
@@ -278,7 +278,7 @@ end
 
 function i8042_read(f, action)
 	if action.addr == 0x60 then
-		f.reg.sts = bit32.band(f.reg.sts, 0xfe)
+		f.reg.sts = (f.reg.sts & 0xfe)
 		return handle_action(f, action)
 	end
 	if action.addr == 0x64 then
@@ -330,11 +330,11 @@ filter_i8042 = {
 
 
 function nvram_bank(addr)
-	if bit32.band(0xfe, addr) == 0x70 then
+	if (0xfe & addr) == 0x70 then
 		return 1
-	elseif bit32.band(0xfe, addr) == 0x72 then
+	elseif (0xfe & addr) == 0x72 then
 		return 2
-	elseif bit32.band(0xfe, addr) == 0x74 then
+	elseif (0xfe & addr) == 0x74 then
 		return 2
 	else
 		return 0
@@ -344,12 +344,12 @@ end
 function nvram_write(f, action)
 	local val = action.data
 	local rtc = false
-	local is_index = (bit32.band(0x01, action.addr) == 0x0)
+	local is_index = ((0x01 & action.addr) == 0x0)
 	local bank = nvram_bank(action.addr)
 
 	if bank == 1 then
 		if is_index then
-			f.reg.p70 = bit32.band(0x7f, val)
+			f.reg.p70 = (0x7f & val)
 			if f.reg.p70 < 0x0E then
 				rtc = true
 			end
@@ -362,7 +362,7 @@ function nvram_write(f, action)
 		end
 	elseif bank == 2 then
 		if is_index then
-			f.reg.p72 = bit32.band(0x7f, val)
+			f.reg.p72 = (0x7f & val)
 		else
 			local index = 0x80 + f.reg.p72
 			f.nvram_data[index] = val
@@ -379,7 +379,7 @@ end
 function nvram_read(f, action)
 	local val = 0
 	local rtc = false
-	local is_index = (bit32.band(0x01, action.addr) == 0x0)
+	local is_index = ((0x01 & action.addr) == 0x0)
 	local bank = nvram_bank(action.addr)
 
 	if bank == 1 then
@@ -423,7 +423,7 @@ function nvram_pre(f, action)
 end
 
 function nvram_post(f, action)
-	if bit32.band(0x01, action.addr) == 0x0 then
+	if (0x01 & action.addr) == 0x0 then
 		return true
 	end
 
@@ -463,7 +463,7 @@ filter_nvram = {
 
 function sys_rst_pre(f, action)
 	if action.size == 1 then
-		if action.write and bit32.band(action.data, 0x04) == 0x04 then
+		if action.write and (action.data & 0x04) == 0x04 then
 			SerialICE_system_reset()
 		end
 		return handle_action(f, action)
diff --git a/SerialICE/simba/chipset/smbus_host.lua b/SerialICE/simba/chipset/smbus_host.lua
index 1da4b0c..f8baf2e 100644
--- a/SerialICE/simba/chipset/smbus_host.lua
+++ b/SerialICE/simba/chipset/smbus_host.lua
@@ -50,19 +50,19 @@ local function signal_reset(f)
 end
 
 local function signal_set(f, flag)
-	local mask = bit32.lshift(1, flag)
-	f.host.signals = bit32.bor(f.host.signals, mask)
+	local mask = (1 << flag)
+	f.host.signals = (f.host.signals | mask)
 end
 
 local function signal_clr(f, flag)
-	local mask = bit32.bnot(bit32.lshift(1, flag))
-	f.host.signals = bit32.band(f.host.signals, mask)
+	local mask = ~(1 << flag)
+	f.host.signals = (f.host.signals & mask)
 
 end
 
 local function signal_in(f, flag)
-	local mask = bit32.lshift(1, flag)
-	return bit32.band(f.host.signals, mask) ~= 0
+	local mask = (1 << flag)
+	return (f.host.signals & mask) ~= 0
 end
 
 -- *******************
@@ -119,7 +119,7 @@ local function host_proto(f, proto)
 end
 
 local function host_reading(f)
-	return bit32.band(f.host.slave, 0x01) == 0x01
+	return (f.host.slave & 0x01) == 0x01
 end
 
 
diff --git a/SerialICE/simba/chipset/superio.lua b/SerialICE/simba/chipset/superio.lua
index 7d6252c..03e1e61 100644
--- a/SerialICE/simba/chipset/superio.lua
+++ b/SerialICE/simba/chipset/superio.lua
@@ -59,7 +59,7 @@ function superio_try_enable_io(f, idx)
 
 	if ldn.set[0x30] and ldn.data[0x30] ~= 0x0 then
 		if idx == 0 and ldn.set[0x60] and ldn.set[0x61] then
-			local iobase = bit32.bor(bit32.lshift(ldn.data[0x60], 8), ldn.data[0x61])
+			local iobase = (ldn.data[0x60] << 8) | ldn.data[0x61]
 			if not ldn.bar0.size then
 				ldn.bar0.size = 1
 			end
@@ -73,7 +73,7 @@ function superio_try_enable_io(f, idx)
 			end
 		end
 		if idx == 1 and ldn.set[0x62] and ldn.set[0x63] then
-			local iobase = bit32.bor(bit32.lshift(ldn.data[0x62], 8), ldn.data[0x63])
+			local iobase = (ldn.data[0x62] << 8) | ldn.data[0x63]
 			if not ldn.bar1.size then
 				ldn.bar1.size = 1
 			end
diff --git a/SerialICE/simba/chipset/via_bars.lua b/SerialICE/simba/chipset/via_bars.lua
index 5610230..71f026a 100644
--- a/SerialICE/simba/chipset/via_bars.lua
+++ b/SerialICE/simba/chipset/via_bars.lua
@@ -35,7 +35,7 @@ dev_nb_traf_ctl = {
 }
 
 function vx900_pcie_bar(f, action)
-	local baseaddr = bit32.lshift(action.data, 28)
+	local baseaddr = (action.data << 28)
 	local size = 256*1024*1024
 
 	-- enable is 0:00.5 [060] .10
@@ -57,7 +57,7 @@ dev_sb = {
 function sb_mmio_bar(f, action)
 	-- This MMIO space is used for SPI and CEC control
 	f.dev.mmio.name = "SB_MMIO"
-	f.dev.mmio.val = bit32.lshift(bit32.band(action.data, 0xfff0), 8)
+	f.dev.mmio.val = (action.data & 0xfff0) << 8
 	f.dev.mmio.size = 0x10000
 
 	generic_mmio_bar(f.dev.mmio)
@@ -65,13 +65,13 @@ end
 
 function pm_io_bar(f, action)
 	f.dev.acpi.name = "ACPI"
-	f.dev.acpi.val = bit32.band(action.data, 0xff80)
+	f.dev.acpi.val = (action.data & 0xff80)
 	f.dev.acpi.size = 0x80
 	generic_io_bar(f.dev.acpi)
 end
 
 function smbus_bar_hook(f, action)
-	local base = bit32.band(action.data, 0xfff0)
+	local base = (action.data & 0xfff0)
 	intel_smbus_setup(base, 0x10)
 end
 
diff --git a/SerialICE/simba/core_io.lua b/SerialICE/simba/core_io.lua
index 08ae42e..f1bf8cb 100644
--- a/SerialICE/simba/core_io.lua
+++ b/SerialICE/simba/core_io.lua
@@ -58,9 +58,9 @@ function mem_post(f, action)
 		end
 	elseif f.decode == F_RANGE then
 		if (action.write) then
-			printk(f, action, "[%08x] <= %s\n", bit32.band(action.addr, (f.size - 1)), size)
+			printk(f, action, "[%08x] <= %s\n", action.addr & (f.size - 1), size)
 		else
-			printk(f, action, "[%08x] => %s\n", bit32.band(action.addr, (f.size - 1)), size)
+			printk(f, action, "[%08x] => %s\n", action.addr & (f.size - 1), size)
 		end
 	end
 	return true
diff --git a/SerialICE/simba/cpu.lua b/SerialICE/simba/cpu.lua
index 02839a9..10a7fe4 100644
--- a/SerialICE/simba/cpu.lua
+++ b/SerialICE/simba/cpu.lua
@@ -19,14 +19,14 @@ function var_mtrr_post(f, action)
 		elseif mt == 6 then memtype = "Write-Back"
 		else memtype = "Unknown"
 		end
-		printk(f, action, "Set MTRR %x base to %08x.%08x (%s)\n", (addr - 0x200) / 2, hi, bit32.band(lo, 0xffffff00), memtype)
+		printk(f, action, "Set MTRR %x base to %08x.%08x (%s)\n", (addr - 0x200) / 2, hi, (lo & 0xffffff00), memtype)
 	else
-		if bit32.band(lo, 0x800) == 0x800 then
+		if (lo & 0x800) == 0x800 then
 			valid = "valid"
 		else
 			valid = "disabled"
 		end
-		printk(f, action, "Set MTRR %x mask to %08x.%08x (%s)\n", (addr - 0x200) / 2, hi, bit32.band(lo, 0xfffff000), valid)
+		printk(f, action, "Set MTRR %x mask to %08x.%08x (%s)\n", (addr - 0x200) / 2, hi, (lo & 0xfffff000), valid)
 	end
 	return true
 end
@@ -114,8 +114,8 @@ function multicore_post(f, action)
 	-- 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);
+		rout.ebx = (0xff00ffff & rout.ebx);
+		rout.ebx = (0x00010000 | rout.ebx);
 		return fake_action(f, action, 0)
 	end
 	return skip_filter(f, action)
diff --git a/SerialICE/simba/hooks.lua b/SerialICE/simba/hooks.lua
index c726e8c..b69c77a 100644
--- a/SerialICE/simba/hooks.lua
+++ b/SerialICE/simba/hooks.lua
@@ -141,7 +141,7 @@ function generic_io_bar(bar)
 		f.size = bar.size
 		bar.f = f
 	end
-	bar.f.base = bit32.band(bar.val, bit32.bnot(bar.size-1))
+	bar.f.base = (bar.val & ~(bar.size-1))
 	if (bar.f.base ~= 0) then
 		enable_hook(io_hooks, bar.f)
 	else
@@ -160,7 +160,7 @@ function generic_mmio_bar(bar)
 		f.size = bar.size
 		bar.f = f
 	end
-	bar.f.base = bit32.band(bar.val, bit32.bnot(bar.size-1))
+	bar.f.base = (bar.val & ~(bar.size-1))
 	if bar.f.base ~= 0 then
 		enable_hook(mem_hooks, bar.f)
 	else
@@ -230,11 +230,11 @@ function pre_action(action, dir_wr, addr, size, data)
 	action.size = size
 	if action.write then
 		if size == 1 then
-			action.data = bit32.band(0xff, data)
+			action.data = (0xff & data)
 		elseif size == 2 then
-			action.data = bit32.band(0xffff, data)
+			action.data = (0xffff & data)
 		elseif size == 4 then
-			action.data = bit32.band(0xffffffff, data)
+			action.data = (0xffffffff & data)
 		end
 	end
 end
diff --git a/SerialICE/simba/mmio.lua b/SerialICE/simba/mmio.lua
index c6ba1e5..628a87e 100644
--- a/SerialICE/simba/mmio.lua
+++ b/SerialICE/simba/mmio.lua
@@ -7,9 +7,9 @@
 -- 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
+	if (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
+		if action.write and (action.data & 0xf0f00) == 0xc0600 then
 			return fake_action(f, action, 0xc0500)
 		end
 	end
diff --git a/SerialICE/simba/pci_cfg.lua b/SerialICE/simba/pci_cfg.lua
index e7bdf65..e0f7784 100644
--- a/SerialICE/simba/pci_cfg.lua
+++ b/SerialICE/simba/pci_cfg.lua
@@ -11,10 +11,10 @@ PCI_CFG_WRITE = true
 pci_cfg_hooks = new_hooks("PCI")
 
 function add_pci_cfg_hook(dev, reg, size, func)
-	local bdfr = bit32.bor(dev.pci_dev, reg)
+	local bdfr = (dev.pci_dev | reg)
 	local name = string.format("%x:%02x.%x [%03x]",
-		bit32.band(0xff,bit32.rshift(bdfr, 20)), bit32.band(0x1f,bit32.rshift(bdfr, 15)),
-		bit32.band(0x7,bit32.rshift(bdfr, 12)), bit32.band(0xfff,bdfr))
+		(0xff & (bdfr >> 20)), (0x1f & (bdfr >> 15)),
+		(0x7 & (bdfr >> 12)), (0xfff & bdfr))
 	local filter = {
 		base = bdfr,
 		dev = dev,
@@ -30,7 +30,7 @@ end
 function is_pci_cfg_hooked(bdf)
 	local l = pci_cfg_hooks.list
 	while l do
-		if bdf == bit32.band(l.hook.base, bit32.bnot(0x03))  then
+		if bdf == (l.hook.base & ~0x03)  then
 			return true
 		end
 		l = l.next
@@ -151,8 +151,8 @@ function pci_cfg_print(f, action, bdfr)
 	end
 
 	printk(f, action, "%x:%02x.%x [%03x] %s %s\n",
-		bit32.band(0xff,bit32.rshift(bdfr, 20)), bit32.band(0x1f,bit32.rshift(bdfr, 15)),
-		bit32.band(0x7,bit32.rshift(bdfr, 12)), bit32.band(0xfff,bdfr),
+		(0xff & (bdfr >> 20)), (0x1f & (bdfr >> 15)),
+		(0x7 & (bdfr >> 12)), (0xfff & bdfr),
 		dir_str, size_data(action.size, action.data))
 end
 
@@ -186,19 +186,19 @@ function pci_cfg_access(f, action)
 	if (size == 1) then
 		av[addr%4] = true
 		bv[addr%4] = true
-		amask = bit32.lshift(0xff, ll)
-		omask = bit32.lshift(data, ll)
-		f.reg.data = bit32.band(f.reg.data, bit32.bnot(amask))
-		f.reg.data = bit32.bor(f.reg.data, omask)
+		amask = (0xff << ll)
+		omask = (data << ll)
+		f.reg.data = (f.reg.data & ~amask)
+		f.reg.data = (f.reg.data | omask)
 	elseif (size == 2) then
 		av[addr%4] = true
 		bv[addr%4] = true
 		av[addr%4+1] = true
 		bv[addr%4+1] = true
-		amask = bit32.lshift(0xffff, ll)
-		omask = bit32.lshift(data, ll)
-		f.reg.data = bit32.band(f.reg.data, bit32.bnot(amask))
-		f.reg.data = bit32.bor(f.reg.data, omask)
+		amask = (0xffff << ll)
+		omask = (data << ll)
+		f.reg.data = (f.reg.data & ~amask)
+		f.reg.data = (f.reg.data | omask)
 	elseif (size == 4) then
 		f.reg.data = data
 		for i = 0, 3, 1 do av[i] = true end
@@ -211,14 +211,14 @@ function pci_cfg_access(f, action)
 		if (bv[i] and av[i]) then
 			call_pci_cfg_hook(action, bdfr + i, 1, val)
 		end
-		val = bit32.rshift(val, 8)
+		val = (val >> 8)
 	end
 	val = f.reg.data
 	for i = 0, 2, 1 do
 		if ((bv[i] and bv[i+1]) and (av[i] or av[i+1])) then
 			call_pci_cfg_hook(action, bdfr + i, 2, val)
 		end
-		val = bit32.rshift(val, 8)
+		val = (val >> 8)
 	end
 	val = f.reg.data
 	if (bv[0] and bv[1] and bv[2] and bv[3]) then
@@ -233,20 +233,20 @@ end
 function pci_io_cfg_pre(f, action)
 	if action.addr == 0xcf8 and action.size == 4 then
 		if action.write then
-			if bit32.band(0x80000000, action.data) ~= 0 then
+			if (0x80000000 & action.data) ~= 0 then
 				f.reg.reset = true
 				new_parent_action()
 			end
 			local bdfr = 0
 			-- BDFR is like normal BDF but reg has 12 bits to cover all extended space
 			-- Copy bus/device/function
-			bdfr = bit32.lshift(action.data, 4)
-			bdfr = bit32.band(bdfr, 0x0ffff000)
+			bdfr = (action.data << 4)
+			bdfr = (bdfr & 0x0ffff000)
 			-- Some chipsets allows (on request) performing extended register space access
 			-- Usually using bits 27:24, copy that to right place
-			bdfr = bit32.bor(bdfr, bit32.band(0xf00, bit32.rshift(action.data, 24 - 8)))
+			bdfr = bdfr | (0xf00 & (action.data >> (24 - 8)))
 			-- Add the classic PCI register
-			bdfr = bit32.bor(bdfr, bit32.band(action.data, 0xfc))
+			bdfr = bdfr | (action.data & 0xfc)
 			pci_cfg_select(f, bdfr)
 		end
 		return handle_action(f, action)
@@ -287,8 +287,8 @@ filter_pci_io_cfg = {
 
 function pci_mm_cfg_pre(f, action)
 	local bdfr = 0
-	bdfr = bit32.band(action.addr, bit32.bnot(f.base))
-	bdfr = bit32.band(bdfr, bit32.bnot(0x3))
+	bdfr = (action.addr & ~f.base)
+	bdfr = (bdfr & ~0x3)
 
 	pci_cfg_select(f, bdfr)
 	pci_cfg_access(f, action)
@@ -297,7 +297,7 @@ function pci_mm_cfg_pre(f, action)
 end
 
 function pci_mm_cfg_post(f, action)
-	local bdfr = bit32.band(action.addr, bit32.bnot(f.base))
+	local bdfr = (action.addr & ~f.base)
 	pci_cfg_print(f, action, bdfr)
 	return true
 end
diff --git a/SerialICE/simba/replay.lua b/SerialICE/simba/replay.lua
index 8ec3b0a..e7a2868 100644
--- a/SerialICE/simba/replay.lua
+++ b/SerialICE/simba/replay.lua
@@ -153,8 +153,8 @@ function parse_pci(line)
 		return false
 	end
 
-	local nreg = bit32.band(0xfc, tonumber(reg,16))
-	local noff = bit32.band(0x03, tonumber(reg,16))
+	local nreg = 0xfc & tonumber(reg,16)
+	local noff = 0x03 & tonumber(reg,16)
 	local ndata = tonumber(data,16)
 	local nsize = string.len(data)/2
 
diff --git a/qemu-0.15.x/configure b/qemu-0.15.x/configure
index 947fa3f..7f8f104 100755
--- a/qemu-0.15.x/configure
+++ b/qemu-0.15.x/configure
@@ -1743,44 +1743,28 @@ EOF
       got_lua=yes
     fi
   fi
-  if test "$got_lua" != "yes" && $pkg_config --atleast-version=5.2 lua ; then
+  if test "$got_lua" != "yes" && $pkg_config --atleast-version=5.3 lua ; then
     lua_cflags=`$pkg_config --cflags lua 2> /dev/null`
     lua_ldflags=`$pkg_config --libs lua 2> /dev/null`
     if compile_prog "$lua_cflags" "$lua_ldflags" > /dev/null 2> /dev/null ; then
       got_lua=yes
     fi
   fi
-  if test "$got_lua" != "yes" && $pkg_config --exists lua5.2 ; then
-    lua_cflags=`$pkg_config --cflags lua5.2 2> /dev/null`
-    lua_ldflags=`$pkg_config --libs lua5.2 2> /dev/null`
+  if test "$got_lua" != "yes" && $pkg_config --exists lua5.3 ; then
+    lua_cflags=`$pkg_config --cflags lua5.3 2> /dev/null`
+    lua_ldflags=`$pkg_config --libs lua5.3 2> /dev/null`
     if compile_prog "$lua_cflags" "$lua_ldflags" > /dev/null 2> /dev/null ; then
       got_lua=yes
     fi
   fi
   if test "$got_lua" != "yes" ; then
     echo
-    echo "Error Lua version >= 5.2 not found. Can't build QEMU with SerialICE support."
-    echo
-    exit 1
-  fi
-
-# Test if lua-5.2.x-intsize.patch has been applied. On a 32bit host system
-# LUA_INTEGER is often a signed 32bit integer (ptrdiff_t) and not enough for our needs.
-  cat > $TMPC << EOF
-#include <lua.h>
-int main(void) { LUA_INTEGER a = (unsigned long int)1<<31; if (a<0) return 1; else return 0; }
-EOF
-
-  if compile_prog "$lua_cflags" "$lua_ldflags" && $TMPE > /dev/null 2> /dev/null ; then
-    serialice=yes
-  else
-    echo
-    echo "Error Found Lua but it needs a patch to handle 32bit unsigned integers"
-    echo "correctly. Can't build QEMU with SerialICE support."
+    echo "Error Lua version >= 5.3 not found. Can't build QEMU with SerialICE support."
     echo
     exit 1
   fi
 
+  serialice=yes
   libs_softmmu="$lua_ldflags $libs_softmmu"
 fi # test "$serialice"
 
diff --git a/qemu-0.15.x/serialice-lua.c b/qemu-0.15.x/serialice-lua.c
index 0216eb2..cdf3e25 100644
--- a/qemu-0.15.x/serialice-lua.c
+++ b/qemu-0.15.x/serialice-lua.c
@@ -106,7 +106,7 @@ static int serialice_system_reset(lua_State * luastate)
 static int register_set(lua_State * L)
 {
     const char *key = luaL_checkstring(L, 2);
-    int val = luaL_checkint(L, 3);
+    int val = luaL_checkinteger(L, 3);
     int ret = 1;
 
     if (strcmp(key, "eax") == 0) {



More information about the SerialICE mailing list