From: Russ D. <ru...@us...> - 2003-12-04 21:45:23
|
Update of /cvsroot/blob/blob/src/lib In directory sc8-pr-cvs1:/tmp/cvs-serv18205/src/lib Modified Files: download.c Log Message: blob_item patch Index: download.c =================================================================== RCS file: /cvsroot/blob/blob/src/lib/download.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- download.c 27 Nov 2003 08:28:23 -0000 1.3 +++ download.c 4 Dec 2003 21:45:19 -0000 1.4 @@ -40,12 +40,29 @@ #include <blob/arch.h> #include <blob/errno.h> #include <blob/error.h> +#include <blob/main.h> #include <blob/md5.h> #include <blob/md5support.h> #include <blob/serial.h> #include <blob/download.h> #include <blob/command.h> +#include <blob/partition.h> + +blob_item_t *get_blob_item(char *what) +{ + blob_item_t *ret = NULL; + + if (!strcmp(what, "blob")) + ret = &blob_status.blob; + else if (!strcmp(what, "param")) + ret = &blob_status.param; + else if (!strcmp(what, "kernel")) + ret = &blob_status.kernel; + else if (!strcmp(what, "ramdisk")) + ret = &blob_status.ramdisk; + return ret; +} void PrintSerialSpeed(serial_baud_t speed) { @@ -58,41 +75,25 @@ int *bufLen, int **numRead, u32 **digest) { - /* Use of _FLASH_LEN here is WRONG. This should be - the size of the ram buffer */ - if(strncmp(name, "blob", 5) == 0) { - /* download blob */ - *startAddress = BLOB_RAM_BASE; - *bufLen = BLOB_FLASH_LEN; - *numRead = &blob_status.blobSize; - *digest = blob_status.blob_md5_digest; - blob_status.blobType = fromDownload; - } else if(strncmp(name, "param", 6) == 0) { - /* download param */ - *startAddress = PARAM_RAM_BASE; - *bufLen = PARAM_FLASH_LEN; - *numRead = &blob_status.paramSize; - *digest = blob_status.param_md5_digest; - blob_status.paramType = fromDownload; - } else if(strncmp(name, "kernel", 7) == 0) { - /* download kernel */ - *startAddress = KERNEL_RAM_BASE; - *bufLen = KERNEL_FLASH_LEN; - *numRead = &blob_status.kernelSize; - *digest = blob_status.kernel_md5_digest; - blob_status.kernelType = fromDownload; - } else if(strncmp(name, "ramdisk", 8) == 0) { - /* download ramdisk */ - *startAddress = RAMDISK_RAM_BASE; - *bufLen = RAMDISK_FLASH_LEN; - *numRead = &blob_status.ramdiskSize; - *digest = blob_status.ramdisk_md5_digest; - blob_status.ramdiskType = fromDownload; - } else { + const blob_partition_t *ptable; + blob_item_t *item; + + if (!(ptable = pt_find_by_name(name)) || !(item = get_blob_item(name))) { printerror(-EINVAL, name); return -EINVAL; } + if (!(*startAddress = ptable->mem_base)) { + printf("%s cannot be loaded to ram\n", name); + return -EINVAL; + } + + *bufLen = ptable->size; + *numRead = &item->size; + *digest = item->md5_digest; + item->addr = (u32 *) *startAddress; /* FIXME ? */ + item->type = fromDownload; + return 0; } @@ -101,54 +102,48 @@ { u32 *dst = 0; u32 *src = 0; - int numWords; + u32 numWords; + const blob_partition_t *ptable; + blob_item_t *item; - if(strncmp(what, "blob", 5) == 0) { - dst = (u32 *)BLOB_RAM_BASE; - src = (u32 *)BLOB_FLASH_BASE; - numWords = BLOB_FLASH_LEN / 4; - blob_status.blobSize = 0; - blob_status.blobType = fromFlash; - printf("Loading blob from flash "); -#ifdef PARAM_FLASH_BASE - } else if(strncmp(what, "param", 6) == 0) { - dst = (u32 *)PARAM_RAM_BASE; - src = (u32 *)PARAM_FLASH_BASE; - numWords = PARAM_FLASH_LEN / 4; - blob_status.paramSize = 0; - blob_status.paramType = fromFlash; - printf("Loading paramater block from flash "); -#endif - } else if(strncmp(what, "kernel", 7) == 0) { -#if defined(CONFIG_CRAMFS_SUPPORT) || defined(CONFIG_ZIMAGE_SUPPORT) || defined(CONFIG_JFFS2_SUPPORT) - return load_kernel(&blob_status); -#else - dst = (u32 *)KERNEL_RAM_BASE; - src = (u32 *)KERNEL_FLASH_BASE; - numWords = KERNEL_FLASH_LEN / 4; - blob_status.kernelSize = 0; - blob_status.kernelType = fromFlash; - printf("Loading kernel from flash "); -#endif -#ifdef RAMDISK_FLASH_BASE - } else if(strncmp(what, "ramdisk", 8) == 0) { - dst = (u32 *)RAMDISK_RAM_BASE; - src = (u32 *)RAMDISK_FLASH_BASE; - numWords = RAMDISK_FLASH_LEN / 4; - blob_status.ramdiskSize = 0; - blob_status.ramdiskType = fromFlash; - printf("Loading ramdisk from flash "); -#endif - } else { + if (!(ptable = pt_find_by_name(what)) || + !(item = get_blob_item(what))) { printerror(EINVAL, what); return 0; } - MyMemCpy(dst, src, numWords); - printf(" done\n"); + src = pt_flash_start(ptable); + numWords = ptable->size / 4; + if (!(dst = (u32 *) ptable->mem_base)) { + printf("%s cannot be loaded to ram\n", what); + return 0; + } + + + item->size = numWords * 4; + item->type = fromFlash; + item->addr = dst; + + /* This is a bit messy, stuff needs some cleaup for sure */ +#if defined(CONFIG_CRAMFS_SUPPORT) || \ + defined(CONFIG_ZIMAGE_SUPPORT) || \ + defined(CONFIG_JFFS2_SUPPORT) + if (!strcmp("kernel", what)) { + item->size = 0; + load_kernel(&blob_status); + } else +#endif + { + printf("Loading %s from flash ", what); + MyMemCpy(dst, src, numWords); + printf(" done\n"); + } return 0; } + + + void do_md5sum(u32 *addr, size_t len, u32 *digest) |