mirror of
https://gitlab.com/qemu-project/openbios.git
synced 2024-02-13 08:34:06 +08:00
Use firmware configuration instead of NVRAM (initial patch by Aurelien Jarno)
Use firmware configuration device for boot device, kernel, initrd and kernel command line parameters on PPC, Sparc32 and Sparc64. git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@479 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
@@ -22,6 +22,8 @@
|
||||
#include "libc/vsprintf.h"
|
||||
#include "kernel.h"
|
||||
#include "ofmem.h"
|
||||
#define NO_QEMU_PROTOS
|
||||
#include "openbios/fw_cfg.h"
|
||||
|
||||
//#define DEBUG_ELF
|
||||
|
||||
@@ -319,24 +321,6 @@ try_bootinfo(const char *path, const char *param)
|
||||
close_io( fd );
|
||||
}
|
||||
|
||||
static uint8_t nvram_read(uint16_t offset)
|
||||
{
|
||||
outb(offset & 0xff, NVRAM_ADDR_LO);
|
||||
outb(offset >> 8, NVRAM_ADDR_HI);
|
||||
return inb(NVRAM_DATA);
|
||||
}
|
||||
|
||||
static uint32_t nvram_read_be32(uint16_t offset)
|
||||
{
|
||||
uint32_t ret;
|
||||
|
||||
ret = nvram_read(offset) << 24;
|
||||
ret |= nvram_read(offset + 1) << 16;
|
||||
ret |= nvram_read(offset + 2) << 8;
|
||||
ret |= nvram_read(offset + 3);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define QUIK_SECOND_BASEADDR 0x3e0000
|
||||
#define QUIK_FIRST_BASEADDR 0x3f4000
|
||||
#define QUIK_SECOND_SIZE (QUIK_FIRST_BASEADDR - QUIK_SECOND_BASEADDR)
|
||||
@@ -446,8 +430,7 @@ yaboot_startup( void )
|
||||
try_path(path, param);
|
||||
try_bootinfo(path, param);
|
||||
} else {
|
||||
char boot_device = nvram_read(0x34);
|
||||
|
||||
uint16_t boot_device = fw_cfg_read_i16(FW_CFG_BOOT_DEVICE);
|
||||
switch (boot_device) {
|
||||
case 'c':
|
||||
path = strdup("hd:0");
|
||||
@@ -474,21 +457,22 @@ static void check_preloaded_kernel(void)
|
||||
{
|
||||
unsigned long kernel_image, kernel_size;
|
||||
unsigned long initrd_image, initrd_size;
|
||||
unsigned long cmdline, cmdline_len;
|
||||
const char * kernel_cmdline;
|
||||
|
||||
kernel_size = nvram_read_be32(0x3c);
|
||||
kernel_size = fw_cfg_read_i32(FW_CFG_KERNEL_SIZE);
|
||||
if (kernel_size) {
|
||||
kernel_image = nvram_read_be32(0x38);
|
||||
cmdline = nvram_read_be32(0x40);
|
||||
cmdline_len = nvram_read_be32(0x44);
|
||||
initrd_image = nvram_read_be32(0x48);
|
||||
initrd_size = nvram_read_be32(0x4c);
|
||||
kernel_image = fw_cfg_read_i32(FW_CFG_KERNEL_ADDR);
|
||||
kernel_cmdline = (const char *) 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 (cmdline_len > 0) {
|
||||
phandle_t ph = find_dev("/chosen");
|
||||
set_property(ph, "bootargs", strdup((char *)cmdline), cmdline_len + 1);
|
||||
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);
|
||||
}
|
||||
@@ -501,7 +485,8 @@ static void check_preloaded_kernel(void)
|
||||
void
|
||||
boot( void )
|
||||
{
|
||||
char boot_device = nvram_read(0x34);
|
||||
uint16_t boot_device = fw_cfg_read_i16(FW_CFG_BOOT_DEVICE);
|
||||
|
||||
fword("update-chosen");
|
||||
if (boot_device == 'm') {
|
||||
check_preloaded_kernel();
|
||||
|
||||
@@ -15,9 +15,6 @@
|
||||
#include "openbios.h"
|
||||
#include "openbios/pci.h"
|
||||
#include "asm/pci.h"
|
||||
#include "libc/byteorder.h"
|
||||
#define cpu_to_be16(x) __cpu_to_be16(x)
|
||||
#include "openbios/firmware_abi.h"
|
||||
#include "boot.h"
|
||||
#include "../../drivers/timer.h" // XXX
|
||||
#define NO_QEMU_PROTOS
|
||||
@@ -42,11 +39,9 @@ static ucell *memory;
|
||||
#define NVRAM_SIZE 0x2000
|
||||
#define NVRAM_IDPROM 0x1fd8
|
||||
#define NVRAM_IDPROM_SIZE 32
|
||||
#define NVRAM_OB_START (sizeof(ohwcfg_v3_t) + sizeof(struct sparc_arch_cfg))
|
||||
#define NVRAM_OB_START (0)
|
||||
#define NVRAM_OB_SIZE ((0x1fd0 - NVRAM_OB_START) & ~15)
|
||||
|
||||
static ohwcfg_v3_t nv_info;
|
||||
|
||||
#define OBIO_CMDLINE_MAX 256
|
||||
static char obio_cmdline[OBIO_CMDLINE_MAX];
|
||||
|
||||
@@ -275,7 +270,7 @@ static uint8_t qemu_uuid[16];
|
||||
|
||||
void arch_nvram_get(char *data)
|
||||
{
|
||||
uint32_t size;
|
||||
uint32_t size = 0;
|
||||
const struct cpudef *cpu;
|
||||
const char *bootpath;
|
||||
char buf[256];
|
||||
@@ -284,8 +279,7 @@ void arch_nvram_get(char *data)
|
||||
uint32_t clock_frequency;
|
||||
uint16_t machine_id;
|
||||
const char *stdin_path, *stdout_path;
|
||||
|
||||
nvram_read(0, (char *)&nv_info, sizeof(ohwcfg_v3_t));
|
||||
const char *kernel_cmdline;
|
||||
|
||||
fw_cfg_init();
|
||||
|
||||
@@ -304,16 +298,20 @@ void arch_nvram_get(char *data)
|
||||
for(;;);
|
||||
}
|
||||
|
||||
kernel_image = nv_info.kernel_image;
|
||||
kernel_size = nv_info.kernel_size;
|
||||
size = nv_info.cmdline_size;
|
||||
if (size > OBIO_CMDLINE_MAX - 1)
|
||||
size = OBIO_CMDLINE_MAX - 1;
|
||||
memcpy(&obio_cmdline, (void *)(long)nv_info.cmdline, size);
|
||||
kernel_size = fw_cfg_read_i32(FW_CFG_KERNEL_SIZE);
|
||||
if (kernel_size)
|
||||
kernel_image = fw_cfg_read_i64(FW_CFG_KERNEL_ADDR);
|
||||
kernel_cmdline = (const char *) fw_cfg_read_i64(FW_CFG_KERNEL_CMDLINE);
|
||||
if (kernel_cmdline) {
|
||||
size = strlen(kernel_cmdline);
|
||||
if (size > OBIO_CMDLINE_MAX - 1)
|
||||
size = OBIO_CMDLINE_MAX - 1;
|
||||
memcpy(&obio_cmdline, kernel_cmdline, size);
|
||||
}
|
||||
obio_cmdline[size] = '\0';
|
||||
qemu_cmdline = (uint64_t)obio_cmdline;
|
||||
cmdline_size = size;
|
||||
boot_device = nv_info.boot_devices[0];
|
||||
boot_device = fw_cfg_read_i16(FW_CFG_BOOT_DEVICE);
|
||||
|
||||
if (kernel_size)
|
||||
printk("kernel addr %llx size %llx\n", kernel_image, kernel_size);
|
||||
@@ -372,7 +370,7 @@ void arch_nvram_get(char *data)
|
||||
push_str("/chosen");
|
||||
fword("find-device");
|
||||
|
||||
if (nv_info.boot_devices[0] == 'c')
|
||||
if (boot_device == 'c')
|
||||
bootpath = "disk:a";
|
||||
else
|
||||
bootpath = "cdrom:a";
|
||||
|
||||
Reference in New Issue
Block a user