2 * Creation Date: <2002/10/02 22:24:24 samuel>
3 * Time-stamp: <2004/03/27 01:57:55 samuel>
9 * Copyright (C) 2002, 2003, 2004 Samuel Rydh (samuel@ibrium.se)
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation
18 #include "libopenbios/bindings.h"
19 #include "libopenbios/elf_load.h"
20 #include "arch/common/nvram.h"
21 #include "packages/nvram.h"
22 #include "libc/diskio.h"
23 #include "libc/vsprintf.h"
25 #include "drivers/drivers.h"
26 #include "libopenbios/ofmem.h"
27 #define NO_QEMU_PROTOS
28 #include "arch/common/fw_cfg.h"
33 #define SUBSYS_DPRINTF(subsys, fmt, args...) \
34 do { printk("%s - %s: " fmt, subsys, __func__ , ##args); } while (0)
36 #define SUBSYS_DPRINTF(subsys, fmt, args...) \
39 #define CHRP_DPRINTF(fmt, args...) SUBSYS_DPRINTF("CHRP", fmt, ##args)
40 #define ELF_DPRINTF(fmt, args...) SUBSYS_DPRINTF("ELF", fmt, ##args)
41 #define NEWWORLD_DPRINTF(fmt, args...) SUBSYS_DPRINTF("NEWWORLD", fmt, ##args)
43 static void check_preloaded_kernel(void)
45 unsigned long kernel_image, kernel_size;
46 unsigned long initrd_image, initrd_size;
47 const char * kernel_cmdline;
49 kernel_size = fw_cfg_read_i32(FW_CFG_KERNEL_SIZE);
51 kernel_image = fw_cfg_read_i32(FW_CFG_KERNEL_ADDR);
52 kernel_cmdline = (const char *)(uintptr_t) fw_cfg_read_i32(FW_CFG_KERNEL_CMDLINE);
53 initrd_image = fw_cfg_read_i32(FW_CFG_INITRD_ADDR);
54 initrd_size = fw_cfg_read_i32(FW_CFG_INITRD_SIZE);
55 printk("[ppc] Kernel already loaded (0x%8.8lx + 0x%8.8lx) "
56 "(initrd 0x%8.8lx + 0x%8.8lx)\n",
57 kernel_image, kernel_size, initrd_image, initrd_size);
60 printk("[ppc] Kernel command line: %s\n", kernel_cmdline);
61 ph = find_dev("/chosen");
62 set_property(ph, "bootargs", strdup(kernel_cmdline), strlen(kernel_cmdline) + 1);
64 call_elf(initrd_image, initrd_size, kernel_image);
68 /************************************************************************/
70 /************************************************************************/
75 uint16_t boot_device = fw_cfg_read_i16(FW_CFG_BOOT_DEVICE);
77 fword("update-chosen");
78 if (boot_device == 'm') {
79 check_preloaded_kernel();