From: Christopher H. <ch...@fr...> - 2002-01-15 03:34:03
|
Erik et al: Any interest in the flash commands I wrote? I placed the code into a separate file (see below) and hacked the commands to use (u32 *start, u32 nwords) ranges as that seems to be the preferred interface for the flash functions. If a different organization is preferred, let me know. [The code will have to changed a bit once the new partition code goes in, but hopefully the changes will be isolated to a single function, parse_partition.] Cheers, Christopher. ch...@mu... ch...@hp... p.s. This is last set of my changes that haven't hit the cvs tree. ? diffs ? src/blob/badge4-low.c ? src/blob/flash-commands.c Index: include/blob/flash.h =================================================================== RCS file: /cvsroot/blob/blob/include/blob/flash.h,v retrieving revision 1.9 diff -a -u -r1.9 flash.h --- include/blob/flash.h 2001/12/31 00:28:53 1.9 +++ include/blob/flash.h 2002/01/15 03:17:55 @@ -93,6 +93,6 @@ int flash_lock_region(u32 *start, u32 nwords); int flash_unlock_region(u32 *start, u32 nwords); int flash_query_region(u32 *start, u32 nwords); - +void print_flash_map(); #endif Index: src/blob/Makefile.am =================================================================== RCS file: /cvsroot/blob/blob/src/blob/Makefile.am,v retrieving revision 1.16 diff -a -u -r1.16 Makefile.am --- src/blob/Makefile.am 2002/01/12 01:45:57 1.16 +++ src/blob/Makefile.am 2002/01/15 03:17:55 @@ -126,6 +126,7 @@ bootldrpart.c \ commands.c \ flash.c \ + flash-commands.c \ initcalls.c \ linux.c \ main.c \ Index: src/blob/flash.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/flash.c,v retrieving revision 1.11 diff -a -u -r1.11 flash.c --- src/blob/flash.c 2002/01/03 16:07:17 1.11 +++ src/blob/flash.c 2002/01/15 03:17:55 @@ -143,21 +143,7 @@ } #ifdef BLOB_DEBUG - SerialOutputString("Flash map:\n"); - for(i = 0; i < num_flash_blocks; i++) { - SerialOutputString(" 0x"); - SerialOutputHex(flash_blocks[i].size); - SerialOutputString(" @ 0x"); - SerialOutputHex(flash_blocks[i].start); - SerialOutputString(" ("); - SerialOutputDec(flash_blocks[i].size / 1024); - SerialOutputString(" kB), "); - - if(!flash_blocks[i].lockable) - SerialOutputString("not "); - - SerialOutputString("lockable\n"); - } + print_flash_map(); #endif } @@ -331,7 +317,35 @@ } +void print_flash_map(void) +{ + int i; + + SerialOutputString("Flash map:\n"); + for(i = 0; i < num_flash_blocks; i++) { + u32 start = flash_blocks[i].start; + + SerialOutputDec(i); + SerialOutputString(":\t0x"); + SerialOutputHex(flash_blocks[i].size); + SerialOutputString(" @ 0x"); + SerialOutputHex(start); + SerialOutputString(" ("); + SerialOutputDec(flash_blocks[i].size / 1024); + SerialOutputString(" kB),\t"); + if(flash_blocks[i].lockable && + flash_driver->query_block_lock) { + if ((flash_driver->query_block_lock)((u32 *) start)) + SerialOutputString("locked"); + else + SerialOutputString("unlocked"); + } else { + SerialOutputString("not lockable"); + } + SerialOutputString("\n"); + } +} /* given an address, return the flash block index number (or negative * error number otherwise /*------------------------------------------------------------------------- * Filename: flash-commands.c * Version: $Id$ * Copyright: Copyright (C) 2002, Hewlett-Packard Company * Author: Christopher Hoover <ch...@hp...> * Description: Flash commands for blob * Created at: Tue Jan 15 02:27:30 UTC 2002 *-----------------------------------------------------------------------*/ /* * flash-commands.c: Flash commands for blob * * Copyright (C) 2002 Hewlett-Packard Company * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ident "$Id$" #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/arch.h> #include <blob/errno.h> #include <blob/error.h> #include <blob/util.h> #include <blob/serial.h> #include <blob/flash.h> #include <blob/command.h> static int parse_partition(char *s, u32 **addr, u32 *length) { /* this will eventually be replaced by some functionality in the partition manager */ if(strncmp(s, "blob", 5) == 0) { *addr = (u32 *)BLOB_FLASH_BASE; *length = BLOB_FLASH_LEN; #ifdef PARAM_START } else if(strncmp(s, "param", 6) == 0) { *addr = (u32 *)PARAM_FLASH_BASE; *length = PARAM_FLASH_LEN; #endif } else if(strncmp(s, "kernel", 7) == 0) { *addr = (u32 *)KERNEL_FLASH_BASE; *length = KERNEL_FLASH_LEN; } else if(strncmp(s, "ramdisk", 8) == 0) { *addr = (u32 *)RAMDISK_FLASH_BASE; *length = RAMDISK_FLASH_LEN; } else { return -EINVAL; } return 0; } static int FlLock(int argc, char *argv[]) { int rv; u32 *addr, length; if(argc != 2) return -ENOPARAMS; if (!flash_driver->unlock_block) { printerror(EINVAL, argv[1]); return 0; } rv = parse_partition(argv[1], &addr, &length); if (rv < 0) { printerror(rv, argv[1]); return 0; } rv = flash_lock_region(addr, length >> 2); if (rv < 0) { printerror(rv, argv[1]); return 0; } return 0; } static char fllockhelp[] = "fllock {blob|param|kernel|ramdisk}\n" "Lock <argument> region of flash\n"; __commandlist(FlLock, "fllock", fllockhelp); static int FlUnlock(int argc, char *argv[]) { int rv; u32 *addr, length; if(argc != 2) return -ENOPARAMS; if (!flash_driver->unlock_block) { printerror(EINVAL, argv[1]); return 0; } rv = parse_partition(argv[1], &addr, &length); if (rv < 0) { printerror(rv, argv[1]); return 0; } rv = flash_unlock_region(addr, length >> 2); if (rv < 0) { printerror(rv, argv[1]); return 0; } return 0; } static char flunlockhelp[] = "flunlock {blob|param|kernel|ramdisk}\n" "Unlock <argument> region of flash\n"; __commandlist(FlUnlock, "flunlock", flunlockhelp); static int FlErase(int argc, char *argv[]) { int rv; u32 *addr, length; if(argc != 2) return -ENOPARAMS; if (!flash_driver->unlock_block) { printerror(EINVAL, argv[1]); return 0; } rv = parse_partition(argv[1], &addr, &length); if (rv < 0) { printerror(rv, argv[1]); return 0; } rv = flash_erase_region(addr, length >> 2); if (rv < 0) { printerror(rv, argv[1]); return 0; } return 0; } static char flerasehelp[] = "flerase {blob|param|kernel|ramdisk}\n" "Erase <argument> region of flash\n"; __commandlist(FlErase, "flerase", flerasehelp); static int FlMap(int argc, char *argv[]) { if(argc != 1) return -ENOPARAMS; print_flash_map(); return 0; } static char flmaphelp[] = "flmap"; __commandlist(FlMap, "flmap", flmaphelp); |
From: Erik M. <J.A...@it...> - 2002-01-15 22:42:44
|
On Mon, Jan 14, 2002 at 07:30:55PM -0800, Christopher Hoover wrote: > Any interest in the flash commands I wrote? I placed the code into a > separate file (see below) and hacked the commands to use (u32 *start, > u32 nwords) ranges as that seems to be the preferred interface for the > flash functions. If a different organization is preferred, let me know. > > [The code will have to changed a bit once the new partition code goes > in, but hopefully the changes will be isolated to a single function, > parse_partition.] Agreed. The only thing I don't like is the print_flash_map() function. Printing the complete flash map is really only a debug function, it isn't needed for normal use. Erik -- J.A.K. (Erik) Mouw, Information and Communication Theory Group, Faculty of Information Technology and Systems, Delft University of Technology, PO BOX 5031, 2600 GA Delft, The Netherlands Phone: +31-15-2783635 Fax: +31-15-2781843 Email: J.A...@it... WWW: http://www-ict.its.tudelft.nl/~erik/ |
From: Christopher H. <ch...@mu...> - 2002-01-15 22:45:08
|
OK, I'll nuke that part. > -----Original Message----- > From: blo...@li... > [mailto:blo...@li...] On > Behalf Of Erik Mouw > Sent: Tuesday, January 15, 2002 2:40 PM > To: Christopher Hoover > Cc: blo...@li... > Subject: Re: flash commands > > > On Mon, Jan 14, 2002 at 07:30:55PM -0800, Christopher Hoover wrote: > > Any interest in the flash commands I wrote? I placed the > code into a > > separate file (see below) and hacked the commands to use > (u32 *start, > > u32 nwords) ranges as that seems to be the preferred > interface for the > > flash functions. If a different organization is preferred, let me > > know. > > > > [The code will have to changed a bit once the new partition > code goes > > in, but hopefully the changes will be isolated to a single > function, > > parse_partition.] > > Agreed. The only thing I don't like is the print_flash_map() > function. Printing the complete flash map is really only a > debug function, it isn't needed for normal use. > > > Erik > > -- > J.A.K. (Erik) Mouw, Information and Communication Theory > Group, Faculty of Information Technology and Systems, Delft > University of Technology, PO BOX 5031, 2600 GA Delft, The > Netherlands Phone: +31-15-2783635 > Fax: +31-15-2781843 Email: J.A...@it... > WWW: http://www-ict.its.tudelft.nl/~erik/ > > _______________________________________________ > blob-cvs-commit mailing list blo...@li... > https://lists.sourceforge.net/lists/listinfo/blob-cvs-commit > |