From: Christopher H. <ch...@us...> - 2003-01-28 03:40:43
|
Update of /cvsroot/blob/blob/src/blob In directory sc8-pr-cvs1:/tmp/cvs-serv19274 Modified Files: load_kernel.c Log Message: Iterate over the partition table in load_kernel. Index: load_kernel.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/load_kernel.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- load_kernel.c 24 Jan 2003 09:39:20 -0000 1.13 +++ load_kernel.c 28 Jan 2003 03:40:40 -0000 1.14 @@ -39,6 +39,7 @@ #include <blob/load_kernel.h> #include <blob/util.h> #include <blob/flash.h> +#include <blob/partition.h> #ifdef CONFIG_CRAMFS_SUPPORT extern struct kernel_loader cramfs_load; @@ -50,41 +51,24 @@ extern struct kernel_loader jffs2_load; #endif -#define FODDER_RAM_BASE (0xC0F00000) - -const void *fodder_ram_base = (void *) FODDER_RAM_BASE; - - -/* this will go away once we integrate the new partition code */ -struct hash_defined_partition hash_defined_part_table[] = { +struct kernel_loader *known_loaders[] = { #ifdef CONFIG_CRAMFS_SUPPORT - { - .loader = &cramfs_load, - .offset = (char *) RAMDISK_FLASH_BASE, - .size = RAMDISK_FLASH_LEN - }, + &cramfs_load, #endif #ifdef CONFIG_ZIMAGE_SUPPORT - { - .loader = &zImage_load, - .offset = (char *) KERNEL_FLASH_BASE, - .size = KERNEL_FLASH_LEN - }, + &zImage_load, #endif #ifdef CONFIG_JFFS2_SUPPORT - { - .loader = &jffs2_load, - .offset = (char *) RAMDISK_FLASH_BASE, - .size = RAMDISK_FLASH_LEN - }, + &jffs2_load, #endif - { - .loader = 0, - .offset = 0, - .size = 0 - } + 0 }; +#define FODDER_RAM_BASE (0xC0F00000) + +const void *fodder_ram_base = (void *) FODDER_RAM_BASE; + + /* function calls for blob */ void ldr_update_progress(void) @@ -94,43 +78,49 @@ int load_kernel(blob_status_t *blob_status) { - int i; u32 size; - const struct kernel_loader *loader; + const struct kernel_loader *loader = 0; + const blob_partition_t *p; struct part_info part; - for (i = 0; /**/ ; i++) { - loader = hash_defined_part_table[i].loader; - - if (!loader) - break; - - part.offset = hash_defined_part_table[i].offset; - part.size = hash_defined_part_table[i].size; + for (p = pt_first(); p != 0; p = pt_next(p)) { +#ifdef CONFIG_JFFS2_SUPPORT + if (p->flags & BLOB_PART_FLAG_JFFS2) + loader = &jffs2_load; + else +#endif +#ifdef CONFIG_CRAMFS_SUPPORT + if (p->flags & BLOB_PART_FLAG_CRAMFS) + loader = &cramfs_load; + else +#endif +#ifdef CONFIG_ZIMAGE_SUPPORT + if (p->flags & BLOB_PART_FLAG_EXEC) /* ?? */ + loader = &zImage_load; + else +#endif + continue; + + part.offset = pt_flash_start(p); + part.size = p->size; part.erasesize = flash_get_block_size((u32)part.offset); if (loader->check_magic(&part)) break; } - if (!loader) { -#if defined(KERNEL_FLASH_BASE) - /* if we have an old-style kernel partition, try that */ - eprintf("Unable to find kernel, loading raw data " - "and hoping for the best!\n"); - size = KERNEL_FLASH_LEN; - MyMemCpy((u32 *)KERNEL_RAM_BASE, (u32 *)KERNEL_FLASH_BASE, size >> 2); -#else + if (!p) { eprintf("Unable to find kernel"); return EINVAL; -#endif - } else { - printf("Loading kernel from %s ...", loader->name); - if ((size = loader->load_kernel((u32 *)KERNEL_RAM_BASE, - &part, "/boot/linux")) == 0) { - eprintf("error loading kernel!\n"); - return(EINVAL); - } + } + + + printf("Loading kernel from partition %s (%s) ...", + p->name, loader->name); + if ((size = loader->load_kernel((u32 *) p->mem_base, + &part, "/boot/linux")) == 0) { + eprintf("error loading kernel!\n"); + return(EINVAL); } blob_status->kernelSize = size; |