Advertisement
Guest User

Untitled

a guest
Mar 30th, 2010
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.04 KB | None | 0 0
  1. int smsc911x_irq_handler(_kernel_swi_regs *r, void *pw)
  2. {
  3.         // if the private word didnt math then bail out
  4.         if (pw != local_pw)
  5.         {
  6.             // interrup was not for me.
  7.             return 1;
  8.         }
  9.         ws_t *ws = local_pw;
  10.         // read the status and interrupt registers.
  11.         uint32_t intsts = smsc911x_reg_read(ws->dev, INT_STS);
  12.         uint32_t inten = smsc911x_reg_read(ws->dev, INT_EN);
  13.  
  14.         // if there was no interrupt status bits set then that one wasnt for us
  15.         if (intsts == 0)
  16.         {
  17.             return 1;
  18.         }
  19.  
  20.         // disable irq interrupts
  21.         smsc911x_reg_write(ws->dev, INT_EN,0);
  22.  
  23.         ws->irq_count++;
  24.  
  25.         //int irqs_disabled = _kernel_irqs_disabled();
  26.         // if interrupts are enabled then disable them
  27.         if (!irqs_disabled)
  28.         {
  29.             _kernel_irqs_off();
  30.         }
  31.  
  32.         // clear all interrupts because we are going to handle them here
  33.         // we already have copies of the status registers so we're good
  34.  
  35.         smsc911x_reg_write(ws->dev, INT_STS, 0xFFFFFFFF);
  36.         // call the device clear irq delegate if one has been set by the HAL
  37.         if (ws->nic_device->dev.ClearIRQ != NULL)
  38.         {
  39.             ws->nic_device->dev.ClearIRQ();
  40.         }
  41.         // clear the irq request in the HAL. MUST do this or we get a crash
  42.         _swix(OS_Hardware, _IN(0) | _INR(8,9), ws->nic_device->dev.devicenumber\
  43. &~(1u<<31), 0, EntryNo_HAL_IRQClear);
  44.         // handle the rx case
  45.         if (intsts & inten & INT_STS_RSFL_)
  46.         {
  47.  
  48.             // for debug reasons count the number of rx interrupts
  49.             ws->irq_count_processed++;
  50.             // call the rx poll routine
  51.             read_packet((void *)local_pw);
  52.         }
  53.         //// if interrupts were on then we should re-enable them
  54.         if (!irqs_disabled)
  55.         {
  56.             _kernel_irqs_on();
  57.         }
  58.     // re-enable interrupts
  59.         smsc911x_reg_write(ws->dev, INT_EN,inten);
  60.         // we handled this so return 0.
  61.         return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement