Please see previous message for general PyQemu project description. Here are the patches developed during the project:
1-qemu-override-mtype.patch Add -mtype command line option to let override ARM MTYPE passed to the kernel (useful for initial testing, prototyping, and debugging of new machine). 2-qemu-mplugin.patch Add -mplugin switch to allow loading of shared library and registering a machine declared in it. 3-qemu-build-so.patch Build QEMU as a shared library. 4-qemu-no-statics.patch Remove static declaration from some QEMU symbols, so they were exported from shared library. 5-qemu-gccxml-friendly.patch This is auxiliary patch to make QEMY header C++ friendly, which is required by gccxml, which in turn is required by ctypes utility h2xml to automatically generate Python interface files from C headers. 6-qemu-extra-sdstate-accessors.patch Few extra accessors for SDState structure (as was required to develop emulation of ASIC3 SD controller). Alternative approach would be to make the structure itself public. Best regards, Maria Zabolotnaya.
Index: vl.c =================================================================== RCS file: /sources/qemu/qemu/vl.c,v retrieving revision 1.323 diff -u -r1.323 vl.c --- vl.c 29 Jul 2007 17:57:25 -0000 1.323 +++ vl.c 19 Aug 2007 01:31:31 -0000 @@ -196,6 +197,7 @@ const char *option_rom[MAX_OPTION_ROMS]; int nb_option_roms; int semihosting_enabled = 0; +int override_mtype = 0; int autostart = 1; #ifdef TARGET_ARM int old_param = 0; @@ -6590,6 +6592,9 @@ "\n" "Standard options:\n" "-M machine select emulated machine (-M ? for list)\n" +#ifdef TARGET_ARM + "-mtype machid set ARM machine type for generic machines\n" +#endif "-cpu cpu select CPU (-cpu ? for list)\n" "-fda/-fdb file use 'file' as floppy disk 0/1 image\n" "-hda/-hdb file use 'file' as IDE hard disk 0/1 image\n" @@ -6805,6 +6811,7 @@ QEMU_OPTION_name, QEMU_OPTION_prom_env, QEMU_OPTION_old_param, + QEMU_OPTION_mtype, }; typedef struct QEMUOption { @@ -6901,6 +6909,7 @@ { "option-rom", HAS_ARG, QEMU_OPTION_option_rom }, #if defined(TARGET_ARM) || defined(TARGET_M68K) { "semihosting", 0, QEMU_OPTION_semihosting }, + { "mtype", HAS_ARG, QEMU_OPTION_mtype }, #endif { "name", HAS_ARG, QEMU_OPTION_name }, #if defined(TARGET_SPARC) @@ -7684,6 +7694,12 @@ nb_prom_envs++; break; #endif + case QEMU_OPTION_mtype: + { + const char *p = optarg; + override_mtype = strtol(p, (char **)&p, 0); + } + break; #ifdef TARGET_ARM case QEMU_OPTION_old_param: old_param = 1; Index: vl.h =================================================================== RCS file: /sources/qemu/qemu/vl.h,v retrieving revision 1.260 diff -u -r1.260 vl.h --- vl.h 16 Aug 2007 19:56:27 -0000 1.260 +++ vl.h 19 Aug 2007 01:31:31 -0000 @@ -171,6 +171,8 @@ extern const char *option_rom[MAX_OPTION_ROMS]; extern int nb_option_roms; +extern int override_mtype; + #ifdef TARGET_SPARC #define MAX_PROM_ENVS 128 extern const char *prom_envs[MAX_PROM_ENVS]; Index: hw/arm_boot.c =================================================================== RCS file: /sources/qemu/qemu/hw/arm_boot.c,v retrieving revision 1.8 diff -u -r1.8 arm_boot.c --- hw/arm_boot.c 27 Jul 2007 22:08:46 -0000 1.8 +++ hw/arm_boot.c 19 Aug 2007 01:31:31 -0000 @@ -169,6 +169,8 @@ env->kernel_filename = kernel_filename; env->kernel_cmdline = kernel_cmdline; env->initrd_filename = initrd_filename; + if (override_mtype) + board_id = override_mtype; env->board_id = board_id; env->loader_start = loader_start; qemu_register_reset(main_cpu_reset, env);
Index: osdep.h =================================================================== RCS file: /sources/qemu/qemu/osdep.h,v retrieving revision 1.10 diff -u -r1.10 osdep.h --- osdep.h 7 Jun 2007 23:09:47 -0000 1.10 +++ osdep.h 19 Aug 2007 01:31:30 -0000 @@ -28,4 +28,14 @@ #define qemu_gettimeofday(tp) gettimeofday(tp, NULL); #endif /* !_WIN32 */ +#ifdef _WIN32 +#define qemu_dlopen(name, flags) LoadLibrary(name) +#define qemu_dlsym(handle, name) ((void*)GetProcAddress(handle, name)) +#define qemu_dlerror() "DLL load error" +#else +#define qemu_dlopen(name, flags) dlopen(name, flags) +#define qemu_dlsym(handle, name) dlsym(handle, name) +#define qemu_dlerror() dlerror() +#endif /* !_WIN32 */ + #endif Index: vl.c =================================================================== RCS file: /sources/qemu/qemu/vl.c,v retrieving revision 1.323 diff -u -r1.323 vl.c --- vl.c 29 Jul 2007 17:57:25 -0000 1.323 +++ vl.c 19 Aug 2007 01:31:31 -0000 @@ -42,6 +42,7 @@ #include <netinet/in.h> #include <dirent.h> #include <netdb.h> +#include <dlfcn.h> #ifdef _BSD #include <sys/stat.h> #ifndef __APPLE__ @@ -6712,6 +6713,7 @@ #ifdef TARGET_SPARC "-prom-env variable=value set OpenBIOS nvram variables\n" #endif + "-mplugin machine.so load machine plugin\n" "\n" "During emulation, the following keys are useful:\n" "ctrl-alt-f toggle full screen\n" @@ -6810,6 +6812,7 @@ QEMU_OPTION_prom_env, QEMU_OPTION_old_param, QEMU_OPTION_mtype, + QEMU_OPTION_machine_plugin, }; typedef struct QEMUOption { @@ -6915,6 +6918,7 @@ #if defined(TARGET_ARM) { "old-param", 0, QEMU_OPTION_old_param }, #endif + { "mplugin", HAS_ARG, QEMU_OPTION_machine_plugin }, { NULL }, }; @@ -7690,6 +7694,27 @@ nb_prom_envs++; break; #endif + case QEMU_OPTION_machine_plugin: + { + void *handle; + QEMUMachine *machine; + + handle = qemu_dlopen(optarg, RTLD_NOW | RTLD_GLOBAL); + if (!handle) { + fprintf(stderr, "Cannot load plugin: %s\n", qemu_dlerror()); + exit(1); + } + machine = qemu_dlsym(handle, "machine"); + if (!machine) { + fprintf(stderr, "Cannot find machine in plugin\n"); + exit(1); + } + if (qemu_register_machine(machine)) { + fprintf(stderr, "Cannot register machine\n"); + exit(1); + } + } + break; case QEMU_OPTION_mtype: { const char *p = optarg;
Index: Makefile.target =================================================================== RCS file: /sources/qemu/qemu/Makefile.target,v retrieving revision 1.191 diff -u -r1.191 Makefile.target --- Makefile.target 31 Jul 2007 23:44:21 -0000 1.191 +++ Makefile.target 19 Aug 2007 01:31:30 -0000 @@ -519,6 +519,12 @@ VL_LDFLAGS+=-p endif +ifdef CONFIG_WIN32 +VL_LIBS+=-Wl,--out-implib,libqemu-system-$(TARGET_ARCH2).dll.a +else +VL_LIBS+=-ldl +endif + ifeq ($(ARCH),ia64) VL_LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld endif @@ -535,7 +541,10 @@ endif $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a - $(CC) $(VL_LDFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(VL_LIBS) + $(CC) -Wl,--export-dynamic $(VL_LDFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(VL_LIBS) + +qemu-system-$(TARGET_ARCH2).so: $(VL_OBJS) libqemu.a + $(CC) --shared -Wl,--export-dynamic $(VL_LDFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(VL_LIBS) cocoa.o: cocoa.m $(CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
Index: vl.c =================================================================== RCS file: /sources/qemu/qemu/vl.c,v retrieving revision 1.323 diff -u -r1.323 vl.c --- vl.c 29 Jul 2007 17:57:25 -0000 1.323 +++ vl.c 19 Aug 2007 01:31:31 -0000 @@ -146,7 +147,7 @@ /* point to the block driver where the snapshots are managed */ BlockDriverState *bs_snapshots; int vga_ram_size; -static DisplayState display_state; +DisplayState display_state; int nographic; const char* keyboard_layout = NULL; int64_t ticks_per_sec; @@ -910,7 +912,7 @@ } } -static void init_timers(void) +void init_timers(void) { init_get_clock(); ticks_per_sec = QEMU_TIMER_BASE; @@ -943,7 +945,7 @@ } } -static void timer_save(QEMUFile *f, void *opaque) +void timer_save(QEMUFile *f, void *opaque) { if (cpu_ticks_enabled) { hw_error("cannot save state if virtual timers are running"); @@ -953,7 +955,7 @@ qemu_put_be64s(f, &cpu_clock_offset); } -static int timer_load(QEMUFile *f, void *opaque, int version_id) +int timer_load(QEMUFile *f, void *opaque, int version_id) { if (version_id != 1 && version_id != 2) return -EINVAL; @@ -1063,7 +1065,7 @@ #endif /* !defined(_WIN32) */ -static void init_timer_alarm(void) +void init_timer_alarm(void) { #ifdef _WIN32 { @@ -6016,7 +6018,7 @@ inflateEnd(&s->zstream); } -static void ram_save(QEMUFile *f, void *opaque) +void ram_save(QEMUFile *f, void *opaque) { int i; RamCompressState s1, *s = &s1; @@ -6060,7 +6062,7 @@ ram_compress_close(s); } -static int ram_load(QEMUFile *f, void *opaque, int version_id) +int ram_load(QEMUFile *f, void *opaque, int version_id) { RamDecompressState s1, *s = &s1; uint8_t buf[10];
Index: cpu-all.h =================================================================== RCS file: /sources/qemu/qemu/cpu-all.h,v retrieving revision 1.74 diff -u -r1.74 cpu-all.h --- cpu-all.h 29 Jul 2007 17:57:24 -0000 1.74 +++ cpu-all.h 19 Aug 2007 01:31:30 -0000 @@ -416,7 +416,7 @@ { uint32_t a,b; a = ldl_be_p(ptr); - b = ldl_be_p(ptr+4); + b = ldl_be_p((char*)ptr+4); return (((uint64_t)a<<32)|b); } @@ -453,7 +453,7 @@ static inline void stq_be_p(void *ptr, uint64_t v) { stl_be_p(ptr, v >> 32); - stl_be_p(ptr + 4, v); + stl_be_p((char*)ptr + 4, v); } /* float access */ @@ -482,7 +482,7 @@ { CPU_DoubleU u; u.l.upper = ldl_be_p(ptr); - u.l.lower = ldl_be_p(ptr + 4); + u.l.lower = ldl_be_p((char*)ptr + 4); return u.d; } @@ -491,7 +491,7 @@ CPU_DoubleU u; u.d = v; stl_be_p(ptr, u.l.upper); - stl_be_p(ptr + 4, u.l.lower); + stl_be_p((char*)ptr + 4, u.l.lower); } #else Index: audio/audio.h =================================================================== RCS file: /sources/qemu/qemu/audio/audio.h,v retrieving revision 1.9 diff -u -r1.9 audio.h --- audio/audio.h 17 Feb 2007 22:19:29 -0000 1.9 +++ audio/audio.h 19 Aug 2007 01:31:31 -0000 @@ -144,7 +144,7 @@ static inline void *advance (void *p, int incr) { - uint8_t *d = p; + uint8_t *d = (uint8_t*)p; return (d + incr); }
Index: hw/sd.c =================================================================== RCS file: /sources/qemu/qemu/hw/sd.c,v retrieving revision 1.2 diff -u -r1.2 sd.c --- hw/sd.c 30 Jul 2007 23:54:51 -0000 1.2 +++ hw/sd.c 19 Aug 2007 01:31:31 -0000 @@ -1507,3 +1507,13 @@ { return sd->state == sd_sendingdata_state; } + +int sd_get_card_status(SDState *sd) +{ + return sd->card_status; +} + +int sd_get_state(SDState *sd) +{ + return sd->state; +} Index: hw/sd.h =================================================================== RCS file: /sources/qemu/qemu/hw/sd.h,v retrieving revision 1.2 diff -u -r1.2 sd.h --- hw/sd.h 30 Jul 2007 23:54:51 -0000 1.2 +++ hw/sd.h 19 Aug 2007 01:31:31 -0000 @@ -78,5 +78,7 @@ void (*readonly_cb)(void *, int), void (*inserted_cb)(void *, int)); int sd_data_ready(SDState *sd); +int sd_get_card_status(SDState *sd); +int sd_get_state(SDState *sd); #endif /* __hw_sd_h */