# HG changeset patch # User Mike Kinghan # Date 1280915782 -3600 # Node ID 07b904f40417479896ed030a8069d4e7cc35cab2 # Parent 73ba398cc7f4cf8da132a2d09f4c949cb2085e58 Provisional fix for bug 3508 - Persistent storage support breaks Linux compatibility. Enables libnvmemmory.so to be built and dynamically linked on Linux and rom boot reports persistent storage image created OK, but ROM then crashes. diff -r 73ba398cc7f4 -r 07b904f40417 symbian-qemu-0.9.1-12/model-libraries/commoninc/platformtypes.h --- a/symbian-qemu-0.9.1-12/model-libraries/commoninc/platformtypes.h Thu Jul 29 11:34:55 2010 +0100 +++ b/symbian-qemu-0.9.1-12/model-libraries/commoninc/platformtypes.h Wed Aug 04 10:56:22 2010 +0100 @@ -1,6 +1,8 @@ #ifndef PLATFORMTYPES_H #define PLATFORMTYPES_H - +#ifdef HAVE_STDINT_H +#include +#else // TODO: We should have a proper type definition file created common for standalone model libraries typedef signed __int8 int8_t; typedef signed __int16 int16_t; @@ -15,5 +17,7 @@ typedef unsigned __int64 uint64_t; typedef unsigned __int64 u_int64_t; typedef unsigned char byte_t; +#endif + #endif // PLATFORMTYPES_H diff -r 73ba398cc7f4 -r 07b904f40417 symbian-qemu-0.9.1-12/qemu-symbian-svp/Makefile --- a/symbian-qemu-0.9.1-12/qemu-symbian-svp/Makefile Thu Jul 29 11:34:55 2010 +0100 +++ b/symbian-qemu-0.9.1-12/qemu-symbian-svp/Makefile Wed Aug 04 10:56:22 2010 +0100 @@ -3,7 +3,7 @@ include config-host.mak .PHONY: all clean cscope distclean dvi html info install install-doc \ - recurse-all speed tar tarbin test + recurse-all model-libs speed tar tarbin test VPATH=$(SRC_PATH):$(SRC_PATH)/hw:$(SRC_PATH)/libfdt @@ -32,7 +32,15 @@ LIBS+=-lwinmm -lws2_32 -liphlpapi endif -all: $(TOOLS) $(DOCS) recurse-all +all:: $(TOOLS) $(DOCS) recurse-all + +ifneq ($(MODEL_LIBS_DIR),) +all:: model-libs + +model-libs: + $(MAKE) -C $(MODEL_LIBS_DIR) all +endif + SUBDIR_RULES=$(patsubst %,subdir-%, $(TARGET_DIRS)) @@ -203,6 +211,9 @@ $(CC) $(LDFLAGS) -o $@ $^ -lz $(LIBS) clean: +ifneq ($(MODEL_LIBS_DIR),) + $(MAKE) -C $(MODEL_LIBS_DIR) $@ +endif # avoid old build problems by removing potentially incorrect old files rm -f config.mak config.h op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h rm -f *.o *.d *.a $(TOOLS) TAGS cscope.* *.pod *~ */*~ @@ -213,6 +224,9 @@ done distclean: clean +ifneq ($(MODEL_LIBS_DIR),) + $(MAKE) -C $(MODEL_LIBS_DIR) $@ +endif rm -f config-host.mak config-host.h $(DOCS) rm -f qemu-{doc,tech}.{info,aux,cp,dvi,fn,info,ky,log,pg,toc,tp,vr} for d in $(TARGET_DIRS); do \ @@ -261,6 +275,10 @@ for d in $(TARGET_DIRS); do \ $(MAKE) -C $$d $@ || exit 1 ; \ done +ifneq ($(MODEL_LIBS_DIR),) + $(MAKE) -C $(MODEL_LIBS_DIR) $@ +endif + # various test targets test speed: all diff -r 73ba398cc7f4 -r 07b904f40417 symbian-qemu-0.9.1-12/qemu-symbian-svp/Makefile.target --- a/symbian-qemu-0.9.1-12/qemu-symbian-svp/Makefile.target Thu Jul 29 11:34:55 2010 +0100 +++ b/symbian-qemu-0.9.1-12/qemu-symbian-svp/Makefile.target Wed Aug 04 10:56:22 2010 +0100 @@ -787,6 +787,10 @@ main.o: CFLAGS+=-p endif +ifneq ($(MODEL_LIBS_DIR),) +LDFLAGS+=$(RPATH_FLAGS) +endif + $(QEMU_PROG): $(OBJS) ../libqemu_common.a libqemu.a $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(PNG_LIBS) $(COCOA_LIBS) $(CURSES_LIBS) $(BRLAPI_LIBS) $(VDE_LIBS) diff -r 73ba398cc7f4 -r 07b904f40417 symbian-qemu-0.9.1-12/qemu-symbian-svp/configure --- a/symbian-qemu-0.9.1-12/qemu-symbian-svp/configure Thu Jul 29 11:34:55 2010 +0100 +++ b/symbian-qemu-0.9.1-12/qemu-symbian-svp/configure Wed Aug 04 10:56:22 2010 +0100 @@ -1091,6 +1091,7 @@ datasuffix="" docsuffix="" binsuffix="" + libsuffix="" else if test -z "$prefix" ; then prefix="/usr/local" @@ -1099,11 +1100,22 @@ datasuffix="/share/qemu" docsuffix="/share/doc/qemu" binsuffix="/bin" + libsuffix="/lib" fi +MODEL_LIBS_DIR="" +if test `expr "$source_path" : ".*\/qemu-symbian-svp$"` != 0 ; then + if [ "$linux" = "yes" -a -f "$source_path/../model-libraries/Makefile" ]; then + MODEL_LIBS_DIR="$source_path/../model-libraries" + fi +fi + echo "Install prefix $prefix" echo "BIOS directory $prefix$datasuffix" echo "binary directory $prefix$binsuffix" +if [ ! -z "$MODEL_LIBS_DIR" ]; then + echo "lib directory $prefix$libsuffix" +fi if test "$mingw32" = "no" ; then echo "Manual directory $prefix$mansuffix" echo "ELF interp prefix $interp_prefix" @@ -1181,6 +1193,9 @@ echo "prefix=$prefix" >> $config_mak echo "bindir=\${prefix}$binsuffix" >> $config_mak +if [ ! -z "$MODEL_LIBS_DIR" ]; then + echo "libdir=\${prefix}$libsuffix" >> $config_mak +fi echo "mandir=\${prefix}$mansuffix" >> $config_mak echo "datadir=\${prefix}$datasuffix" >> $config_mak echo "docdir=\${prefix}$docsuffix" >> $config_mak @@ -1200,6 +1215,10 @@ echo "ARCH_LDFLAGS=$ARCH_LDFLAGS" >> $config_mak echo "CFLAGS=$CFLAGS" >> $config_mak echo "LDFLAGS=$LDFLAGS" >> $config_mak +if [ ! -z "$MODEL_LIBS_DIR" ]; then + echo "RPATH_FLAGS=-Wl,-rpath=\"${prefix}$libsuffix\"" >> $config_mak + echo "MODEL_LIBS_DIR=$MODEL_LIBS_DIR" >> $config_mak +fi echo "EXESUF=$EXESUF" >> $config_mak echo "AIOLIBS=$AIOLIBS" >> $config_mak case "$cpu" in @@ -1811,6 +1830,7 @@ echo "#define CONFIG_BSD_USER 1" >> $config_h fi + test -f ${config_h}~ && cmp -s $config_h ${config_h}~ && mv ${config_h}~ $config_h done # for target in $targets diff -r 73ba398cc7f4 -r 07b904f40417 symbian-qemu-0.9.1-12/qemu-symbian-svp/plugins/qemu_arm_plugins.py --- a/symbian-qemu-0.9.1-12/qemu-symbian-svp/plugins/qemu_arm_plugins.py Thu Jul 29 11:34:55 2010 +0100 +++ b/symbian-qemu-0.9.1-12/qemu-symbian-svp/plugins/qemu_arm_plugins.py Wed Aug 04 10:56:22 2010 +0100 @@ -5,5 +5,5 @@ import syborg_timer import syborg_keyboard import syborg_pointer -import syborg_usbtest -import syborg_nvmemorydevice \ No newline at end of file +#import syborg_usbtest +import syborg_nvmemorydevice diff -r 73ba398cc7f4 -r 07b904f40417 symbian-qemu-0.9.1-12/qemu-symbian-svp/plugins/syborg_nvmemorydevice.py --- a/symbian-qemu-0.9.1-12/qemu-symbian-svp/plugins/syborg_nvmemorydevice.py Thu Jul 29 11:34:55 2010 +0100 +++ b/symbian-qemu-0.9.1-12/qemu-symbian-svp/plugins/syborg_nvmemorydevice.py Wed Aug 04 10:56:22 2010 +0100 @@ -28,6 +28,8 @@ import sys import os import array +import platform +import re class syborg_nvmemorydevice(qemu.devclass): # 256 MB default empty drive size if there is no readymade image available @@ -35,7 +37,7 @@ DEVICE_SECTOR_SIZE = 0x200 DRIVE_NAME = "qemudrive.img" DRIVE_PATH = "nvmemory" - + # Memory device registers R_NVMEM_ID = 0x0000 R_NVMEM_TRANSACTION_OFFSET = 0x0004 @@ -54,40 +56,50 @@ # Variables to store the information for current transaction shared_memory_base = 0 shared_memory_size = 0 - transaction_offset = 0 - transaction_size = 0 - transaction_direction = 0 + transaction_offset = 0 + transaction_size = 0 + transaction_direction = 0 # Variables to validate transaction - transaction_offset_set = 0 - transaction_size_set = 0 + transaction_offset_set = 0 + transaction_size_set = 0 transaction_direction_set = 0 nvmemory_sector_count = 0 drive_size = 0 sector_size = 0 - drive_image_name = "" + drive_image_name = "" + host_plat = platform.platform(); def create(self): print "syborg_nvmemorydevice: create\n" # Get properties - self.drive_size = self.properties["drive_size"] - self.sector_size = self.properties["sector_size"] + self.drive_size = self.properties["drive_size"] + self.sector_size = self.properties["sector_size"] self.drive_image_name = self.properties["drive_image_name"] print "drive size: ", self.drive_size print "sector size: ", self.sector_size - print "drive name: ", self.drive_image_name + print "drive name: ", self.drive_image_name - drive_path_and_name = self.DRIVE_PATH + "\\" + self.drive_image_name + drive_path_and_name = os.path.join(self.DRIVE_PATH, self.drive_image_name) # Save working directory self.working_dir = os.getcwd() + nvmem_lib = "" + open_mode = 0 + if re.match('^linux',self.host_plat,re.I): + nvmemlib_name = "libnvmemmory.so" + open_mode = os.O_RDWR + else: + nvmemlib_name = "nvmemmory.dll" + open_mode = os.O_RDWR|os.O_BINARY # Open the nvmemory library try: - self.nvmemlib = ctypes.CDLL("nvmemmory.dll") - except: - sys.exit("syborg_nvmemorydevice: nvmemmory.dll load failed") + self.nvmemlib = ctypes.CDLL(nvmemlib_name) + except Exception, e: + print repr(e) + sys.exit("syborg_nvmemorydevice: nvmemmory load failed") # Create an instance of non volatile memory handler class self.obj = self.nvmemlib.nvmem_create( self.sector_size ) @@ -101,7 +113,7 @@ # Here we could check why we failed - usually because the path already exists \n" pass try: - self.filehandle = os.open( drive_path_and_name, os.O_RDWR|os.O_BINARY ) + self.filehandle = os.open( drive_path_and_name, open_mode ) os.close( self.filehandle ) except: print "syborg_nvmemorydevice: drive image not found - create\n" @@ -119,7 +131,7 @@ index = index+1 # Create path and get handle to the raw memory array - imagepath = self.working_dir + "\\" + drive_path_and_name + imagepath = os.path.join(self.working_dir, drive_path_and_name) print "imagepath: ", imagepath self.nvmemhandle = self.nvmemlib.nvmem_open( self.obj, imagepath ) if( self.nvmemhandle < 0 ): @@ -132,7 +144,7 @@ print "syborg_nvmemorydevice: created\n" def updateIrq(self,new_value): - self.set_irq_level(0, new_value) + self.set_irq_level(0, new_value) def nvmem_request_callback(self, result): #print "graphics_request_callback: " , result @@ -145,48 +157,48 @@ self.nvmem_callback = self.CALLBACKFUNC(self.nvmem_request_callback) self.nvmemlib.nvmem_set_callback( self.obj, self.nvmem_callback ) - def read_reg(self, offset): + def read_reg(self, offset): offset >>= 2 - #print "read register: 0x%x" % (offset) - if offset == self.R_NVMEM_ID: - return 0xDEADBEEF - elif offset == self.R_NVMEM_TRANSACTION_OFFSET: - return self.transaction_offset - elif offset == self.R_NVMEM_TRANSACTION_SIZE: - return self.transaction_size - elif offset == self.R_NVMEM_TRANSACTION_DIRECTION: - return self.transaction_direction + #print "read register: 0x%x" % (offset) + if offset == self.R_NVMEM_ID: + return 0xDEADBEEF + elif offset == self.R_NVMEM_TRANSACTION_OFFSET: + return self.transaction_offset + elif offset == self.R_NVMEM_TRANSACTION_SIZE: + return self.transaction_size + elif offset == self.R_NVMEM_TRANSACTION_DIRECTION: + return self.transaction_direction elif offset == self.R_NVMEM_SHARED_MEMORY_BASE: - return self.shared_memory_base + return self.shared_memory_base elif offset == self.R_NVMEM_SHARED_MEMORY_SIZE: - return self.shared_memory_size + return self.shared_memory_size elif offset == self.R_NVMEM_NV_MEMORY_SIZE: - return self.nvmemory_sector_count + return self.nvmemory_sector_count elif offset == self.R_NVMEM_STATUS: self.updateIrq(0) - return self.status_reg - else: - reg_read_error = "syborg_nvmemorydevice: Illegal register read at: ", offset + return self.status_reg + else: + reg_read_error = "syborg_nvmemorydevice: Illegal register read at: ", offset sys.exit( reg_read_error ) - - def write_reg(self, offset, value): - offset >>= 2 - #print "write register: 0x%x value: 0x%x" % (offset, value) - if offset == self.R_NVMEM_TRANSACTION_OFFSET: - self.transaction_offset = value - self.transaction_offset_set = 1 - elif offset == self.R_NVMEM_TRANSACTION_SIZE: - self.transaction_size = value - self.transaction_size_set = 1 - elif offset == self.R_NVMEM_TRANSACTION_DIRECTION: - self.transaction_direction = value - self.transaction_direction_set = 1 + + def write_reg(self, offset, value): + offset >>= 2 + #print "write register: 0x%x value: 0x%x" % (offset, value) + if offset == self.R_NVMEM_TRANSACTION_OFFSET: + self.transaction_offset = value + self.transaction_offset_set = 1 + elif offset == self.R_NVMEM_TRANSACTION_SIZE: + self.transaction_size = value + self.transaction_size_set = 1 + elif offset == self.R_NVMEM_TRANSACTION_DIRECTION: + self.transaction_direction = value + self.transaction_direction_set = 1 elif offset == self.R_NVMEM_TRANSACTION_EXECUTE: if( (self.transaction_offset_set == 0) | (self.transaction_size_set == 0) | (self.transaction_direction_set == 0) ): - error_msg = "syborg_nvmemorydevice: Illegal transaction! All the required parameters are not set" + error_msg = "syborg_nvmemorydevice: Illegal transaction! All the required parameters are not set" sys.exit( error_msg ) elif(self.transaction_size == 0 ): - error_msg = "syborg_nvmemorydevice: Zero size transaction issued!" + error_msg = "syborg_nvmemorydevice: Zero size transaction issued!" sys.exit( error_msg ) else: if( self.transaction_direction == self.NVMEM_TRANSACTION_READ ): @@ -194,28 +206,28 @@ elif( self.transaction_direction == self.NVMEM_TRANSACTION_WRITE ): self.nvmemlib.nvmem_write( self.obj, self.nvmemory_sharedmemory_host_address, self.nvmemhandle, self.transaction_offset, self.transaction_size ) else: - error_msg = "syborg_nvmemorydevice: Transaction direction not set!" + error_msg = "syborg_nvmemorydevice: Transaction direction not set!" sys.exit( error_msg ) - self.transaction_offset_set = 0 - self.transaction_size_set = 0 - self.transaction_direction_set = 0 + self.transaction_offset_set = 0 + self.transaction_size_set = 0 + self.transaction_direction_set = 0 elif offset == self.R_NVMEM_SHARED_MEMORY_BASE: self.shared_memory_base = value elif offset == self.R_NVMEM_SHARED_MEMORY_SIZE: - self.shared_memory_size = value + self.shared_memory_size = value elif offset == self.R_NVMEM_ENABLE: if( value > 0 ): self.nvmemory_memregion = qemu.memregion( self.shared_memory_base, self.shared_memory_size ) self.nvmemory_sharedmemory_host_address = self.nvmemory_memregion.region_host_addr() print"syborg_nvmemorydevice: host addr: 0x%08x" % (self.nvmemory_sharedmemory_host_address) else: - reg_write_error = "syborg_nvmemorydevice: Illegal register write to: ", offset + reg_write_error = "syborg_nvmemorydevice: Illegal register write to: ", offset sys.exit( reg_write_error ) - # Device class properties - regions = [qemu.ioregion(0x1000, readl=read_reg, writel=write_reg)] - irqs = 1 - name = "syborg,nvmemorydevice" - properties = {"drive_size":DEFAULT_DRIVE_SIZE, "sector_size":DEVICE_SECTOR_SIZE, "drive_image_name":DRIVE_NAME} - -qemu.register_device(syborg_nvmemorydevice) + # Device class properties + regions = [qemu.ioregion(0x1000, readl=read_reg, writel=write_reg)] + irqs = 1 + name = "syborg,nvmemorydevice" + properties = {"drive_size":DEFAULT_DRIVE_SIZE, "sector_size":DEVICE_SECTOR_SIZE, "drive_image_name":DRIVE_NAME} + +qemu.register_device(syborg_nvmemorydevice)