gonzui


Format: Advanced Search

tkernel_2/monitor/driver/flash/src/flash.hbare sourcepermlink (0.01 seconds)

Search this content:

    1: /*
    2:  *----------------------------------------------------------------------
    3:  *    T-Kernel 2.0 Software Package
    4:  *
    5:  *    Copyright 2011 by Ken Sakamura.
    6:  *    This software is distributed under the latest version of T-License 2.x.
    7:  *----------------------------------------------------------------------
    8:  *
    9:  *    Released by T-Engine Forum(http://www.t-engine.org/) at 2011/05/17.
   10:  *    Modified by T-Engine Forum at 2013/03/04.
   11:  *    Modified by TRON Forum(http://www.tron.org/) at 2015/06/01.
   12:  *
   13:  *----------------------------------------------------------------------
   14:  */
   15: 
   16: /*
   17:  *      flash.h
   18:  *
   19:  *       Flash ROM write processing
   20:  */
   21: 
   22: #include <tmonitor.h>
   23: 
   24: /* ------------------------------------------------------------------------ */
   25: 
   26: /*
   27:  * JEDEC Flash ROM specification
   28:  *       bsec, and tsec show the sector configuration of boot block.
   29:  *       Ordinary sectors are divided into 8KB units, and
   30:  *       lower address is mapped to MSB side (this is the bitwise mapping ) The leading bit of a sector is 1, and
   31:  *       if this is a continued part of a sector, then it is 0.
   32:  *
   33:  *                             range
   34:  *              bit15       0x00000 - 0x01fff
   35:  *              bit14       0x02000 - 0x03fff
   36:  *              bit13       0x04000 - 0x05fff
   37:  *              bit12       0x06000 - 0x07fff
   38:  *                :    :         :
   39:  *              bit3        0x18000 - 0x19fff
   40:  *              bit2        0x1a000 - 0x1bfff
   41:  *              bit1        0x1c000 - 0x1dfff
   42:  *              bit0        0x1e000 - 0x1ffff
   43:  *
   44:  *       example: if sector size if 64KB, and boot block is configured as follows,
   45:  *               address size
   46:  *               0x0000    32KB
   47:  *               0x8000     8KB
   48:  *               0xa000     8KB
   49:  *               0xc000    16KB
   50:  *               the configured value is 1000_1110_0000_0000 (binary) = 0x8e00
   51:  */
   52: typedef struct {
   53:         UH     man;                /* manufacturer ID */
   54:         UH     dev;                /* device ID */
   55:         UH     ex1;                /* extended device ID 1 */
   56:         UH     ex2;                /* extended device ID 2 2 */
   57:         UH     size;               /* capacity (MB) */
   58:         UH     wrmode:1;   /* write mode */
   59:         UH     bsec;               /* bottom (low address) boot sector configuration */
   60:         UH     tsec;               /* top (upper address) boot sector configuration */
   61: } JEDEC_SPEC;
   62: 
   63: /* write mode */
   64: #define JD_WRSINGLE     0   /* single write */
   65: #define JD_WRMULTI      1    /* multiple write (command 0x20) */
   66: 
   67: IMPORT const JEDEC_SPEC JedecSpec[];
   68: IMPORT const W          N_JedecSpec;
   69: 
   70: /* ------------------------------------------------------------------------ */
   71: 
   72: IMPORT const UW FROM_SECSZ;     /* Flash ROM sector size (byte)
   73:                                    in the case of FWM, it is block size */
   74: /*
   75:  * function definition
   76:  */
   77: IMPORT ER   flashwr( UW addr, void *data, W nsec, BOOL reset );
   78: IMPORT void flashwr_reset( void );
   79: IMPORT ER   flashwr_protect( UW addr, W nsec );
   80: IMPORT void flashwr_setup( BOOL reset );
   81: IMPORT void flashwr_done( void );