j
: Next unread message k
: Previous unread message j a
: Jump to all threads
j l
: Jump to MailingList overview
Author: laurent Date: 2009-01-11 01:19:02 +0100 (Sun, 11 Jan 2009) New Revision: 385
Modified: openbios-devel/arch/ppc/qemu/main.c Log: Add quik support (oldworld bootloader).
Load two first sectors of the partition and check quik signature ('QUIK'). If it is quik, execute it to boot.
Currently partition and parameter are hardcoded to "hd:2" and "Linux".
Modified: openbios-devel/arch/ppc/qemu/main.c =================================================================== --- openbios-devel/arch/ppc/qemu/main.c 2009-01-11 00:01:40 UTC (rev 384) +++ openbios-devel/arch/ppc/qemu/main.c 2009-01-11 00:19:02 UTC (rev 385) @@ -234,7 +234,78 @@ return ret; }
+#define QUIK_SECOND_BASEADDR 0x3e0000 +#define QUIK_FIRST_BASEADDR 0x3f4000 +#define QUIK_SECOND_SIZE (QUIK_FIRST_BASEADDR - QUIK_SECOND_BASEADDR) +#define QUIK_FIRST_INFO_OFF 0x2c8 + +struct first_info { + char quik_vers[8]; + int nblocks; + int blocksize; + unsigned second_base; + int conf_part; + char conf_file[32]; + unsigned blknos[64]; +}; + + static void +quik_startup( void ) +{ + int fd; + int len; + const char *path = "hd:2"; + union { + char buffer[1024]; + int first_word; + struct { + char pad[QUIK_FIRST_INFO_OFF]; + struct first_info fi; + } fi; + } u; + phandle_t ph; + + if ((fd = open_io(path)) == -1) { + ELF_DPRINTF("Can't open %s\n", path); + return; + } + + seek_io(fd, 0); + len = read_io(fd, u.buffer, sizeof(u)); + close_io( fd ); + + if (len == -1) { + ELF_DPRINTF("Can't read %s\n", path); + return; + } + + /* is it quik ? */ + + if (memcmp(u.fi.fi.quik_vers, "QUIK", 4)) + return; + + ph = find_dev("/options"); + set_property(ph, "boot-device", path, strlen(path) + 1); + ph = find_dev("/chosen"); + set_property(ph, "bootargs", "Linux", 6); + + if( ofmem_claim( QUIK_FIRST_BASEADDR, len, 0 ) == -1 ) + fatal_error("Claim failed!\n"); + + memcpy(QUIK_FIRST_BASEADDR, u.buffer, len); + + /* quik fist level doesn't claim second level memory */ + + if( ofmem_claim( QUIK_SECOND_BASEADDR, QUIK_SECOND_SIZE, 0 ) == -1 ) + fatal_error("Claim failed!\n"); + + call_elf(0, 0, QUIK_FIRST_BASEADDR); + + return; +} + +static void yaboot_startup( void ) { static const char * const paths[] = { "hd:2,\ofclient", "hd:2,\yaboot" }; @@ -318,5 +389,6 @@ { fword("update-chosen"); check_preloaded_kernel(); + quik_startup(); yaboot_startup(); }