gonzui


Format: Advanced Search

mtkernel_3/include/tk/syscall.hbare sourcepermlink (0.07 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:  *      syscall.h
   16:  *
   17:  *      micro T-Kernel System Calls
   18:  */
   19: 
   20: #ifndef __TK_SYSCALL_H__
   21: #define __TK_SYSCALL_H__
   22: 
   23: /* Task creation */
   24: #define TSK_SELF        0              /* Its own task specify */
   25: #define TPRI_INI        0              /* Specify priority at task startup */
   26: #define TPRI_RUN        0              /* Specify highest priority during running */
   27: 
   28: #define TA_ASM          0x00000000UL    /* Program by assembler */
   29: #define TA_HLNG         0x00000001UL   /* Program by high level programming language */
   30: #define TA_USERBUF      0x00000020UL /* Specify user buffer */
   31: #define TA_DSNAME       0x00000040UL  /* Use object name */
   32: 
   33: #define TA_RNG0         0x00000000UL   /* Execute by protection level 0 */
   34: #define TA_RNG1         0x00000100UL   /* Execute by protection level 1 */
   35: #define TA_RNG2         0x00000200UL   /* Execute by protection level 2 */
   36: #define TA_RNG3         0x00000300UL   /* Execute by protection level 3 */
   37: 
   38: #define TA_COP0         0x00001000U    /* Use coprocessor (ID=0) */
   39: #define TA_COP1         0x00002000U    /* Use coprocessor (ID=1) */
   40: #define TA_COP2         0x00004000U    /* Use coprocessor (ID=2) */
   41: #define TA_COP3         0x00008000U    /* Use coprocessor (ID=3) */
   42: 
   43: /* Task state tskstat */
   44: #define TTS_RUN         0x00000001U    /* RUN */
   45: #define TTS_RDY         0x00000002U    /* READY */
   46: #define TTS_WAI         0x00000004U    /* WAIT */
   47: #define TTS_SUS         0x00000008U    /* SUSPEND */
   48: #define TTS_WAS         0x0000000cU    /* WAIT-SUSPEND */
   49: #define TTS_DMT         0x00000010U    /* DORMANT */
   50: #define TTS_NODISWAI    0x00000080U        /* Wait disable rejection state */
   51: 
   52: /* Wait factor tskwait */
   53: #define TTW_SLP         0x00000001UL   /* Wait caused by wakeup wait */
   54: #define TTW_DLY         0x00000002UL   /* Wait caused by task delay */
   55: #define TTW_SEM         0x00000004UL   /* Semaphore wait */
   56: #define TTW_FLG         0x00000008UL   /* Event flag wait */
   57: #define TTW_MBX         0x00000040UL   /* Mail box wait */
   58: #define TTW_MTX         0x00000080UL   /* Mutex wait */
   59: #define TTW_SMBF        0x00000100UL   /* Message buffer send wait */
   60: #define TTW_RMBF        0x00000200UL   /* Message buffer receive wait */
   61: #define TTW_CAL         0x00000400UL   /* Rendezvous call wait */
   62: #define TTW_ACP         0x00000800UL   /* Rendezvous accept wait */
   63: #define TTW_RDV         0x00001000UL   /* Rendezvous end wait */
   64: #define TTW_MPF         0x00002000UL   /* Fixed size memory pool wait */
   65: #define TTW_MPL         0x00004000UL   /* Variable size memory pool wait */
   66: 
   67: /* Semaphore generation */
   68: #define TA_TFIFO        0x00000000UL   /* Manage wait task by FIFO */
   69: #define TA_TPRI         0x00000001UL   /* Manage wait task by priority order */
   70: #define TA_FIRST        0x00000000UL   /* Give priority to task at head of wait queue */
   71: #define TA_CNT          0x00000002UL    /* Give priority to task whose request counts is less */
   72: #define TA_DSNAME       0x00000040UL  /* Use object name */
   73: 
   74: /* Mutex */
   75: #define TA_TFIFO        0x00000000UL   /* Manage wait task by FIFO */
   76: #define TA_TPRI         0x00000001UL   /* Manage wait task by priority order */
   77: #define TA_INHERIT      0x00000002UL /* Priority inherited protocol */
   78: #define TA_CEILING      0x00000003UL /* Upper limit priority protocol */
   79: #define TA_DSNAME       0x00000040UL  /* Use object name */
   80: 
   81: /* Event flag */
   82: #define TA_TFIFO        0x00000000UL   /* Manage wait task by FIFO */
   83: #define TA_TPRI         0x00000001UL   /* Manage wait task by priority order */
   84: #define TA_WSGL         0x00000000UL   /* Disable multiple tasks wait */
   85: #define TA_WMUL         0x00000008UL   /* Enable multiple tasks wait */
   86: #define TA_DSNAME       0x00000040UL  /* Use object name */
   87: 
   88: /* Event flag wait mode */
   89: #define TWF_ANDW        0x00000000U    /* AND wait */
   90: #define TWF_ORW         0x00000001U    /* OR wait */
   91: #define TWF_CLR         0x00000010U    /* All clear specify */
   92: #define TWF_BITCLR      0x00000020U  /* Only condition bit clear specify */
   93: 
   94: /* Mail box */
   95: #define TA_TFIFO        0x00000000UL   /* Manage wait task by FIFO */
   96: #define TA_TPRI         0x00000001UL   /* Manage wait task by priority order */
   97: #define TA_MFIFO        0x00000000UL   /* Manage messages by FIFO */
   98: #define TA_MPRI         0x00000002UL   /* Manage messages by priority order */
   99: #define TA_DSNAME       0x00000040UL  /* Use object name */
  100: 
  101: /* Message buffer */
  102: #define TA_TFIFO        0x00000000UL   /* Manage wait task by FIFO */
  103: #define TA_TPRI         0x00000001UL   /* Manage wait task by priority order */
  104: #define TA_USERBUF      0x00000020UL /* Specify user buffer */
  105: #define TA_DSNAME       0x00000040UL  /* Use object name */
  106: 
  107: /* Rendezvous */
  108: #define TA_TFIFO        0x00000000UL   /* Manage wait task by FIFO */
  109: #define TA_TPRI         0x00000001UL   /* Manage wait task by priority order */
  110: #define TA_DSNAME       0x00000040UL  /* Use object name */
  111: 
  112: /* Handler */
  113: #define TA_ASM          0x00000000UL    /* Program by assembler */
  114: #define TA_HLNG         0x00000001UL   /* Program by high level programming language */
  115: 
  116: /* Variable size memory pool */
  117: #define TA_TFIFO        0x00000000UL   /* Manage wait task by FIFO */
  118: #define TA_TPRI         0x00000001UL   /* Manage wait task by priority order */
  119: #define TA_USERBUF      0x00000020UL /* Specify user buffer */
  120: #define TA_DSNAME       0x00000040UL  /* Use object name */
  121: #define TA_RNG0         0x00000000UL   /* Protection level 0 */
  122: #define TA_RNG1         0x00000100UL   /* Protection level 1 */
  123: #define TA_RNG2         0x00000200UL   /* Protection level 2 */
  124: #define TA_RNG3         0x00000300UL   /* Protection level 3 */
  125: 
  126: /* Fixed size memory pool */
  127: #define TA_TFIFO        0x00000000UL   /* Manage wait task by FIFO */
  128: #define TA_TPRI         0x00000001UL   /* Manage wait task by priority order */
  129: #define TA_USERBUF      0x00000020UL /* Specify user buffer */
  130: #define TA_DSNAME       0x00000040UL  /* Use object name */
  131: #define TA_RNG0         0x00000000UL   /* Protection level 0 */
  132: #define TA_RNG1         0x00000100UL   /* Protection level 1 */
  133: #define TA_RNG2         0x00000200UL   /* Protection level 2 */
  134: #define TA_RNG3         0x00000300UL   /* Protection level 3 */
  135: 
  136: /* Cycle handler */
  137: #define TA_ASM          0x00000000UL    /* Program by assembler */
  138: #define TA_HLNG         0x00000001UL   /* Program by high level programming language */
  139: #define TA_STA          0x00000002UL    /* Cycle handler startup */
  140: #define TA_PHS          0x00000004UL    /* Save cycle handler phase */
  141: #define TA_DSNAME       0x00000040UL  /* Use object name */
  142: 
  143: #define TCYC_STP        0x00U          /* Cycle handler is not operating */
  144: #define TCYC_STA        0x01U          /* Cycle handler is operating */
  145: 
  146: /* Alarm handler address */
  147: #define TA_ASM          0x00000000UL    /* Program by assembler */
  148: #define TA_HLNG         0x00000001UL   /* Program by high level programming language */
  149: #define TA_DSNAME       0x00000040UL  /* Use object name */
  150: 
  151: #define TALM_STP        0x00U          /* Alarm handler is not operating */
  152: #define TALM_STA        0x01U          /* Alarm handler is operating */
  153: 
  154: /* System state */
  155: #define TSS_TSK         0x00U  /* During execution of task part(context) */
  156: #define TSS_DDSP        0x01U  /* During dispatch disable */
  157: #define TSS_DINT        0x02U  /* During Interrupt disable */
  158: #define TSS_INDP        0x04U  /* During execution of task independent part */
  159: #define TSS_QTSK        0x08U  /* During execution of semi-task part */
  160: 
  161: /* Power-saving mode */
  162: #define TPW_DOSUSPEND   1 /* Transit to suspend state */
  163: #define TPW_DISLOWPOW   2 /* Power-saving mode switch disable */
  164: #define TPW_ENALOWPOW   3 /* Power-saving mode switch enable */
  165: 
  166: 
  167: /* CPU dependent definition */
  168: #define CPUDEF_PATH_(a)         #a
  169: #define CPUDEF_PATH(a)          CPUDEF_PATH_(a)
  170: #define CPUDEF_SYSDEP()         CPUDEF_PATH(sysdepend/TARGET_DIR/cpudef.h)
  171: 
  172: #include CPUDEF_SYSDEP()
  173: 
  174: /*
  175:  * Task creation information            tk_cre_tsk
  176:  */
  177: typedef struct t_ctsk {
  178:         void   *exinf;           /* Extended information */
  179:         ATR    tskatr;            /* Task attribute */
  180:         FP     task;               /* Task startup address */
  181:         PRI    itskpri;   /* Priority at task startup */
  182:         SZ     stksz;              /* User stack size (byte) */
  183: #if USE_OBJECT_NAME
  184:         UB     dsname[OBJECT_NAME_LENGTH]; /* Object name */
  185: #endif
  186:         void   *bufptr;  /* User buffer */
  187: } T_CTSK;
  188: 
  189: /*
  190:  * Task state information               tk_ref_tsk
  191:  */
  192: typedef struct t_rtsk {
  193:         void   *exinf;           /* Extended information */
  194:         PRI    tskpri;            /* Current priority */
  195:         PRI    tskbpri;   /* Base priority */
  196:         UINT   tskstat;  /* Task state */
  197:         UW     tskwait;    /* Wait factor */
  198:         ID     wid;                /* Wait object ID */
  199:         INT    wupcnt;            /* Number of wakeup requests queuing */
  200:         INT    suscnt;            /* Number of SUSPEND request nests */
  201: } T_RTSK;
  202: 
  203: /*
  204:  * Semaphore creation information               tk_cre_sem
  205:  */
  206: typedef struct t_csem {
  207:         void   *exinf;           /* Extended information */
  208:         ATR    sematr;            /* Semaphore attribute */
  209:         INT    isemcnt;   /* Semaphore initial count value */
  210:         INT    maxsem;            /* Semaphore maximum count value */
  211: #if USE_OBJECT_NAME
  212:         UB     dsname[OBJECT_NAME_LENGTH]; /* Object name */
  213: #endif
  214: } T_CSEM;
  215: 
  216: /*
  217:  * Semaphore state information          tk_ref_sem
  218:  */
  219: typedef struct t_rsem {
  220:         void   *exinf;           /* Extended information */
  221:         ID     wtsk;               /* Wait task ID */
  222:         INT    semcnt;            /* Current semaphore value */
  223: } T_RSEM;
  224: 
  225: /*
  226:  * Mutex creation information           tk_cre_mtx
  227:  */
  228: typedef struct t_cmtx {
  229:         void   *exinf;           /* Extended information */
  230:         ATR    mtxatr;            /* Mutex attribute */
  231:         PRI    ceilpri;   /* Upper limit priority of mutex */
  232: #if USE_OBJECT_NAME
  233:         UB     dsname[OBJECT_NAME_LENGTH]; /* Object name */
  234: #endif
  235: } T_CMTX;
  236: 
  237: /*
  238:  * Mutex state information              tk_ref_mtx
  239:  */
  240: typedef struct t_rmtx {
  241:         void   *exinf;           /* Extended information */
  242:         ID     htsk;               /* Locking task ID */
  243:         ID     wtsk;               /* Lock wait task ID */
  244: } T_RMTX;
  245: 
  246: /*
  247:  * Event flag creation information      tk_cre_flg
  248:  */
  249: typedef struct t_cflg {
  250:         void   *exinf;           /* Extended information */
  251:         ATR    flgatr;            /* Event flag attribute */
  252:         UINT   iflgptn;  /* Event flag initial value */
  253: #if USE_OBJECT_NAME
  254:         UB     dsname[OBJECT_NAME_LENGTH]; /* Object name */
  255: #endif
  256: } T_CFLG;
  257: 
  258: /*
  259:  * Event flag state information         tk_ref_flg
  260:  */
  261: typedef struct t_rflg {
  262:         void   *exinf;           /* Extended information */
  263:         ID     wtsk;               /* Wait task ID */
  264:         UINT   flgptn;           /* Current event flag pattern */
  265: } T_RFLG;
  266: 
  267: /*
  268:  * Mail box creation information        tk_cre_mbx
  269:  */
  270: typedef struct t_cmbx {
  271:         void   *exinf;           /* Extended information */
  272:         ATR    mbxatr;            /* Mail box attribute */
  273: #if USE_OBJECT_NAME
  274:         UB     dsname[OBJECT_NAME_LENGTH]; /* Object name */
  275: #endif
  276: } T_CMBX;
  277: 
  278: /*
  279:  * Mail box message header
  280:  */
  281: typedef struct t_msg {
  282:         void   *msgque[1];       /* Area for message queue */
  283: } T_MSG;
  284: 
  285: typedef struct t_msg_pri {
  286:         T_MSG  msgque;          /* Area for message queue */
  287:         PRI    msgpri;            /* Message priority */
  288: } T_MSG_PRI;
  289: 
  290: /*
  291:  * Mail box state information           tk_ref_mbx
  292:  */
  293: typedef struct t_rmbx {
  294:         void   *exinf;           /* Extended information */
  295:         ID     wtsk;               /* Wait task ID */
  296:         T_MSG  *pk_msg; /* Next received message */
  297: } T_RMBX;
  298: 
  299: /*
  300:  * Message buffer creation information  tk_cre_mbf
  301:  */
  302: typedef struct t_cmbf {
  303:         void   *exinf;           /* Extended information */
  304:         ATR    mbfatr;            /* Message buffer attribute */
  305:         SZ     bufsz;              /* Message buffer size (byte) */
  306:         INT    maxmsz;            /* Maximum length of message (byte) */
  307: #if USE_OBJECT_NAME
  308:         UB     dsname[OBJECT_NAME_LENGTH]; /* Object name */
  309: #endif
  310:         void   *bufptr;          /* User buffer */
  311: } T_CMBF;
  312: 
  313: /*
  314:  * Message buffer state information     tk_ref_mbf
  315:  */
  316: typedef struct t_rmbf {
  317:         void   *exinf;           /* Extended information */
  318:         ID     wtsk;               /* Receive wait task ID */
  319:         ID     stsk;               /* Send wait task ID */
  320:         INT    msgsz;             /* Next received message size (byte) */
  321:         SZ     frbufsz;    /* Free buffer size (byte) */
  322:         INT    maxmsz;            /* Maximum length of message (byte) */
  323: } T_RMBF;
  324: 
  325: /*
  326:  * Rendezvous port creation information tk_cre_por
  327:  */
  328: typedef struct t_cpor {
  329:         void   *exinf;           /* Extended information */
  330:         ATR    poratr;            /* Port attribute */
  331:         INT    maxcmsz;   /* Maximum length of call message (byte) */
  332:         INT    maxrmsz;   /* Maximum length of replay message (byte) */
  333: #if USE_OBJECT_NAME
  334:         UB     dsname[OBJECT_NAME_LENGTH]; /* Object name */
  335: #endif
  336: } T_CPOR;
  337: 
  338: /*
  339:  * Rendezvous port state information    tk_ref_por
  340:  */
  341: typedef struct t_rpor {
  342:         void   *exinf;           /* Extended information */
  343:         ID     wtsk;               /* Call wait task ID */
  344:         ID     atsk;               /* Receive wait task ID */
  345:         INT    maxcmsz;   /* Maximum length of call message (byte) */
  346:         INT    maxrmsz;   /* Maximum length of replay message (byte) */
  347: } T_RPOR;
  348: 
  349: /*
  350:  * Interrupt handler definition information     tk_def_int
  351:  */
  352: typedef struct t_dint {
  353:         ATR    intatr;            /* Interrupt handler attribute */
  354:         FP     inthdr;             /* Interrupt handler address */
  355: } T_DINT;
  356: 
  357: /*
  358:  * Variable size memory pool creation information       tk_cre_mpl
  359:  */
  360: typedef struct t_cmpl {
  361:         void   *exinf;           /* Extended information */
  362:         ATR    mplatr;            /* Memory pool attribute */
  363:         SZ     mplsz;              /* Size of whole memory pool (byte) */
  364: #if USE_OBJECT_NAME
  365:         UB     dsname[OBJECT_NAME_LENGTH]; /* Object name */
  366: #endif
  367:         void   *bufptr;          /* User buffer */
  368: } T_CMPL;
  369: 
  370: /*
  371:  * Variable size memory pool state information  tk_ref_mpl
  372:  */
  373: typedef struct t_rmpl {
  374:         void   *exinf;           /* Extended information */
  375:         ID     wtsk;               /* Wait task ID */
  376:         SZ     frsz;               /* Total size of free area (byte) */
  377:         SZ     maxsz;              /* Size of maximum continuous free area
  378:                                    (byte) */
  379: } T_RMPL;
  380: 
  381: /*
  382:  * Fixed size memory pool state information     tk_cre_mpf
  383:  */
  384: typedef struct t_cmpf {
  385:         void   *exinf;           /* Extended information */
  386:         ATR    mpfatr;            /* Memory pool attribute */
  387:         SZ     mpfcnt;             /* Number of blocks in whole memory pool */
  388:         SZ     blfsz;              /* Fixed size memory block size (byte) */
  389: #if USE_OBJECT_NAME
  390:         UB     dsname[OBJECT_NAME_LENGTH]; /* Object name */
  391: #endif
  392:         void   *bufptr;          /* User buffer */
  393: } T_CMPF;
  394: 
  395: /*
  396:  * Fixed size memory pool state information     tk_ref_mpf
  397:  */
  398: typedef struct t_rmpf {
  399:         void   *exinf;           /* Extended information */
  400:         ID     wtsk;               /* Wait task ID */
  401:         SZ     frbcnt;             /* Number of free area blocks */
  402: } T_RMPF;
  403: 
  404: /*
  405:  * Cycle handler creation information   tk_cre_cyc
  406:  */
  407: typedef struct t_ccyc {
  408:         void   *exinf;           /* Extended information */
  409:         ATR    cycatr;            /* Cycle handler attribute */
  410:         FP     cychdr;             /* Cycle handler address */
  411:         RELTIM cyctim;         /* Cycle interval */
  412:         RELTIM cycphs;         /* Cycle phase */
  413: #if USE_OBJECT_NAME
  414:         UB     dsname[OBJECT_NAME_LENGTH]; /* Object name */
  415: #endif
  416: } T_CCYC;
  417: 
  418: /*
  419:  * Cycle handler state information      tk_ref_cyc
  420:  */
  421: typedef struct t_rcyc {
  422:         void   *exinf;           /* Extended information */
  423:         RELTIM lfttim;         /* Remaining time until next handler startup */
  424:         UINT   cycstat;  /* Cycle handler status */
  425: } T_RCYC;
  426: 
  427: /*
  428:  * Alarm handler creation information           tk_cre_alm
  429:  */
  430: typedef struct t_calm {
  431:         void   *exinf;           /* Extended information */
  432:         ATR    almatr;            /* Alarm handler attribute */
  433:         FP     almhdr;             /* Alarm handler address */
  434: #if USE_OBJECT_NAME
  435:         UB     dsname[OBJECT_NAME_LENGTH]; /* Object name */
  436: #endif
  437: } T_CALM;
  438: 
  439: /*
  440:  * Alarm handler state information      tk_ref_alm
  441:  */
  442: typedef struct t_ralm {
  443:         void   *exinf;           /* Extended information */
  444:         RELTIM lfttim;         /* Remaining time until handler startup */
  445:         UINT   almstat;  /* Alarm handler state */
  446: } T_RALM;
  447: 
  448: /*
  449:  * Version information          tk_ref_ver
  450:  */
  451: typedef struct t_rver {
  452:         UH     maker;              /* OS manufacturer */
  453:         UH     prid;               /* OS identification number */
  454:         UH     spver;              /* Specification version */
  455:         UH     prver;              /* OS product version */
  456:         UH     prno[4];    /* Product number, Product management
  457:                                    information */
  458: } T_RVER;
  459: 
  460: /*
  461:  * System state information             tk_ref_sys
  462:  */
  463: typedef struct t_rsys {
  464:         UINT   sysstat;  /* System state */
  465:         ID     runtskid;   /* ID of task in execution state */
  466:         ID     schedtskid; /* ID of the task that should be the
  467:                                    execution state */
  468: } T_RSYS;
  469: 
  470: /*
  471:  * Subsystem definition information             tk_def_ssy
  472:  */
  473: typedef struct t_dssy {
  474:         ATR    ssyatr;            /* Subsystem attribute */
  475:         PRI    ssypri;            /* Subsystem priority */
  476:         FP     svchdr;             /* Extended SVC handler address */
  477:         FP     breakfn;    /* Break function address */
  478:         FP     eventfn;    /* Event function address */
  479: } T_DSSY;
  480: 
  481: /*
  482:  * Subsystem state information          tk_ref_ssy
  483:  */
  484: typedef struct t_rssy {
  485:         PRI    ssypri;            /* Subsystem priority */
  486: } T_RSSY;
  487: 
  488: /* ------------------------------------------------------------------------ */
  489: 
  490: /*
  491:  * Device manager
  492:  */
  493: 
  494: #define L_DEVNM         8      /* Device name length */
  495: 
  496: /*
  497:  * Device attribute (ATR)
  498:  *
  499:  *      IIII IIII IIII IIII PRxx xxxx KKKK KKKK
  500:  *
  501:  *      The first 16-bit is the device-dependent attribute and
  502:  *      defined by each device.
  503:  *      The last 16-bit is the standard attribute and defined
  504:  *      like as followings.
  505:  */
  506: #define TD_PROTECT      0x8000U              /* P: Write protected */
  507: #define TD_REMOVABLE    0x4000U            /* R: Media remove enabled */
  508: 
  509: #define TD_DEVKIND      0x00ffU              /* K: Device/media type */
  510: #define TD_DEVTYPE      0x00f0U              /*    Device type */
  511: 
  512: /* Device type */
  513: #define TDK_UNDEF       0x0000U               /* Undefined/Unknown */
  514: #define TDK_DISK        0x0010U                /* Disk device */
  515: 
  516: /* Disk type */
  517: #define TDK_DISK_UNDEF  0x0010U          /* Other disks */
  518: #define TDK_DISK_RAM    0x0011U            /* RAM disk (Use main memory) */
  519: #define TDK_DISK_ROM    0x0012U            /* ROM disk (Use main memory) */
  520: #define TDK_DISK_FLA    0x0013U            /* Flash ROM, other silicon disks */
  521: #define TDK_DISK_FD     0x0014U             /* Floppy disk */
  522: #define TDK_DISK_HD     0x0015U             /* Hard disk */
  523: #define TDK_DISK_CDROM  0x0016U          /* CD-ROM */
  524: 
  525: /*
  526:  * Device open mode
  527:  */
  528: #define TD_READ         0x0001U                /* Read only */
  529: #define TD_WRITE        0x0002U                /* Write only */
  530: #define TD_UPDATE       0x0003U               /* Read and write */
  531: #define TD_EXCL         0x0100U                /* Exclusive */
  532: #define TD_WEXCL        0x0200U                /* Exclusive write */
  533: #define TD_REXCL        0x0400U                /* Exclusive read */
  534: 
  535: /*
  536:  * Device close option
  537:  */
  538: #define TD_EJECT        0x0001U                /* Media eject */
  539: 
  540: /*
  541:  * Suspend mode
  542:  */
  543: #define TD_SUSPEND      0x0001U              /* Suspend */
  544: #define TD_DISSUS       0x0002U               /* Disable suspend */
  545: #define TD_ENASUS       0x0003U               /* Enable suspend */
  546: #define TD_CHECK        0x0004U                /* Get suspend disable request count */
  547: #define TD_FORCE        0x8000U                /* Specify forced suspend */
  548: 
  549: /*
  550:  * Device information
  551:  */
  552: typedef struct t_rdev {
  553:         ATR    devatr;            /* Device attribute */
  554:         W      blksz;               /* Specific data block size (-1: Unknown) */
  555:         INT    nsub;              /* Number of subunits */
  556:         INT    subno;             /* 0: Physical device,
  557:                                    1 - nsub: Subunit number +1 */
  558: } T_RDEV;
  559: 
  560: /*
  561:  * Registration device information
  562:  */
  563: typedef struct t_ldev {
  564:         ATR    devatr;            /* Device attribute */
  565:         W      blksz;               /* Specific data block size (-1: Unknown) */
  566:         INT    nsub;              /* Number of subunits */
  567:         UB     devnm[L_DEVNM];     /* Physical device name */
  568: } T_LDEV;
  569: 
  570: /*
  571:  * Common attribute data number
  572:  *      RW: Readable (tk_rea_dev)/writable (tk_wri_dev)
  573:  *      R-: Readable (tk_rea_dev) only
  574:  */
  575: #define TDN_EVENT       (-1)  /* RW:Message buffer ID
  576:                                       for event notification */
  577: #define TDN_DISKINFO    (-2)       /* R-:Disk information */
  578: #define TDN_DISPSPEC    (-3)       /* R-:Display device specification */
  579: #define TDN_PCMCIAINFO  (-4)     /* R-:PC card information */
  580: 
  581: /*
  582:  * Device event type
  583:  */
  584: typedef enum tdevttyp {
  585:         TDE_unknown    = 0,               /* Undefined */
  586:         TDE_MOUNT      = 0x01,              /* Media insert */
  587:         TDE_EJECT      = 0x02,              /* Media eject */
  588:         TDE_ILLMOUNT   = 0x03,           /* Media incorrect insert */
  589:         TDE_ILLEJECT   = 0x04,           /* Media incorrect eject */
  590:         TDE_REMOUNT    = 0x05,            /* Media re-insert */
  591:         TDE_CARDBATLOW = 0x06,         /* Card battery low */
  592:         TDE_CARDBATFAIL        = 0x07,                /* Card battery abnormal */
  593:         TDE_REQEJECT   = 0x08,           /* Media eject request */
  594:         TDE_PDBUT      = 0x11,              /* PD button state change */
  595:         TDE_PDMOVE     = 0x12,             /* PD position move */
  596:         TDE_PDSTATE    = 0x13,            /* PD state change */
  597:         TDE_PDEXT      = 0x14,              /* PD extended event */
  598:         TDE_KEYDOWN    = 0x21,            /* Key down */
  599:         TDE_KEYUP      = 0x22,              /* Key up */
  600:         TDE_KEYMETA    = 0x23,            /* Meta key state change */
  601:         TDE_POWEROFF   = 0x31,           /* Power switch off */
  602:         TDE_POWERLOW   = 0x32,           /* Power low */
  603:         TDE_POWERFAIL  = 0x33,          /* Power abnormal */
  604:         TDE_POWERSUS   = 0x34,           /* Automatic suspend */
  605:         TDE_POWERUPTM  = 0x35,          /* Clock update */
  606:         TDE_CKPWON     = 0x41              /* Automatic power on notification */
  607: } TDEvtTyp;
  608: 
  609: /*
  610:  * Device event message format
  611:  */
  612: typedef struct t_devevt {
  613:         TDEvtTyp       evttyp;               /* Event type */
  614:         /* Information by each event type is added below */
  615: } T_DEVEVT;
  616: 
  617: /*
  618:  * Device event message format with device ID
  619:  */
  620: typedef struct t_devevt_id {
  621:         TDEvtTyp       evttyp;               /* Event type */
  622:         ID             devid;             /* Device ID */
  623:         /* Information by each event type is added below */
  624: } T_DEVEVT_ID;
  625: 
  626: /* ------------------------------------------------------------------------ */
  627: 
  628: /*
  629:  * Device registration information
  630:  */
  631: typedef struct t_ddev {
  632:         void   *exinf;           /* Extended information */
  633:         ATR    drvatr;            /* Driver attribute */
  634:         ATR    devatr;            /* Device attribute */
  635:         INT    nsub;              /* Number of subunits */
  636:         W      blksz;               /* Specific data block size (-1: Unknown) */
  637:         FP     openfn;             /* Open function */
  638:         FP     closefn;    /* Close function */
  639:         FP     execfn;             /* Execute function */
  640:         FP     waitfn;             /* Completion wait function */
  641:         FP     abortfn;    /* Abort function */
  642:         FP     eventfn;    /* Event function */
  643: } T_DDEV;
  644: 
  645: /*
  646:  * Open function:
  647:  *      ER  openfn( ID devid, UINT omode, void *exinf )
  648:  * Close function:
  649:  *      ER  closefn( ID devid, UINT option, void *exinf )
  650:  * Execute function:
  651:  *      ER  execfn( T_DEVREQ *devreq, TMO tmout, void *exinf )
  652:  * Completion wait function:
  653:  *      INT waitfn( T_DEVREQ *devreq, INT nreq, TMO tmout, void *exinf )
  654:  * Abort function:
  655:  *      ER  abortfn( ID tskid, T_DEVREQ *devreq, INT nreq, void *exinf) 
  656:  * Event function:
  657:  *      INT eventfn( INT evttyp, void *evtinf, void *exinf )
  658:  */
  659: 
  660: /*
  661:  * Driver attribute
  662:  */
  663: #define TDA_OPENREQ     0x0001U     /* Every time open/close */
  664: 
  665: /*
  666:  * Device initial setting information
  667:  */
  668: typedef struct t_idev {
  669:         ID     evtmbfid;   /* Message buffer ID for event notification */
  670: } T_IDEV;
  671: 
  672: /*
  673:  * Device request packet
  674:  *       I: Input parameter
  675:  *       O: Output parameter
  676:  */
  677: typedef struct t_devreq {
  678:         struct t_devreq        *next; /* I:Link to request packet (NULL:End) */
  679:         void   *exinf;           /* X:Extended information */
  680:         ID     devid;              /* I:Target device ID */
  681:         INT    cmd:4;             /* I:Request command */
  682:         BOOL   abort:1;  /* I:When executing abort request, TRUE */
  683:         W      start;               /* I:Start data number */
  684:         W      size;                /* I:Request size */
  685:         void   *buf;             /* I:Input/output buffer address */
  686:         W      asize;               /* O:Result size */
  687:         ER     error;              /* O:Result error */
  688: } T_DEVREQ;
  689: 
  690: /*
  691:  * Request command
  692:  */
  693: #define TDC_READ        1      /* Read request */
  694: #define TDC_WRITE       2     /* Write request */
  695: 
  696: /*
  697:  * Driver request event
  698:  */
  699: #define TDV_SUSPEND     (-1)        /* Suspend */
  700: #define TDV_RESUME      (-2) /* Resume */
  701: #define TDV_CARDEVT     1   /* PC card event (Refer card manager) */
  702: #define TDV_USBEVT      2    /* USB event     (Refer USB manager) */
  703: 
  704: /*
  705:  * System call prototype declaration
  706:  */
  707: IMPORT ID tk_cre_tsk( CONST T_CTSK *pk_ctsk );
  708: IMPORT ER tk_del_tsk( ID tskid );
  709: IMPORT ER tk_sta_tsk( ID tskid, INT stacd );
  710: IMPORT void tk_ext_tsk( void );
  711: IMPORT void tk_exd_tsk( void );
  712: IMPORT ER tk_ter_tsk( ID tskid );
  713: IMPORT ER tk_dis_dsp( void );
  714: IMPORT ER tk_ena_dsp( void );
  715: IMPORT ER tk_chg_pri( ID tskid, PRI tskpri );
  716: IMPORT ER tk_rot_rdq( PRI tskpri );
  717: IMPORT ER tk_rel_wai( ID tskid );
  718: IMPORT ID tk_get_tid( void );
  719: IMPORT ER tk_ref_tsk( ID tskid, T_RTSK *pk_rtsk );
  720: IMPORT ER tk_sus_tsk( ID tskid );
  721: IMPORT ER tk_rsm_tsk( ID tskid );
  722: IMPORT ER tk_frsm_tsk( ID tskid );
  723: IMPORT ER tk_slp_tsk( TMO tmout );
  724: IMPORT ER tk_wup_tsk( ID tskid );
  725: IMPORT INT tk_can_wup( ID tskid );
  726: IMPORT ER tk_dly_tsk( RELTIM dlytim );
  727: 
  728: #if TK_SUPPORT_REGOPS
  729: IMPORT ER tk_get_reg( ID tskid, T_REGS *pk_regs, T_EIT *pk_eit, T_CREGS *pk_cregs );
  730: IMPORT ER tk_set_reg( ID tskid, CONST T_REGS *pk_regs, CONST T_EIT *pk_eit, CONST T_CREGS *pk_cregs );
  731: #endif /* TK_SUPPORT_REGOPS */
  732: 
  733: #if NUM_COPROCESSOR > 0
  734: IMPORT ER tk_get_cpr( ID tskid, INT copno, T_COPREGS *pk_copregs);
  735: IMPORT ER tk_set_cpr(ID tskid, INT copno, CONST T_COPREGS *pk_copregs);
  736: #endif
  737: 
  738: IMPORT ID tk_cre_sem( CONST T_CSEM *pk_csem );
  739: IMPORT ER tk_del_sem( ID semid );
  740: IMPORT ER tk_sig_sem( ID semid, INT cnt );
  741: IMPORT ER tk_wai_sem( ID semid, INT cnt, TMO tmout );
  742: IMPORT ER tk_ref_sem( ID semid, T_RSEM *pk_rsem );
  743: 
  744: IMPORT ID tk_cre_mtx( CONST T_CMTX *pk_cmtx );
  745: IMPORT ER tk_del_mtx( ID mtxid );
  746: IMPORT ER tk_loc_mtx( ID mtxid, TMO tmout );
  747: IMPORT ER tk_unl_mtx( ID mtxid );
  748: IMPORT ER tk_ref_mtx( ID mtxid, T_RMTX *pk_rmtx );
  749: 
  750: IMPORT ID tk_cre_flg( CONST T_CFLG *pk_cflg );
  751: IMPORT ER tk_del_flg( ID flgid );
  752: IMPORT ER tk_set_flg( ID flgid, UINT setptn );
  753: IMPORT ER tk_clr_flg( ID flgid, UINT clrptn );
  754: IMPORT ER tk_wai_flg( ID flgid, UINT waiptn, UINT wfmode, UINT *p_flgptn, TMO tmout );
  755: IMPORT ER tk_ref_flg( ID flgid, T_RFLG *pk_rflg );
  756: 
  757: IMPORT ID tk_cre_mbx( CONST T_CMBX* pk_cmbx );
  758: IMPORT ER tk_del_mbx( ID mbxid );
  759: IMPORT ER tk_snd_mbx( ID mbxid, T_MSG *pk_msg );
  760: IMPORT ER tk_rcv_mbx( ID mbxid, T_MSG **ppk_msg, TMO tmout );
  761: IMPORT ER tk_ref_mbx( ID mbxid, T_RMBX *pk_rmbx );
  762: IMPORT ID tk_cre_mbf( CONST T_CMBF *pk_cmbf );
  763: IMPORT ER tk_del_mbf( ID mbfid );
  764: IMPORT ER tk_snd_mbf( ID mbfid, CONST void *msg, INT msgsz, TMO tmout );
  765: IMPORT INT tk_rcv_mbf( ID mbfid, void *msg, TMO tmout );
  766: IMPORT ER tk_ref_mbf( ID mbfid, T_RMBF *pk_rmbf );
  767: 
  768: IMPORT ID tk_cre_por( CONST T_CPOR *pk_cpor );
  769: IMPORT ER tk_del_por( ID porid );
  770: IMPORT INT tk_cal_por( ID porid, UINT calptn, void *msg, INT cmsgsz, TMO tmout );
  771: IMPORT INT tk_acp_por( ID porid, UINT acpptn, RNO *p_rdvno, void *msg, TMO tmout );
  772: IMPORT ER tk_fwd_por( ID porid, UINT calptn, RNO rdvno, CONST void *msg, INT cmsgsz );
  773: IMPORT ER tk_rpl_rdv( RNO rdvno, CONST void *msg, INT rmsgsz );
  774: IMPORT ER tk_ref_por( ID porid, T_RPOR *pk_rpor );
  775: 
  776: IMPORT ER tk_def_int( UINT intno, CONST T_DINT *pk_dint );
  777: IMPORT void tk_ret_int( void );
  778: 
  779: IMPORT ID tk_cre_mpl( CONST T_CMPL *pk_cmpl );
  780: IMPORT ER tk_del_mpl( ID mplid );
  781: IMPORT ER tk_get_mpl( ID mplid, SZ blksz, void **p_blk, TMO tmout );
  782: IMPORT ER tk_rel_mpl( ID mplid, void *blk );
  783: IMPORT ER tk_ref_mpl( ID mplid, T_RMPL *pk_rmpl );
  784: 
  785: IMPORT ID tk_cre_mpf( CONST T_CMPF *pk_cmpf );
  786: IMPORT ER tk_del_mpf( ID mpfid );
  787: IMPORT ER tk_get_mpf( ID mpfid, void **p_blf, TMO tmout );
  788: IMPORT ER tk_rel_mpf( ID mpfid, void *blf );
  789: IMPORT ER tk_ref_mpf( ID mpfid, T_RMPF *pk_rmpf );
  790: 
  791: IMPORT ER tk_set_utc( CONST SYSTIM *pk_tim );
  792: IMPORT ER tk_get_utc( SYSTIM *pk_tim );
  793: IMPORT ER tk_set_tim( CONST SYSTIM *pk_tim );
  794: IMPORT ER tk_get_tim( SYSTIM *pk_tim );
  795: IMPORT ER tk_get_otm( SYSTIM *pk_tim );
  796: 
  797: IMPORT ID tk_cre_cyc( CONST T_CCYC *pk_ccyc );
  798: IMPORT ER tk_del_cyc( ID cycid );
  799: IMPORT ER tk_sta_cyc( ID cycid );
  800: IMPORT ER tk_stp_cyc( ID cycid );
  801: IMPORT ER tk_ref_cyc( ID cycid, T_RCYC *pk_rcyc );
  802: 
  803: IMPORT ID tk_cre_alm( CONST T_CALM *pk_calm );
  804: IMPORT ER tk_del_alm( ID almid );
  805: IMPORT ER tk_sta_alm( ID almid, RELTIM almtim );
  806: IMPORT ER tk_stp_alm( ID almid );
  807: IMPORT ER tk_ref_alm( ID almid, T_RALM *pk_ralm );
  808: 
  809: IMPORT ER tk_ref_sys( T_RSYS *pk_rsys );
  810: IMPORT ER tk_set_pow( UINT powmode);
  811: IMPORT ER tk_ref_ver( T_RVER *pk_rver );
  812: 
  813: IMPORT ER tk_def_ssy( ID ssid, CONST T_DSSY *pk_dssy );
  814: IMPORT ER tk_ref_ssy( ID ssid, T_RSSY *pk_rssy );
  815: 
  816: IMPORT ID tk_opn_dev( CONST UB *devnm, UINT omode );
  817: IMPORT ER tk_cls_dev( ID dd, UINT option );
  818: IMPORT ID tk_rea_dev( ID dd, W start, void *buf, SZ size, TMO tmout );
  819: IMPORT ER tk_srea_dev( ID dd, W start, void *buf, SZ size, SZ *asize );
  820: IMPORT ID tk_wri_dev( ID dd, W start, CONST void *buf, SZ size, TMO tmout );
  821: IMPORT ER tk_swri_dev( ID dd, W start, CONST void *buf, SZ size, SZ *asize );
  822: IMPORT ID tk_wai_dev( ID dd, ID reqid, SZ *asize, ER *ioer, TMO tmout );
  823: IMPORT INT tk_sus_dev( UINT mode );
  824: IMPORT ID tk_get_dev( ID devid, UB *devnm );
  825: IMPORT ID tk_ref_dev( CONST UB *devnm, T_RDEV *pk_rdev );
  826: IMPORT ID tk_oref_dev( ID dd, T_RDEV *pk_rdev );
  827: IMPORT INT tk_lst_dev( T_LDEV *pk_ldev, INT start, INT ndev );
  828: IMPORT INT tk_evt_dev( ID devid, INT evttyp, void *evtinf );
  829: IMPORT ID tk_def_dev( CONST UB *devnm, CONST T_DDEV *pk_ddev, T_IDEV *pk_idev );
  830: IMPORT ER tk_ref_idv( T_IDEV *pk_idev );
  831: 
  832: #endif /* __TK_SYSCALL_H__ */