From 1beaaac8fa81996c963b321593f087955148f6dc Mon Sep 17 00:00:00 2001 From: Blue Swirl Date: Thu, 25 Dec 2008 10:38:40 +0000 Subject: [PATCH] Allow yaboot to read files from cdrom (Laurent Vivier) git-svn-id: svn://coreboot.org/openbios/openbios-devel@325 f158a5a8-5612-0410-a976-696ce0be7e32 --- arch/ppc/qemu/main.c | 22 ++++++++++++++-------- modules/filesystems.c | 7 +++++++ modules/mac-parts.c | 2 +- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/arch/ppc/qemu/main.c b/arch/ppc/qemu/main.c index f778e55..facf7d0 100644 --- a/arch/ppc/qemu/main.c +++ b/arch/ppc/qemu/main.c @@ -61,10 +61,12 @@ load_elf_rom( ulong *elf_entry, int fd ) /* the ELF-image (usually) starts at offset 0x4000 */ if( (elf_offs=find_elf(fd)) < 0 ) { ELF_DPRINTF("----> %s is not an ELF image\n", get_file_path(fd)); - exit(1); + return -1; + } + if( !(phdr=elf_readhdrs(fd, elf_offs, &ehdr)) ) { + ELF_DPRINTF("elf_readhdrs failed\n"); + return -1; } - if( !(phdr=elf_readhdrs(fd, elf_offs, &ehdr)) ) - fatal_error("elf_readhdrs failed\n"); *elf_entry = ehdr.e_entry; @@ -89,8 +91,10 @@ load_elf_rom( ulong *elf_entry, int fd ) fatal_error("Claim failed!\n"); addr = (char*)phdr[i].p_vaddr; - if( read_io(fd, addr, s) != s ) - fatal_error("read failed\n"); + if( read_io(fd, addr, s) != s ) { + ELF_DPRINTF("read failed\n"); + return -1; + } flush_icache_range( addr, addr+s ); @@ -116,14 +120,16 @@ static void try_path(const char *path, const char *param) { ulong elf_entry; - int fd; + int fd, ret; ELF_DPRINTF("Trying %s %s\n", path, param); if ((fd = open_io(path)) == -1) { ELF_DPRINTF("Can't open %s\n", path); return; } - (void) load_elf_rom( &elf_entry, fd ); + ret = load_elf_rom( &elf_entry, fd ); + if (ret < 0) + return; close_io( fd ); encode_bootpath( path, param ); @@ -258,8 +264,8 @@ yaboot_startup( void ) POP(); param = pop_fstr_copy(); } - try_bootinfo(path); try_path(path, param); + try_bootinfo(path); } else { char boot_device = nvram_read(0x34); diff --git a/modules/filesystems.c b/modules/filesystems.c index 5a4d9fe..726bcb9 100644 --- a/modules/filesystems.c +++ b/modules/filesystems.c @@ -255,6 +255,12 @@ files_probe( files_info_t *dummy ) PUSH( ret ); } +static void +files_block_size( files_info_t *dummy ) +{ + PUSH(512); +} + static void files_initializer( files_info_t *dummy ) { @@ -269,6 +275,7 @@ NODE_METHODS( files ) = { { "write", files_write }, { "seek", files_seek }, { "tell", files_tell }, + { "block-size", files_block_size }, /* special */ { "reopen", files_reopen }, diff --git a/modules/mac-parts.c b/modules/mac-parts.c index 1eb93dd..96464a4 100644 --- a/modules/mac-parts.c +++ b/modules/mac-parts.c @@ -55,7 +55,7 @@ macparts_open( macparts_info_t *di ) free( str ); } if( parnum < 0 ) - parnum = 1; + parnum = 0; DPRINTF("macparts_open %d\n", parnum); SEEK( 0 );