gonzui


Format: Advanced Search

tkernel_2/monitor/driver/flash/src/setup-em1d.cbare sourcepermlink (0.02 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 TRON Forum(http://www.tron.org/) at 2015/06/01.
   11:  *
   12:  *----------------------------------------------------------------------
   13:  */
   14: 
   15: /*
   16:  *      setup.c
   17:  *
   18:  *       prepare for Flash ROM write
   19:  */
   20: 
   21: #include "flash.h"
   22: 
   23: EXPORT void ChangeMemAttr( UW top, UW end, UW attr );
   24: 
   25: /* Update Flash ROM page table so that it can be written to. */
   26: LOCAL void flashwr_pagetable(BOOL writable)
   27: {
   28:         MEMSEG *mp;
   29:         UW     attr;
   30: 
   31:         mp = MemArea(MSA_FROM, 1);
   32:         attr = (writable) ? (PGA_RW | PGA_D | PGA_S) : (mp->pa & 0x000fffff);
   33:         ChangeMemAttr(mp->top, mp->end, attr);
   34: 
   35:         return;
   36: }
   37: 
   38: /*
   39:  * check Flash ROM write-protect status
   40:  *       return value      E_OK            writable (OK)
   41:  *                         E_PROTECT       write-protected
   42:  */
   43: EXPORT ER flashwr_protect( UW addr, W nsec )
   44: {
   45:         return E_OK;
   46: }
   47: 
   48: /*
   49:  * set up Flash ROM write
   50:  */
   51: EXPORT void flashwr_setup( BOOL reset )
   52: {
   53:         /* invalidate cache
   54:            keep MMU enabled so that we can use WKRAM */
   55:         DisableCache();
   56: 
   57:         /* page table is modified so that ROM area can be written to. */
   58:         flashwr_pagetable(TRUE);
   59: }
   60: 
   61: /*
   62:  * post processing after Flash ROM write completed
   63:  */
   64: EXPORT void flashwr_done( void )
   65: {
   66:         /* restore the page table setting to the original. */
   67:         flashwr_pagetable(FALSE);
   68: 
   69:         /* validate cache */
   70:         EnableCache();
   71: }