gonzui


Format: Advanced Search

tkernel_2/kernel/tkernel/src/objname.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 T-Engine Forum at 2014/09/10.
   11:  *    Modified by TRON Forum(http://www.tron.org/) at 2015/06/01.
   12:  *
   13:  *----------------------------------------------------------------------
   14:  */
   15: 
   16: /*
   17:  *      objname.c (T-Kernel/DS)
   18:  *      Object name support
   19:  */
   20: 
   21: #include "kernel.h"
   22: #include <libstr.h>
   23: 
   24: #if USE_DBGSPT
   25: 
   26: #if USE_OBJECT_NAME
   27: LOCAL ER object_getname( UINT objtype, ID objid, UB **name)
   28: {
   29:         ER     ercd;
   30: 
   31:         switch (objtype) {
   32: #ifdef NUM_TSKID
   33:           case TN_TSK:
   34:                 {
   35:                         IMPORT ER task_getname(ID id, UB **name);
   36:                         ercd = task_getname(objid, name);
   37:                         break;
   38:                 }
   39: #endif
   40: 
   41: #ifdef NUM_SEMID
   42:           case TN_SEM:
   43:                 {
   44:                         IMPORT ER semaphore_getname(ID id, UB **name);
   45:                         ercd = semaphore_getname(objid, name);
   46:                         break;
   47:                 }
   48: #endif
   49: 
   50: #ifdef NUM_FLGID
   51:           case TN_FLG:
   52:                 {
   53:                         IMPORT ER eventflag_getname(ID id, UB **name);
   54:                         ercd = eventflag_getname(objid, name);
   55:                         break;
   56:                 }
   57: #endif
   58: 
   59: #ifdef NUM_MBXID
   60:           case TN_MBX:
   61:                 {
   62:                         IMPORT ER mailbox_getname(ID id, UB **name);
   63:                         ercd = mailbox_getname(objid, name);
   64:                         break;
   65:                 }
   66: #endif
   67: 
   68: #ifdef NUM_MBFID
   69:           case TN_MBF:
   70:                 {
   71:                         IMPORT ER messagebuffer_getname(ID id, UB **name);
   72:                         ercd = messagebuffer_getname(objid, name);
   73:                         break;
   74:                 }
   75: #endif
   76: 
   77: #ifdef NUM_PORID
   78:           case TN_POR:
   79:                 {
   80:                         IMPORT ER rendezvous_getname(ID id, UB **name);
   81:                         ercd = rendezvous_getname(objid, name);
   82:                         break;
   83:                 }
   84: #endif
   85: 
   86: #ifdef NUM_MTXID
   87:           case TN_MTX:
   88:                 {
   89:                         IMPORT ER mutex_getname(ID id, UB **name);
   90:                         ercd = mutex_getname(objid, name);
   91:                         break;
   92:                 }
   93: #endif
   94: 
   95: #ifdef NUM_MPLID
   96:           case TN_MPL:
   97:                 {
   98:                         IMPORT ER memorypool_getname(ID id, UB **name);
   99:                         ercd = memorypool_getname(objid, name);
  100:                         break;
  101:                 }
  102: #endif
  103: 
  104: #ifdef NUM_MPFID
  105:           case TN_MPF:
  106:                 {
  107:                         IMPORT ER fix_memorypool_getname(ID id, UB **name);
  108:                         ercd = fix_memorypool_getname(objid, name);
  109:                         break;
  110:                 }
  111: #endif
  112: 
  113: #ifdef NUM_CYCID
  114:           case TN_CYC:
  115:                 {
  116:                         IMPORT ER cyclichandler_getname(ID id, UB **name);
  117:                         ercd = cyclichandler_getname(objid, name);
  118:                         break;
  119:                 }
  120: #endif
  121: 
  122: #ifdef NUM_ALMID
  123:           case TN_ALM:
  124:                 {
  125:                         IMPORT ER alarmhandler_getname(ID id, UB **name);
  126:                         ercd = alarmhandler_getname(objid, name);
  127:                         break;
  128:                 }
  129: #endif
  130: 
  131:           default:
  132:                 ercd = E_PAR;
  133: 
  134:         }
  135: 
  136:         return ercd;
  137: }
  138: #endif /* USE_OBJECT_NAME */
  139: 
  140: 
  141: SYSCALL ER _td_ref_dsname( UINT type, ID id, UB *dsname )
  142: {
  143: #if USE_OBJECT_NAME
  144:         UB     *name_cb;
  145:         ER     ercd;
  146: 
  147:         ercd = object_getname(type, id, &name_cb);
  148:         if (ercd == E_OK) {
  149:                 STRNCPY((char*)dsname, (char*)name_cb, OBJECT_NAME_LENGTH);
  150:         }
  151: 
  152:         return ercd;
  153: #else
  154:         return E_NOSPT;
  155: #endif /* USE_OBJECT_NAME */
  156: }
  157: 
  158: SYSCALL ER _td_set_dsname( UINT type, ID id, CONST UB *dsname )
  159: {
  160: #if USE_OBJECT_NAME
  161:         UB     *name_cb;
  162:         ER     ercd;
  163: 
  164:         ercd = object_getname(type, id, &name_cb);
  165:         if (ercd == E_OK) {
  166:                 STRNCPY((char*)name_cb, (char*)dsname, OBJECT_NAME_LENGTH);
  167:         }
  168: 
  169:         return ercd;
  170: #else
  171:         return E_NOSPT;
  172: #endif /* USE_OBJECT_NAME */
  173: }
  174: 
  175: #endif /* USE_DBGSPT */