qemu-system-ppc -prep initial port
Subsystems (2)
PATCH 1/1 qemu-system-ppc -prep initial port
Hi.
Some people have been asking about booting powerpc kernels on qemu.
Based on some comments about the existing rom for qemu, I looked at OpenHackWare enough to discern how qemu started its execution and how it gets its config.
I then proceeded to write a wrapper patch to use as the rom and then proceeded with a minimal platform (based on David Gibson's prep patch) to boot a ARCH=powerpc kernel.
These patches are being posted early to allow others to use them, they are not ready to be merged.
What works:
-prep (not default pmac, or core99 in later qemu) serial console in bootwrapper
serial console in kernel (console=ttyS0)
kernel must be loaded with --kernel=
vmlinux, or vmlinuz (gzip'ed elf).
zImage.qemu, zImage.initrd.qemu (with compiler assumptions)
-initrd (optional)
-append (optional)
ide-disk and cdrom appear to work
floppy is untested, and needs io port added.
What doesn't work:
boot from disk
vga (needs bios post, maybe pci)
pci (config cycles are not working, at least on 0.6.3)
How it works:
wrapper is compiled to run as rom
copied from rom to ram (linked address) supplies initial device tree blob (because dtb = NULL) reads nvram for memory size, kernel, initrd, command line
if invoked with device tree, then it only uses attached kernel
initrd either attached or from kernel
what you need:
2.6.23-rc3 + [ from powerpc.git for-2.6.24 branch ] commit 0602801c22ea1767cd0298b11da140bd5cb764d2 [POWERPC] bootwrapper: dt_xlate_range() bugfixes commit a73ac50c4787b1b28d5c94bb18c60352f5dd7d6f [POWERPC] bootwrapper: Add dt_is_compatible() commit 6e913c67b3eb93e2b8bc1dc0ff854f00a760f41b [POWERPC] bootwrapper: Add 16-bit I/O, sync(), eieio(), and barrier() commit dc4f397d6e385c4ea0fe9732df911a86f1a78c9a [POWERPC] bootwrapper: serial_console_init() fixes commit 2f1d4899321be87bc5f0c4ee0e62c9d9ced05f80 [POWERPC] bootwrapper: Move linker symbols into ops.h tell wrapper where initrd is, so it can move it if needed http://patchwork.ozlabs.org/linuxppc/patch?id=12168 tell code where vmlinuz is http://patchwork.ozlabs.org/linuxppc/patch?id=12178 build rom without vmlinuz http://patchwork.ozlabs.org/linuxppc/patch?id=12180 Subject: Move serial_dev_init to device_initcall() http://patchwork.ozlabs.org/linuxppc/patch?id=13097
To run:
build ppc_rom.bin using CONFIG_DEVICE_TREE=prep.dts with the dtc installed. This will be based on zBoot.qemu and will not have a kernel attached. Put this in a directory and invoke qemu-system-ppc -prep -L <dir-with-rom> -kernel <kernel> where kernel is either zImage.qemu or a (possibly compressed) vmlinux elf , add ide drives, -append, and -initrd as desired.
My tree has all patches in for-2.6.24 that touch arch/powerpc/boot plus ojn's patch plus my kexec series plus the prep patch, so there will be some rejects, especially to makefiles etc.
The first hunk to main.c to check loader_info for a command line after the fixup callback should be a seperate patch.
The boot/Makefile has a hack to avoid ovewriting qemu.dtb.
arch/powerpc/boot/main.c +5 -0
@@ -181,6 +181,11 @@ void start(void)if (platform_ops.fixups) platform_ops.fixups (); +/* check again, in case fixups told us about it */ +if ((loader_info.cmdline_len >0 ) && (cmdline[0 ] =='\0' )) +memmove (cmdline, loader_info.cmdline, +min (loader_info.cmdline_len,COMMAND_LINE_SIZE -1 )); +printf ("\n\rzImage starting: loaded at 0x%p (sp: 0x%p)\n\r" , _start,get_sp ());
arch/powerpc/boot/qemu.c new file +237 -0
237 lines not on this page · raw message
arch/powerpc/boot/Makefile +7 -3
@@ -49,7 +49,7 @@ src-wlib := string.S crt0.S stdio.c main cpm-serial.c src-plat := of.c cuboot-83xx.c cuboot-85xx.c holly.c crt0_kexec.S \ cuboot-ebony.c treeboot-ebony.c prpmc2800.c crt0_bml.S bml.c \ - ps3-head.S ps3-hvcall.S ps3.c prep.c \ + ps3-head.S ps3-hvcall.S ps3.c prep.c qemu.c \ treeboot-bamboo.c cuboot-8xx.c cuboot-pq2.c src-boot := $(src-wlib) $(src-plat) empty.c
@@ -144,6 +144,7 @@ image-$(CONFIG_PPC_HOLLY) += zImage.hol image-$(CONFIG_PPC_PRPMC2800) += zImage.prpmc2800 image-$(CONFIG_PPC_ISERIES) += zImage.iseries image-$(CONFIG_PPC_PREP) += zImage.prep +image-$(CONFIG_PPC_QEMU) += zImage.qemu zBoot.qemu image-$(CONFIG_DEFAULT_UIMAGE) += uImage image-$(CONFIG_KEXEC) += $(kexec-y) image-$(CONFIG_KEXEC) += $(patsubst zImage%,zBoot%,$(kexec-y))
@@ -201,6 +202,9 @@ $(obj)/zImage.iseries: vmlinux $(obj)/zBoot.%: $(wrapperbits) $(dts) $(call if_changed,wrap,$*,$(dts),,,$(obj)/empty.o) +# horrible hack to avoid overlapping calls to wrapper script clobbering dtb. +$(obj)/zImage.qemu: $(obj)/zBoot.qemu + $(obj)/zImage.ps3: vmlinux $(wrapper) $(wrapperbits) $(srctree)/$(src)/dts/ps3.dts $(STRIP) -s -R .comment $< -o vmlinux.strip $(call cmd,wrap,ps3,$(srctree)/$(src)/dts/ps3.dts,,)
@@ -234,8 +238,8 @@ install: $(CONFIGURE) $(addprefix $(obj) sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)" $< # anything not in $(targets) -clean-files += $(image-) $(initrd-) zImage zImage.initrd cuImage.* treeImage.* \ - otheros.bld $(kexec-) +clean-files += $(image-) $(initrd-) zImage zImage.initrd cuImage.* treeImage.* +clean-files += otheros.bld ppc_rom.bin $(kexec-) # clean up files cached by wrapper clean-kernel := vmlinux.strip vmlinux.bin empty.o.bin
arch/powerpc/boot/dts/qemu.dts new file +100 -0
100 lines not on this page · raw message
arch/powerpc/platforms/Kconfig +1 -0
@@ -47,6 +47,7 @@ source "arch/powerpc/platforms/chrp/Kcon source "arch/powerpc/platforms/52xx/Kconfig" source "arch/powerpc/platforms/powermac/Kconfig" source "arch/powerpc/platforms/prep/Kconfig" +source "arch/powerpc/platforms/qemu/Kconfig" source "arch/powerpc/platforms/maple/Kconfig" source "arch/powerpc/platforms/pasemi/Kconfig" source "arch/powerpc/platforms/celleb/Kconfig"
arch/powerpc/boot/wrapper +49 -0
53 lines not on this page · raw message
arch/powerpc/platforms/qemu/Kconfig new file +10 -0
@@ -0,0 +1,10 @@ +config PPC_QEMU + bool "PowerPC Reference Platform (PReP) based QEMU emulated systems" + depends on PPC_MULTIPLATFORM && PPC32 + select PPC_I8259 + select PPC_INDIRECT_PCI + select PPC_UDBG_16550 + select PPC_NATIVE + select WANT_DEVICE_TREE + default n +
arch/powerpc/platforms/qemu/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +obj-y += setup.o +obj-$(CONFIG_PCI) += pci.o
arch/powerpc/platforms/qemu/pci.c new file +133 -0
133 lines not on this page · raw message
arch/powerpc/platforms/qemu/setup.c new file +290 -0
290 lines not on this page · raw message
arch/powerpc/platforms/Makefile +1 -0
@@ -7,6 +7,7 @@ endif endif obj-$(CONFIG_PPC_CHRP) += chrp/ obj-$(CONFIG_PPC_PREP) += prep/ +obj-$(CONFIG_PPC_QEMU) += qemu/ #obj-$(CONFIG_4xx) += 4xx/ obj-$(CONFIG_44x) += 44x/ obj-$(CONFIG_PPC_MPC52xx) += 52xx/
arch/powerpc/boot/.gitignore +1 -0
@@ -17,6 +17,7 @@ infutil.h kernel-vmlinux.strip.c kernel-vmlinux.strip.gz mktree +ppc_rom.bin uImage cuImage.* zImage