gonzui


Format: Advanced Search

tkernel_2/kernel/sysdepend/device/tef_em1d/tkdev_init.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:  *      tkdev_init.c (EM1-D512)
   17:  *      T-Kernel Device-Dependent Initialization/Finalization
   18:  */
   19: 
   20: #include "kernel.h"
   21: #include <tk/sysdef.h>
   22: #include <tk/syslib.h>
   23: #include <tm/tmonitor.h>
   24: #include "tkdev_conf.h"
   25: 
   26: /*
   27:  * Target system-dependent initialization
   28:  */
   29: EXPORT ER tkdev_initialize( void )
   30: {
   31: static  UINT     giob[4] = { _L, _H, _HH, _HHH };
   32:         UINT   gb;
   33:         INT    i;
   34: 
   35:         /* initialize GPIO interrupt */
   36:         for ( i = 0; i < 4; ++i ) {
   37:                 gb = giob[i];
   38:                 out_w(GIO_IDS(gb), 0xffffffff); /* disable interrupt */
   39:                 out_w(GIO_IIA(gb), 0x00000000); /* disassert interrupt pin */
   40:                 out_w(GIO_GSW(gb), 0x00000000); /* disassert FIQ pin */
   41:         }
   42: 
   43:         /* initialize interrupt controller (AINT) */
   44:         out_w(IT0_IDSS0,    0xffffffff);       /* disassert interrupt pin  */
   45:         out_w(IT0_IDSS1,    0xffffffff);
   46:         out_w(IT0_IDSS2,    0xffffffff);
   47:         out_w(IT0_IDS0,            0xffffffff);       /* disable interrupt */
   48:         out_w(IT0_IDS1,            0xffffffff);
   49:         out_w(IT0_IDS2,            0xffffffff);
   50:         out_w(IT_PINV_CLR0, 0xffffffff);       /* reset inverted logic */
   51:         out_w(IT_PINV_CLR1, 0xffffffff);
   52:         out_w(IT_PINV_CLR2, 0xffffffff);
   53:         out_w(IT_LIIR,     0xffffffff);        /* clear interrupt */
   54:         out_w(IT0_IIR,     0xffffffff);
   55:         out_w(IT0_FIE,     0x00000001);        /* enable FIQ */
   56: 
   57:         /* enable GPIO interrupt on AINT */
   58:         out_w(IT0_IENS0, IRQM(26)|IRQM(27));   /* assert interrupt pin */
   59:         out_w(IT0_IENS1, IRQM(50)|IRQM(51)|IRQM(52)|IRQM(53));
   60:         out_w(IT0_IENS2, IRQM(79)|IRQM(80));
   61:         out_w(IT0_IEN0,         IRQM(26)|IRQM(27));   /* enable interrupt */
   62:         out_w(IT0_IEN1,         IRQM(50)|IRQM(51)|IRQM(52)|IRQM(53));
   63:         out_w(IT0_IEN2,         IRQM(79)|IRQM(80));
   64: 
   65:         /* enable abort switch(SW1) */
   66:         SetIntMode(IV_GPIO(8), IM_ENA|IM_LEVEL|IM_HI);
   67:         EnableInt(IV_GPIO(8));
   68: 
   69:         return E_OK;
   70: }
   71: 
   72: /*
   73:  * Target system-dependent finalization
   74:  *      Normally jump to ROM monitor.
   75:  *      No return from this function.
   76:  */
   77: EXPORT void tkdev_exit( void )
   78: {
   79:         disint();
   80:         tm_exit(0);    /* Turn off power and exit */
   81: 
   82:         /* Not suppose to return from 'tm_exit,' but just in case */
   83:         for ( ;; ) {
   84:                 tm_monitor();  /* To T-Monitor */
   85:         }
   86: }