Changeset 63 for GPL/trunk/lib32/irq.c


Ignore:
Timestamp:
Jan 3, 2006, 11:33:10 PM (20 years ago)
Author:
vladest
Message:

(Patches by Ruediger Ihle)
Support for IRQs > 15
Fixed resource manager registration
Fixed crash on APM suspend/resume and system shutdown

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk/lib32/irq.c

    r34 r63  
    3737
    3838
    39 static IRQHANDLER_INFO irqHandlers[MAX_IRQS][MAX_SHAREDIRQS] = {0};
    40 static ULONG           nrIrqHandlers[MAX_IRQS] = {0};
    41 static ULONG           eoiIrq[MAX_IRQS] = {0};
    42 
    4339BOOL fInInterrupt = FALSE;
    4440extern BOOL fSuspended; //pci.c
    4541
    46 //******************************************************************************
    47 //******************************************************************************
     42
     43//******************************************************************************
     44//******************************************************************************
     45
     46static IRQ_SLOT         arSlots[MAX_IRQ_SLOTS] = { 0 };
     47
     48
     49//******************************************************************************
     50//******************************************************************************
     51static IRQ_SLOT *FindSlot(unsigned irq)
     52{
     53  IRQ_SLOT      *pSlot;
     54
     55  for( pSlot = arSlots; pSlot != &arSlots[MAX_IRQ_SLOTS]; pSlot++ )
     56  {
     57    if( pSlot->irqNo == irq )   return pSlot;
     58  }
     59
     60  return NULL;
     61}
     62
     63
     64//******************************************************************************
     65//******************************************************************************
     66
    4867int request_irq(unsigned int irq,
    4968                int (near *handler)(int, void *, struct pt_regs *),
    5069                unsigned long x0, const char *x1, void *x2)
    5170{
    52     int i;
    53 
    54     if(RMRequestIRQ(hResMgr, irq, (x0 & SA_SHIRQ) ? TRUE : FALSE) == FALSE) {
    55         dprintf(("RMRequestIRQ failed for irq %d", irq));
    56         return 0;
    57     }
    58 
    59     if(irq > 0xF) {
    60         DebugInt3();
    61         return 0;
    62     }
    63 
    64     for(i=0;i<MAX_SHAREDIRQS;i++)
    65     {
    66         if(irqHandlers[irq][i].handler == 0)
    67         {
    68             irqHandlers[irq][i].handler = handler;
    69             irqHandlers[irq][i].x0      = x0;
    70             irqHandlers[irq][i].x1      = (char *)x1;
    71             irqHandlers[irq][i].x2      = x2;
    72             nrIrqHandlers[irq]++;
    73 
    74             if(nrIrqHandlers[irq] == 1)
    75             {
    76                 if(RMSetIrq(irq, (x0 & SA_SHIRQ) ? TRUE : FALSE, &oss_process_interrupt) == FALSE)
     71    IRQ_SLOT    *pSlot = FindSlot(irq);
     72    unsigned    u, uSlotNo = (unsigned)-1;
     73  if( !pSlot )
     74  {
     75    // find empty slot
     76    for( uSlotNo = 0; uSlotNo < MAX_IRQ_SLOTS; uSlotNo++ )
     77    {
     78      if( arSlots[uSlotNo].flHandlers == 0 )
     79      {
     80        pSlot = &arSlots[uSlotNo];      break;
     81      }
     82    }
     83
     84    }
     85
     86  if( pSlot )
     87  {
     88    if(RMRequestIRQ(/*hResMgr,*/ irq, (x0 & SA_SHIRQ) != 0) == FALSE) {
     89        dprintf(("RMRequestIRQ failed for irq %d", irq));
     90//      return 0;
     91    }
     92
     93    for( u = 0; u < MAX_SHAREDIRQS; u++ )
     94    {
     95      if( pSlot->irqHandlers[u].handler == NULL )
     96      {
     97          pSlot->irqNo = irq;
     98        pSlot->irqHandlers[u].handler = handler;
     99        pSlot->irqHandlers[u].x0 = x0;
     100        pSlot->irqHandlers[u].x1 = (char *)x1;
     101        pSlot->irqHandlers[u].x2 = x2;
     102
     103        if( pSlot->flHandlers != 0 ||
     104            ALSA_SetIrq(irq, uSlotNo, (x0 & SA_SHIRQ) != 0) )
    77105                {
    78                     break;
     106          pSlot->flHandlers |= 1 << u;
     107          return 0;
    79108                }
     109
     110        break;
    80111            }
    81             return 0;
    82112        }
    83113    }
    84     dprintf(("request_irq: Unable to register irq handler for irq %d\n", irq));
     114
     115  dprintf(("request_irq: Unable to register irq handler for irq %d\n", irq));
    85116    return 1;
    86117}
     118
     119
    87120//******************************************************************************
    88121//******************************************************************************
    89122void free_irq(unsigned int irq, void *userdata)
    90123{
    91     int i;
    92 
    93     for(i=0;i<MAX_SHAREDIRQS;i++)
    94     {
    95         if(irqHandlers[irq][i].x2 == userdata) {
    96             irqHandlers[irq][i].handler = 0;
    97             irqHandlers[irq][i].x0      = 0;
    98             irqHandlers[irq][i].x1      = 0;
    99             irqHandlers[irq][i].x2      = 0;
    100             if(--nrIrqHandlers[irq] == 0) {
    101                 RMFreeIrq(irq);
     124  unsigned      u;
     125  IRQ_SLOT      *pSlot;
     126
     127  if( (pSlot = FindSlot(irq)) != NULL )
     128  {
     129    for( u = 0; u < MAX_SHAREDIRQS; u++ )
     130    {
     131      if( pSlot->irqHandlers[u].x2 == userdata )
     132      {
     133        pSlot->flHandlers &= ~(1 << u);
     134        if( pSlot->flHandlers == 0 )
     135        {
     136          ALSA_FreeIrq(pSlot->irqNo);
     137          pSlot->irqNo = 0;
     138//        pSlot->fEOI = 0;
    102139            }
    103             break;
    104         }
    105     }
    106 }
     140
     141        pSlot->irqHandlers[u].handler = NULL;
     142        pSlot->irqHandlers[u].x0 = 0;
     143        pSlot->irqHandlers[u].x1 = NULL;
     144        pSlot->irqHandlers[u].x2 = NULL;
     145
     146        return;
     147
     148      }
     149    }
     150}
     151}
     152
     153
    107154//******************************************************************************
    108155//******************************************************************************
    109156void eoi_irq(unsigned int irq)
    110157{
    111     if(irq > 0xff) {
    112         DebugInt3();
    113         return;
    114     }
    115     eoiIrq[irq]++;
    116 }
    117 //******************************************************************************
    118 //******************************************************************************
    119 BOOL oss_process_interrupt(int irq)
    120 {
     158  (void)irq;
     159/*
     160  IRQ_SLOT      *pSlot = FindSlot(irq);
     161
     162  if( pSlot )   pSlot->fEOI = 1;
     163*/
     164}
     165
     166
     167//******************************************************************************
     168//******************************************************************************
     169BOOL process_interrupt(ULONG ulSlotNo, ULONG *pulIrq)
     170{
     171  unsigned      u;
    121172 int rc;
    122  int  i;
     173  IRQ_SLOT      *pSlot;
    123174
    124175#ifdef DEBUG
     
    137188    }
    138189
    139     for(i=0;i<MAX_SHAREDIRQS;i++)
    140     {
    141         if(irqHandlers[irq][i].handler != 0)
     190  if( ulSlotNo < MAX_IRQ_SLOTS )
     191    {
     192    pSlot = &arSlots[ulSlotNo];
     193
     194    for( u = 0; u < MAX_SHAREDIRQS; u++ )
     195    {
     196      if( pSlot->irqHandlers[u].handler )
    142197        {
    143198            fInInterrupt = TRUE;
    144             rc = irqHandlers[irq][i].handler(irq, irqHandlers[irq][i].x2, 0);
    145             //rc = (eoiIrq[irq] > 0);
     199        rc = pSlot->irqHandlers[u].handler(pSlot->irqNo,
     200                                           pSlot->irqHandlers[u].x2, 0);
    146201            fInInterrupt = FALSE;
    147             if(rc == 1) {
     202
     203        if( rc /*== 1 || pSlot->fEOI*/ ) {
     204
     205            *pulIrq = pSlot->irqNo;
     206//          pSlot->fEOI = 0;
     207
    148208                //ok, this interrupt was intended for us; notify the 16 bits MMPM/2 driver
    149209                OSS32_ProcessIRQ();
    150                 eoiIrq[irq] = 0;
    151210                return TRUE;
    152211            }
    153212        }
    154213    }
     214    }
     215
    155216    return FALSE;
    156217}
     218
     219
    157220//******************************************************************************
    158221//******************************************************************************
     
    161224    return fInInterrupt;
    162225}
     226
     227
    163228//******************************************************************************
    164229//******************************************************************************
     
    167232    dprintf(("disable_irq %d NOT implemented", irq));
    168233}
    169 //******************************************************************************
    170 //******************************************************************************
     234
     235//******************************************************************************
     236//******************************************************************************
     237
     238
     239
Note: See TracChangeset for help on using the changeset viewer.