gonzui


Format: Advanced Search

mtkernel_3/kernel/knlinc/kernel.hbare sourcepermlink (0.02 seconds)

Search this content:

    1: /*
    2:  *----------------------------------------------------------------------
    3:  *    micro T-Kernel 3.00.03
    4:  *
    5:  *    Copyright (C) 2006-2021 by Ken Sakamura.
    6:  *    This software is distributed under the T-License 2.2.
    7:  *----------------------------------------------------------------------
    8:  *
    9:  *    Released by TRON Forum(http://www.tron.org) at 2021/03/31.
   10:  *
   11:  *----------------------------------------------------------------------
   12:  */
   13: 
   14: /*
   15:  *      kernel.h
   16:  *      micro T-Kernel Common Definition
   17:  */
   18: 
   19: #ifndef _KERNEL_
   20: #define _KERNEL_
   21: 
   22: #include <sys/machine.h>
   23: #include <sys/queue.h>
   24: 
   25: #include <tk/typedef.h>
   26: #include <tk/errno.h>
   27: #include <tk/syscall.h>
   28: #include <tk/dbgspt.h>
   29: 
   30: #include "tstdlib.h"
   31: 
   32: typedef struct task_control_block       TCB;
   33: 
   34: #include "../tkernel/timer.h"
   35: #include "../tkernel/winfo.h"
   36: #include "../tkernel/mutex.h"
   37: 
   38: #include "../sysdepend/sys_msg.h"
   39: #include "../sysdepend/cpu_status.h"
   40: 
   41: #define SYSCALL         EXPORT         /* Definition of system call */
   42: 
   43: /* User defined handler ( Sub-system calls, time-event handler ) */
   44: # define CallUserHandlerP1(   p1,         hdr, cb)      (*(hdr))(p1)
   45: # define CallUserHandlerP2(   p1, p2,     hdr, cb)      (*(hdr))(p1, p2)
   46: # define CallUserHandlerP3(   p1, p2, p3, hdr, cb)      (*(hdr))(p1, p2, p3)
   47: 
   48: /*
   49:  * Task control block (TCB)
   50:  */
   51: struct task_control_block {
   52:         QUEUE  tskque;          /* Task queue */
   53:         ID     tskid;              /* Task ID */
   54:         void   *exinf;           /* Extended information */
   55:         ATR    tskatr;            /* Task attribute */
   56:         FP     task;               /* Task startup address */
   57:         CTXB   tskctxb;  /* Task context block */
   58:         W      sstksz;              /* stack size */
   59: 
   60:         B      isysmode;    /* Task operation mode initial value */
   61:         H      sysmode;     /* Task operation mode, quasi task part call level */
   62: 
   63:         UB     ipriority;  /* Priority at task startup */
   64:         UB     bpriority;  /* Base priority */
   65:         UB     priority;   /* Current priority */
   66: 
   67:         UB /*TSTAT*/   state;    /* Task state (Int. expression) */
   68: 
   69:         BOOL   klockwait:1;      /* TRUE at wait kernel lock */
   70:         BOOL   klocked:1;        /* TRUE at hold kernel lock */
   71: 
   72:         CONST WSPEC *wspec;    /* Wait specification */
   73:         ID     wid;                /* Wait object ID */
   74:         INT    wupcnt;            /* Number of wakeup requests queuing */
   75:         INT    suscnt;            /* Number of SUSPEND request nests */
   76:         ER     *wercd;             /* Wait error code set area */
   77:         WINFO  winfo;           /* Wait information */
   78:         TMEB   wtmeb;            /* Wait timer event block */
   79: 
   80:         void   *isstack; /* stack pointer initial value */
   81: 
   82: #if USE_LEGACY_API && USE_RENDEZVOUS
   83:         RNO    wrdvno;            /* For creating rendezvous number */
   84: #endif
   85: #if USE_MUTEX == 1
   86:         MTXCB  *mtxlist;        /* List of hold mutexes */
   87: #endif
   88: 
   89: #if USE_DBGSPT && defined(USE_FUNC_TD_INF_TSK)
   90:         UW     stime;              /* System execution time (ms) */
   91:         UW     utime;              /* User execution time (ms) */
   92: #endif
   93: 
   94: #if USE_OBJECT_NAME
   95:         UB     name[OBJECT_NAME_LENGTH];   /* name */
   96: #endif
   97: };
   98: 
   99: 
  100: /*
  101:  * Task dispatch disable state
  102:  *      0 = DDS_ENABLE                : ENABLE
  103:  *      1 = DDS_DISABLE_IMPLICIT : DISABLE with implicit process
  104:  *      2 = DDS_DISABLE               : DISABLE with tk_dis_dsp()
  105:  *      |    |
  106:  *      |    use in *.c
  107:  *      use in *.S
  108:  *        --> Do NOT change these literals, because using in assembler code
  109:  *
  110:  *      'dispatch_disabled' records dispatch disable status set by tk_dis_dsp()
  111:  *      for some CPU, that accepts delayed interrupt.
  112:  *      In this case, you can NOT refer the dispatch disabled status
  113:  *      only by 'dispatch_disabled'.
  114:  *      Use 'in_ddsp()' to refer the task dispatch status.
  115:  *      'in_ddsp()' is a macro definition in CPU-dependent definition files.
  116:  */
  117: #define DDS_ENABLE              (0)
  118: #define DDS_DISABLE_IMPLICIT    (1)        /* set with implicit process */
  119: #define DDS_DISABLE             (2)        /* set by tk_dis_dsp() */
  120: IMPORT INT      knl_dispatch_disabled;
  121: 
  122: /*
  123:  * Task in execution
  124:  *      ctxtsk is a variable that indicates TCB task in execution
  125:  *      (= the task that CPU holds context). During system call processing,
  126:  *      when checking information about the task that requested system call,
  127:  *      use 'ctxtsk'. Only task dispatcher changes 'ctxtsk'.
  128:  */
  129: IMPORT TCB      *knl_ctxtsk;
  130: 
  131: /*
  132:  * Task which should be executed
  133:  *      'schedtsk' is a variable that indicates the task TCB to be executed.
  134:  *      If a dispatch is delayed by the delayed dispatch or dispatch disable, 
  135:  *      it does not match with 'ctxtsk.' 
  136:  */
  137: IMPORT TCB      *knl_schedtsk;
  138: 
  139: /*
  140:  * Kernel-object initialization (each object)
  141:  */
  142: IMPORT ER knl_task_initialize( void );
  143: IMPORT ER knl_semaphore_initialize( void );
  144: IMPORT ER knl_eventflag_initialize( void );
  145: IMPORT ER knl_mailbox_initialize( void );
  146: IMPORT ER knl_messagebuffer_initialize( void );
  147: IMPORT ER knl_rendezvous_initialize( void );
  148: IMPORT ER knl_mutex_initialize( void );
  149: IMPORT ER knl_memorypool_initialize( void );
  150: IMPORT ER knl_fix_memorypool_initialize( void );
  151: IMPORT ER knl_cyclichandler_initialize( void );
  152: IMPORT ER knl_alarmhandler_initialize( void );
  153: IMPORT ER knl_subsystem_initialize( void );
  154: 
  155: /*
  156:  * Kernel-object initialization (each object) (tkinit.c)
  157:  */
  158: IMPORT ER knl_init_object(void);
  159: 
  160: /*
  161:  * Initialization of Devive management (device.c)
  162:  */
  163: IMPORT ER knl_initialize_devmgr( void );
  164: 
  165: /*
  166:  * System timer control (timer.c)
  167:  */
  168: IMPORT ER   knl_timer_startup( void );
  169: IMPORT void knl_timer_shutdown( void );
  170: IMPORT void knl_timer_handler( void );
  171: 
  172: /*
  173:  * Mutex control (mutex.c)
  174:  */
  175: IMPORT void knl_signal_all_mutex( TCB *tcb );
  176: IMPORT INT knl_chg_pri_mutex( TCB *tcb, INT priority );
  177: 
  178: /*
  179:  * Internal memory allocation (Imalloc) (memory.c)
  180:  */
  181: IMPORT ER knl_init_Imalloc( void );
  182: IMPORT void* knl_Imalloc( SZ size );
  183: IMPORT void* knl_Icalloc( SZ nmemb, SZ size );
  184: IMPORT void* knl_Irealloc( void *ptr, SZ size );
  185: IMPORT void  knl_Ifree( void *ptr );
  186: 
  187: /*
  188:  * Initial task creation parameter (inittask.c)
  189:  */
  190: IMPORT const T_CTSK knl_init_ctsk;
  191: 
  192: /*
  193:  * User main program (usermain.c)
  194:  */
  195: IMPORT INT usermain( void );
  196: 
  197: /*
  198:  * power-saving function (power.c)
  199:  */
  200: IMPORT UINT     knl_lowpow_discnt;
  201: 
  202: 
  203: /* ----------------------------------------------------------------------- */
  204: /*
  205:  * Target system-dependent routine (/sysdepend)
  206:  */
  207: 
  208: /* Low-level memory management information (reset_hdl.c) */
  209: IMPORT  void     *knl_lowmem_top, *knl_lowmem_limit;
  210: 
  211: /*
  212:  * Startup / Re-start / Shutdown Hardware (hw_setting.c)
  213:  */
  214: IMPORT void knl_startup_hw(void);
  215: IMPORT void knl_shutdown_hw( void );
  216: IMPORT ER knl_restart_hw( W mode );
  217: 
  218: /*
  219:  * CPU control (cpu_cntl.c)
  220:  */
  221: #if TK_SUPPORT_REGOPS
  222: IMPORT void knl_set_reg( TCB *tcb, CONST T_REGS *regs, CONST T_EIT *eit, CONST T_CREGS *cregs );
  223: IMPORT void knl_get_reg( TCB *tcb, T_REGS *regs, T_EIT *eit, T_CREGS *cregs );
  224: #endif /* TK_SUPPORT_REGOPS */
  225: 
  226: #if NUM_COPROCESSOR > 0
  227: IMPORT ER knl_get_cpr( TCB *tcb, INT copno, T_COPREGS *copregs);
  228: IMPORT ER knl_set_cpr( TCB *tcb, INT copno, CONST T_COPREGS *copregs);
  229: #endif
  230: 
  231: /*
  232:  *      Task dispatcher (cpu_cntl.c)
  233:  */
  234: IMPORT void knl_force_dispatch( void );
  235: IMPORT void knl_dispatch( void );
  236: 
  237: /*
  238:  * Interuupt control (interrupt.c)
  239:  */
  240: IMPORT ER knl_init_interrupt( void );
  241: IMPORT ER knl_define_inthdr( INT intno, ATR intatr, FP inthdr );
  242: IMPORT void knl_return_inthdr(void);
  243: 
  244: /*
  245:  * Device Driver Startup / Finalization (devinit.c)
  246:  */
  247: IMPORT ER knl_init_device( void );
  248: IMPORT ER knl_start_device( void );
  249: IMPORT ER knl_finish_device( void );
  250: 
  251: /*
  252:  * micro T-Kernel Startup / Finalization (sysinit.c)
  253:  */
  254: IMPORT INT main(void);
  255: IMPORT void knl_tkernel_exit( void );
  256: 
  257: /*
  258:  * System Call entry
  259:  */
  260: IMPORT void knl_call_entry( void );
  261: 
  262: /*
  263:  *      Power-Saving Function (power_save.c)
  264:  */
  265: IMPORT void low_pow( void );            /* Switch to power-saving mode */
  266: IMPORT void off_pow( void );            /* Move to suspend mode */
  267: 
  268: #endif /* _KERNEL_ */