From: Christopher H. <ch...@us...> - 2003-01-28 03:36:39
|
Update of /cvsroot/blob/blob/src/blob In directory sc8-pr-cvs1:/tmp/cvs-serv16782 Modified Files: main.c Log Message: Moved Flash command to flash-commands.c Find parameter block using partition table. Index: main.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/main.c,v retrieving revision 1.51 retrieving revision 1.52 diff -u -d -r1.51 -r1.52 --- main.c 24 Jan 2003 09:39:20 -0000 1.51 +++ main.c 28 Jan 2003 03:36:36 -0000 1.52 @@ -39,12 +39,11 @@ #endif #include <blob/arch.h> +#include <blob/debug.h> #include <blob/command.h> #include <blob/errno.h> #include <blob/error.h> -#include <blob/flash.h> #include <blob/init.h> -#include <blob/led.h> #include <blob/main.h> #include <blob/md5.h> #include <blob/md5support.h> @@ -56,13 +55,13 @@ #include <blob/uucodec.h> #include <blob/xmodem.h> #include <blob/load_kernel.h> +#include <blob/partition.h> static int do_reload(char *what); static void PrintSerialSpeed(serial_baud_t speed); static void print_elf_sections(void); - - +static void *find_parameters(void); blob_status_t blob_status; @@ -72,9 +71,8 @@ { int numRead = 0; char commandline[MAX_COMMANDLINE_LENGTH]; -#ifdef PARAM_START u32 conf = 0; -#endif + void *params; /* initialise status */ blob_status.paramType = fromFlash; @@ -89,18 +87,20 @@ /* call subsystems (blob_status.* may change) */ init_subsystems(); + /* find parameter partition, if it exists */ + params = find_parameters(); + /* call serial_init() because the default 9k6 speed might not be what the user requested */ serial_init(blob_status.terminalSpeed); /* parse the core tag, for critical things like terminal speed */ -#ifdef PARAM_START - parse_ptag((void *) PARAM_START, &conf); -#endif + if (params) + parse_ptag(params, &conf); /* Print the required GPL string */ printf("\nConsider yourself BLOBed!\n\n"); - printf("%sCopyright (C) 1999 2000 2001 2002 " + printf("%sCopyright (C) 1999 2000 2001 2002 2003 " "Jan-Derk Bakker and Erik Mouw\n", version_str); printf(PACKAGE " comes with ABSOLUTELY NO WARRANTY; " "read the GNU GPL for details.\n"); @@ -121,10 +121,9 @@ } #endif - /* Parse all the tags in the parameter block */ -#ifdef PARAM_START - parse_ptags((void *) PARAM_START, &conf); -#endif + /* Load remaining parameters */ + if (params) + parse_ptags(params, &conf); /* Load kernel and ramdisk from flash to RAM */ do_reload("blob"); @@ -190,6 +189,8 @@ 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; @@ -197,7 +198,6 @@ *numRead = &blob_status.blobSize; *digest = blob_status.blob_md5_digest; blob_status.blobType = fromDownload; -#ifdef PARAM_START } else if(strncmp(name, "param", 6) == 0) { /* download param */ *startAddress = PARAM_RAM_BASE; @@ -205,7 +205,6 @@ *numRead = &blob_status.paramSize; *digest = blob_status.param_md5_digest; blob_status.paramType = fromDownload; -#endif } else if(strncmp(name, "kernel", 7) == 0) { /* download kernel */ *startAddress = KERNEL_RAM_BASE; @@ -402,97 +401,6 @@ #endif /* #ifdef CONFIG_XMODEM_SUPPORT */ - - - - - - -static int Flash(int argc, char *argv[]) -{ - u32 *src; - u32 *dst; - u32 numBytes = 0; - u32 maxSize = 0; - u32 nwords; - block_source_t type = fromFlash; - - - if(argc < 2) - return -ENOPARAMS; - - if(strncmp(argv[1], "blob", 5) == 0) { - src = (u32 *)BLOB_RAM_BASE; - dst = (u32 *)BLOB_FLASH_BASE; - maxSize = BLOB_FLASH_LEN; - numBytes = blob_status.blobSize; - type = blob_status.blobType; -#ifdef PARAM_FLASH_BASE - } else if(strncmp(argv[1], "param", 6) == 0) { - src = (u32 *)PARAM_RAM_BASE; - dst = (u32 *)PARAM_FLASH_BASE; - maxSize = PARAM_FLASH_LEN; - numBytes = blob_status.paramSize; - type = blob_status.paramType; -#endif -#ifdef KERNEL_FLASH_BASE - } else if(strncmp(argv[1], "kernel", 7) == 0) { -# if defined(RAMDISK_FLASH_BASE) && (KERNEL_FLASH_BASE == RAMDISK_FLASH_BASE) - printerrprefix(); - printf("configured for kernel in ramdisk\n"); - return -EINVAL; -# else - src = (u32 *)KERNEL_RAM_BASE; - dst = (u32 *)KERNEL_FLASH_BASE; - numBytes = blob_status.kernelSize; - maxSize = KERNEL_FLASH_LEN; - type = blob_status.kernelType; -# endif -#endif -#ifdef RAMDISK_FLASH_BASE - } else if(strncmp(argv[1], "ramdisk", 8) == 0) { - src = (u32 *)RAMDISK_RAM_BASE; - dst = (u32 *)RAMDISK_FLASH_BASE; - numBytes = blob_status.ramdiskSize; - maxSize = RAMDISK_FLASH_LEN; - type = blob_status.ramdiskType; -#endif - } else { - printerror(EINVAL, argv[1]); - return 0; - } - - if(type == fromFlash) { - printerrprefix(); - printf("%s not downloaded\n", argv[1]); - return -EINVAL; - } - - if(numBytes > maxSize) { - printerrprefix(); - printf("image too large for flash: 0x%08x > 0x%08x\n", - (unsigned int)numBytes, (unsigned int)maxSize); - - return -ETOOLONG; - } - - nwords = (numBytes + sizeof(u32) - 1) / sizeof(u32); - - printf("Saving %s to flash\n", argv[1]); - - flash_write_region(dst, src, nwords); - - return 0; -} - -static char flashhelp[] = "flash {blob|param|kernel|ramdisk}\n" -"Write <argument> image to flash\n"; - -__commandlist(Flash, "flash", flashhelp); - - - - static int SetDownloadSpeed(int argc, char *argv[]) { if(argc < 2) @@ -780,4 +688,11 @@ PRINT_ELF_SECTION(__bss_start, __bss_end, ".bss"); PRINT_ELF_SECTION(__stack_start, __stack_end, ".stack (in .bss)"); #endif +} + +static void *find_parameters(void) +{ + const blob_partition_t *p = pt_find_by_name("parameters"); + + return p ? pt_flash_start(p) : 0; } |