* [Qemu-devel] [Patch] Mac OS X Port
@ 2004-07-02 22:56 Pierre d'Herbemont
2004-07-03 13:34 ` Jean-Michel POURE
` (2 more replies)
0 siblings, 3 replies; 22+ messages in thread
From: Pierre d'Herbemont @ 2004-07-02 22:56 UTC (permalink / raw)
To: qemu-devel; +Cc: Darwine List, Matt Reda
[-- Attachment #1.1: Type: text/plain, Size: 1439 bytes --]
Hi!
Here is a patch against the Qemu CVS makes Mac OS X able to run Qemu.
It was mainly done by Matt Reda and I. Now Qemu/Mac OS X is able to
boot the linux-test image, the freedos image, the netbsd image and even
the ReactOS image from the FreeOSZoo.
If you have any question feel free to ask myself or Matt Reda.
Here is a summary of the modifications:
configure:
- Darwin/Mac OS X Support
Makefile*:
- Support for various Mac OS X Specific flags.
cpu-all.h:
- host_page_size is already a system symbol, so its better to change it.
cpu-exec.h:
- support for Mac OS X signals.
dyngen-exec.h:
- various fixes for Mac OS X.
dyngen.c:
- Mach-O port.
exec-all.h:
- Mach-O support.
exec.c:
- host_page_size related changes.
oss.c:
- ifdef out for Mac OS X.
sdl.c:
- keyboard support. Probably need a review.
vl.c:
- inclusion of <SDL/SDL.h> required for Mac OS X build
- use valloc instead of malloc for correctness
- define rtc_fd for darwin
linux-user/elfload.c:
- preliminary support for darwin, fix for host_page_size related
changes.
linux-user/main.c:
- preliminary support for darwin, fix for host_page_size related
changes.
linux-user/syscall.c:
- preliminary support for darwin.
slirp/slirp_config.h:
- support for Mac OS X.
target-i386/exec.h:
- fix correctness for symbols definitions
f15rk,parity_table,rclw_table,rclb_table
target-i386/op.c:
- don't do the bsd rounding mode on Mac OS X
Thanks,
Pierre
[-- Attachment #1.2: Type: text/enriched, Size: 1491 bytes --]
Hi!
Here is a patch against the Qemu CVS makes Mac OS X able to run Qemu.
It was mainly done by Matt Reda and I. Now Qemu/Mac OS X is able to
boot the linux-test image, the freedos image, the netbsd image and
even the ReactOS image from the FreeOSZoo.
If you have any question feel free to ask myself or Matt Reda.
Here is a summary of the modifications:
configure:
- Darwin/Mac OS X Support
Makefile*:
- Support for various Mac OS X Specific flags.
cpu-all.h:
- host_page_size is already a system symbol, so its better to change
it.
cpu-exec.h:
- support for Mac OS X signals.
dyngen-exec.h:
- various fixes for Mac OS X.
dyngen.c:
- Mach-O port.
exec-all.h:
- Mach-O support.
exec.c:
- host_page_size related changes.
oss.c:
- ifdef out for Mac OS X.
sdl.c:
- keyboard support. Probably need a review.
vl.c:
- inclusion of <<SDL/SDL.h> required for Mac OS X build
- use valloc instead of malloc for correctness
- define rtc_fd for darwin
linux-user/elfload.c:
- preliminary support for darwin, fix for host_page_size related
changes.
linux-user/main.c:
- preliminary support for darwin, fix for host_page_size related
changes.
linux-user/syscall.c:
- preliminary support for darwin.
slirp/slirp_config.h:
- support for Mac OS X.
target-i386/exec.h:
- fix correctness for symbols definitions
<fixed>f15rk,parity_table,rclw_table,rclb_table
</fixed>target-i386/op.c:
- don't do the bsd rounding mode on Mac OS X
Thanks,
Pierre
[-- Attachment #2: qemuosx.diff --]
[-- Type: application/octet-stream, Size: 56003 bytes --]
Index: Makefile
===================================================================
RCS file: /cvsroot/qemu/qemu/Makefile,v
retrieving revision 1.68
diff -u -r1.68 Makefile
--- Makefile 21 Jun 2004 19:53:39 -0000 1.68
+++ Makefile 2 Jul 2004 22:43:49 -0000
@@ -1,6 +1,9 @@
include config-host.mak
CFLAGS=-Wall -O2 -g
+ifdef CONFIG_DARWIN
+CFLAGS+= -mdynamic-no-pic
+endif
ifdef CONFIG_WIN32
CFLAGS+=-fpack-struct
endif
Index: Makefile.target
===================================================================
RCS file: /cvsroot/qemu/qemu/Makefile.target,v
retrieving revision 1.34
diff -u -r1.34 Makefile.target
--- Makefile.target 21 Jun 2004 16:44:21 -0000 1.34
+++ Makefile.target 2 Jul 2004 22:43:49 -0000
@@ -100,6 +100,7 @@
endif
ifeq ($(ARCH),ppc)
+CFLAGS+= -D__powerpc__
OP_CFLAGS=$(CFLAGS)
LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld
endif
@@ -152,6 +153,10 @@
OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
endif
+ifeq ($(CONFIG_DARWIN),yes)
+OP_CFLAGS+= -mdynamic-no-pic
+endif
+
#########################################################
DEFINES+=-D_GNU_SOURCE
@@ -268,8 +273,10 @@
VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld
endif
ifndef CONFIG_WIN32
+ifndef CONFIG_DARWIN
VL_LIBS=-lutil
endif
+endif
$(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
$(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(VL_LIBS)
Index: configure
===================================================================
RCS file: /cvsroot/qemu/qemu/configure,v
retrieving revision 1.40
diff -u -r1.40 configure
--- configure 4 Jun 2004 11:13:20 -0000 1.40
+++ configure 2 Jul 2004 22:43:50 -0000
@@ -88,12 +88,19 @@
OpenBSD)
bsd="yes"
;;
+Darwin)
+bsd="yes"
+darwin="yes"
+;;
*) ;;
esac
-if [ "$bsd" = "yes" ] ; then
+if [ "$bsd" = "yes" ] && ! [ "$darwin" = "yes" ] ; then
make="gmake"
- target_list="i386-softmmu"
+fi
+
+if [ "$bsd" = "yes" ] ; then
+ target_list="i386-softmmu ppc-softmmu"
fi
# find source path
@@ -391,6 +398,10 @@
elif test -f "/usr/include/byteswap.h" ; then
echo "#define HAVE_BYTESWAP_H 1" >> $config_h
fi
+if test "$darwin" = "yes" ; then
+ echo "CONFIG_DARWIN=yes" >> $config_mak
+ echo "#define CONFIG_DARWIN 1" >> $config_h
+fi
if test "$gdbstub" = "yes" ; then
echo "CONFIG_GDBSTUB=yes" >> $config_mak
echo "#define CONFIG_GDBSTUB 1" >> $config_h
@@ -420,9 +431,11 @@
if [ "$bsd" = "yes" ] ; then
echo "#define O_LARGEFILE 0" >> $config_h
echo "#define lseek64 lseek" >> $config_h
+ echo "#define mkstemp64 mkstemp" >> $config_h
echo "#define ftruncate64 ftruncate" >> $config_h
echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h
echo "#define _BSD 1" >> $config_h
+ echo "#define off64_t off_t" >> $config_h
fi
for target in $target_list; do
Index: cpu-all.h
===================================================================
RCS file: /cvsroot/qemu/qemu/cpu-all.h,v
retrieving revision 1.33
diff -u -r1.33 cpu-all.h
--- cpu-all.h 20 Jun 2004 12:35:26 -0000 1.33
+++ cpu-all.h 2 Jul 2004 22:43:50 -0000
@@ -538,12 +538,12 @@
#define TARGET_PAGE_MASK ~(TARGET_PAGE_SIZE - 1)
#define TARGET_PAGE_ALIGN(addr) (((addr) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK)
-extern unsigned long real_host_page_size;
-extern unsigned long host_page_bits;
-extern unsigned long host_page_size;
-extern unsigned long host_page_mask;
+extern unsigned long qemu_real_host_page_size;
+extern unsigned long qemu_host_page_bits;
+extern unsigned long qemu_host_page_size;
+extern unsigned long qemu_host_page_mask;
-#define HOST_PAGE_ALIGN(addr) (((addr) + host_page_size - 1) & host_page_mask)
+#define HOST_PAGE_ALIGN(addr) (((addr) + qemu_host_page_size - 1) & qemu_host_page_mask)
/* same as PROT_xxx */
#define PAGE_READ 0x0001
Index: cpu-exec.c
===================================================================
RCS file: /cvsroot/qemu/qemu/cpu-exec.c,v
retrieving revision 1.36
diff -u -r1.36 cpu-exec.c
--- cpu-exec.c 22 Jun 2004 18:43:30 -0000 1.36
+++ cpu-exec.c 2 Jul 2004 22:43:51 -0000
@@ -852,9 +852,58 @@
&uc->uc_sigmask, puc);
}
-#elif defined(__powerpc)
+#elif defined(__powerpc__)
-int cpu_signal_handler(int host_signum, struct siginfo *info,
+/***********************************************************************
+ * signal context platform-specific definitions
+ * From Wine
+ */
+#ifdef linux
+/* All Registers access - only for local access */
+# define REG_sig(reg_name, context) ((context)->uc_mcontext.regs->reg_name)
+/* Gpr Registers access */
+# define GPR_sig(reg_num, context) REG_sig(gpr[reg_num], context)
+# define IAR_sig(context) REG_sig(nip, context) /* Program counter */
+# define MSR_sig(context) REG_sig(msr, context) /* Machine State Register (Supervisor) */
+# define CTR_sig(context) REG_sig(ctr, context) /* Count register */
+# define XER_sig(context) REG_sig(xer, context) /* User's integer exception register */
+# define LR_sig(context) REG_sig(link, context) /* Link register */
+# define CR_sig(context) REG_sig(ccr, context) /* Condition register */
+/* Float Registers access */
+# define FLOAT_sig(reg_num, context) (((double*)((char*)((context)->uc_mcontext.regs+48*4)))[reg_num])
+# define FPSCR_sig(context) (*(int*)((char*)((context)->uc_mcontext.regs+(48+32*2)*4)))
+/* Exception Registers access */
+# define DAR_sig(context) REG_sig(dar, context)
+# define DSISR_sig(context) REG_sig(dsisr, context)
+# define TRAP_sig(context) REG_sig(trap, context)
+#endif /* linux */
+
+#ifdef __APPLE__
+# include <sys/ucontext.h>
+typedef struct ucontext SIGCONTEXT;
+/* All Registers access - only for local access */
+# define REG_sig(reg_name, context) ((context)->uc_mcontext->ss.reg_name)
+# define FLOATREG_sig(reg_name, context) ((context)->uc_mcontext->fs.reg_name)
+# define EXCEPREG_sig(reg_name, context) ((context)->uc_mcontext->es.reg_name)
+# define VECREG_sig(reg_name, context) ((context)->uc_mcontext->vs.reg_name)
+/* Gpr Registers access */
+# define GPR_sig(reg_num, context) REG_sig(r##reg_num, context)
+# define IAR_sig(context) REG_sig(srr0, context) /* Program counter */
+# define MSR_sig(context) REG_sig(srr1, context) /* Machine State Register (Supervisor) */
+# define CTR_sig(context) REG_sig(ctr, context)
+# define XER_sig(context) REG_sig(xer, context) /* Link register */
+# define LR_sig(context) REG_sig(lr, context) /* User's integer exception register */
+# define CR_sig(context) REG_sig(cr, context) /* Condition register */
+/* Float Registers access */
+# define FLOAT_sig(reg_num, context) FLOATREG_sig(fpregs[reg_num], context)
+# define FPSCR_sig(context) ((double)FLOATREG_sig(fpscr, context))
+/* Exception Registers access */
+# define DAR_sig(context) EXCEPREG_sig(dar, context) /* Fault registers for coredump */
+# define DSISR_sig(context) EXCEPREG_sig(dsisr, context)
+# define TRAP_sig(context) EXCEPREG_sig(exception, context) /* number of powerpc exception taken */
+#endif /* __APPLE__ */
+
+int cpu_signal_handler(int host_signum, siginfo *info,
void *puc)
{
struct ucontext *uc = puc;
@@ -862,14 +911,14 @@
unsigned long pc;
int is_write;
- pc = regs->nip;
+ pc = IAR_sig(uc);
is_write = 0;
#if 0
/* ppc 4xx case */
- if (regs->dsisr & 0x00800000)
+ if (DSISR_sig(uc) & 0x00800000)
is_write = 1;
#else
- if (regs->trap != 0x400 && (regs->dsisr & 0x02000000))
+ if (TRAP_sig(uc) != 0x400 && (DSISR_sig(uc) & 0x02000000))
is_write = 1;
#endif
return handle_cpu_signal(pc, (unsigned long)info->si_addr,
Index: dyngen-exec.h
===================================================================
RCS file: /cvsroot/qemu/qemu/dyngen-exec.h,v
retrieving revision 1.12
diff -u -r1.12 dyngen-exec.h
--- dyngen-exec.h 12 May 2004 19:32:15 -0000 1.12
+++ dyngen-exec.h 2 Jul 2004 22:43:51 -0000
@@ -22,6 +22,11 @@
#include <stddef.h>
+#ifdef __APPLE__
+/* Already defined here */
+# include <stdint.h>
+#else
+
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
@@ -32,9 +37,6 @@
typedef unsigned long long uint64_t;
#endif
-typedef signed char int8_t;
-typedef signed short int16_t;
-typedef signed int int32_t;
#if defined (__x86_64__)
typedef signed long int64_t;
#else
@@ -54,12 +56,14 @@
#define UINT32_MAX (4294967295U)
#define UINT64_MAX ((uint64_t)(18446744073709551615))
+#endif /* __APPLE__ */
+
typedef struct FILE FILE;
extern int fprintf(FILE *, const char *, ...);
extern int printf(const char *, ...);
#undef NULL
#define NULL 0
-#ifdef _BSD
+#if defined(_BSD) && !defined(__APPLE__)
#include <ieeefp.h>
#else
#include <fenv.h>
@@ -187,12 +191,16 @@
#define PARAM1 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param1)); _r; })
#define PARAM2 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param2)); _r; })
#define PARAM3 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param3)); _r; })
-#else
+#else /* __alpha__ */
+# ifdef __APPLE__
+static int __op_param1, __op_param2, __op_param3;
+# else
extern int __op_param1, __op_param2, __op_param3;
+# endif
#define PARAM1 ((long)(&__op_param1))
#define PARAM2 ((long)(&__op_param2))
#define PARAM3 ((long)(&__op_param3))
-#endif
+#endif /* __alpha__ */
extern int __op_jmp0, __op_jmp1, __op_jmp2, __op_jmp3;
Index: dyngen.c
===================================================================
RCS file: /cvsroot/qemu/qemu/dyngen.c,v
retrieving revision 1.34
diff -u -r1.34 dyngen.c
--- dyngen.c 4 Apr 2004 12:56:28 -0000 1.34
+++ dyngen.c 2 Jul 2004 22:43:53 -0000
@@ -6,6 +6,8 @@
* The COFF object format support was extracted from Kazu's QEMU port
* to Win32.
*
+ * Mach-O Support by Matt Reda and Pierre d'Herbemont
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -34,6 +36,8 @@
compilation */
#if defined(CONFIG_WIN32)
#define CONFIG_FORMAT_COFF
+#elif defined(CONFIG_DARWIN)
+#define CONFIG_FORMAT_MACH
#else
#define CONFIG_FORMAT_ELF
#endif
@@ -169,6 +173,44 @@
#endif /* CONFIG_FORMAT_COFF */
+#ifdef CONFIG_FORMAT_MACH
+
+#include <mach-o/loader.h>
+#include <mach-o/nlist.h>
+#include <mach-o/reloc.h>
+#include <mach-o/ppc/reloc.h>
+
+# define check_mach_header(x) (x.magic == MH_MAGIC)
+typedef int32_t host_long;
+typedef uint32_t host_ulong;
+
+/* File Header */
+struct mach_header mach_hdr;
+
+/* commands */
+struct segment_command *segment = 0;
+struct dysymtab_command *dysymtabcmd = 0;
+struct symtab_command *symtabcmd = 0;
+
+/* section */
+struct section *section_hdr;
+struct section *text_sec_hdr;
+uint8_t **sdata;
+
+/* relocs */
+struct relocation_info *relocs;
+
+/* symbols */
+struct nlist *symtab;
+char *strtab;
+
+/* indirect symbols */
+uint32_t *tocdylib;
+#define EXE_RELOC struct relocation_info
+#define EXE_SYM struct nlist
+
+#endif /* CONFIG_FORMAT_MACH */
+
#include "bswap.h"
enum {
@@ -177,8 +219,17 @@
OUT_INDEX_OP,
};
+
+#ifdef CONFIG_FORMAT_MACH
+# define ASM_NAME(x) "_" #x
+# define CSYM_NAME(x) ((char*)x)+1
+#else
+# define ASM_NAME(x) x
+# define CSYM_NAME(x) x
+#endif
+
/* all dynamically generated functions begin with this code */
-#define OP_PREFIX "op_"
+#define OP_PREFIX ASM_NAME(op_)
int do_swap;
@@ -399,6 +450,11 @@
return 0;
}
+static int get_rel_offset(EXE_RELOC *rel)
+{
+ return rel->r_offset;
+}
+
static char *get_rel_sym_name(EXE_RELOC *rel)
{
return strtab + symtab[ELFW(R_SYM)(rel->r_info)].st_name;
@@ -600,6 +656,11 @@
return name;
}
+static int get_rel_offset(EXE_RELOC *rel)
+{
+ return rel->r_offset;
+}
+
struct external_scnhdr *find_coff_section(struct external_scnhdr *shdr, int shnum, const char *name)
{
int i;
@@ -758,6 +819,331 @@
#endif /* CONFIG_FORMAT_COFF */
+#ifdef CONFIG_FORMAT_MACH
+
+/* Utility functions */
+
+static inline char *find_str_by_index(int index)
+{
+ return strtab+index;
+}
+
+static inline char *find_symname_by_symindex(EXE_SYM *syms, int index)
+{
+ return find_str_by_index(syms[index].n_un.n_strx);
+}
+
+/* Used by dyngen common code */
+static char *get_sym_name(EXE_SYM *sym)
+{
+ return find_str_by_index(sym->n_un.n_strx);
+}
+
+/* find a section index given its segname, sectname */
+static int find_mach_sec_index(struct section *section_hdr, int shnum, const char *segname,
+ const char *sectname)
+{
+ int i;
+ struct section *sec = section_hdr;
+
+ for(i = 0; i < shnum; i++, sec++) {
+ if (!sec->segname || !sec->sectname)
+ continue;
+ if (!strcmp(sec->sectname, sectname) && !strcmp(sec->segname, segname))
+ return i;
+ }
+ return -1;
+}
+
+/* find a section header given its segname, sectname */
+struct section *find_mach_sec_hdr(struct section *section_hdr, int shnum, const char *segname,
+ const char *sectname)
+{
+ int index = find_mach_sec_index(section_hdr, shnum, segname, sectname);
+ if(index == -1)
+ return NULL;
+ return section_hdr+index;
+}
+
+
+static inline void fetch_next_pair_value(struct relocation_info * rel, unsigned int *value)
+{
+ struct scattered_relocation_info * scarel;
+
+ if(R_SCATTERED & rel->r_address) {
+ scarel = (struct scattered_relocation_info*)rel;
+ if(scarel->r_type != PPC_RELOC_PAIR)
+ error("fetch_next_pair_value: looking for a pair which was not found (1)");
+ *value = scarel->r_value;
+ } else {
+ if(rel->r_type != PPC_RELOC_PAIR)
+ error("fetch_next_pair_value: looking for a pair which was not found (2)");
+ *value = rel->r_address;
+ }
+}
+
+/* find a sym name given its value, in a section number */
+static const char * find_sym_with_value_and_sec_number( int value, int sectnum, int * offset )
+{
+ int i, ret = -1;
+
+ for( i = 0 ; i < nb_syms; i++ )
+ {
+ if( !(symtab[i].n_type & N_STAB) &&
+ (symtab[i].n_type & N_SECT) &&
+ (symtab[i].n_sect == sectnum) &&
+ (symtab[i].n_value <= value))
+ {
+ if( (ret<0) || (symtab[i].n_value >= symtab[ret].n_value) )
+ {
+ ret = i;
+ }
+ }
+ }
+ if(ret<0) {
+ *offset = 0;
+ return 0;
+ } else {
+ *offset = value - symtab[ret].n_value;
+ return find_str_by_index(symtab[ret].n_un.n_strx);
+ }
+}
+
+/*
+ * Find symbol name given a (virtual) address, and a section which is of type
+ * S_NON_LAZY_SYMBOL_POINTERS or S_LAZY_SYMBOL_POINTERS or S_SYMBOL_STUBS
+ */
+static const char * find_reloc_name_in_sec_ptr(int address, struct section * sec_hdr)
+{
+ unsigned int tocindex, symindex, size;
+ const char *name = 0;
+
+ /* Sanity check */
+ if(!( address >= sec_hdr->addr && address < (sec_hdr->addr + sec_hdr->size) ) )
+ return (char*)0;
+
+ if( sec_hdr->flags & S_SYMBOL_STUBS ){
+ size = sec_hdr->reserved2;
+ if(size == 0)
+ error("size = 0");
+
+ }
+ else if( sec_hdr->flags & S_LAZY_SYMBOL_POINTERS ||
+ sec_hdr->flags & S_NON_LAZY_SYMBOL_POINTERS)
+ size = sizeof(unsigned long);
+ else
+ return 0;
+
+ /* Compute our index in toc */
+ tocindex = (address - sec_hdr->addr)/size;
+ symindex = tocdylib[sec_hdr->reserved1 + tocindex];
+
+ name = find_str_by_index(symtab[symindex].n_un.n_strx);
+
+ return name;
+}
+
+static const char * find_reloc_name_given_its_address(int address)
+{
+ unsigned int i;
+ for(i = 0; i < segment->nsects ; i++)
+ {
+ const char * name = find_reloc_name_in_sec_ptr(address, §ion_hdr[i]);
+ if((long)name != -1)
+ return name;
+ }
+ return 0;
+}
+
+static const char * get_reloc_name(EXE_RELOC * rel, int * sslide)
+{
+ char * name = 0;
+ struct scattered_relocation_info * sca_rel = (struct scattered_relocation_info*)rel;
+ int sectnum = rel->r_symbolnum;
+ int sectoffset;
+ int other_half=0;
+
+ /* init the slide value */
+ *sslide = 0;
+
+ if(R_SCATTERED & rel->r_address)
+ return (char *)find_reloc_name_given_its_address(sca_rel->r_value);
+
+ if(rel->r_extern)
+ {
+ /* ignore debug sym */
+ if ( symtab[rel->r_symbolnum].n_type & N_STAB /* || symtab[rel->r_symbolnum].n_sect != 1*/)
+ return 0;
+ return find_symname_by_symindex(symtab, rel->r_symbolnum);
+ }
+
+ /* Intruction contains an offset to the symbols pointed to, in the rel->r_symbolnum section */
+ sectoffset = *(uint32_t *)(text + rel->r_address) & 0xffff;
+
+ if(sectnum==0xffffff)
+ return 0;
+
+ /* Sanity Check */
+ if(sectnum > segment->nsects)
+ error("sectnum > segment->nsects");
+
+ switch(rel->r_type)
+ {
+ case PPC_RELOC_LO16: fetch_next_pair_value(rel+1, &other_half); sectoffset = (sectoffset & 0xffff);
+ break;
+ case PPC_RELOC_HI16: fetch_next_pair_value(rel+1, &other_half); sectoffset = (other_half & 0xffff);
+ break;
+ case PPC_RELOC_HA16: fetch_next_pair_value(rel+1, &other_half); sectoffset = (other_half & 0xffff);
+ break;
+ case PPC_RELOC_BR24:
+ sectoffset = ( *(uint32_t *)(text + rel->r_address) & 0x03fffffc );
+ if (sectoffset & 0x02000000) sectoffset |= 0xfc000000;
+ break;
+ default:
+ error("switch(rel->type) not found");
+ }
+
+ if(rel->r_pcrel)
+ sectoffset += rel->r_address;
+
+ if (rel->r_type == PPC_RELOC_BR24)
+ name = (char *)find_reloc_name_in_sec_ptr((int)sectoffset, §ion_hdr[sectnum-1]);
+
+ /* search it in the full symbol list, if not found */
+ if(!name)
+ name = (char *)find_sym_with_value_and_sec_number(sectoffset, sectnum, sslide);
+
+ return name;
+}
+
+/* Used by dyngen common code */
+static const char * get_rel_sym_name(EXE_RELOC * rel)
+{
+ int sslide;
+ return get_reloc_name( rel, &sslide);
+}
+
+/* Used by dyngen common code */
+static int get_rel_offset(EXE_RELOC *rel)
+{
+ struct scattered_relocation_info * sca_rel = (struct scattered_relocation_info*)rel;
+ if(R_SCATTERED & rel->r_address)
+ return sca_rel->r_address;
+ else
+ return rel->r_address;
+}
+
+/* load a mach-o object file */
+int load_object(const char *filename)
+{
+ int fd;
+ unsigned int offset_to_segment = 0;
+ unsigned int offset_to_dysymtab = 0;
+ unsigned int offset_to_symtab = 0;
+
+ struct load_command lc;
+ unsigned int i, j;
+
+ fd = open(filename, O_RDONLY);
+ if (fd < 0)
+ error("can't open file '%s'", filename);
+
+ /* Read Mach header. */
+ if (read(fd, &mach_hdr, sizeof (mach_hdr)) != sizeof (mach_hdr))
+ error("unable to read file header");
+
+ /* Check Mach identification. */
+ if (!check_mach_header(mach_hdr)) {
+ error("bad Mach header");
+ }
+
+ if (mach_hdr.cputype != CPU_TYPE_POWERPC)
+ error("Unsupported CPU");
+
+ if (mach_hdr.filetype != MH_OBJECT)
+ error("Unsupported Mach Object");
+
+ /* read segment headers */
+ for(i=0, j=sizeof(mach_hdr); i<mach_hdr.ncmds ; i++)
+ {
+ if(read(fd, &lc, sizeof(struct load_command)) != sizeof(struct load_command))
+ error("unable to read load_command");
+ if(lc.cmd == LC_SEGMENT)
+ {
+ offset_to_segment = j;
+ lseek(fd, offset_to_segment, SEEK_SET);
+ segment = malloc(sizeof(struct segment_command));
+ if(read(fd, segment, sizeof(struct segment_command)) != sizeof(struct segment_command))
+ error("unable to read LC_SEGMENT");
+ }
+ if(lc.cmd == LC_DYSYMTAB)
+ {
+ offset_to_dysymtab = j;
+ lseek(fd, offset_to_dysymtab, SEEK_SET);
+ dysymtabcmd = malloc(sizeof(struct dysymtab_command));
+ if(read(fd, dysymtabcmd, sizeof(struct dysymtab_command)) != sizeof(struct dysymtab_command))
+ error("unable to read LC_DYSYMTAB");
+ }
+ if(lc.cmd == LC_SYMTAB)
+ {
+ offset_to_symtab = j;
+ lseek(fd, offset_to_symtab, SEEK_SET);
+ symtabcmd = malloc(sizeof(struct symtab_command));
+ if(read(fd, symtabcmd, sizeof(struct symtab_command)) != sizeof(struct symtab_command))
+ error("unable to read LC_SYMTAB");
+ }
+ j+=lc.cmdsize;
+
+ lseek(fd, j, SEEK_SET);
+ }
+
+ if(!segment)
+ error("unable to find LC_SEGMENT");
+
+ /* read section headers */
+ section_hdr = load_data(fd, offset_to_segment + sizeof(struct segment_command), segment->nsects * sizeof(struct section));
+
+ /* read all section data */
+ sdata = (uint8_t **)malloc(sizeof(void *) * segment->nsects);
+ memset(sdata, 0, sizeof(void *) * segment->nsects);
+
+ /* Load the data in section data */
+ for(i = 0; i < segment->nsects; i++) {
+ sdata[i] = load_data(fd, section_hdr[i].offset, section_hdr[i].size);
+ }
+
+ /* text section */
+ text_sec_hdr = find_mach_sec_hdr(section_hdr, segment->nsects, SEG_TEXT, SECT_TEXT);
+ i = find_mach_sec_index(section_hdr, segment->nsects, SEG_TEXT, SECT_TEXT);
+ if (i == -1 || !text_sec_hdr)
+ error("could not find __TEXT,__text section");
+ text = sdata[i];
+
+ /* Make sure dysym was loaded */
+ if(!(int)dysymtabcmd)
+ error("could not find __DYSYMTAB segment");
+
+ /* read the table of content of the indirect sym */
+ tocdylib = load_data( fd, dysymtabcmd->indirectsymoff, dysymtabcmd->nindirectsyms * sizeof(uint32_t) );
+
+ /* Make sure symtab was loaded */
+ if(!(int)symtabcmd)
+ error("could not find __SYMTAB segment");
+ nb_syms = symtabcmd->nsyms;
+
+ symtab = load_data(fd, symtabcmd->symoff, symtabcmd->nsyms * sizeof(struct nlist));
+ strtab = load_data(fd, symtabcmd->stroff, symtabcmd->strsize);
+
+ /* Find Reloc */
+ relocs = load_data(fd, text_sec_hdr->reloff, text_sec_hdr->nreloc * sizeof(struct relocation_info));
+ nb_relocs = text_sec_hdr->nreloc;
+
+ close(fd);
+ return 0;
+}
+
+#endif /* CONFIG_FORMAT_MACH */
+
#ifdef HOST_ARM
int arm_emit_ldr_info(const char *name, unsigned long start_offset,
@@ -1049,10 +1435,13 @@
args_present[i] = 0;
for(i = 0, rel = relocs;i < nb_relocs; i++, rel++) {
- if (rel->r_offset >= start_offset &&
- rel->r_offset < start_offset + (p_end - p_start)) {
+ int offset = get_rel_offset(rel);
+ if (offset >= start_offset &&
+ offset < start_offset + (p_end - p_start)) {
sym_name = get_rel_sym_name(rel);
- if (strstart(sym_name, "__op_param", &p)) {
+ if(!sym_name)
+ continue;
+ if (strstart(sym_name, ASM_NAME(__op_param), &p)) {
n = strtoul(p, NULL, 10);
if (n > MAX_ARGS)
error("too many arguments in %s", name);
@@ -1070,11 +1459,11 @@
}
if (gen_switch == 2) {
- fprintf(outfile, "DEF(%s, %d, %d)\n", name + 3, nb_args, copy_size);
+ fprintf(outfile, "DEF(%s, %d, %d)\n", CSYM_NAME(name) + 3, nb_args, copy_size);
} else if (gen_switch == 1) {
/* output C code */
- fprintf(outfile, "case INDEX_%s: {\n", name);
+ fprintf(outfile, "case INDEX_%s: {\n", CSYM_NAME(name));
if (nb_args > 0) {
fprintf(outfile, " long ");
for(i = 0; i < nb_args; i++) {
@@ -1084,15 +1473,18 @@
}
fprintf(outfile, ";\n");
}
- fprintf(outfile, " extern void %s();\n", name);
+ fprintf(outfile, " extern void %s();\n", CSYM_NAME(name));
for(i = 0, rel = relocs;i < nb_relocs; i++, rel++) {
- if (rel->r_offset >= start_offset &&
- rel->r_offset < start_offset + (p_end - p_start)) {
+ int offset = get_rel_offset(rel);
+ if (offset >= start_offset &&
+ offset < start_offset + (p_end - p_start)) {
sym_name = get_rel_sym_name(rel);
+ if(!sym_name)
+ continue;
if (*sym_name &&
- !strstart(sym_name, "__op_param", NULL) &&
- !strstart(sym_name, "__op_jmp", NULL)) {
+ !strstart(sym_name, ASM_NAME(__op_param), NULL) &&
+ !strstart(sym_name, ASM_NAME(__op_jmp), NULL)) {
#if defined(HOST_SPARC)
if (sym_name[0] == '.') {
fprintf(outfile,
@@ -1101,12 +1493,18 @@
continue;
}
#endif
- fprintf(outfile, "extern char %s;\n", sym_name);
+#ifdef __APPLE__
+/* set __attribute((unused)) on darwin because we wan't to avoid warning when we don't use the symbol */
+ fprintf(outfile, "extern char %s __attribute__((unused));\n", CSYM_NAME(sym_name));
+#else
+ fprintf(outfile, "extern char %s;\n", CSYM_NAME(sym_name));
+#endif
}
}
}
- fprintf(outfile, " memcpy(gen_code_ptr, (void *)((char *)&%s+%d), %d);\n", name, start_offset - offset, copy_size);
+ fprintf(outfile, " memcpy(gen_code_ptr, (void *)((char *)&%s+%d), %d);\n",
+ CSYM_NAME(name), (int)(start_offset - offset), copy_size);
/* emit code offset information */
{
@@ -1117,7 +1515,7 @@
for(i = 0, sym = symtab; i < nb_syms; i++, sym++) {
sym_name = get_sym_name(sym);
- if (strstart(sym_name, "__op_label", &p)) {
+ if (strstart(sym_name, ASM_NAME(__op_label), &p)) {
uint8_t *ptr;
unsigned long offset;
@@ -1131,12 +1529,20 @@
} else {
ptr = NULL;
}
+#elif defined(CONFIG_FORMAT_MACH)
+ if(!sym->n_sect)
+ continue;
+ ptr = sdata[sym->n_sect-1];
#else
ptr = sdata[sym->st_shndx];
#endif
if (!ptr)
error("__op_labelN in invalid section");
+#ifdef CONFIG_FORMAT_MACH
+ offset = sym->n_value - section_hdr[sym->n_sect-1].addr;
+#else
offset = sym->st_value;
+#endif
val = *(unsigned long *)(ptr + offset);
#ifdef ELF_USES_RELOCA
{
@@ -1284,6 +1690,7 @@
}
#elif defined(HOST_PPC)
{
+#ifdef CONFIG_FORMAT_ELF
char name[256];
int type;
int addend;
@@ -1337,6 +1744,98 @@
}
}
}
+#elif defined(CONFIG_FORMAT_MACH)
+ struct scattered_relocation_info *scarel;
+ struct relocation_info * rel;
+ char final_sym_name[256];
+ const char *sym_name;
+ const char *p;
+ int slide, sslide;
+ int i;
+
+ for(i = 0, rel = relocs; i < nb_relocs; i++, rel++) {
+ unsigned int offset, length, value = 0;
+ unsigned int type, pcrel, isym = 0;
+ unsigned int usesym = 0;
+
+ if(R_SCATTERED & rel->r_address) {
+ scarel = (struct scattered_relocation_info*)rel;
+ offset = (unsigned int)scarel->r_address;
+ length = scarel->r_length;
+ pcrel = scarel->r_pcrel;
+ type = scarel->r_type;
+ value = scarel->r_value;
+ } else {
+ value = isym = rel->r_symbolnum;
+ usesym = (rel->r_extern);
+ offset = rel->r_address;
+ length = rel->r_length;
+ pcrel = rel->r_pcrel;
+ type = rel->r_type;
+ }
+
+ slide = offset - start_offset;
+
+ if (!(offset >= start_offset && offset < start_offset + size))
+ continue; /* not in our range */
+
+ sym_name = get_reloc_name(rel, &sslide);
+
+ if(usesym && symtab[isym].n_type & N_STAB)
+ {
+ fprintf(outfile, " /* N_STAB %s */\n", sym_name);
+ continue; /* don't handle STAB (debug sym) */
+ }
+
+ if (sym_name && strstart(sym_name, ASM_NAME(__op_jmp), &p)) {
+ int n;
+ n = strtol(p, NULL, 10);
+ fprintf(outfile, " jmp_offsets[%d] = %d + (gen_code_ptr - gen_code_buf);\n",
+ n, slide);
+ continue; /* Nothing more to do */
+ }
+
+ if(!sym_name)
+ {
+ fprintf(outfile, "/* #warning relocation not handled in %s (value 0x%x, %s, offset 0x%x, length 0x%x, %s, type 0x%x) */\n",
+ CSYM_NAME(name), value, usesym ? "use sym" : "don't use sym", offset, length, pcrel ? "pcrel":"", type);
+ continue; /* dunno how to handle without final_sym_name */
+ }
+
+ if (strstart(sym_name, ASM_NAME(__op_param), &p)) {
+ snprintf(final_sym_name, sizeof(final_sym_name), "param%s", p);
+ } else {
+ snprintf(final_sym_name, sizeof(final_sym_name), "(long)(&%s)", CSYM_NAME(sym_name));
+ }
+
+ switch(type) {
+ case PPC_RELOC_BR24:
+ fprintf(outfile, "{\n");
+ fprintf(outfile, " uint32_t imm = *(uint32_t *)(gen_code_ptr + %d) & 0x3fffffc;\n", slide);
+ fprintf(outfile, " *(uint32_t *)(gen_code_ptr + %d) = (*(uint32_t *)(gen_code_ptr + %d) & ~0x03fffffc) | ((imm + ((long)%s - (long)gen_code_ptr) + %d) & 0x03fffffc);\n",
+ slide, slide, CSYM_NAME(name), sslide );
+ fprintf(outfile, "}\n");
+ break;
+ case PPC_RELOC_HI16:
+ fprintf(outfile, " *(uint16_t *)(gen_code_ptr + %d + 2) = (%s + %d) >> 16;\n",
+ slide, final_sym_name, sslide);
+ break;
+ case PPC_RELOC_LO16:
+ fprintf(outfile, " *(uint16_t *)(gen_code_ptr + %d + 2) = (%s + %d);\n",
+ slide, final_sym_name, sslide);
+ break;
+ case PPC_RELOC_HA16:
+ fprintf(outfile, " *(uint16_t *)(gen_code_ptr + %d + 2) = (%s + %d + 0x8000) >> 16;\n",
+ slide, final_sym_name, sslide);
+ break;
+ default:
+ fprintf(outfile, "/* unsupported powerpc relocation %d %s */\n", type, usesym ? "with sym" : "without syms");
+ error("unsupported powerpc relocation (%d)", type);
+ }
+ }
+#else
+#error unsupport object format
+#endif
}
#elif defined(HOST_S390)
{
@@ -1657,7 +2156,7 @@
fprintf(outfile, "}\n");
fprintf(outfile, "break;\n\n");
} else {
- fprintf(outfile, "static inline void gen_%s(", name);
+ fprintf(outfile, "static inline void gen_%s(", CSYM_NAME(name));
if (nb_args == 0) {
fprintf(outfile, "void");
} else {
@@ -1672,11 +2171,50 @@
for(i = 0; i < nb_args; i++) {
fprintf(outfile, " *gen_opparam_ptr++ = param%d;\n", i + 1);
}
- fprintf(outfile, " *gen_opc_ptr++ = INDEX_%s;\n", name);
+ fprintf(outfile, " *gen_opc_ptr++ = INDEX_%s;\n", CSYM_NAME(name));
fprintf(outfile, "}\n\n");
}
}
+#ifdef CONFIG_FORMAT_MACH
+# define begin_go_through_syms(symtab, nb_syms, sym, i) \
+ for(i = 0, sym = symtab; i < nb_syms; i++, sym++) { \
+ const char *name; \
+ struct nlist *sym_follow, *sym_next = 0; \
+ unsigned int j, size; \
+ name = find_str_by_index(sym->n_un.n_strx); \
+ if ( sym->n_type & N_STAB || sym->n_sect != 1 || !strstart(name, OP_PREFIX, NULL) ) \
+ continue; \
+ /* Find the following symbol in order to get the current symbol size */ \
+ for(j = 0, sym_follow = symtab; j < nb_syms; j++, sym_follow++) { \
+ if ( sym_follow->n_sect != 1 || sym_follow->n_type & N_STAB || !(sym_follow->n_value > sym->n_value)) \
+ continue; \
+ if(!sym_next) { \
+ sym_next = sym_follow; \
+ continue; \
+ } \
+ if(!(sym_next->n_value > sym_follow->n_value)) \
+ continue; \
+ sym_next = sym_follow; \
+ } \
+ if(sym_next) \
+ size = sym_next->n_value - sym->n_value; \
+ else \
+ size = text_sec_hdr->size - sym->n_value;
+# define end_go_through_syms() \
+ }
+# define macro_gen_code(i) gen_code(name, sym->n_value, size, outfile, i)
+#else
+# define begin_go_through_syms(symtab, nb_syms, sym, i) \
+ for(i = 0, sym = symtab; i < nb_syms; i++, sym++) { \
+ const char *name, *p; \
+ name = get_sym_name(sym); \
+ if (strstart(name, OP_PREFIX, &p)) {
+# define end_go_through_syms() \
+ } }
+# define macro_gen_code(i) gen_code(name, sym->st_value, sym->st_size, outfile, i)
+#endif
+
int gen_file(FILE *outfile, int out_type)
{
int i;
@@ -1688,25 +2226,20 @@
fprintf(outfile, "DEF(nop1, 1, 0)\n");
fprintf(outfile, "DEF(nop2, 2, 0)\n");
fprintf(outfile, "DEF(nop3, 3, 0)\n");
- for(i = 0, sym = symtab; i < nb_syms; i++, sym++) {
- const char *name, *p;
- name = get_sym_name(sym);
- if (strstart(name, OP_PREFIX, &p)) {
- gen_code(name, sym->st_value, sym->st_size, outfile, 2);
- }
- }
+
+ begin_go_through_syms(symtab, nb_syms, sym, i)
+ macro_gen_code(2);
+ end_go_through_syms()
+
} else if (out_type == OUT_GEN_OP) {
/* generate gen_xxx functions */
-
- for(i = 0, sym = symtab; i < nb_syms; i++, sym++) {
- const char *name;
- name = get_sym_name(sym);
- if (strstart(name, OP_PREFIX, NULL)) {
- if (sym->st_shndx != text_shndx)
+ begin_go_through_syms(symtab, nb_syms, sym, i)
+#if defined(CONFIG_FORMAT_ELF) || defined(CONFIG_FORMAT_COFF)
+ if (sym->st_shndx != text_shndx)
error("invalid section for opcode (0x%x)", sym->st_shndx);
- gen_code(name, sym->st_value, sym->st_size, outfile, 0);
- }
- }
+#endif
+ macro_gen_code(0);
+ end_go_through_syms()
} else {
/* generate big code generation switch */
@@ -1738,20 +2271,18 @@
" for(;;) {\n"
" switch(*opc_ptr++) {\n"
);
-
- for(i = 0, sym = symtab; i < nb_syms; i++, sym++) {
- const char *name;
- name = get_sym_name(sym);
- if (strstart(name, OP_PREFIX, NULL)) {
+ begin_go_through_syms(symtab, nb_syms, sym, i)
#if 0
- printf("%4d: %s pos=0x%08x len=%d\n",
- i, name, sym->st_value, sym->st_size);
+ printf("%4d: %s pos=0x%08x len=%d\n",
+ i, name, sym->st_value, sym->st_size);
#endif
- if (sym->st_shndx != text_shndx)
- error("invalid section for opcode (0x%x)", sym->st_shndx);
- gen_code(name, sym->st_value, sym->st_size, outfile, 1);
- }
- }
+#if defined(CONFIG_FORMAT_ELF) || defined(CONFIG_FORMAT_COFF)
+ if (sym->st_shndx != text_shndx)
+ error("invalid section for opcode (0x%x)", sym->st_shndx);
+#endif
+ macro_gen_code(1);
+ end_go_through_syms()
+
fprintf(outfile,
" case INDEX_op_nop:\n"
Index: exec-all.h
===================================================================
RCS file: /cvsroot/qemu/qemu/exec-all.h,v
retrieving revision 1.19
diff -u -r1.19 exec-all.h
--- exec-all.h 3 Jun 2004 14:01:42 -0000 1.19
+++ exec-all.h 2 Jul 2004 22:43:53 -0000
@@ -303,16 +303,30 @@
#define offsetof(type, field) ((size_t) &((type *)0)->field)
#endif
+#ifdef _WIN32
+#define ASM_DATA_SECTION ".section \".data\"\n"
+#define ASM_PREVIOUS_SECTION ".section .text\n"
+#elif __APPLE__
+#define ASM_DATA_SECTION ".data\n"
+#define ASM_PREVIOUS_SECTION ".text\n"
+#define ASM_NAME(x) "_" #x
+#else
+#define ASM_DATA_SECTION ".section \".data\"\n"
+#define ASM_PREVIOUS_SECTION ".previous\n"
+#define ASM_NAME(x) stringify(x)
+#endif
+
+
#if defined(__powerpc__)
/* we patch the jump instruction directly */
#define JUMP_TB(opname, tbparam, n, eip)\
do {\
- asm volatile (".section \".data\"\n"\
- "__op_label" #n "." stringify(opname) ":\n"\
+ asm volatile (ASM_DATA_SECTION\
+ ASM_NAME(__op_label) #n "." ASM_NAME(opname) ":\n"\
".long 1f\n"\
- ".previous\n"\
- "b __op_jmp" #n "\n"\
+ ASM_PREVIOUS_SECTION\
+ "b " ASM_NAME(__op_jmp) #n "\n"\
"1:\n");\
T0 = (long)(tbparam) + (n);\
EIP = eip;\
@@ -321,17 +335,11 @@
#define JUMP_TB2(opname, tbparam, n)\
do {\
- asm volatile ("b __op_jmp" #n "\n");\
+ asm volatile ("b " ASM_NAME(__op_jmp) #n "\n");\
} while (0)
#elif defined(__i386__) && defined(USE_DIRECT_JUMP)
-#ifdef _WIN32
-#define ASM_PREVIOUS_SECTION ".section .text\n"
-#else
-#define ASM_PREVIOUS_SECTION ".previous\n"
-#endif
-
/* we patch the jump instruction directly */
#define JUMP_TB(opname, tbparam, n, eip)\
do {\
@@ -384,11 +392,11 @@
{
int ret;
__asm__ __volatile__ (
- "0: lwarx %0,0,%1 ;"
- " xor. %0,%3,%0;"
- " bne 1f;"
- " stwcx. %2,0,%1;"
- " bne- 0b;"
+ "0: lwarx %0,0,%1\n"
+ " xor. %0,%3,%0\n"
+ " bne 1f\n"
+ " stwcx. %2,0,%1\n"
+ " bne- 0b\n"
"1: "
: "=&r" (ret)
: "r" (p), "r" (1), "r" (0)
Index: exec.c
===================================================================
RCS file: /cvsroot/qemu/qemu/exec.c,v
retrieving revision 1.43
diff -u -r1.43 exec.c
--- exec.c 22 Jun 2004 18:48:46 -0000 1.43
+++ exec.c 2 Jul 2004 22:43:55 -0000
@@ -100,10 +100,10 @@
static void io_mem_init(void);
-unsigned long real_host_page_size;
-unsigned long host_page_bits;
-unsigned long host_page_size;
-unsigned long host_page_mask;
+unsigned long qemu_real_host_page_size;
+unsigned long qemu_host_page_bits;
+unsigned long qemu_host_page_size;
+unsigned long qemu_host_page_mask;
/* XXX: for system emulation, it could just be an array */
static PageDesc *l1_map[L1_SIZE];
@@ -127,21 +127,21 @@
static void page_init(void)
{
- /* NOTE: we can always suppose that host_page_size >=
+ /* NOTE: we can always suppose that qemu_host_page_size >=
TARGET_PAGE_SIZE */
#ifdef _WIN32
- real_host_page_size = 4096;
+ qemu_real_host_page_size = 4096;
#else
- real_host_page_size = getpagesize();
+ qemu_real_host_page_size = getpagesize();
#endif
- if (host_page_size == 0)
- host_page_size = real_host_page_size;
- if (host_page_size < TARGET_PAGE_SIZE)
- host_page_size = TARGET_PAGE_SIZE;
- host_page_bits = 0;
- while ((1 << host_page_bits) < host_page_size)
- host_page_bits++;
- host_page_mask = ~(host_page_size - 1);
+ if (qemu_host_page_size == 0)
+ qemu_host_page_size = qemu_real_host_page_size;
+ if (qemu_host_page_size < TARGET_PAGE_SIZE)
+ qemu_host_page_size = TARGET_PAGE_SIZE;
+ qemu_host_page_bits = 0;
+ while ((1 << qemu_host_page_bits) < qemu_host_page_size)
+ qemu_host_page_bits++;
+ qemu_host_page_mask = ~(qemu_host_page_size - 1);
#if !defined(CONFIG_USER_ONLY)
virt_valid_tag = 1;
#endif
@@ -831,12 +831,12 @@
/* force the host page as non writable (writes will have a
page fault + mprotect overhead) */
- host_start = page_addr & host_page_mask;
- host_end = host_start + host_page_size;
+ host_start = page_addr & qemu_host_page_mask;
+ host_end = host_start + qemu_host_page_size;
prot = 0;
for(addr = host_start; addr < host_end; addr += TARGET_PAGE_SIZE)
prot |= page_get_flags(addr);
- mprotect((void *)host_start, host_page_size,
+ mprotect((void *)host_start, qemu_host_page_size,
(prot & PAGE_BITS) & ~PAGE_WRITE);
#ifdef DEBUG_TB_INVALIDATE
printf("protecting code page: 0x%08lx\n",
@@ -1737,12 +1737,12 @@
PageDesc *p, *p1;
unsigned long host_start, host_end, addr;
- host_start = address & host_page_mask;
+ host_start = address & qemu_host_page_mask;
page_index = host_start >> TARGET_PAGE_BITS;
p1 = page_find(page_index);
if (!p1)
return 0;
- host_end = host_start + host_page_size;
+ host_end = host_start + qemu_host_page_size;
p = p1;
prot = 0;
for(addr = host_start;addr < host_end; addr += TARGET_PAGE_SIZE) {
@@ -1754,7 +1754,7 @@
if (prot & PAGE_WRITE_ORG) {
pindex = (address - host_start) >> TARGET_PAGE_BITS;
if (!(p1[pindex].flags & PAGE_WRITE)) {
- mprotect((void *)host_start, host_page_size,
+ mprotect((void *)host_start, qemu_host_page_size,
(prot & PAGE_BITS) | PAGE_WRITE);
p1[pindex].flags |= PAGE_WRITE;
/* and since the content will be modified, we must invalidate
Index: oss.c
===================================================================
RCS file: /cvsroot/qemu/qemu/oss.c,v
retrieving revision 1.4
diff -u -r1.4 oss.c
--- oss.c 7 Jun 2004 20:58:31 -0000 1.4
+++ oss.c 2 Jul 2004 22:43:56 -0000
@@ -23,7 +23,7 @@
*/
#include "vl.h"
-#ifndef _WIN32
+#if !defined(_WIN32) && !defined(__APPLE__)
#include <ctype.h>
#include <fcntl.h>
#include <errno.h>
Index: sdl.c
===================================================================
RCS file: /cvsroot/qemu/qemu/sdl.c,v
retrieving revision 1.14
diff -u -r1.14 sdl.c
--- sdl.c 20 Jun 2004 12:36:04 -0000 1.14
+++ sdl.c 2 Jul 2004 22:43:56 -0000
@@ -63,6 +63,110 @@
ds->depth = screen->format->BitsPerPixel;
}
+static uint8_t scancodeForKey(SDLKey key)
+{
+ static const uint8_t scancodes[] = {
+ [SDLK_ESCAPE] = 0x01,
+ [SDLK_1] = 0x02,
+ [SDLK_2] = 0x03,
+ [SDLK_3] = 0x04,
+ [SDLK_4] = 0x05,
+ [SDLK_5] = 0x06,
+ [SDLK_6] = 0x07,
+ [SDLK_7] = 0x08,
+ [SDLK_8] = 0x09,
+ [SDLK_9] = 0x0a,
+ [SDLK_0] = 0x0b,
+ [SDLK_MINUS] = 0x0c,
+ [SDLK_EQUALS] = 0x0d,
+ [SDLK_BACKSPACE] = 0x0e,
+ [SDLK_TAB] = 0x0f,
+ [SDLK_q] = 0x10,
+ [SDLK_w] = 0x11,
+ [SDLK_e] = 0x12,
+ [SDLK_r] = 0x13,
+ [SDLK_t] = 0x14,
+ [SDLK_y] = 0x15,
+ [SDLK_u] = 0x16,
+ [SDLK_i] = 0x17,
+ [SDLK_o] = 0x18,
+ [SDLK_p] = 0x19,
+ [SDLK_LEFTBRACKET] = 0x1a,
+ [SDLK_RIGHTBRACKET] = 0x1b,
+ [SDLK_RETURN] = 0x1c,
+ [SDLK_LCTRL] = 0x1d,
+ [SDLK_a] = 0x1e,
+ [SDLK_s] = 0x1f,
+ [SDLK_d] = 0x20,
+ [SDLK_f] = 0x21,
+ [SDLK_g] = 0x22,
+ [SDLK_h] = 0x23,
+ [SDLK_j] = 0x24,
+ [SDLK_k] = 0x25,
+ [SDLK_l] = 0x26,
+ [SDLK_SEMICOLON] = 0x27,
+ [SDLK_QUOTE] = 0x28,
+ [SDLK_BACKQUOTE] = 0x29,
+ [SDLK_LSHIFT] = 0x2a,
+ [SDLK_BACKSLASH] = 0x2b,
+ [SDLK_z] = 0x2c,
+ [SDLK_x] = 0x2d,
+ [SDLK_c] = 0x2e,
+ [SDLK_v] = 0x2f,
+ [SDLK_b] = 0x30,
+ [SDLK_n] = 0x31,
+ [SDLK_m] = 0x32,
+ [SDLK_COMMA] = 0x33,
+ [SDLK_PERIOD] = 0x34,
+ [SDLK_SLASH] = 0x35,
+ [SDLK_KP_MULTIPLY] = 0x37,
+ [SDLK_LALT] = 0x38,
+ [SDLK_SPACE] = 0x39,
+ [SDLK_CAPSLOCK] = 0x3a,
+ [SDLK_F1] = 0x3b,
+ [SDLK_F2] = 0x3c,
+ [SDLK_F3] = 0x3d,
+ [SDLK_F4] = 0x3e,
+ [SDLK_F5] = 0x3f,
+ [SDLK_F6] = 0x40,
+ [SDLK_F7] = 0x41,
+ [SDLK_F8] = 0x42,
+ [SDLK_F9] = 0x43,
+ [SDLK_F10] = 0x44,
+ [SDLK_NUMLOCK] = 0x45,
+ [SDLK_SCROLLOCK] = 0x46,
+ [SDLK_KP7] = 0x47,
+ [SDLK_KP8] = 0x48,
+ [SDLK_KP9] = 0x49,
+ [SDLK_KP_MINUS] = 0x4a,
+ [SDLK_KP4] = 0x4b,
+ [SDLK_KP5] = 0x4c,
+ [SDLK_KP6] = 0x4d,
+ [SDLK_KP_PLUS] = 0x4e,
+ [SDLK_KP1] = 0x4f,
+ [SDLK_KP2] = 0x50,
+ [SDLK_KP3] = 0x51,
+ [SDLK_KP0] = 0x52,
+ [SDLK_KP_PERIOD] = 0x53,
+ [SDLK_PRINT] = 0x54,
+ [SDLK_LMETA] = 0x56,
+
+ // These reuse the KP values - is this correct?
+ [SDLK_UP] = 0x48,
+ [SDLK_DOWN] = 0x50,
+ [SDLK_RIGHT] = 0x4b,
+ [SDLK_LEFT] = 0x4d,
+ [SDLK_INSERT] = 0x52,
+ [SDLK_HOME] = 0x47,
+ [SDLK_END] = 0x4f,
+ [SDLK_PAGEUP] = 0x49,
+ [SDLK_PAGEDOWN] = 0x51,
+
+ };
+
+ return scancodes[key];
+}
+
static const uint8_t x_keycode_to_pc_keycode[61] = {
0xc7, /* 97 Home */
0xc8, /* 98 Up */
@@ -143,11 +247,11 @@
return;
}
- /* XXX: not portable, but avoids complicated mappings */
- keycode = ev->keysym.scancode;
+ keycode = scancodeForKey(ev->keysym.sym);
/* XXX: windows version may not work: 0xe0/0xe1 should be trapped
? */
+#if 0
#ifndef _WIN32
if (keycode < 9) {
keycode = 0;
@@ -160,6 +264,7 @@
keycode = 0;
}
#endif
+#endif
switch(keycode) {
case 0x00:
Index: vl.c
===================================================================
RCS file: /cvsroot/qemu/qemu/vl.c,v
retrieving revision 1.86
diff -u -r1.86 vl.c
--- vl.c 25 Jun 2004 17:06:27 -0000 1.86
+++ vl.c 2 Jul 2004 22:43:58 -0000
@@ -40,7 +40,9 @@
#include <sys/socket.h>
#ifdef _BSD
#include <sys/stat.h>
+# ifndef __APPLE__
#include <libutil.h>
+# endif
#else
#include <linux/if.h>
#include <linux/if_tun.h>
@@ -63,6 +65,7 @@
#endif
#ifdef CONFIG_SDL
+#include <SDL/SDL.h>
#if defined(__linux__)
/* SDL use the pthreads and they modify sigaction. We don't
want that. */
@@ -825,14 +828,14 @@
}
}
-#ifndef _WIN32
+#if !defined(_WIN32)
+
+static int rtc_fd;
#if defined(__linux__)
#define RTC_FREQ 1024
-static int rtc_fd;
-
static int start_rtc_timer(void)
{
rtc_fd = open("/dev/rtc", O_RDONLY);
@@ -908,7 +911,7 @@
/* we probe the tick duration of the kernel to inform the user if
the emulated kernel requested a too high timer frequency */
getitimer(ITIMER_REAL, &itv);
-
+#if defined(__linux__)
if (itv.it_interval.tv_usec > 1000) {
/* try to use /dev/rtc to have a faster timer */
if (start_rtc_timer() < 0)
@@ -924,7 +927,9 @@
sigaction(SIGIO, &act, NULL);
fcntl(rtc_fd, F_SETFL, O_ASYNC);
fcntl(rtc_fd, F_SETOWN, getpid());
- } else {
+ } else
+#endif
+ {
use_itimer:
pit_min_timer_count = ((uint64_t)itv.it_interval.tv_usec *
PIT_FREQ) / 1000000;
@@ -2263,9 +2268,11 @@
const char *r, *optarg;
#if !defined(CONFIG_SOFTMMU)
+#if !defined(__APPLE__)
/* we never want that malloc() uses mmap() */
mallopt(M_MMAP_THRESHOLD, 4096 * 1024);
#endif
+#endif
initrd_filename = NULL;
for(i = 0; i < MAX_FD; i++)
fd_filename[i] = NULL;
@@ -2621,9 +2628,10 @@
phys_ram_size = ram_size + vga_ram_size + bios_size;
#ifdef CONFIG_SOFTMMU
+
#ifdef _BSD
- /* mallocs are always aligned on BSD. */
- phys_ram_base = malloc(phys_ram_size);
+ /* mallocs are always aligned on BSD. valloc is better for correctness */
+ phys_ram_base = valloc(phys_ram_size);
#else
phys_ram_base = memalign(TARGET_PAGE_SIZE, phys_ram_size);
#endif
Index: linux-user/elfload.c
===================================================================
RCS file: /cvsroot/qemu/qemu/linux-user/elfload.c,v
retrieving revision 1.22
diff -u -r1.22 elfload.c
--- linux-user/elfload.c 19 Jun 2004 17:23:13 -0000 1.22
+++ linux-user/elfload.c 2 Jul 2004 22:44:05 -0000
@@ -13,6 +13,16 @@
#include "qemu.h"
#include "disas.h"
+/* this flag is uneffective under linux too, should be deleted */
+#ifndef MAP_DENYWRITE
+#define MAP_DENYWRITE 0
+#endif
+
+/* should probably go in elf.h */
+#ifndef ELIBBAD
+#define ELIBBAD 80
+#endif
+
#ifdef TARGET_I386
#define ELF_START_MMAP 0x80000000
@@ -332,7 +342,7 @@
/* User-space version of kernel get_free_page. Returns a page-aligned
* page-sized chunk of memory.
*/
- retval = (void *)target_mmap(0, host_page_size, PROT_READ|PROT_WRITE,
+ retval = (void *)target_mmap(0, qemu_host_page_size, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
if((long)retval == -1) {
@@ -346,7 +356,7 @@
static void free_page(void * pageaddr)
{
- target_munmap((unsigned long)pageaddr, host_page_size);
+ target_munmap((unsigned long)pageaddr, qemu_host_page_size);
}
/*
@@ -502,7 +512,7 @@
if (size < MAX_ARG_PAGES*TARGET_PAGE_SIZE)
size = MAX_ARG_PAGES*TARGET_PAGE_SIZE;
error = target_mmap(0,
- size + host_page_size,
+ size + qemu_host_page_size,
PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS,
-1, 0);
@@ -511,7 +521,7 @@
exit(-1);
}
/* we reserve one extra page at the top of the stack as guard */
- target_mprotect(error + size, host_page_size, PROT_NONE);
+ target_mprotect(error + size, qemu_host_page_size, PROT_NONE);
stack_base = error + size - MAX_ARG_PAGES*TARGET_PAGE_SIZE;
p += stack_base;
@@ -562,10 +572,10 @@
of the file may not be mapped. A better fix would be to
patch target_mmap(), but it is more complicated as the file
size must be known */
- if (real_host_page_size < host_page_size) {
+ if (qemu_real_host_page_size < qemu_host_page_size) {
unsigned long end_addr, end_addr1;
- end_addr1 = (elf_bss + real_host_page_size - 1) &
- ~(real_host_page_size - 1);
+ end_addr1 = (elf_bss + qemu_real_host_page_size - 1) &
+ ~(qemu_real_host_page_size - 1);
end_addr = HOST_PAGE_ALIGN(elf_bss);
if (end_addr1 < end_addr) {
mmap((void *)end_addr1, end_addr - end_addr1,
@@ -574,9 +584,9 @@
}
}
- nbyte = elf_bss & (host_page_size-1);
+ nbyte = elf_bss & (qemu_host_page_size-1);
if (nbyte) {
- nbyte = host_page_size - nbyte;
+ nbyte = qemu_host_page_size - nbyte;
fpnt = (char *) elf_bss;
do {
*fpnt++ = 0;
@@ -811,7 +821,7 @@
* bss page.
*/
padzero(elf_bss);
- elf_bss = TARGET_ELF_PAGESTART(elf_bss + host_page_size - 1); /* What we have mapped so far */
+ elf_bss = TARGET_ELF_PAGESTART(elf_bss + qemu_host_page_size - 1); /* What we have mapped so far */
/* Map the last of the bss segment */
if (last_bss > elf_bss) {
@@ -1252,7 +1262,7 @@
and some applications "depend" upon this behavior.
Since we do not have the power to recompile these, we
emulate the SVr4 behavior. Sigh. */
- mapped_addr = target_mmap(0, host_page_size, PROT_READ | PROT_EXEC,
+ mapped_addr = target_mmap(0, qemu_host_page_size, PROT_READ | PROT_EXEC,
MAP_FIXED | MAP_PRIVATE, -1, 0);
}
Index: linux-user/main.c
===================================================================
RCS file: /cvsroot/qemu/qemu/linux-user/main.c,v
retrieving revision 1.51
diff -u -r1.51 main.c
--- linux-user/main.c 21 May 2004 12:59:18 -0000 1.51
+++ linux-user/main.c 2 Jul 2004 22:44:06 -0000
@@ -28,6 +28,11 @@
#define DEBUG_LOGFILE "/tmp/qemu.log"
+#ifdef __APPLE__
+#include <crt_externs.h>
+# define environ (*_NSGetEnviron())
+#endif
+
static const char *interp_prefix = CONFIG_QEMU_PREFIX;
#if defined(__i386__) && !defined(CONFIG_STATIC)
@@ -977,9 +982,9 @@
} else if (!strcmp(r, "L")) {
interp_prefix = argv[optind++];
} else if (!strcmp(r, "p")) {
- host_page_size = atoi(argv[optind++]);
- if (host_page_size == 0 ||
- (host_page_size & (host_page_size - 1)) != 0) {
+ qemu_host_page_size = atoi(argv[optind++]);
+ if (qemu_host_page_size == 0 ||
+ (qemu_host_page_size & (qemu_host_page_size - 1)) != 0) {
fprintf(stderr, "page size must be a power of two\n");
exit(1);
}
@@ -1007,7 +1012,7 @@
init_paths(interp_prefix);
/* NOTE: we need to init the CPU at this stage to get the
- host_page_size */
+ qemu_host_page_size */
env = cpu_init();
if (elf_exec(filename, argv+optind, environ, regs, info) != 0) {
Index: linux-user/syscall.c
===================================================================
RCS file: /cvsroot/qemu/qemu/linux-user/syscall.c,v
retrieving revision 1.50
diff -u -r1.50 syscall.c
--- linux-user/syscall.c 19 Jun 2004 16:59:03 -0000 1.50
+++ linux-user/syscall.c 2 Jul 2004 22:44:08 -0000
@@ -22,7 +22,9 @@
#include <stdarg.h>
#include <string.h>
#include <elf.h>
+#ifndef __APPLE__
#include <endian.h>
+#endif
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
@@ -34,10 +36,11 @@
#include <sys/mount.h>
#include <sys/resource.h>
#include <sys/mman.h>
+#ifndef __APPLE__
#include <sys/swap.h>
+#endif
#include <signal.h>
#include <sched.h>
-#include <sys/socket.h>
#include <sys/uio.h>
#include <sys/poll.h>
#include <sys/times.h>
@@ -45,6 +48,7 @@
#include <utime.h>
#include <sys/sysinfo.h>
//#include <sys/user.h>
+#include <sys/socket.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
@@ -55,6 +59,7 @@
#define tchars host_tchars /* same as target */
#define ltchars host_ltchars /* same as target */
+#ifndef __APPLE__
#include <linux/termios.h>
#include <linux/unistd.h>
#include <linux/utsname.h>
@@ -63,6 +68,7 @@
#include <linux/soundcard.h>
#include <linux/dirent.h>
#include <linux/kd.h>
+#endif
#include "qemu.h"
Index: slirp/slirp_config.h
===================================================================
RCS file: /cvsroot/qemu/qemu/slirp/slirp_config.h,v
retrieving revision 1.1
diff -u -r1.1 slirp_config.h
--- slirp/slirp_config.h 22 Apr 2004 00:10:47 -0000 1.1
+++ slirp/slirp_config.h 2 Jul 2004 22:44:12 -0000
@@ -65,6 +65,9 @@
/* Define if you have sys/filio.h */
#undef HAVE_SYS_FILIO_H
+#ifdef __APPLE__
+#define HAVE_SYS_FILIO_H
+#endif
/* Define if you have strerror */
#define HAVE_STRERROR
@@ -163,6 +166,9 @@
/* Define if you have <termios.h> */
#undef HAVE_TERMIOS_H
+#ifdef __APPLE__
+#define HAVE_TERMIOS_H
+#endif
/* Define if you have gethostid */
#undef HAVE_GETHOSTID
Index: target-i386/exec.h
===================================================================
RCS file: /cvsroot/qemu/qemu/target-i386/exec.h,v
retrieving revision 1.13
diff -u -r1.13 exec.h
--- target-i386/exec.h 29 May 2004 11:08:52 -0000 1.13
+++ target-i386/exec.h 2 Jul 2004 22:44:18 -0000
@@ -498,7 +498,7 @@
#define FPUC_EM 0x3f
-const CPU86_LDouble f15rk[7];
+extern const CPU86_LDouble f15rk[7];
void helper_fldt_ST0_A0(void);
void helper_fstt_ST0_A0(void);
@@ -528,9 +528,9 @@
void restore_native_fp_state(CPUState *env);
void save_native_fp_state(CPUState *env);
-const uint8_t parity_table[256];
-const uint8_t rclw_table[32];
-const uint8_t rclb_table[32];
+extern const uint8_t parity_table[256];
+extern const uint8_t rclw_table[32];
+extern const uint8_t rclb_table[32];
static inline uint32_t compute_eflags(void)
{
Index: target-i386/op.c
===================================================================
RCS file: /cvsroot/qemu/qemu/target-i386/op.c,v
retrieving revision 1.20
diff -u -r1.20 op.c
--- target-i386/op.c 25 Jun 2004 14:58:58 -0000 1.20
+++ target-i386/op.c 2 Jul 2004 22:44:22 -0000
@@ -1955,7 +1955,7 @@
int rnd_type;
env->fpuc = lduw((void *)A0);
/* set rounding mode */
-#ifdef _BSD
+#if defined(_BSD) && !defined(__APPLE__)
switch(env->fpuc & RC_MASK) {
default:
case RC_NEAR:
^ permalink raw reply [flat|nested] 22+ messages in thread
* [Qemu-devel] re: [Patch] Mac OS X Port
@ 2004-07-02 23:14 Fred Hope
2004-07-03 9:18 ` Raphaël Enrici
0 siblings, 1 reply; 22+ messages in thread
From: Fred Hope @ 2004-07-02 23:14 UTC (permalink / raw)
To: qemu-devel
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body>
<font size="3"><font face="Comic Sans MS,sans-serif">Pierre,<br>
<br>
Great work and congrats on making that OS X port of qemu; I'm sure it's
no easy task. I downloaded the patch file you included (qemuosx.diff)
but am not sure what to do with it. I discovered that there is a
"diff" Unix program; does this patch involve using diff somehow in
Terminal? Perhaps, but I'm not sure of the exact commands to use. I
don't know much about this sort of development or coding (though I know
some C, Obj-C, and Cocoa)...could someone please tell me how to use
that patch? I already have a copy of the qemu source code from CVS; I
downloaded it weeks/months ago.<br>
<br>
Thanks,<br>
Fred Hope<br>
</font></font>
</body>
</html>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] re: [Patch] Mac OS X Port
2004-07-02 23:14 [Qemu-devel] re: [Patch] Mac OS X Port Fred Hope
@ 2004-07-03 9:18 ` Raphaël Enrici
0 siblings, 0 replies; 22+ messages in thread
From: Raphaël Enrici @ 2004-07-03 9:18 UTC (permalink / raw)
To: qemu-devel
Fred Hope wrote:
> Pierre,
>
> Great work and congrats on making that OS X port of qemu; I'm sure
> it's no easy task. I downloaded the patch file you included
> (qemuosx.diff) but am not sure what to do with it. I discovered that
> there is a "diff" Unix program; does this patch involve using diff
> somehow in Terminal? Perhaps, but I'm not sure of the exact commands
> to use. I don't know much about this sort of development or coding
> (though I know some C, Obj-C, and Cocoa)...could someone please tell
> me how to use that patch? I already have a copy of the qemu source
> code from CVS; I downloaded it weeks/months ago.
Hi Pierre,
checkout qemu from CVS:
<>export CVS_RSH="ssh"
cvs -z3 -d:ext:anoncvs@savannah.nongnu.org:/cvsroot/qemu co qemu
cd qemu
patch -p0 < location_of_your_diff_file
Take a look at "man patch" for futher details.
Regards,
Raphaël
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] [Patch] Mac OS X Port
2004-07-02 22:56 [Qemu-devel] [Patch] Mac OS X Port Pierre d'Herbemont
@ 2004-07-03 13:34 ` Jean-Michel POURE
2004-07-04 7:21 ` [Qemu-devel] " Christian Walther
2004-07-05 1:22 ` [Qemu-devel] " Leigh Dyer
2 siblings, 0 replies; 22+ messages in thread
From: Jean-Michel POURE @ 2004-07-03 13:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Darwine List, Matt Reda
> Here is a patch against the Qemu CVS makes Mac OS X able to run Qemu.
Dear Pierre,
Screenshots showing a GNU/Linux guest running inside a MacOsX host
are available on FreeOsZoo: http://www.freeoszoo.org/screenshots.php
These screenshots were submited by Pierre d'Herbemont.
Please note that a QEMU MacOsX installer is not yet available on FreeOsZoo. If
you would like to install QEMU, please use Pierre patch.
Kindest regards, Jean-Michel
^ permalink raw reply [flat|nested] 22+ messages in thread
* [Qemu-devel] Re: [Patch] Mac OS X Port
2004-07-02 22:56 [Qemu-devel] [Patch] Mac OS X Port Pierre d'Herbemont
2004-07-03 13:34 ` Jean-Michel POURE
@ 2004-07-04 7:21 ` Christian Walther
2004-07-04 10:08 ` Pierre d'Herbemont
2004-07-05 1:22 ` [Qemu-devel] " Leigh Dyer
2 siblings, 1 reply; 22+ messages in thread
From: Christian Walther @ 2004-07-04 7:21 UTC (permalink / raw)
To: qemu-devel
Wow! It works! And it even has networking! Cool! That's the moment I was
hoping for when I started observing the qemu list some weeks ago... :)
It also boots Windows 95, Windows 98 SE and the Mandrake Linux 10.0
installer.
A few questions and remarks:
o To make it compile, I had to make the following change to
Makefile.target: add $(SDL_CFLAGS) to the %.o %.c rule. ($(CC) $(CFLAGS)
$(DEFINES) $(SDL_CFLAGS) -c -o $@ $<)
o Is PPC emulation supposed to work? When I try to compile it, I get the
following:
gcc -Wall -O2 -g -fno-strict-aliasing -D__powerpc__ -I.
-I/Users/cwalther/Desktop/Incoming/qemu/qemu/target-ppc
-I/Users/cwalther/Desktop/Incoming/qemu/qemu -D_GNU_SOURCE
-I/Users/cwalther/Desktop/Incoming/qemu/qemu/slirp -I/sw/include/SDL
-D_THREAD_SAFE -c -o translate.o
/Users/cwalther/Desktop/Incoming/qemu/qemu/target-ppc/translate.c
/var/tmp//ccfgCnLg.s:534:Expected comma after segment-name
/var/tmp//ccfgCnLg.s:534:Rest of line ignored. 1st junk character valued
32 ( ).
/var/tmp//ccfgCnLg.s:662:Expected comma after segment-name
/var/tmp//ccfgCnLg.s:662:Rest of line ignored. 1st junk character valued
32 ( ).
[... 203 more of these ...]
/var/tmp//ccfgCnLg.s:31194:Expected comma after segment-name
/var/tmp//ccfgCnLg.s:31194:Rest of line ignored. 1st junk character
valued 32 ( ).
/var/tmp//ccfgCnLg.s:31312:Expected comma after segment-name
/var/tmp//ccfgCnLg.s:31312:Rest of line ignored. 1st junk character
valued 32 ( ).
make[1]: *** [translate.o] Error 1
make: *** [all] Error 1
myriad:qemu cwalther$ cc --version
cc (GCC) 3.3 20030304 (Apple Computer, Inc. build 1640)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
o Is there a reason for the window to be resizable? When I tried
resizing it, qemu just crashed.
Thanks!
-Christian
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] Re: [Patch] Mac OS X Port
2004-07-04 7:21 ` [Qemu-devel] " Christian Walther
@ 2004-07-04 10:08 ` Pierre d'Herbemont
2004-07-04 10:37 ` Leigh Dyer
0 siblings, 1 reply; 22+ messages in thread
From: Pierre d'Herbemont @ 2004-07-04 10:08 UTC (permalink / raw)
To: qemu-devel
Le 4 juil. 04, à 09:21, Christian Walther a écrit :
> o To make it compile, I had to make the following change to
> Makefile.target: add $(SDL_CFLAGS) to the %.o %.c rule. ($(CC)
> $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<)
Weird, you shouldn't need to do it.
> o Is PPC emulation supposed to work? When I try to compile it, I get
> the following:
No, its not, but I have more patch to make it compile.
> o Is there a reason for the window to be resizable? When I tried
> resizing it, qemu just crashed.
How does it go with the Qemu/Linux?
Pierre
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] Re: [Patch] Mac OS X Port
2004-07-04 10:08 ` Pierre d'Herbemont
@ 2004-07-04 10:37 ` Leigh Dyer
0 siblings, 0 replies; 22+ messages in thread
From: Leigh Dyer @ 2004-07-04 10:37 UTC (permalink / raw)
To: qemu-devel
On 04/07/2004, at 8:08 PM, Pierre d'Herbemont wrote:
>
> Le 4 juil. 04, à 09:21, Christian Walther a écrit :
>
>> o To make it compile, I had to make the following change to
>> Makefile.target: add $(SDL_CFLAGS) to the %.o %.c rule. ($(CC)
>> $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<)
>
> Weird, you shouldn't need to do it.
>
I also had trouble building due to the compiler not finding SDL
headers. I added the path to the SDL headers in to the CFLAGS in
Makefile.target and that fixed things. I didn't think of adding
$(SDL_CFLAGS), but I guess that probably would have done the job too.
Apart from that, it looks good :) I haven't had a chance to play with
Windows yet, but some Linux ISOs I had handy ran just as they do on
qemu under Linux.
Thanks
Leigh
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] [Patch] Mac OS X Port
2004-07-02 22:56 [Qemu-devel] [Patch] Mac OS X Port Pierre d'Herbemont
2004-07-03 13:34 ` Jean-Michel POURE
2004-07-04 7:21 ` [Qemu-devel] " Christian Walther
@ 2004-07-05 1:22 ` Leigh Dyer
2004-07-05 22:24 ` [Qemu-devel] Inquiry, speed comparison on OS X, QEMU vs Virtual PC Daniel J. Guinan
2 siblings, 1 reply; 22+ messages in thread
From: Leigh Dyer @ 2004-07-05 1:22 UTC (permalink / raw)
To: qemu-devel
On Sat, 2004-07-03 at 00:56 +0200, Pierre d'Herbemont wrote:
>
> Hi!
>
> Here is a patch against the Qemu CVS makes Mac OS X able to run
> Qemu.It was mainly done by Matt Reda and I. Now Qemu/Mac OS X is able
> toboot the linux-test image, the freedos image, the netbsd image
> andeven the ReactOS image from the FreeOSZoo.
>
Great work - I've just successfully installed a Debian Woody system from
scratch on my Powerbook running OS X 10.3, and everything worked exactly
as I'd expect it to. The only small thing I found was that the left and
right cursor keys seem to be reversed: ie: at a bash prompt, pushing
left moves the cursor to the right, and vice versa.
Besides this tiny glitch, it's been fantastic so far. I'll let you know
if I find any other problems.
Thanks
Leigh
> If you have any question feel free to ask myself or Matt Reda.
>
> Here is a summary of the modifications:
>
> configure:
> - Darwin/Mac OS X Support
>
> Makefile*:
> - Support for various Mac OS X Specific flags.
>
> cpu-all.h:
> - host_page_size is already a system symbol, so its better to
> changeit.
>
> cpu-exec.h:
> - support for Mac OS X signals.
>
> dyngen-exec.h:
> - various fixes for Mac OS X.
>
> dyngen.c:
> - Mach-O port.
>
> exec-all.h:
> - Mach-O support.
>
> exec.c:
> - host_page_size related changes.
>
> oss.c:
> - ifdef out for Mac OS X.
>
> sdl.c:
> - keyboard support. Probably need a review.
>
> vl.c:
> - inclusion of <SDL/SDL.h> required for Mac OS X build
> - use valloc instead of malloc for correctness
> - define rtc_fd for darwin
>
> linux-user/elfload.c:
> - preliminary support for darwin, fix for host_page_size
> relatedchanges.
>
> linux-user/main.c:
> - preliminary support for darwin, fix for host_page_size
> relatedchanges.
>
> linux-user/syscall.c:
> - preliminary support for darwin.
>
> slirp/slirp_config.h:
> - support for Mac OS X.
>
> target-i386/exec.h:
> - fix correctness for symbols
> definitionsf15rk,parity_table,rclw_table,rclb_table
>
> target-i386/op.c:
> - don't do the bsd rounding mode on Mac OS X
>
> Thanks,
>
> Pierre
> _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel
^ permalink raw reply [flat|nested] 22+ messages in thread
* [Qemu-devel] Inquiry, speed comparison on OS X, QEMU vs Virtual PC
2004-07-05 1:22 ` [Qemu-devel] " Leigh Dyer
@ 2004-07-05 22:24 ` Daniel J. Guinan
2004-07-06 0:23 ` Leigh Dyer
0 siblings, 1 reply; 22+ messages in thread
From: Daniel J. Guinan @ 2004-07-05 22:24 UTC (permalink / raw)
To: qemu-devel
I'm curious, how does the speed compare to Virtual PC?
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] Inquiry, speed comparison on OS X, QEMU vs Virtual PC
2004-07-05 22:24 ` [Qemu-devel] Inquiry, speed comparison on OS X, QEMU vs Virtual PC Daniel J. Guinan
@ 2004-07-06 0:23 ` Leigh Dyer
2004-07-06 0:29 ` dguinan
0 siblings, 1 reply; 22+ messages in thread
From: Leigh Dyer @ 2004-07-06 0:23 UTC (permalink / raw)
To: qemu-devel
On Mon, 2004-07-05 at 15:24 -0700, Daniel J.Guinan wrote:
> I'm curious, how does the speed compare to Virtual PC?
>
Not terribly well yet - on my 1Ghz Tibook, it feels about the same speed
as on my 800Mhz PIII desktop PC at work, which is to say that the
emulated system seems somewhere around high-end-468/low-end-Pentium
speed. However, it's important to remember that Virtual PC:
* has been around for ages, and has seen lots of development and
optimisation
* uses a hand-written and heavily optimised x86->PPC translator
* uses special PPC features like Altivec and little-endian mode to speed
things up
* uses the host system's MMU to accelerate memory access
Qemu's still fast enough to be usable for a great many things though, so
if you're debating whether or not to try it, by all means download it
and give it a go.
Thanks
Leigh
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] Inquiry, speed comparison on OS X, QEMU vs Virtual PC
2004-07-06 0:23 ` Leigh Dyer
@ 2004-07-06 0:29 ` dguinan
2004-07-09 19:37 ` Pierre d'Herbemont
0 siblings, 1 reply; 22+ messages in thread
From: dguinan @ 2004-07-06 0:29 UTC (permalink / raw)
To: qemu-devel
It was precisely because it has not yet been optimized that I was
curious of first impressions. The fact that it has been described as
"somewhat" slower is encouraging. No one expects it to be faster than
VPC out the gate, but to be in the same ballpark is quite an
achievement.
-Daniel
On Jul 5, 2004, at 5:23 PM, Leigh Dyer wrote:
> On Mon, 2004-07-05 at 15:24 -0700, Daniel J.Guinan wrote:
>> I'm curious, how does the speed compare to Virtual PC?
>>
>
> Not terribly well yet - on my 1Ghz Tibook, it feels about the same
> speed
> as on my 800Mhz PIII desktop PC at work, which is to say that the
> emulated system seems somewhere around high-end-468/low-end-Pentium
> speed. However, it's important to remember that Virtual PC:
>
> * has been around for ages, and has seen lots of development and
> optimisation
> * uses a hand-written and heavily optimised x86->PPC translator
> * uses special PPC features like Altivec and little-endian mode to
> speed
> things up
> * uses the host system's MMU to accelerate memory access
>
> Qemu's still fast enough to be usable for a great many things though,
> so
> if you're debating whether or not to try it, by all means download it
> and give it a go.
>
> Thanks
> Leigh
>
>
>
> _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] Inquiry, speed comparison on OS X, QEMU vs Virtual PC
2004-07-06 0:29 ` dguinan
@ 2004-07-09 19:37 ` Pierre d'Herbemont
2004-07-09 20:07 ` Natalia Portillo
2004-07-10 13:14 ` Fabrice Bellard
0 siblings, 2 replies; 22+ messages in thread
From: Pierre d'Herbemont @ 2004-07-09 19:37 UTC (permalink / raw)
To: qemu-devel
I probably should add that the Mac OS X version that is avalaible for
download doesn't include support for the PowerPC swapping instructions
(little-endian storing and loading instructions). Next release will.
Pierre
Le 6 juil. 04, à 02:29, dguinan@mac.com a écrit :
> It was precisely because it has not yet been optimized that I was
> curious of first impressions. The fact that it has been described as
> "somewhat" slower is encouraging. No one expects it to be faster than
> VPC out the gate, but to be in the same ballpark is quite an
> achievement.
>
> -Daniel
>
>
> On Jul 5, 2004, at 5:23 PM, Leigh Dyer wrote:
>
>> On Mon, 2004-07-05 at 15:24 -0700, Daniel J.Guinan wrote:
>>> I'm curious, how does the speed compare to Virtual PC?
>>>
>>
>> Not terribly well yet - on my 1Ghz Tibook, it feels about the same
>> speed
>> as on my 800Mhz PIII desktop PC at work, which is to say that the
>> emulated system seems somewhere around high-end-468/low-end-Pentium
>> speed. However, it's important to remember that Virtual PC:
>>
>> * has been around for ages, and has seen lots of development and
>> optimisation
>> * uses a hand-written and heavily optimised x86->PPC translator
>> * uses special PPC features like Altivec and little-endian mode to
>> speed
>> things up
>> * uses the host system's MMU to accelerate memory access
>>
>> Qemu's still fast enough to be usable for a great many things though,
>> so
>> if you're debating whether or not to try it, by all means download it
>> and give it a go.
>>
>> Thanks
>> Leigh
>>
>>
>>
>> _______________________________________________
>> Qemu-devel mailing list
>> Qemu-devel@nongnu.org
>> http://lists.nongnu.org/mailman/listinfo/qemu-devel
>>
>
>
>
> _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* RE: [Qemu-devel] Inquiry, speed comparison on OS X, QEMU vs Virtual PC
2004-07-09 19:37 ` Pierre d'Herbemont
@ 2004-07-09 20:07 ` Natalia Portillo
2004-07-09 20:14 ` Chad Page
2004-07-10 12:47 ` Pierre d'Herbemont
2004-07-10 13:14 ` Fabrice Bellard
1 sibling, 2 replies; 22+ messages in thread
From: Natalia Portillo @ 2004-07-09 20:07 UTC (permalink / raw)
To: qemu-devel
I think that including support for the PowerPC swapping instructions in QEMU
will break compatibility with host PowerPCs before G3, so that instructions
should be used in a run-time capability detection scheme.
> -----Mensaje original-----
> De: qemu-devel-bounces+iosglpgc=teleline.es@nongnu.org
> [mailto:qemu-devel-bounces+iosglpgc=teleline.es@nongnu.org]
> En nombre de Pierre d'Herbemont
> Enviado el: viernes, 09 de julio de 2004 20:38
> Para: qemu-devel@nongnu.org
> Asunto: Re: [Qemu-devel] Inquiry, speed comparison on OS X,
> QEMU vs Virtual PC
>
> I probably should add that the Mac OS X version that is
> avalaible for download doesn't include support for the
> PowerPC swapping instructions (little-endian storing and
> loading instructions). Next release will.
>
> Pierre
>
> Le 6 juil. 04, à 02:29, dguinan@mac.com a écrit :
>
> > It was precisely because it has not yet been optimized that I was
> > curious of first impressions. The fact that it has been
> described as
> > "somewhat" slower is encouraging. No one expects it to be
> faster than
> > VPC out the gate, but to be in the same ballpark is quite an
> > achievement.
> >
> > -Daniel
> >
> >
> > On Jul 5, 2004, at 5:23 PM, Leigh Dyer wrote:
> >
> >> On Mon, 2004-07-05 at 15:24 -0700, Daniel J.Guinan wrote:
> >>> I'm curious, how does the speed compare to Virtual PC?
> >>>
> >>
> >> Not terribly well yet - on my 1Ghz Tibook, it feels about the same
> >> speed as on my 800Mhz PIII desktop PC at work, which is to
> say that
> >> the emulated system seems somewhere around
> >> high-end-468/low-end-Pentium speed. However, it's important to
> >> remember that Virtual PC:
> >>
> >> * has been around for ages, and has seen lots of development and
> >> optimisation
> >> * uses a hand-written and heavily optimised x86->PPC translator
> >> * uses special PPC features like Altivec and little-endian mode to
> >> speed things up
> >> * uses the host system's MMU to accelerate memory access
> >>
> >> Qemu's still fast enough to be usable for a great many
> things though,
> >> so if you're debating whether or not to try it, by all
> means download
> >> it and give it a go.
> >>
> >> Thanks
> >> Leigh
> >>
> >>
> >>
> >> _______________________________________________
> >> Qemu-devel mailing list
> >> Qemu-devel@nongnu.org
> >> http://lists.nongnu.org/mailman/listinfo/qemu-devel
> >>
> >
> >
> >
> > _______________________________________________
> > Qemu-devel mailing list
> > Qemu-devel@nongnu.org
> > http://lists.nongnu.org/mailman/listinfo/qemu-devel
> >
>
>
>
> _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel
^ permalink raw reply [flat|nested] 22+ messages in thread
* RE: [Qemu-devel] Inquiry, speed comparison on OS X, QEMU vs Virtual PC
2004-07-09 20:07 ` Natalia Portillo
@ 2004-07-09 20:14 ` Chad Page
2004-07-10 12:47 ` Pierre d'Herbemont
1 sibling, 0 replies; 22+ messages in thread
From: Chad Page @ 2004-07-09 20:14 UTC (permalink / raw)
To: qemu-devel
On Fri, 9 Jul 2004, Natalia Portillo wrote:
> I think that including support for the PowerPC swapping instructions in QEMU
> will break compatibility with host PowerPCs before G3, so that instructions
> should be used in a run-time capability detection scheme.
It also dosen't work on the 970 (G5) - one of my friends has been
waiting for QEMU for OS X for that reason ;)
- Chad
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] Inquiry, speed comparison on OS X, QEMU vs Virtual PC
2004-07-09 20:07 ` Natalia Portillo
2004-07-09 20:14 ` Chad Page
@ 2004-07-10 12:47 ` Pierre d'Herbemont
2004-07-10 13:08 ` J. Mayer
1 sibling, 1 reply; 22+ messages in thread
From: Pierre d'Herbemont @ 2004-07-10 12:47 UTC (permalink / raw)
To: qemu-devel
Which PowerPC Implementations? According to The PowerPC Architecture
Book, all the implementation 601,603,604,620 should include support for
the lwbrx and stwbrx instructions.
Pierre.
Le 9 juil. 04, à 22:07, Natalia Portillo a écrit :
> I think that including support for the PowerPC swapping instructions
> in QEMU
> will break compatibility with host PowerPCs before G3, so that
> instructions
> should be used in a run-time capability detection scheme.
>
>> -----Mensaje original-----
>> De: qemu-devel-bounces+iosglpgc=teleline.es@nongnu.org
>> [mailto:qemu-devel-bounces+iosglpgc=teleline.es@nongnu.org]
>> En nombre de Pierre d'Herbemont
>> Enviado el: viernes, 09 de julio de 2004 20:38
>> Para: qemu-devel@nongnu.org
>> Asunto: Re: [Qemu-devel] Inquiry, speed comparison on OS X,
>> QEMU vs Virtual PC
>>
>> I probably should add that the Mac OS X version that is
>> avalaible for download doesn't include support for the
>> PowerPC swapping instructions (little-endian storing and
>> loading instructions). Next release will.
>>
>> Pierre
>>
>> Le 6 juil. 04, à 02:29, dguinan@mac.com a écrit :
>>
>>> It was precisely because it has not yet been optimized that I was
>>> curious of first impressions. The fact that it has been
>> described as
>>> "somewhat" slower is encouraging. No one expects it to be
>> faster than
>>> VPC out the gate, but to be in the same ballpark is quite an
>>> achievement.
>>>
>>> -Daniel
>>>
>>>
>>> On Jul 5, 2004, at 5:23 PM, Leigh Dyer wrote:
>>>
>>>> On Mon, 2004-07-05 at 15:24 -0700, Daniel J.Guinan wrote:
>>>>> I'm curious, how does the speed compare to Virtual PC?
>>>>>
>>>>
>>>> Not terribly well yet - on my 1Ghz Tibook, it feels about the same
>>>> speed as on my 800Mhz PIII desktop PC at work, which is to
>> say that
>>>> the emulated system seems somewhere around
>>>> high-end-468/low-end-Pentium speed. However, it's important to
>>>> remember that Virtual PC:
>>>>
>>>> * has been around for ages, and has seen lots of development and
>>>> optimisation
>>>> * uses a hand-written and heavily optimised x86->PPC translator
>>>> * uses special PPC features like Altivec and little-endian mode to
>>>> speed things up
>>>> * uses the host system's MMU to accelerate memory access
>>>>
>>>> Qemu's still fast enough to be usable for a great many
>> things though,
>>>> so if you're debating whether or not to try it, by all
>> means download
>>>> it and give it a go.
>>>>
>>>> Thanks
>>>> Leigh
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Qemu-devel mailing list
>>>> Qemu-devel@nongnu.org
>>>> http://lists.nongnu.org/mailman/listinfo/qemu-devel
>>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Qemu-devel mailing list
>>> Qemu-devel@nongnu.org
>>> http://lists.nongnu.org/mailman/listinfo/qemu-devel
>>>
>>
>>
>>
>> _______________________________________________
>> Qemu-devel mailing list
>> Qemu-devel@nongnu.org
>> http://lists.nongnu.org/mailman/listinfo/qemu-devel
>
>
>
> _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] Inquiry, speed comparison on OS X, QEMU vs Virtual PC
2004-07-10 12:47 ` Pierre d'Herbemont
@ 2004-07-10 13:08 ` J. Mayer
2004-07-10 13:23 ` Pierre d'Herbemont
2004-08-12 10:56 ` David Woodhouse
0 siblings, 2 replies; 22+ messages in thread
From: J. Mayer @ 2004-07-10 13:08 UTC (permalink / raw)
To: qemu-devel
Le 9 juil. 04, à 22:07, Natalia Portillo a écrit :
>
> > I think that including support for the PowerPC swapping instructions
> > in QEMU
> > will break compatibility with host PowerPCs before G3, so that
> > instructions
> > should be used in a run-time capability detection scheme.
> >
On Sat, 2004-07-10 at 14:47, Pierre d'Herbemont wrote:
> Which PowerPC Implementations? According to The PowerPC Architecture
> Book, all the implementation 601,603,604,620 should include support for
> the lwbrx and stwbrx instructions.
I think all PPC include those instructions and gcc already uses them for
endian-swapping.
It seems to me that the feature which is discussed here is the presence
of IE bit in the machine state register.
I don't think using this bit could improve performances a lot. Because
there is only one bit to control the CPU and because most of the
problems are already solved using brx load and stores.
You would need to patch the kernel to use this bit (if it exists) and
need kernel calls when you ever want to change the access mode, which
seems not so great.
What could be more benefic would be a feature which exists in the PPC
405: one can define a memory area using big or little endian accesses.
But this seems to be very specific to the 405 and, once again, the win
would not be spectacular, imho.
--
J. Mayer <l_indien@magic.fr>
Never organized
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] Inquiry, speed comparison on OS X, QEMU vs Virtual PC
2004-07-09 19:37 ` Pierre d'Herbemont
2004-07-09 20:07 ` Natalia Portillo
@ 2004-07-10 13:14 ` Fabrice Bellard
2004-07-10 13:27 ` Pierre d'Herbemont
1 sibling, 1 reply; 22+ messages in thread
From: Fabrice Bellard @ 2004-07-10 13:14 UTC (permalink / raw)
To: qemu-devel
Pierre d'Herbemont wrote:
> I probably should add that the Mac OS X version that is avalaible for
> download doesn't include support for the PowerPC swapping instructions
> (little-endian storing and loading instructions). Next release will.
You mean that lwbrx is disabled for example ? I did not notice that in
your patch.
An important note: the PowerPC host register usage is currently disabled
in QEMU in system emulation mode (see dyngen-exec.c:88) because there
are issues left in exception support. Once it is enabled again, there
will be a noticable speed boost.
Fabrice.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] Inquiry, speed comparison on OS X, QEMU vs Virtual PC
2004-07-10 13:08 ` J. Mayer
@ 2004-07-10 13:23 ` Pierre d'Herbemont
2004-07-10 14:05 ` J. Mayer
2004-08-12 10:56 ` David Woodhouse
1 sibling, 1 reply; 22+ messages in thread
From: Pierre d'Herbemont @ 2004-07-10 13:23 UTC (permalink / raw)
To: qemu-devel
Le 10 juil. 04, à 15:08, J. Mayer a écrit :
> Le 9 juil. 04, à 22:07, Natalia Portillo a écrit :
>>
>>> I think that including support for the PowerPC swapping instructions
>>> in QEMU
>>> will break compatibility with host PowerPCs before G3, so that
>>> instructions
>>> should be used in a run-time capability detection scheme.
>>>
>
> On Sat, 2004-07-10 at 14:47, Pierre d'Herbemont wrote:
>> Which PowerPC Implementations? According to The PowerPC Architecture
>> Book, all the implementation 601,603,604,620 should include support
>> for
>> the lwbrx and stwbrx instructions.
>
> I think all PPC include those instructions and gcc already uses them
> for
> endian-swapping.
> It seems to me that the feature which is discussed here is the presence
> of IE bit in the machine state register.
you mean the LE bit? I first read the IE bit ;) Again according the
this same book the LE bit should exits in the previous implementation.
> I don't think using this bit could improve performances a lot. Because
> there is only one bit to control the CPU and because most of the
> problems are already solved using brx load and stores.
> You would need to patch the kernel to use this bit (if it exists) and
> need kernel calls when you ever want to change the access mode, which
> seems not so great.
ok, thanks... I wonder if it can help the darwine project in some ways:
having Wine compiled as LE/PowerPC, and running it in some kind of
virtualizer which would only swap sycall... Anyway I was speaking at
the begining of the thread of the *brx instructions which are not used
in the Mac OS X build.
> What could be more benefic would be a feature which exists in the PPC
> 405: one can define a memory area using big or little endian accesses.
> But this seems to be very specific to the 405 and, once again, the win
> would not be spectacular, imho.
In fact you can emulate this with mprotect-ing the region, and handle
the conversion at signal catch, but it shouldn't be really performant.
Pierre
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] Inquiry, speed comparison on OS X, QEMU vs Virtual PC
2004-07-10 13:14 ` Fabrice Bellard
@ 2004-07-10 13:27 ` Pierre d'Herbemont
0 siblings, 0 replies; 22+ messages in thread
From: Pierre d'Herbemont @ 2004-07-10 13:27 UTC (permalink / raw)
To: qemu-devel
Le 10 juil. 04, à 15:14, Fabrice Bellard a écrit :
> Pierre d'Herbemont wrote:
>> I probably should add that the Mac OS X version that is avalaible for
>> download doesn't include support for the PowerPC swapping
>> instructions (little-endian storing and loading instructions). Next
>> release will.
>
> You mean that lwbrx is disabled for example ? I did not notice that in
> your patch.
byteswap.h is not present on Mac OS X. So if bswap.h is where you
define the swapping functions, a fix like this is required:
Index: bswap.h
===================================================================
RCS file: /cvsroot/qemu/qemu/bswap.h,v
retrieving revision 1.3
diff -u -r1.3 bswap.h
--- bswap.h 21 Mar 2004 17:06:25 -0000 1.3
+++ bswap.h 10 Jul 2004 13:27:03 -0000
@@ -7,6 +7,11 @@
#ifdef HAVE_BYTESWAP_H
#include <byteswap.h>
+#elif defined(__APPLE__)
+#include <machine/byte_order.h>
+#define bswap_16(x) NXSwapShort(x)
+#define bswap_32(x) NXSwapInt(x)
+#define bswap_64(x) NXSwapLongLong(x)
#else
#define bswap_16(x) \
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] Inquiry, speed comparison on OS X, QEMU vs Virtual PC
2004-07-10 13:23 ` Pierre d'Herbemont
@ 2004-07-10 14:05 ` J. Mayer
0 siblings, 0 replies; 22+ messages in thread
From: J. Mayer @ 2004-07-10 14:05 UTC (permalink / raw)
To: qemu-devel
On Sat, 2004-07-10 at 15:23, Pierre d'Herbemont wrote:
> Le 10 juil. 04, à 15:08, J. Mayer a écrit :
> > On Sat, 2004-07-10 at 14:47, Pierre d'Herbemont wrote:
> >> Which PowerPC Implementations? According to The PowerPC Architecture
> >> Book, all the implementation 601,603,604,620 should include support
> >> for
> >> the lwbrx and stwbrx instructions.
> >
> > I think all PPC include those instructions and gcc already uses them
> > for
> > endian-swapping.
> > It seems to me that the feature which is discussed here is the presence
> > of IE bit in the machine state register.
>
> you mean the LE bit? I first read the IE bit ;) Again according the
> this same book the LE bit should exits in the previous implementation.
Yes, you're right, my confusion came from the ILE bit :-)
> > I don't think using this bit could improve performances a lot. Because
> > there is only one bit to control the CPU and because most of the
> > problems are already solved using brx load and stores.
> > You would need to patch the kernel to use this bit (if it exists) and
> > need kernel calls when you ever want to change the access mode, which
> > seems not so great.
>
> ok, thanks... I wonder if it can help the darwine project in some ways:
> having Wine compiled as LE/PowerPC, and running it in some kind of
> virtualizer which would only swap sycall... Anyway I was speaking at
> the begining of the thread of the *brx instructions which are not used
> in the Mac OS X build.
Oh, well, so you're right, using those instructions will boost the
emulation.
I just check: PPC601, 602, 603e and 604 user manuals claim those
instructions are available.
I doubt that some PPC don't implement those instr because they are very
useful for IO accesses: many devices and busses are designed for use
with Intel CPU/busses. So OSes need that feature !
> > What could be more benefic would be a feature which exists in the PPC
> > 405: one can define a memory area using big or little endian accesses.
> > But this seems to be very specific to the 405 and, once again, the win
> > would not be spectacular, imho.
>
> In fact you can emulate this with mprotect-ing the region, and handle
> the conversion at signal catch, but it shouldn't be really performant.
Yes, this could only be used if the memory controler can manage it by
itself. I'm sure emulating this feature would be less performant than
using *brx instructions.
The only drawback of *brx instructions is that only one addressing mode
is available, so it needs an extra register load to emulate an register
+ offset access.
--
J. Mayer <l_indien@magic.fr>
Never organized
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] Inquiry, speed comparison on OS X, QEMU vs Virtual PC
2004-07-10 13:08 ` J. Mayer
2004-07-10 13:23 ` Pierre d'Herbemont
@ 2004-08-12 10:56 ` David Woodhouse
2004-08-12 12:51 ` Pierre d'Herbemont
1 sibling, 1 reply; 22+ messages in thread
From: David Woodhouse @ 2004-08-12 10:56 UTC (permalink / raw)
To: qemu-devel
On Sat, 2004-07-10 at 15:08 +0200, J. Mayer wrote:
> Le 9 juil. 04, à 22:07, Natalia Portillo a écrit :
> >
> > > I think that including support for the PowerPC swapping instructions
> > > in QEMU
> > > will break compatibility with host PowerPCs before G3, so that
> > > instructions
> > > should be used in a run-time capability detection scheme.
> > >
>
> On Sat, 2004-07-10 at 14:47, Pierre d'Herbemont wrote:
> > Which PowerPC Implementations? According to The PowerPC Architecture
> > Book, all the implementation 601,603,604,620 should include support for
> > the lwbrx and stwbrx instructions.
>
> I think all PPC include those instructions and gcc already uses them for
> endian-swapping.
I definitely think gcc could do with __attribute__((littleendian)) :)
--
dwmw2
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] Inquiry, speed comparison on OS X, QEMU vs Virtual PC
2004-08-12 10:56 ` David Woodhouse
@ 2004-08-12 12:51 ` Pierre d'Herbemont
0 siblings, 0 replies; 22+ messages in thread
From: Pierre d'Herbemont @ 2004-08-12 12:51 UTC (permalink / raw)
To: qemu-devel
On 12 août 04, at 12:56, David Woodhouse wrote:
> On Sat, 2004-07-10 at 15:08 +0200, J. Mayer wrote:
>> Le 9 juil. 04, à 22:07, Natalia Portillo a écrit :
>>>
>>>> I think that including support for the PowerPC swapping instructions
>>>> in QEMU
>>>> will break compatibility with host PowerPCs before G3, so that
>>>> instructions
>>>> should be used in a run-time capability detection scheme.
>>>>
>>
>> On Sat, 2004-07-10 at 14:47, Pierre d'Herbemont wrote:
>>> Which PowerPC Implementations? According to The PowerPC Architecture
>>> Book, all the implementation 601,603,604,620 should include support
>>> for
>>> the lwbrx and stwbrx instructions.
>>
>> I think all PPC include those instructions and gcc already uses them
>> for
>> endian-swapping.
>
> I definitely think gcc could do with __attribute__((littleendian)) :)
>
http://gcc.gnu.org/ml/gcc/2004-07/msg01097.html
Pierre
^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2004-08-14 12:21 UTC | newest]
Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-02 22:56 [Qemu-devel] [Patch] Mac OS X Port Pierre d'Herbemont
2004-07-03 13:34 ` Jean-Michel POURE
2004-07-04 7:21 ` [Qemu-devel] " Christian Walther
2004-07-04 10:08 ` Pierre d'Herbemont
2004-07-04 10:37 ` Leigh Dyer
2004-07-05 1:22 ` [Qemu-devel] " Leigh Dyer
2004-07-05 22:24 ` [Qemu-devel] Inquiry, speed comparison on OS X, QEMU vs Virtual PC Daniel J. Guinan
2004-07-06 0:23 ` Leigh Dyer
2004-07-06 0:29 ` dguinan
2004-07-09 19:37 ` Pierre d'Herbemont
2004-07-09 20:07 ` Natalia Portillo
2004-07-09 20:14 ` Chad Page
2004-07-10 12:47 ` Pierre d'Herbemont
2004-07-10 13:08 ` J. Mayer
2004-07-10 13:23 ` Pierre d'Herbemont
2004-07-10 14:05 ` J. Mayer
2004-08-12 10:56 ` David Woodhouse
2004-08-12 12:51 ` Pierre d'Herbemont
2004-07-10 13:14 ` Fabrice Bellard
2004-07-10 13:27 ` Pierre d'Herbemont
-- strict thread matches above, loose matches on Subject: below --
2004-07-02 23:14 [Qemu-devel] re: [Patch] Mac OS X Port Fred Hope
2004-07-03 9:18 ` Raphaël Enrici
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).