home *** CD-ROM | disk | FTP | other *** search
/ Phoenix Heaven Sunny 2 / APPARE2.BIN / oh_towns / his / source / hisl11.c < prev    next >
C/C++ Source or Header  |  1995-06-20  |  2KB  |  78 lines

  1. /***********************************************************************
  2.  *                                                                     *
  3.  *                    ハードウェア割り込み支援ライブラリ               *
  4.  *                                                                     *
  5.  *        1995.6.12                                  by ちょもらんま   *
  6.  *                                                                     *
  7.  ***********************************************************************/
  8.  
  9. #include <hisinner.h>
  10.  
  11. /************************ 割り込みハンドラの解除 ***********************/
  12.  
  13. int HIS_detachHandler( int intnum )
  14. {
  15.     intInfo *nowInfo,*preInfo;
  16.  
  17.     /*--------------- 割り込み番号は正常か? --------------*/
  18.     if( HIS_checkIntNumber( intnum ) == HIS_IllegalIntNumber )
  19.     {
  20.         return HIS_IllegalIntNumber;
  21.     }
  22.  
  23.     /*--------- 割り込みハンドラは登録されているか? ------*/
  24.     if( ( preInfo = topIntInfo[ intnum ] )== NULL )
  25.     {
  26.         return HIS_NoHandler;
  27.     }
  28.  
  29.     /*----------------- 割り込みの一時禁止 ----------------*/
  30.     HIS_disableAllInt();
  31.  
  32.     /*----------------- 登録前の状態に戻す ----------------*/
  33.     HIS_disableInterrupt( intnum );
  34.  
  35.     nowInfo = preInfo->nextInfo;
  36.     if( nowInfo == NULL )
  37.     {
  38.         /*------------ 先客がいない場合 -----------*/
  39.         nowInfo = preInfo;
  40.         /* リアル側ハンドラ復帰     */
  41.         _setrvect( intnum + HardVector , nowInfo->RealHandler );
  42.         /* ネイティブ側ハンドラ復帰 */
  43.         _setpvect( intnum + HardVector , nowInfo->NativeHandler );
  44.         topIntInfo[ intnum ] = NULL;
  45.     }
  46.     else
  47.     {
  48.         /*------------ 先客がいる場合 -----------*/
  49.         while( nowInfo->nextInfo != NULL )
  50.         {
  51.             preInfo = nowInfo;
  52.             nowInfo = nowInfo->nextInfo;
  53.         }
  54.         userHandler[ intnum ].handlerAdr
  55.                            = (_Far void(*)())nowInfo->NativeHandler;
  56.         userHandler[ intnum ].dataSegment = nowInfo->dataSegment;
  57.         preInfo->nextInfo = NULL;
  58.     }
  59.  
  60.     /* IMR復帰 */
  61.     if( nowInfo->IMR == HIS_intUnmasked )
  62.     {
  63.         HIS_enableInterrupt( intnum );
  64.     }
  65.     else
  66.     {
  67.         HIS_disableInterrupt( intnum );
  68.     }
  69.  
  70.     /*-------------- ハンドラ等の退避先を開放 -------------*/
  71.     free( nowInfo );
  72.  
  73.     /*------------------- 割り込みの許可 ------------------*/
  74.     HIS_enableAllInt();
  75.  
  76.     return HIS_NoError;
  77. }
  78.