gonzui


Format: Advanced Search

tkernel_2/driver/tef_em1d/kbpd/src/accept.cbare sourcepermlink (0.08 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:  *      accept.c
   18:  *
   19:  *       KB/PD device manager
   20:  *       request handler task
   21:  */
   22: 
   23: #include "kbpd.h"
   24: 
   25: /*
   26:  * set KB/PD status (DN_KPSTAT)
   27:  */
   28: LOCAL ER setKpState( KPStat *state )
   29: {
   30:         ER     err;
   31: 
   32:         /*
   33:          * only PD position can be changed.
   34:          * (other information can not be changed.)
   35:          */
   36:         err = kpMovePointerAndNotify(state->xpos, state->ypos);
   37: 
   38:         return err;
   39: }
   40: 
   41: /*
   42:  * set meta key / button status (DN_KPMETABUT)
   43:  */
   44: LOCAL ER setKpMetaBut( MetaBut meta[2] )
   45: {
   46: const   UW        KBMET =        ES_ALPH|ES_KANA
   47:                         |ES_LSHFT|ES_RSHFT|ES_EXT|ES_CMD
   48:                         |ES_LLSHFT|ES_LRSHFT|ES_LEXT|ES_LCMD
   49:                         |ES_TLSHFT|ES_TRSHFT|ES_TEXT|ES_TCMD
   50:                         |ES_HAN|ES_KBSEL;
   51: const   UW        PDBUT =        ES_BUT|ES_BUT2;
   52: const   UW        PDMOV =        ES_NODSP;
   53: const   UW        PDSIM =        ES_PDSIM;
   54:         UW     stat, chg;
   55:         ER     err, error = E_OK;
   56:         union {
   57:                 MetaBut       stat;
   58:                 UW    uw;
   59:         } u;
   60: 
   61:         u.stat = kpMgrInfo.kpState.stat;
   62:         stat = (u.uw & *(UW*)&meta[0]) | *(UW*)&meta[1];
   63:         chg = stat ^ u.uw;
   64: 
   65:         if ( (chg & KBMET) != 0 ) {
   66:                 /* change meta key status */
   67:                 u.stat = kpMgrInfo.kpState.stat;
   68:                 u.uw ^= chg & KBMET;
   69:                 kpMgrInfo.kpState.stat = u.stat;
   70: 
   71:                 if ( (chg & (ES_ALPH|ES_KANA)) != 0 ) {
   72:                         /* change keyboard LED */
   73:                         err = kpChangeKbInputMode(kpMgrInfo.kpState.stat.mode);
   74:                         if ( err < E_OK ) error = err;
   75:                 }
   76: 
   77:                 err = kpNotifyMetaEvent();
   78:                 if ( err < E_OK ) error = err;
   79:         }
   80: 
   81:         if ( (chg & (PDBUT|PDMOV)) != 0 ) {
   82:                 /* change PD status */
   83:                 u.stat = kpMgrInfo.kpState.stat;
   84:                 u.uw ^= chg & (PDBUT|PDMOV);
   85:                 kpMgrInfo.kpState.stat = u.stat;
   86: 
   87:                 err = kpNotifyPdEvent(
   88:                         ( (chg & PDBUT) != 0 )? TDE_PDBUT: TDE_PDMOVE,
   89:                         kpMgrInfo.kpState.stat.nodsp);
   90:                 if ( err < E_OK ) error = err;
   91:         }
   92: 
   93:         if ( (chg & PDSIM) != 0 ) {
   94:                 /* change PD simulation status */
   95:                 u.stat = kpMgrInfo.kpState.stat;
   96:                 u.uw ^= chg & PDSIM;
   97:                 kpMgrInfo.kpState.stat = u.stat;
   98: 
   99:                 err = kpNotifyPdEvent(TDE_PDSTATE,
  100:                         kpMgrInfo.kpState.stat.nodsp);
  101:                 if ( err < E_OK ) error = err;
  102:         }
  103: 
  104:         return error;
  105: }
  106: 
  107: /*
  108:  * select keyboard definition
  109:  *      if datano is invalid, return FALSE.
  110:  */
  111: Inline BOOL SelKbDef( UW *kbsel, UW *kid, W datano )
  112: {
  113:         if ( datano <= DN_KEYDEF_S && datano >= DN_KEYDEF_E ) {
  114:                 *kbsel = 0;
  115:                 *kid = DN_KEYDEF_S - datano;
  116:                 return TRUE;
  117:         }
  118:         if ( datano <= DN_KEYDEF2_S && datano >= DN_KEYDEF2_E ) {
  119:                 *kbsel = 1;
  120:                 *kid = DN_KEYDEF2_S - datano;
  121:                 return TRUE;
  122:         }
  123:         return FALSE;
  124: }
  125: 
  126: /*
  127:  * keyboard definition
  128:  *       keytopofs < 0   change keytable only
  129:  *       keytabsz <= 0   change keytop code offset only
  130:  */
  131: LOCAL ER defineKeyboard( UW kbsel, UW kid,
  132:                                 W keytopofs, KeyTab *keytab, W keytabsz )
  133: {
  134:         KbDef  *kbdef = GetKbDef(kbsel, kid);
  135:         ER     err;
  136: 
  137:         if ( keytabsz <= 0 ) {
  138:                 /* change keytop code offset only */
  139:                 if ( kbdef == NULL ) { err = E_NOEXS; goto err_ret; }
  140:         } else {
  141:                 /* change keytable, too */
  142:                 if ( keytabsz < offsetof(KeyTab, kct)
  143:                   || !(keytab->keymax > 0 && keytab->keymax <= KEYMAX)
  144:                   || !(keytab->kctmax > 0 && keytab->kctmax <= KCTSEL)
  145:                   || !(keytabsz >= keytab->keymax * keytab->kctmax * sizeof(UH)
  146:                                                 + offsetof(KeyTab, kct)) )
  147:                         { err = E_PAR; goto err_ret; }
  148: 
  149:                 /* During new registration, if keytop code offset is unspecified,
  150:                    set keytop code offset to 0 */
  151:                 if ( kbdef == NULL && keytopofs < 0 ) keytopofs = 0;
  152:         }
  153: 
  154:         if ( keytabsz > 0 ) {
  155:                 /* chnage keytable */
  156:                 kbdef = Vrealloc(kbdef,
  157:                                 offsetof(KbDef, keyDef.keytab) + keytabsz);
  158:                 if ( kbdef == NULL ) { err = E_NOMEM; goto err_ret; }
  159:                 kbdef->size = offsetof(KeyDef, keytab) + keytabsz;
  160:                 SetKbDef(kbsel, kid, kbdef);
  161: 
  162:                 MEMCPY(&kbdef->keyDef.keytab, keytab, keytabsz);
  163:         }
  164: 
  165:         if ( keytopofs >= 0 ) {
  166:                 /* change keytop code offset */
  167:                 kbdef->keyDef.keytopofs = keytopofs;
  168:         }
  169: 
  170:         return E_OK;
  171: 
  172: err_ret:
  173:         DEBUG_PRINT(("defineKeyboard err = %d\n", err));
  174:         return err;
  175: }
  176: 
  177: /*
  178:  * configure keyboard definition (DN_KEYDEF)
  179:  */
  180: LOCAL ER setKeyDef( KeyDef *keydef, UW kbsel, UW kid, W datacnt )
  181: {
  182:         ER             err;
  183: 
  184:         if ( datacnt >= offsetof(KeyDef, keytab.kctmax)
  185:           && keydef->keytab.keymax == 0 ) {
  186:                 /* deletion */
  187:                 KbDef *kbdef = GetKbDef(kbsel, kid);
  188:                 if ( kbdef != NULL ) {
  189:                         SetKbDef(kbsel, kid, NULL);
  190:                         Vfree(kbdef);
  191:                 }
  192:         } else {
  193:                 /* set */
  194:                 if ( (datacnt -= offsetof(KeyDef, keytab)) < 0 )
  195:                                         return E_PAR;
  196:                 err = defineKeyboard(kbsel, kid,
  197:                                 keydef->keytopofs, &keydef->keytab, datacnt);
  198:                 if ( err < E_OK ) return err;
  199:         }
  200: 
  201:         return E_OK;
  202: }
  203: 
  204: /*
  205:  * configure keytable (DN_KEYTAB)
  206:  */
  207: LOCAL ER setKeyTab( KeyTab *table, W datacnt )
  208: {
  209:         return defineKeyboard(0, kpMgrInfo.kb.keyID, -1, table, datacnt);
  210: }
  211: 
  212: /*
  213:  * set keyboard ID (DN_KEYID)
  214:  */
  215: LOCAL ER setKeyID( UW kid )
  216: {
  217:         /* parameter check */
  218:         if ( kid < 0 || kid > MAX_KID ) return E_PAR;
  219: 
  220:         kpMgrInfo.kb.keyID = kid;
  221:         kpMgrInfo.kb.defKeyID = 2; /* fixed */
  222: 
  223:         return E_OK;
  224: }
  225: 
  226: /*
  227:  * set key mode (DN_KEYMODE)
  228:  */
  229: LOCAL ER setKeyMode( KeyMode *mode )
  230: {
  231: #define settime(time)                                   \
  232:         if ( mode->time >= 0 ) {                       \
  233:                 kpMgrInfo.kb.keyMode.time             \
  234:                         = min(mode->time, KB_MAXTIME);       \
  235:         }
  236: 
  237:         /* change key mode */
  238:         settime(ontime);
  239:         settime(offtime);
  240:         settime(invtime);
  241:         settime(contime);
  242:         settime(sclktime);
  243:         settime(dclktime);
  244:         kpMgrInfo.kb.keyMode.tslock = mode->tslock;
  245: 
  246:         return E_OK;
  247: 
  248: #undef settime
  249: }
  250: 
  251: /*
  252:  * set PD mode (DN_PDMODE)
  253:  */
  254: LOCAL ER setPdMode( PdMode *mode )
  255: {
  256: #define settime(time)                                   \
  257:         if ( mode->time >= 0 ) {                       \
  258:                 kpMgrInfo.pd.pdMode.time              \
  259:                         = min(mode->time, PD_MAXTIME);       \
  260:         }
  261: 
  262:         union {
  263:                 PdAttr        attr;
  264:                 UW    uw;
  265:         } u;
  266: 
  267:         /* change PD mode */
  268:         settime(ontime);
  269:         settime(offtime);
  270:         settime(invtime);
  271:         settime(timeout);
  272:         kpMgrInfo.pd.pdMode.attr = mode->attr;
  273: 
  274:         /* change PD scan frequency */
  275:         kpChangePdScanRate(mode->attr.rate);
  276: 
  277:         /* change sensitivity */
  278:         u.attr = mode->attr;
  279:         kpChangePdSense(u.uw & (PD_ACMSK|PD_ABS|PD_SNMSK));
  280: 
  281:         return E_OK;
  282: 
  283: #undef settime
  284: }
  285: 
  286: /*
  287:  * set PD range (DN_PDRANGE)
  288:  */
  289: LOCAL ER setPdRange( PdRange *range )
  290: {
  291:         BOOL   move;
  292:         ER     err = E_OK;
  293: 
  294:         /* parameter check */
  295:         if ( range->xmax < 0 || range->ymax < 0 )
  296:                                 return E_PAR;
  297: 
  298:         /* change PD range */
  299:         kpMgrInfo.pd.pdRange = *range;
  300: 
  301:         /* adjust pointer position */
  302:         move = kpMovePointer(kpMgrInfo.kpState.xpos, kpMgrInfo.kpState.ypos);
  303: 
  304:         if ( move ) {
  305:                 /* notify PD movement event */
  306:                 err = kpNotifyPdEvent(TDE_PDMOVE, 0);
  307:         }
  308: 
  309:         return err;
  310: }
  311: 
  312: /*
  313:  * set PD simulation speed (DN_PDSIM)
  314:  */
  315: LOCAL ER setPdSimSpeed( W simSpeed )
  316: {
  317:         /* parameter check */
  318:         if ( !(simSpeed >= 0 && simSpeed <= 15) )
  319:                                 return E_PAR;
  320: 
  321:         /* change PD simulation speed */
  322:         kpMgrInfo.pd.pdSimSpeed = simSpeed;
  323: 
  324:         if ( simSpeed == 0 ) {
  325:                 /* halt PD simulation */
  326:                 kpMgrInfo.kpState.stat.pdsim = 0;
  327:         }
  328: 
  329:         return E_OK;
  330: }
  331: 
  332: /*
  333:  * configure PD simulation temporary halt(DN_PDSIMINH)
  334:  */
  335: LOCAL ER setPdSimInh( BOOL inhibit )
  336: {
  337:         /* change PD simulation temporary halt configuration */
  338:         kpMgrInfo.pd.pdSimInh = inhibit;
  339: 
  340:         return E_OK;
  341: }
  342: 
  343: /* ------------------------------------------------------------------------ */
  344: 
  345: /*
  346:  * read data
  347:  */
  348: LOCAL INT readData( ID devid, INT datano, INT datacnt, void *buf, SDI sdi )
  349: {
  350: #define setAddrAndSize(var)     addr = &(var); size = sizeof(var)
  351: 
  352:         void   *addr;
  353:         W      size;
  354:         KbDef  *kbdef;
  355:         UW     kbsel, kid;
  356: 
  357:         /* parameter check */
  358:         if ( datacnt < 0 ) {
  359:                 DEBUG_PRINT(("readData, datacnt(%d) err\n", datacnt));
  360:                 return E_PAR;
  361:         }
  362: 
  363:         switch ( datano ) {
  364:           case DN_KPEVENT:     /* message buffer ID for event notification    (RW) */
  365:                 setAddrAndSize(kpMgrInfo.eventMbf);
  366:                 break;
  367:           case DN_KPSTAT:      /* KB/PD status                             (RW) */
  368:                 setAddrAndSize(kpMgrInfo.kpState);
  369:                 break;
  370:           case DN_KEYMAP:      /* keymap                                (R)  */
  371:                 setAddrAndSize(kpMgrInfo.kb.keyMap);
  372:                 break;
  373:           case DN_KEYTAB:      /* keytable                               (RW) */
  374:                 kbdef = GetKbDef(0, kpMgrInfo.kb.keyID);
  375:                 if ( kbdef == NULL ) return E_NOEXS;
  376:                 addr = &kbdef->keyDef.keytab;
  377:                 size = kbdef->size - offsetof(KeyDef, keytab);
  378:                 break;
  379:           case DN_KEYMODE:     /* change key mode                  (RW) */
  380:                 setAddrAndSize(kpMgrInfo.kb.keyMode);
  381:                 break;
  382:           case DN_PDMODE:      /* PD mode                           (RW) */
  383:                 setAddrAndSize(kpMgrInfo.pd.pdMode);
  384:                 break;
  385:           case DN_PDRANGE:     /* PD range            (RW) */
  386:                 setAddrAndSize(kpMgrInfo.pd.pdRange);
  387:                 break;
  388:           case DN_PDSIM:       /* PD simulation speed                (RW) */
  389:                 setAddrAndSize(kpMgrInfo.pd.pdSimSpeed);
  390:                 break;
  391:           case DN_PDSIMINH:    /* halt PD simulation temporarily (RW) */
  392:                 setAddrAndSize(kpMgrInfo.pd.pdSimInh);
  393:                 break;
  394:           case DN_KPINPUT:     /* input mailbox ID                  (R)  */
  395:                 setAddrAndSize(kpMgrInfo.dataMbx);
  396:                 break;
  397:           case DN_KEYID:       /* keyboard ID                     (RW) */
  398:                 setAddrAndSize(kpMgrInfo.kb.keyID);
  399:                 break;
  400: 
  401:           default:
  402:                 if ( SelKbDef(&kbsel, &kid, datano) ) {
  403:                         /* DN_KEYDEF keyboard definition                    (RW) */
  404:                         kbdef = GetKbDef(kbsel, kid);
  405:                         if ( kbdef == NULL ) return E_NOEXS;
  406:                         addr = &kbdef->keyDef;
  407:                         size = kbdef->size;
  408:                 } else {
  409:                         /* data number error */
  410:                         DEBUG_PRINT(("readData, datano(%d) err\n", datano));
  411:                         return E_PAR;
  412:                 }
  413:         }
  414: 
  415:         if ( datacnt > 0 ) {
  416:                 /* read data */
  417:                 if ( datacnt < size ) size = datacnt;
  418:                 MEMCPY(buf, addr, size);
  419:         }
  420:         return size;
  421: 
  422: #undef  setAddrAndSize
  423: }
  424: 
  425: EXPORT INT kpReadFn( ID devid, INT datano, INT datacnt, void *buf, SDI sdi )
  426: {
  427:         INT    er;
  428: 
  429:         Lock(&kpMgrInfo.lock);
  430:         er = readData(devid, datano, datacnt, buf, sdi);
  431:         Unlock(&kpMgrInfo.lock);
  432: 
  433:         return er;
  434: }
  435: 
  436: /*
  437:  * data write
  438:  */
  439: LOCAL INT writeData( ID devid, INT datano, INT datacnt, void *buf, SDI sdi )
  440: {
  441:         W      size;
  442:         KbDef  *kbdef;
  443:         UW     kbsel, kid;
  444:         ER     err = E_OK;
  445: 
  446:         /* parameter check */
  447:         if ( datacnt < 0 ) {
  448:                 DEBUG_PRINT(("writeData, datacnt(%d) err\n", datacnt));
  449:                 return E_PAR;
  450:         }
  451: 
  452:         kbsel = kid = 0;
  453:         switch ( datano ) {
  454:           case DN_KPEVENT:     /* message buffer ID for event notification    (RW) */
  455:                 size = sizeof(kpMgrInfo.eventMbf);
  456:                 break;
  457:           case DN_KPSTAT:      /* KB/PD status                             (RW) */
  458:                 size = sizeof(kpMgrInfo.kpState);
  459:                 break;
  460:           case DN_KEYTAB:      /* keytable                               (RW) */
  461:                 kbdef = GetKbDef(0, kpMgrInfo.kb.keyID);
  462:                 size = ( kbdef == NULL )?
  463:                                 0: kbdef->size - offsetof(KeyDef, keytab);
  464:                 break;
  465:           case DN_KEYMODE:     /* change key mode                  (RW) */
  466:                 size = sizeof(kpMgrInfo.kb.keyMode);
  467:                 break;
  468:           case DN_PDMODE:      /* PD mode                   (RW) */
  469:                 size = sizeof(kpMgrInfo.pd.pdMode);
  470:                 break;
  471:           case DN_PDRANGE:     /* PD range            (RW) */
  472:                 size = sizeof(kpMgrInfo.pd.pdRange);
  473:                 break;
  474:           case DN_PDSIM:       /* PD simulation speed                (RW) */
  475:                 size = sizeof(kpMgrInfo.pd.pdSimSpeed);
  476:                 break;
  477:           case DN_PDSIMINH:    /* halt PD simulation temporarily (RW) */
  478:                 size = sizeof(kpMgrInfo.pd.pdSimInh);
  479:                 break;
  480:           case DN_KEYID:       /* keyboard ID                     (RW) */
  481:                 size = sizeof(kpMgrInfo.kb.keyID);
  482:                 break;
  483:           case DN_KPMETABUT:   /* meta key / button status                   (W)  */
  484:                 size = sizeof(MetaBut) * 2;
  485:                 break;
  486: 
  487:           case DN_KEYMAP:      /* keymap                                (R)  */
  488:           case DN_KPINPUT:     /* input mailbox ID                  (R)  */
  489:                 /* read-only attribute data */
  490:                 DEBUG_PRINT(("writeData, read only\n"));
  491:                 return E_PAR;
  492: 
  493:           default:
  494:                 if ( SelKbDef(&kbsel, &kid, datano) ) {
  495:                         /* DN_KEYDEF keyboard definition                    (RW) */
  496:                         kbdef = GetKbDef(kbsel, kid);
  497:                         size = ( kbdef == NULL )? 0: kbdef->size;
  498:                 } else {
  499:                         /* data number error */
  500:                         DEBUG_PRINT(("writeData, datano(%d) err\n", datano));
  501:                         return E_PAR;
  502:                 }
  503:         }
  504: 
  505:         if ( datacnt > 0 ) {
  506:                 if ( datano != DN_KEYTAB
  507:                   && !(datano <= DN_KEYDEF_S && datano >= DN_KEYDEF_E)
  508:                   && !(datano <= DN_KEYDEF2_S && datano >= DN_KEYDEF2_E) ) {
  509:                         /* except for keytable, partial write is prohibited */
  510:                         if ( datacnt < size ) return E_PAR;
  511:                 }
  512: 
  513:                 /* data write */
  514:                 switch ( datano ) {
  515:                   case DN_KPEVENT:    /* message buffer ID for event notification */
  516:                         kpMgrInfo.eventMbf = *(ID*)buf;
  517:                         break;
  518:                   case DN_KPSTAT:     /* KB/PD status                          */
  519:                         err = setKpState((KPStat*)buf);
  520:                         break;
  521:                   case DN_KEYTAB:     /* keytable */
  522:                         err = setKeyTab((KeyTab*)buf, datacnt);
  523:                         break;
  524:                   case DN_KEYMODE:    /* key mode */
  525:                         err = setKeyMode((KeyMode*)buf);
  526:                         break;
  527:                   case DN_PDMODE:     /* PD mode */
  528:                         err = setPdMode((PdMode*)buf);
  529:                         break;
  530:                   case DN_PDRANGE:    /* PD range */
  531:                         err = setPdRange((PdRange*)buf);
  532:                         break;
  533:                   case DN_PDSIM:      /* PD simulation speed                */
  534:                         err = setPdSimSpeed(*(W*)buf);
  535:                         break;
  536:                   case DN_PDSIMINH:   /* halt PD simulation temporarily */
  537:                         err = setPdSimInh(*(BOOL*)buf);
  538:                         break;
  539:                   case DN_KEYID:      /* keyboard ID */
  540:                         err = setKeyID(*(UW*)buf);
  541:                         break;
  542:                   case DN_KPMETABUT:  /* meta key / button status  */
  543:                         err = setKpMetaBut((MetaBut*)buf);
  544:                         break;
  545:                   default:            /* keyboard definition */
  546:                         err = setKeyDef((KeyDef*)buf,
  547:                                                 kbsel, kid, datacnt);
  548:                 }
  549:         }
  550:         if ( err != E_OK ) {
  551:                 DEBUG_PRINT(("writeData, write err = %d\n", err));
  552:                 return err;
  553:         }
  554:         return size;
  555: }
  556: 
  557: EXPORT INT kpWriteFn( ID devid, INT datano, INT datacnt, void *buf, SDI sdi )
  558: {
  559:         INT    er;
  560: 
  561:         Lock(&kpMgrInfo.lock);
  562:         er = writeData(devid, datano, datacnt, buf, sdi);
  563:         Unlock(&kpMgrInfo.lock);
  564: 
  565:         return er;
  566: }
  567: 
  568: /* ------------------------------------------------------------------------ */
  569: 
  570: /*
  571:  * enter suspend state
  572:  */
  573: LOCAL ER suspend( void )
  574: {
  575:         ER     err, error = E_OK;
  576: 
  577:         /* I/O driver suspend request */
  578:         err = kpSendDeviceCommand(SuspendKBPD);
  579:         if ( err < E_OK ) error = err;
  580: 
  581:         /* key and button forced to up state */
  582:         err = kpKeyAndButtonForceUp();
  583:         if ( err < E_OK ) error = err;
  584: 
  585:         kpMgrInfo.suspended = TRUE;  /* suspended */
  586: 
  587: DO_DEBUG(
  588:         if ( error < E_OK ) DEBUG_PRINT(("suspend err = %d\n", error));
  589: )
  590:         return error;
  591: }
  592: 
  593: /*
  594:  * resume
  595:  */
  596: LOCAL ER resume( void )
  597: {
  598:         ER     err, error = E_OK;
  599: 
  600:         /* ignored if the system is not suspended */
  601:         if ( !kpMgrInfo.suspended ) return E_OK;
  602: 
  603:         /* I/O driver resume request */
  604:         err = kpSendDeviceCommand(ResumeKBPD);
  605:         if ( err < E_OK ) error = err;
  606: 
  607:         /* record current status in I/O driver */
  608:         err = kpSetAllDeviceStatus();
  609:         if ( err < E_OK ) error = err;
  610: 
  611:         kpMgrInfo.suspended = FALSE;  /* release suspend */
  612: 
  613: DO_DEBUG(
  614:         if ( error < E_OK ) DEBUG_PRINT(("resume err = %d\n", error));
  615: )
  616:         return error;
  617: }
  618: 
  619: /* ------------------------------------------------------------------------ */
  620: 
  621: /*
  622:  * event request processing
  623:  */
  624: EXPORT INT kpEventFn( INT evttyp, void *evtinf, SDI sdi )
  625: {
  626:         ER     err;
  627: 
  628:         Lock(&kpMgrInfo.lock);
  629: 
  630:         switch ( evttyp ) {
  631:           case TDV_SUSPEND:
  632:                 err = suspend();
  633:                 break;
  634: 
  635:           case TDV_RESUME:
  636:                 err = resume();
  637:                 break;
  638: 
  639:           default:
  640:                 /* command error */
  641:                 err = E_PAR;
  642:                 DEBUG_PRINT(("evttyp(%d) err\n", evttyp));
  643:         }
  644: 
  645:         Unlock(&kpMgrInfo.lock);
  646:         return err;
  647: }
  648: