From: Stefano Bonifazi <stefboombastic@gmail.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH] fix qruncom compilation problems
Date: Wed, 08 Dec 2010 22:43:54 +0100 [thread overview]
Message-ID: <4CFFFC1A.1090001@gmail.com> (raw)
In-Reply-To: <1291812551-12590-1-git-send-email-pbonzini@redhat.com>
On 12/08/2010 01:49 PM, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>
> ---
> I had this patch lying around but I don't think I ever got
> qruncom to work completely.
>
> Makefile.target | 3 ++
> tests/Makefile | 7 ++--
> tests/qruncom.c | 93 +++++++++++++++++++++++++++++++++++-------------------
> 3 files changed, 67 insertions(+), 36 deletions(-)
>
> diff --git a/Makefile.target b/Makefile.target
> index 5784844..4ac8f6f 100644
> --- a/Makefile.target
> +++ b/Makefile.target
> @@ -339,6 +339,9 @@ obj-y += $(addprefix ../libdis/, $(libdis-y))
> obj-y += $(libobj-y)
> obj-y += $(addprefix $(HWDIR)/, $(hw-obj-y))
>
> +else # !CONFIG_SOFTMMU
> +libqemu.a: $(addprefix ../, $(common-obj-y)) $(libobj-y) $(addprefix ../libdis/, $(libdis-y))
> + ar rc $@ $^
> endif # CONFIG_SOFTMMU
>
> obj-y += $(addprefix ../, $(trace-obj-y))
> diff --git a/tests/Makefile b/tests/Makefile
> index e43ec70..6dbeb6f 100644
> --- a/tests/Makefile
> +++ b/tests/Makefile
> @@ -116,9 +116,10 @@ speed: sha1 sha1-i386
>
> # broken test
> # NOTE: -fomit-frame-pointer is currently needed : this is a bug in libqemu
> -qruncom: qruncom.c ../ioport-user.c ../i386-user/libqemu.a
> - $(CC) $(CFLAGS) -fomit-frame-pointer $(LDFLAGS) -I../target-i386 -I.. -I../i386-user -I../fpu \
> - -o $@ $(filter %.c, $^) -L../i386-user -lqemu -lm
> +qruncom: qruncom.c
> + #$(MAKE) -C ../i386-linux-user libqemu.a
> + $(CC) $(CFLAGS) -fomit-frame-pointer $(LDFLAGS) -I../target-i386 -I.. -I../linux-user -I../i386-linux-user -I../fpu \
> + -o $@ $(filter %.c, $^) -L../i386-linux-user -lqemu -lm
>
> # arm test
> hello-arm: hello-arm.o
> diff --git a/tests/qruncom.c b/tests/qruncom.c
> index 079f7a2..66fc223 100644
> --- a/tests/qruncom.c
> +++ b/tests/qruncom.c
> @@ -12,10 +12,68 @@
> #include<signal.h>
> #include<malloc.h>
>
> +#define NEED_CPU_H 1
> #include "cpu.h"
>
> //#define SIGTEST
>
> +unsigned long guest_base = 0;
> +int have_guest_base = 0;
> +int singlestep = 0;
> +unsigned long last_brk = 0;
> +
> +void cpu_outb(uint32_t addr, uint8_t val)
> +{
> + fprintf(stderr, "outb: port=0x%04"PRIx32", data=%02"PRIx8"\n",
> + addr, val);
> +}
> +
> +void cpu_outw(uint32_t addr, uint16_t val)
> +{
> + fprintf(stderr, "outw: port=0x%04"PRIx32", data=%04"PRIx16"\n",
> + addr, val);
> +}
> +
> +void cpu_outl(uint32_t addr, uint32_t val)
> +{
> + fprintf(stderr, "outl: port=0x%04"PRIx32", data=%08"PRIx32"\n",
> + addr, val);
> +}
> +
> +uint8_t cpu_inb(uint32_t addr)
> +{
> + fprintf(stderr, "inb: port=0x%04"PRIx32"\n", addr);
> + return 0;
> +}
> +
> +uint16_t cpu_inw(uint32_t addr)
> +{
> + fprintf(stderr, "inw: port=0x%04"PRIx32"\n", addr);
> + return 0;
> +}
> +
> +uint32_t cpu_inl(uint32_t addr)
> +{
> + fprintf(stderr, "inl: port=0x%04"PRIx32"\n", addr);
> + return 0;
> +}
> +
> +void cpu_list_lock(void)
> +{
> +}
> +
> +void cpu_list_unlock(void)
> +{
> +}
> +
> +void mmap_lock(void)
> +{
> +}
> +
> +void mmap_unlock(void)
> +{
> +}
> +
> int cpu_get_pic_interrupt(CPUState *env)
> {
> return -1;
> @@ -44,26 +102,6 @@ static void set_idt(int n, unsigned int dpl)
> set_gate(idt_table + n, 0, dpl, 0, 0);
> }
>
> -void qemu_free(void *ptr)
> -{
> - free(ptr);
> -}
> -
> -void *qemu_malloc(size_t size)
> -{
> - return malloc(size);
> -}
> -
> -void *qemu_mallocz(size_t size)
> -{
> - void *ptr;
> - ptr = qemu_malloc(size);
> - if (!ptr)
> - return NULL;
> - memset(ptr, 0, size);
> - return ptr;
> -}
> -
> void *qemu_vmalloc(size_t size)
> {
> return memalign(4096, size);
> @@ -74,17 +112,6 @@ void qemu_vfree(void *ptr)
> free(ptr);
> }
>
> -void qemu_printf(const char *fmt, ...)
> -{
> - va_list ap;
> - va_start(ap, fmt);
> - vprintf(fmt, ap);
> - va_end(ap);
> -}
> -
> -/* XXX: this is a bug in helper2.c */
> -int errno;
> -
> /**********************************************/
>
> #define COM_BASE_ADDR 0x10100
> @@ -99,7 +126,7 @@ static void usage(void)
>
> static inline uint8_t *seg_to_linear(unsigned int seg, unsigned int reg)
> {
> - return (uint8_t *)((seg<< 4) + (reg& 0xffff));
> + return (uint8_t *)(uintptr_t) ((seg<< 4) + (reg& 0xffff));
> }
>
> static inline void pushw(CPUState *env, int val)
> @@ -241,7 +268,7 @@ int main(int argc, char **argv)
> case EXCP0D_GPF:
> {
> int int_num, ah;
> - int_num = *(uint8_t *)(env->segs[R_CS].base + env->eip + 1);
> + int_num = *(uint8_t *)(uintptr_t) (env->segs[R_CS].base + env->eip + 1);
> if (int_num != 0x21)
> goto unknown_int;
> ah = (env->regs[R_EAX]>> 8)& 0xff;
Hi!
Thank you for your help!
I've linked qemu-malloc.o and cutils.o together with qruncom.c and I
managed to succesfully make it!
here the make line:
> #$(MAKE) -C ../i386-linux-user libqemu.a
> $(CC) $(CFLAGS) -fomit-frame-pointer $(LDFLAGS) -I../target-i386
> -I.. -I../linux-user -I../i386-linux-user -I../fpu \
> -o $@ ../qemu-malloc.o ../cutils.o $(filter %.c, $^)
> -L../i386-linux-user -lqemu -lm
Anyway running it with a com file as argument gave the error:
> mmap: Operation not permitted
I think the problem is with "MAP_FIXED" parameter in mmap
(http://opengroup.org/onlinepubs/007908799/xsh/mmap.html) having chosen
0x00000000 as starting address.. but it is pretty difficult for me atm
to understand it, I've never used this function before and I am a
beginner in these topics
Removing that parameter mmap succeeds, but then I get "segmentation
fault" in cpu_init
Any idea?
Thank you in advance!
Stefano B.
next prev parent reply other threads:[~2010-12-08 21:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-08 11:39 [Qemu-devel] Compiling tests/qruncom.c Stefano Bonifazi
2010-12-08 12:49 ` [Qemu-devel] [PATCH] fix qruncom compilation problems Paolo Bonzini
2010-12-08 21:43 ` Stefano Bonifazi [this message]
2010-12-09 7:16 ` [Qemu-devel] " Paolo Bonzini
2010-12-09 17:29 ` Stefano Bonifazi
2010-12-10 8:53 ` Paolo Bonzini
2010-12-10 21:43 ` Stefano Bonifazi
[not found] ` <4D02A030.6080400@redhat.com>
2010-12-11 14:42 ` [Qemu-devel] " Stefano Bonifazi
2010-12-13 8:27 ` [Qemu-devel] " Paolo Bonzini
2010-12-09 3:32 ` [Qemu-devel] " Isaku Yamahata
2010-12-09 7:16 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4CFFFC1A.1090001@gmail.com \
--to=stefboombastic@gmail.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.