Skip to contentSkip to conversation

Arm system emulation

Qemu-devel Paul Brook 2 participants 3 messages Nov 22, 2005 – Nov 25, 2005 Kbuild

lore
Share & tools
lore

Paul Brook

author
#0 lore raw

The attached patch implements Arm system emulation. Also attached is the prerequisite PS/2 emulation separation patch.

The emulated hardware is based on an Arm Integrator/CP board with an arm1026ej-s cpu. This is an embedded development board that supports a variety of core modules and peripherals. Currently timers, interrupt controller and UART(x2) are implemented. Network should follow shortly.

In the medium term I plan to extend this to also emulate an Integrator/AP board. This is similar but includes which includes a PCI bus, so existing PCI peripherals can be used.

Longer term these boards can be used as a base for future ARM cpus, including SMP support.

Generally speaking Arm boards don't have a BIOS.The kernel/bootloader is loaded directly from flash. The -kernel option can be used to load linux kernels (and probably any other image).

For anyone wanting to try this, there's a kernel image and small initrd filesystem at:
https://nowt.dyndns.org/integratorcp.zImage
https://nowt.dyndns.org/arm_root.img

There's nothing special about these. Just a vanilla 2.6.14 kernel configured with a serial console and busybox+bash from a Debian arm-linux install.

Paul

Index: Makefile.target
===================================================================
RCS file: /cvsroot/qemu/qemu/Makefile.target,v
retrieving revision 1.86

Makefile.target +3 -3
diff -u -p -r1.86 Makefile.target
@@ -298,13 +298,13 @@ VL_OBJS+= usb.o usb-uhci.o usb-linux.o u
 
 ifeq ($(TARGET_BASE_ARCH), i386)
 # Hardware support
-VL_OBJS+= ide.o ne2000.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
+VL_OBJS+= ide.o ne2000.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
 VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o
 VL_OBJS+= cirrus_vga.o mixeng.o apic.o parallel.o
 DEFINES += -DHAS_AUDIO
 endif
 ifeq ($(TARGET_BASE_ARCH), ppc)
-VL_OBJS+= ppc.o ide.o ne2000.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
+VL_OBJS+= ppc.o ide.o ne2000.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
 VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o
 VL_OBJS+= ppc_prep.o ppc_chrp.o cuda.o adb.o openpic.o heathrow_pic.o mixeng.o
 DEFINES += -DHAS_AUDIO
@@ -315,7 +315,7 @@ VL_OBJS+= mips_r4k.o dma.o vga.o serial.
 endif
 ifeq ($(TARGET_BASE_ARCH), sparc)
 ifeq ($(TARGET_ARCH), sparc64)
-VL_OBJS+= sun4u.o ide.o ne2000.o pckbd.o vga.o
+VL_OBJS+= sun4u.o ide.o ne2000.o pckbd.o ps2.o vga.o
 VL_OBJS+= fdc.o mc146818rtc.o serial.o m48t59.o
 VL_OBJS+= cirrus_vga.o parallel.o
 VL_OBJS+= magic-load.o

Index: vl.h
===================================================================
RCS file: /cvsroot/qemu/qemu/vl.h,v
retrieving revision 1.91

vl.h +8 -0
diff -u -p -r1.91 vl.h
@@ -916,6 +916,14 @@ void do_usb_add(const char *devname);
 void do_usb_del(const char *devname);
 void usb_info(void);
 
+/* ps2.c */
+void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg);
+void *ps2_mouse_init(void (*update_irq)(void *, int), void *update_arg);
+void ps2_write_mouse(void *, int val);
+void ps2_write_keyboard(void *, int val);
+uint32_t ps2_read_data(void *);
+void ps2_queue(void *, int b);
+
 #endif /* defined(QEMU_TOOL) */
 
 /* monitor.c */

Index: hw/pckbd.c
===================================================================
RCS file: /cvsroot/qemu/qemu/hw/pckbd.c,v
retrieving revision 1.11

pckbd.c +42 -365

513 lines not on this page · raw message

Index: hw/ps2.c
===================================================================
RCS file: hw/ps2.c

ps2.c new file +512 -0

512 lines not on this page · raw message

#1 lore raw
Quoted 1 line · Paul Brook

The attached patch implements Arm system emulation.

Cool :-)

Quoted 2 lines

There's nothing special about these. Just a vanilla 2.6.14 kernel configured with a serial console and busybox+bash from a Debian arm-linux install.

I checked out qemu from CVS, applied your patches and I can confirm that after some tweaks with configuring qemu and getting the right command line arguments I can indeed boot the sample kernel and image. I also compiled linux 2.6.14.3 with a .config from the /proc/config.gz of the sample kernel and the compiled kernel boots also fine.

While trying out gdb I ran into the same issue as reported by Johannes Schindelin that cpu_single_env is cleared upon exiting cpu_exec(), but e.g. breakpoint insertion ends up into tb_invalidate_phys_page_range() which seems to assume that cpu_single_env is valid. Just commenting out the clearing of cpu_single_env makes kernel debugging possible, but I suppose that's not the right fix.

It seems that the sysemu is busylooping - is that currently to be expected or do I have something misconfigured?

author
#2 lore raw
Quoted 2 lines

It seems that the sysemu is busylooping - is that currently to be expected or do I have something misconfigured?

Yes. The Wait For Interrupt instruction (aka halt/suspend) is currently implemented as a Nop. I have a followup patch to fix that.

Paul