X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=qemu%2Froms%2Fopenbios%2Farch%2Fppc%2Fqemu%2Fmain.c;fp=qemu%2Froms%2Fopenbios%2Farch%2Fppc%2Fqemu%2Fmain.c;h=44b16666bd36c8d330067398209e2911a89ef7bf;hb=e44e3482bdb4d0ebde2d8b41830ac2cdb07948fb;hp=0000000000000000000000000000000000000000;hpb=9ca8dbcc65cfc63d6f5ef3312a33184e1d726e00;p=kvmfornfv.git diff --git a/qemu/roms/openbios/arch/ppc/qemu/main.c b/qemu/roms/openbios/arch/ppc/qemu/main.c new file mode 100644 index 000000000..44b16666b --- /dev/null +++ b/qemu/roms/openbios/arch/ppc/qemu/main.c @@ -0,0 +1,85 @@ +/* + * Creation Date: <2002/10/02 22:24:24 samuel> + * Time-stamp: <2004/03/27 01:57:55 samuel> + * + * + * + * + * + * Copyright (C) 2002, 2003, 2004 Samuel Rydh (samuel@ibrium.se) + * + * 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 + * + */ + +#include "config.h" +#include "libopenbios/bindings.h" +#include "libopenbios/elf_load.h" +#include "arch/common/nvram.h" +#include "packages/nvram.h" +#include "libc/diskio.h" +#include "libc/vsprintf.h" +#include "kernel.h" +#include "drivers/drivers.h" +#include "libopenbios/ofmem.h" +#define NO_QEMU_PROTOS +#include "arch/common/fw_cfg.h" + +//#define DEBUG_QEMU + +#ifdef DEBUG_QEMU +#define SUBSYS_DPRINTF(subsys, fmt, args...) \ + do { printk("%s - %s: " fmt, subsys, __func__ , ##args); } while (0) +#else +#define SUBSYS_DPRINTF(subsys, fmt, args...) \ + do { } while (0) +#endif +#define CHRP_DPRINTF(fmt, args...) SUBSYS_DPRINTF("CHRP", fmt, ##args) +#define ELF_DPRINTF(fmt, args...) SUBSYS_DPRINTF("ELF", fmt, ##args) +#define NEWWORLD_DPRINTF(fmt, args...) SUBSYS_DPRINTF("NEWWORLD", fmt, ##args) + +static void check_preloaded_kernel(void) +{ + unsigned long kernel_image, kernel_size; + unsigned long initrd_image, initrd_size; + const char * kernel_cmdline; + + kernel_size = fw_cfg_read_i32(FW_CFG_KERNEL_SIZE); + if (kernel_size) { + kernel_image = fw_cfg_read_i32(FW_CFG_KERNEL_ADDR); + kernel_cmdline = (const char *)(uintptr_t) fw_cfg_read_i32(FW_CFG_KERNEL_CMDLINE); + initrd_image = fw_cfg_read_i32(FW_CFG_INITRD_ADDR); + initrd_size = fw_cfg_read_i32(FW_CFG_INITRD_SIZE); + printk("[ppc] Kernel already loaded (0x%8.8lx + 0x%8.8lx) " + "(initrd 0x%8.8lx + 0x%8.8lx)\n", + kernel_image, kernel_size, initrd_image, initrd_size); + if (kernel_cmdline) { + phandle_t ph; + printk("[ppc] Kernel command line: %s\n", kernel_cmdline); + ph = find_dev("/chosen"); + set_property(ph, "bootargs", strdup(kernel_cmdline), strlen(kernel_cmdline) + 1); + } + call_elf(initrd_image, initrd_size, kernel_image); + } +} + +/************************************************************************/ +/* entry */ +/************************************************************************/ + +void +boot( void ) +{ + uint16_t boot_device = fw_cfg_read_i16(FW_CFG_BOOT_DEVICE); + + fword("update-chosen"); + if (boot_device == 'm') { + check_preloaded_kernel(); + } + + if (is_apple()) { + update_nvram(); + } +}