gonzui


Format: Advanced Search

mtkernel_3/kernel/tkernel/objname.cbare sourcepermlink (0.02 seconds)

Search this content:

    1: /*
    2:  *----------------------------------------------------------------------
    3:  *    micro T-Kernel 3.00.00
    4:  *
    5:  *    Copyright (C) 2006-2019 by Ken Sakamura.
    6:  *    This software is distributed under the T-License 2.1.
    7:  *----------------------------------------------------------------------
    8:  *
    9:  *    Released by TRON Forum(http://www.tron.org) at 2019/12/11.
   10:  *
   11:  *----------------------------------------------------------------------
   12:  */
   13: 
   14: /*
   15:  *      objname.c
   16:  *      Object name support
   17:  */
   18: 
   19: #include "kernel.h"
   20: 
   21: #if USE_DBGSPT
   22: 
   23: #if USE_OBJECT_NAME
   24: LOCAL ER knl_object_getname( UINT objtype, ID objid, UB **name)
   25: {
   26:         ER     ercd;
   27: 
   28:         switch (objtype) {
   29:           case TN_TSK:
   30:                 {
   31:                         IMPORT ER knl_task_getname(ID id, UB **name);
   32:                         ercd = knl_task_getname(objid, name);
   33:                         break;
   34:                 }
   35: 
   36: #if USE_SEMAPHORE
   37:           case TN_SEM:
   38:                 {
   39:                         IMPORT ER knl_semaphore_getname(ID id, UB **name);
   40:                         ercd = knl_semaphore_getname(objid, name);
   41:                         break;
   42:                 }
   43: #endif
   44: 
   45: #if USE_EVENTFLAG
   46:           case TN_FLG:
   47:                 {
   48:                         IMPORT ER knl_eventflag_getname(ID id, UB **name);
   49:                         ercd = knl_eventflag_getname(objid, name);
   50:                         break;
   51:                 }
   52: #endif
   53: 
   54: #if USE_MAILBOX
   55:           case TN_MBX:
   56:                 {
   57:                         IMPORT ER knl_mailbox_getname(ID id, UB **name);
   58:                         ercd = knl_mailbox_getname(objid, name);
   59:                         break;
   60:                 }
   61: #endif
   62: 
   63: #if USE_MESSAGEBUFFER
   64:           case TN_MBF:
   65:                 {
   66:                         IMPORT ER knl_messagebuffer_getname(ID id, UB **name);
   67:                         ercd = knl_messagebuffer_getname(objid, name);
   68:                         break;
   69:                 }
   70: #endif
   71: 
   72: #if USE_LEGACY_API && USE_RENDEZVOUS
   73:           case TN_POR:
   74:                 {
   75:                         IMPORT ER knl_rendezvous_getname(ID id, UB **name);
   76:                         ercd = knl_rendezvous_getname(objid, name);
   77:                         break;
   78:                 }
   79: #endif
   80: 
   81: #if USE_MUTEX
   82:           case TN_MTX:
   83:                 {
   84:                         IMPORT ER knl_mutex_getname(ID id, UB **name);
   85:                         ercd = knl_mutex_getname(objid, name);
   86:                         break;
   87:                 }
   88: #endif
   89: 
   90: #if USE_MEMORYPOOL
   91:           case TN_MPL:
   92:                 {
   93:                         IMPORT ER knl_memorypool_getname(ID id, UB **name);
   94:                         ercd = knl_memorypool_getname(objid, name);
   95:                         break;
   96:                 }
   97: #endif
   98: 
   99: #if USE_FIX_MEMORYPOOL
  100:           case TN_MPF:
  101:                 {
  102:                         IMPORT ER knl_fix_memorypool_getname(ID id, UB **name);
  103:                         ercd = knl_fix_memorypool_getname(objid, name);
  104:                         break;
  105:                 }
  106: #endif
  107: 
  108: #if USE_CYCLICHANDLER
  109:           case TN_CYC:
  110:                 {
  111:                         IMPORT ER knl_cyclichandler_getname(ID id, UB **name);
  112:                         ercd = knl_cyclichandler_getname(objid, name);
  113:                         break;
  114:                 }
  115: #endif
  116: 
  117: #if USE_ALARMHANDLER
  118:           case TN_ALM:
  119:                 {
  120:                         IMPORT ER knl_alarmhandler_getname(ID id, UB **name);
  121:                         ercd = knl_alarmhandler_getname(objid, name);
  122:                         break;
  123:                 }
  124: #endif
  125: 
  126:           default:
  127:                 ercd = E_PAR;
  128: 
  129:         }
  130: 
  131:         return ercd;
  132: }
  133: #endif /* USE_OBJECT_NAME */
  134: 
  135: 
  136: SYSCALL ER td_ref_dsname( UINT type, ID id, UB *dsname )
  137: {
  138: #if USE_OBJECT_NAME
  139:         UB     *name_cb;
  140:         ER     ercd;
  141: 
  142:         ercd = knl_object_getname(type, id, &name_cb);
  143:         if (ercd == E_OK) {
  144:                 knl_strncpy((char*)dsname, (char*)name_cb, OBJECT_NAME_LENGTH);
  145:         }
  146: 
  147:         return ercd;
  148: #else
  149:         return E_NOSPT;
  150: #endif /* USE_OBJECT_NAME */
  151: }
  152: 
  153: 
  154: SYSCALL ER td_set_dsname( UINT type, ID id, CONST UB *dsname )
  155: {
  156: #if USE_OBJECT_NAME
  157:         UB     *name_cb;
  158:         ER     ercd;
  159: 
  160:         ercd = knl_object_getname(type, id, &name_cb);
  161:         if (ercd == E_OK) {
  162:                 knl_strncpy((char*)name_cb, (char*)dsname, OBJECT_NAME_LENGTH);
  163:         }
  164: 
  165:         return ercd;
  166: #else
  167:         return E_NOSPT;
  168: #endif /* USE_OBJECT_NAME */
  169: }
  170: 
  171: #endif /* USE_DBGSPT */