From: Russ D. <ru...@us...> - 2003-12-04 21:45:23
|
Update of /cvsroot/blob/blob/src/blob In directory sc8-pr-cvs1:/tmp/cvs-serv18205/src/blob Modified Files: flash-commands.c linux.c load_kernel.c main.c Log Message: blob_item patch Index: flash-commands.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/flash-commands.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- flash-commands.c 11 Mar 2003 19:36:25 -0000 1.7 +++ flash-commands.c 4 Dec 2003 21:45:16 -0000 1.8 @@ -41,6 +41,7 @@ #include <blob/flash.h> #include <blob/partition.h> #include <blob/main.h> +#include <blob/download.h> #include <blob/command.h> @@ -62,14 +63,12 @@ static int Flash(int argc, char *argv[]) { int rv; - u32 *src; u32 *dst; - u32 numBytes = 0; u32 maxSize = 0; u32 nwords; char *dest_part; - block_source_t type = fromFlash; - + blob_item_t *item; + if(argc < 2) return -ENOPARAMS; @@ -85,46 +84,30 @@ return 0; } - if(strncmp(argv[1], "blob", 5) == 0) { - src = (u32 *)BLOB_RAM_BASE; - numBytes = blob_status.blobSize; - type = blob_status.blobType; - } else if(strncmp(argv[1], "param", 6) == 0) { - src = (u32 *)PARAM_RAM_BASE; - numBytes = blob_status.paramSize; - type = blob_status.paramType; - } else if(strncmp(argv[1], "kernel", 7) == 0) { - src = (u32 *)KERNEL_RAM_BASE; - numBytes = blob_status.kernelSize; - type = blob_status.kernelType; - } else if(strncmp(argv[1], "ramdisk", 8) == 0) { - src = (u32 *)RAMDISK_RAM_BASE; - numBytes = blob_status.ramdiskSize; - type = blob_status.ramdiskType; - } else { + if (!(item = get_blob_item(argv[1]))) { printerror(EINVAL, argv[1]); return 0; } - if(type == fromFlash) { + if(item->type == fromFlash) { printerrprefix(); printf("%s not downloaded\n", argv[1]); return -EINVAL; } - if(numBytes > maxSize) { + if(item->size > maxSize) { printerrprefix(); printf("image too large for flash: 0x%08x > 0x%08x\n", - (unsigned int)numBytes, (unsigned int)maxSize); + (unsigned int)item->size, (unsigned int)maxSize); return -ETOOLONG; } - nwords = (numBytes + sizeof(u32) - 1) / sizeof(u32); + nwords = (item->size + sizeof(u32) - 1) / sizeof(u32); printf("Saving %s to flash\n", argv[1]); - flash_write_region(dst, src, nwords); + flash_write_region(dst, item->addr, nwords); return 0; } Index: linux.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/linux.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- linux.c 4 Sep 2003 17:27:33 -0000 1.18 +++ linux.c 4 Dec 2003 21:45:17 -0000 1.19 @@ -34,6 +34,7 @@ #include <blob/main.h> #include <blob/memory.h> #include <blob/util.h> +#include <blob/param_block.h> #include <asm-arm/setup.h> @@ -52,7 +53,7 @@ static int boot_linux(int argc, char *argv[]) { void (*theKernel)(int zero, int arch, u32 params) = - (void (*)(int, int, u32))KERNEL_RAM_BASE; + (void (*)(int, int, u32))blob_status.kernel.addr; setup_start_tag(); setup_memory_tags(); @@ -175,8 +176,8 @@ params->hdr.tag = ATAG_INITRD; params->hdr.size = tag_size(tag_initrd); - params->u.initrd.start = RAMDISK_RAM_BASE; - params->u.initrd.size = RAMDISK_FLASH_LEN; + params->u.initrd.start = blob_status.ramdisk.addr; + params->u.initrd.size = blob_status.ramdisk.size; params = tag_next(params); @@ -197,8 +198,8 @@ params->hdr.tag = ATAG_INITRD2; params->hdr.size = tag_size(tag_initrd); - params->u.initrd.start = RAMDISK_RAM_BASE; - params->u.initrd.size = RAMDISK_FLASH_LEN; + params->u.initrd.start = blob_status.ramdisk.addr; + params->u.initrd.size = blob_status.ramdisk.size; params = tag_next(params); } Index: load_kernel.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/load_kernel.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- load_kernel.c 6 Aug 2003 22:55:41 -0000 1.16 +++ load_kernel.c 4 Dec 2003 21:45:18 -0000 1.17 @@ -64,6 +64,7 @@ 0 }; +/* FIXME: need other fodder ram bases too */ #define FODDER_RAM_BASE (0xC0F00000) const void *fodder_ram_base = (void *) FODDER_RAM_BASE; @@ -117,14 +118,14 @@ printf("Loading kernel from partition %s (%s) ...", p->name, loader->name); - if ((size = loader->load_kernel((u32 *) KERNEL_RAM_BASE, + if ((size = loader->load_kernel(blob_status->kernel.addr, &part, "/boot/linux")) == 0) { eprintf("error loading kernel!\n"); return(EINVAL); } - blob_status->kernelSize = size; - blob_status->kernelType = fromFlash; + blob_status->kernel.size = size; + blob_status->kernel.type = fromFlash; printf("loaded 0x%08x (%d) bytes\n", size, size); return(ENOERROR); Index: main.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/main.c,v retrieving revision 1.54 retrieving revision 1.55 diff -u -d -r1.54 -r1.55 --- main.c 4 Sep 2003 17:46:59 -0000 1.54 +++ main.c 4 Dec 2003 21:45:19 -0000 1.55 @@ -72,9 +72,9 @@ void *params; /* initialise status */ - blob_status.paramType = fromFlash; - blob_status.kernelType = fromFlash; - blob_status.ramdiskType = fromFlash; + blob_status.param.type = fromFlash; + blob_status.kernel.type = fromFlash; + blob_status.ramdisk.type = fromFlash; blob_status.downloadSpeed = baud_115200; blob_status.terminalSpeed = TERMINAL_SPEED; blob_status.load_ramdisk = LOAD_RAMDISK; @@ -179,79 +179,51 @@ } /* main */ - -static int PrintStatus(int argc, char *argv[]) +static int print_item_status(char *name) { - printf(version_str); + blob_item_t *item = get_blob_item(name); + const blob_partition_t *p = pt_find_by_name(name); - printf("Download speed : "); - PrintSerialSpeed(blob_status.downloadSpeed); - printf(" baud\n"); + if (!item || (!p && item->type == fromFlash)) return -EINVAL; - printf("Terminal speed : "); - PrintSerialSpeed(blob_status.terminalSpeed); - printf(" baud\n"); - printf("blob (0x%08x): ", BLOB_FLASH_BASE); - if(blob_status.blobType == fromFlash) { - printf("from flash\n"); - } else { - printf("downloaded at 0x%08x, %i bytes\n", - BLOB_RAM_BASE, blob_status.blobSize); -#ifdef CONFIG_MD5_SUPPORT - printf(" MD5: "); - print_md5_digest(blob_status.blob_md5_digest); - printf("\n"); -#endif - } + printf("%7s ", name); + if (p) + printf("(0x%08x): ", pt_flash_start(p)); + else + printf("%10s", ":"); -#ifdef PARAM_FLASH_BASE - printf("param (0x%08x): ", PARAM_FLASH_BASE); - if(blob_status.paramType == fromFlash) { + if(item->type == fromFlash) { printf("from flash\n"); } else { printf("downloaded at 0x%08x, %i bytes\n", - PARAM_RAM_BASE, blob_status.paramSize); + item->addr, item->size); #ifdef CONFIG_MD5_SUPPORT printf(" MD5: "); - print_md5_digest(blob_status.param_md5_digest); + print_md5_digest(item->md5_digest); printf("\n"); #endif } -#else - printf("param : Not available\n"); -#endif +} -#ifdef KERNEL_FLASH_BASE - printf("kernel (0x%08x): ", KERNEL_FLASH_BASE); - if(blob_status.kernelType == fromFlash) { - printf("from flash\n"); - } else { - printf("downloaded at 0x%08x, %i bytes\n", - KERNEL_RAM_BASE, blob_status.kernelSize); -#ifdef CONFIG_MD5_SUPPORT - printf(" MD5: "); - print_md5_digest(blob_status.kernel_md5_digest); - printf("\n"); -#endif - } -#endif -#ifdef RAMDISK_FLASH_BASE - printf("ramdisk (0x%08x): ", RAMDISK_FLASH_BASE); - if(blob_status.ramdiskType == fromFlash) { - printf("from flash\n"); - } else { - printf("downloaded at 0x%08x, %i bytes\n", - RAMDISK_RAM_BASE, blob_status.ramdiskSize); -#ifdef CONFIG_MD5_SUPPORT - printf(" MD5: "); - print_md5_digest(blob_status.ramdisk_md5_digest); - printf("\n"); -#endif - } -#endif - +static int PrintStatus(int argc, char *argv[]) +{ + printf(version_str); + + printf("Download speed : "); + PrintSerialSpeed(blob_status.downloadSpeed); + printf(" baud\n"); + + printf("Terminal speed : "); + PrintSerialSpeed(blob_status.terminalSpeed); + printf(" baud\n"); + + print_item_status("blob"); + print_item_status("param"); + print_item_status("kernel"); + print_item_status("ramdisk"); + return 0; } |