gonzui


Format: Advanced Search

t2ex/t2ex_source/t2ex/load/src/service.cbare sourcepermlink (0.01 seconds)

Search this content:

    1: /*
    2:  *----------------------------------------------------------------------
    3:  *    T2EX Software Package
    4:  *
    5:  *    Copyright 2012 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 2012/12/12.
   10:  *    Modified by TRON Forum(http://www.tron.org/) at 2015/06/04.
   11:  *
   12:  *----------------------------------------------------------------------
   13:  */
   14: /*
   15:  * This software package is available for use, modification, 
   16:  * and redistribution in accordance with the terms of the attached 
   17:  * T-License 2.x.
   18:  * If you want to redistribute the source code, you need to attach 
   19:  * the T-License 2.x document.
   20:  * There's no obligation to publish the content, and no obligation 
   21:  * to disclose it to the TRON Forum if you have modified the 
   22:  * software package.
   23:  * You can also distribute the modified source code. In this case, 
   24:  * please register the modification to T-Kernel traceability service.
   25:  * People can know the history of modifications by the service, 
   26:  * and can be sure that the version you have inherited some 
   27:  * modification of a particular version or not.
   28:  *
   29:  *    http://trace.tron.org/tk/?lang=en
   30:  *    http://trace.tron.org/tk/?lang=ja
   31:  *
   32:  * As per the provisions of the T-License 2.x, TRON Forum ensures that 
   33:  * the portion of the software that is copyrighted by Ken Sakamura or 
   34:  * the TRON Forum does not infringe the copyrights of a third party.
   35:  * However, it does not make any warranty other than this.
   36:  * DISCLAIMER: TRON Forum and Ken Sakamura shall not be held
   37:  * responsible for any consequences or damages caused directly or
   38:  * indirectly by the use of this software package.
   39:  *
   40:  * The source codes in bsd_source.tar.gz in this software package are 
   41:  * derived from NetBSD or OpenBSD and not covered under T-License 2.x.
   42:  * They need to be changed or redistributed according to the 
   43:  * representation of each source header.
   44:  */
   45: 
   46: /*
   47:  *      service.c
   48:  *
   49:  *       T2EX: program load functions
   50:  *       manager initialization
   51:  */
   52: 
   53: #include <basic.h>
   54: #include <tk/tkernel.h>
   55: #include <t2ex/load.h>
   56: #include "ifload.h"
   57: #include "service.h"
   58: #include "pminfo.h"
   59: 
   60: IMPORT ER ChkT2EXLevel( void );
   61: 
   62: /* Manager lock */
   63: EXPORT  FastLock pmLock;
   64: 
   65: /*
   66:  * Service call entries
   67:  */
   68: LOCAL   ER        svcEntry(void* para, W fn)
   69: {
   70:         ER     er;
   71: 
   72:         er = ChkT2EXLevel();
   73:         if (er < E_OK) {
   74:                 return er;
   75:         }
   76: 
   77:         switch (fn) {
   78:         case PM_PM_LOAD_FN: {
   79:                 PM_PM_LOAD_PARA* p = (PM_PM_LOAD_PARA*)para;
   80:                 er = _pm_load(p->prog, p->attr, p->entry);
   81:                 break;
   82:         }
   83:         case PM_PM_LOADSPG_FN: {
   84:                 PM_PM_LOADSPG_PARA* p = (PM_PM_LOADSPG_PARA*)para;
   85:                 er = _pm_loadspg(p->prog, p->ac, p->av);
   86:                 break;
   87:         }
   88:         case PM_PM_STATUS_FN: {
   89:                 PM_PM_STATUS_PARA* p = (PM_PM_STATUS_PARA*)para;
   90:                 er = _pm_status(p->progid, p->status);
   91:                 break;
   92:         }
   93:         case PM_PM_UNLOAD_FN: {
   94:                 PM_PM_UNLOAD_PARA* p = (PM_PM_UNLOAD_PARA*)para;
   95:                 er = _pm_unload(p->progid);
   96:                 break;
   97:         }
   98:         default:
   99:                 er = E_RSFN;
  100:                 break;
  101:         }
  102: 
  103:         return er;
  104: }
  105: 
  106: /*
  107:  * Program load functions entry
  108:  */
  109: EXPORT  ER       pm_main(INT ac, UB* av[])
  110: {
  111:         ER     er;
  112:         T_DSSY dssy;
  113:         INT    maxprog;
  114: 
  115:         if (ac < 0) {
  116:                 /* Stop other tasks from executing SVC */
  117:                 Lock(&pmLock);
  118: 
  119:                 /* Unregister subsystem */
  120:                 tk_def_ssy(PM_SVC, NULL);
  121: 
  122:                 /* Cleanup control block */
  123:                 pmCleanupInfo();
  124: 
  125:                 /* Delete lock */
  126:                 DeleteLock(&pmLock);
  127:                 return E_OK;
  128:         }
  129: 
  130:         /* Create lock */
  131:         er = CreateLock(&pmLock, "pmLk");
  132:         if ( er < E_OK ) {
  133:                 goto err_ret0;
  134:         }
  135: 
  136:         /* Initialize control block */
  137:         er = tk_get_cfn((UB*)"PmMaxProg", &maxprog, 1);
  138:         if ( er <= 0 || maxprog < 0 ) maxprog = DEFAULT_MAX_PROG;
  139: 
  140:         er = pmInitInfo(maxprog);
  141:         if ( er < E_OK ) {
  142:                 goto err_ret1;
  143:         }
  144: 
  145:         /* Register subsystem */
  146:         dssy.ssyatr    = TA_NULL;
  147:         dssy.ssypri    = PM_PRI;
  148:         dssy.svchdr    = (FP)svcEntry;
  149:         dssy.breakfn   = NULL;
  150:         dssy.startupfn = NULL;
  151:         dssy.cleanupfn = NULL;
  152:         dssy.eventfn   = NULL;
  153:         dssy.resblksz  = 0;
  154:         er = tk_def_ssy(PM_SVC, &dssy);
  155:         if ( er < E_OK ) {
  156:                 goto err_ret2;
  157:         }
  158: 
  159:         return E_OK;
  160: 
  161: err_ret2:
  162:         pmCleanupInfo();
  163: err_ret1:
  164:         DeleteLock(&pmLock);
  165: err_ret0:
  166:         return er;
  167: }