⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 advioint.c

📁 pc机上经由pci连接的ata和atapi设备驱动
💻 C
📖 第 1 页 / 共 2 页
字号:
      irq_info[irqNum].useFlag[0] = 0;
      irq_info[irqNum].useFlag[1] = 0;
      irq_info[irqNum].useFlag[2] = 0;
      irq_info[irqNum].useFlag[3] = 0;
   }
}

//*************************************************************
//
// Turn on the device interrupt in use flag.
//
//*************************************************************


void int_on( void )

{

   ADP->intOnOff = 1;
   ADP->intFlag = 0;
}

//*************************************************************
//
// Turn off the device interrupt in use flag.
//
//*************************************************************


void int_off( void )

{

   ADP->intOnOff = 0;
}

//*************************************************************
//
// Clear the interrupt flag.
//
//*************************************************************


void int_clear( void )

{

   ADP->intFlag = 0;
}

//*************************************************************
//
// return the interrupt flag value.
//
//*************************************************************

int int_check( void )

{

   return ADP->intFlag;
}

//*************************************************************
//
// Common interrupt handler code.
//
// Check for interupt and increment interrupt flag.
//
// NOTE: This function is part of the interrupt handler.
//
//*************************************************************

void far int_monitor( void )

{

   //--- check the primary side interrupt status

   // read the primary side BMCR/BMIDE status...
   monBmStatus = inportb( irq_info[monIrqNum].priBmcrAddr + BM_STATUS_REG );

   // does primary side have Interrupt=1 ?
   if ( monBmStatus & BM_SR_MASK_INT )
   {
      // check primary devices 0 and 1
      for ( monNdx = 0; monNdx <= 1; monNdx ++ )
      {
         // get device pointer
         monADP = irq_info[monIrqNum].devPtr[monNdx];
         // if device pointer...
         if ( monADP )
         {
            // ...if expecting an interrupt...
            if ( monADP->intOnOff )
            {
               // ...save BMCR/BMIDE status
               monADP->bmStatus = monBmStatus;
               // ... increment interrupt flag,
               monADP->intFlag ++ ;
               // ... read ATA status,
               monADP->ataStatus = inportb( monADP->pio_base_addr1 + 7 );
            }
         }
      }
      // reset (acknowledge) the interrupt
      outportb( irq_info[monIrqNum].priBmcrAddr + BM_STATUS_REG, BM_SR_MASK_INT );
   }

   //--- check the secondary side devices

   // read the secondary side BMCR/BMIDE status...
   monBmStatus = inportb( irq_info[monIrqNum].secBmcrAddr + BM_STATUS_REG );

   // does secondary side have Interrupt=1 ?
   if ( monBmStatus & BM_SR_MASK_INT )
   {
      // check secondary devices 0 and 1
      for ( monNdx = 2; monNdx <= 3; monNdx ++ )
      {
         // get device pointer
         monADP = irq_info[monIrqNum].devPtr[monNdx];
         // if device pointer...
         if ( monADP )
         {
            // ...if expecting an interrupt...
            if ( monADP->intOnOff )
            {
               // ...save BMCR/BMIDE status
               monADP->bmStatus = monBmStatus;
               // ... increment interrupt flag,
               monADP->intFlag ++ ;
               // ... read ATA status,
               monADP->ataStatus = inportb( monADP->pio_base_addr1 + 7 );
            }
         }
      }
      // reset (acknowledge) the interrupt
      outportb( irq_info[monIrqNum].secBmcrAddr + BM_STATUS_REG, BM_SR_MASK_INT );
   }

   //--- if interrupt is shared, jump to the original handler...

   if ( irq_info[monIrqNum].irqShared )
   {

      // get the old (previous) interrupt vector
      oldVect = irq_info[monIrqNum].intVect;

      // pop return address off stack = effectively hidding
      // this function (as if it had never been called).

      asm pop bp
      asm pop ax
      asm pop ax

      // pop all regs

      asm pop   bp
      asm pop   edi
      asm pop   esi
      asm pop   ds
      asm pop   es
      asm pop   edx
      asm pop   ecx
      asm pop   ebx
      asm pop   eax

      // put cs:ip of next interrupt handler on stack

      asm push  ax            // will be bp+8
      asm push  ax            // will be bp+6
      asm push  ax
      asm push  bp
      asm push  ds
      asm mov   bp,DGROUP
      asm mov   ds,bp
      asm mov   bp, sp
      asm mov   ax, word ptr DGROUP:oldVect
      asm mov   [bp+6], ax
      asm mov   ax, word ptr DGROUP:oldVect+2
      asm mov   [bp+8], ax
      asm pop   ds
      asm pop   bp
      asm pop   ax

      // jump to the original interrupt handler

      asm retf

   }

   //--- Send End-of-Interrupt to the system interrupt controllers.

   outportb( PIC0_CTRL, PIC_EOI );
   if ( monIrqNum >= 8 )
      outportb( PIC1_CTRL, PIC_EOI );

   //--- return to interrupt function and then IRET (return from interrupt)
}

//*************************************************************
//
// Interrupt Handlers for IRQ 1 15.
//
//*************************************************************

// static void far interrupt int_handler0( void )
//
// {
//    monIrqNum = 0;
//    int_monitor();
// }

//*************************************************************

static void far interrupt int_handler1( void )

{
   monIrqNum = 1;
   int_monitor();
}

//*************************************************************

// static void far interrupt int_handler2( void )
//
// {
//    monIrqNum = 2;
//    int_monitor();
// }

//*************************************************************

static void far interrupt int_handler3( void )

{
   monIrqNum = 3;
   int_monitor();
}

//*************************************************************

static void far interrupt int_handler4( void )

{
   monIrqNum = 4;
   int_monitor();
}

//*************************************************************

static void far interrupt int_handler5( void )

{
   monIrqNum = 5;
   int_monitor();
}

//*************************************************************

static void far interrupt int_handler6( void )

{
   monIrqNum = 6;
   int_monitor();
}

//*************************************************************

static void far interrupt int_handler7( void )

{
   monIrqNum = 7;
   int_monitor();
}

//*************************************************************

static void far interrupt int_handler8( void )

{
   monIrqNum = 8;
   int_monitor();
}

//*************************************************************

static void far interrupt int_handler9( void )

{
   monIrqNum = 9;
   int_monitor();
}

//*************************************************************

static void far interrupt int_handler10( void )

{
   monIrqNum = 10;
   int_monitor();
}

//*************************************************************

static void far interrupt int_handler11( void )

{
   monIrqNum = 11;
   int_monitor();
}

//*************************************************************

static void far interrupt int_handler12( void )

{
   monIrqNum = 12;
   int_monitor();
}

//*************************************************************

static void far interrupt int_handler13( void )

{
   monIrqNum = 13;
   int_monitor();
}

//*************************************************************

static void far interrupt int_handler14( void )

{
   monIrqNum = 14;
   int_monitor();
}

//*************************************************************

static void far interrupt int_handler15( void )

{
   monIrqNum = 15;
   int_monitor();
}

// end advioint.c

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -