Changeset 63 for GPL/trunk/lib32/irq.c
- Timestamp:
- Jan 3, 2006, 11:33:10 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk/lib32/irq.c
r34 r63 37 37 38 38 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 43 39 BOOL fInInterrupt = FALSE; 44 40 extern BOOL fSuspended; //pci.c 45 41 46 //****************************************************************************** 47 //****************************************************************************** 42 43 //****************************************************************************** 44 //****************************************************************************** 45 46 static IRQ_SLOT arSlots[MAX_IRQ_SLOTS] = { 0 }; 47 48 49 //****************************************************************************** 50 //****************************************************************************** 51 static 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 48 67 int request_irq(unsigned int irq, 49 68 int (near *handler)(int, void *, struct pt_regs *), 50 69 unsigned long x0, const char *x1, void *x2) 51 70 { 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) ) 77 105 { 78 break; 106 pSlot->flHandlers |= 1 << u; 107 return 0; 79 108 } 109 110 break; 80 111 } 81 return 0;82 112 } 83 113 } 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)); 85 116 return 1; 86 117 } 118 119 87 120 //****************************************************************************** 88 121 //****************************************************************************** 89 122 void free_irq(unsigned int irq, void *userdata) 90 123 { 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; 102 139 } 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 107 154 //****************************************************************************** 108 155 //****************************************************************************** 109 156 void eoi_irq(unsigned int irq) 110 157 { 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 //****************************************************************************** 169 BOOL process_interrupt(ULONG ulSlotNo, ULONG *pulIrq) 170 { 171 unsigned u; 121 172 int rc; 122 int i;173 IRQ_SLOT *pSlot; 123 174 124 175 #ifdef DEBUG … … 137 188 } 138 189 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 ) 142 197 { 143 198 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); 146 201 fInInterrupt = FALSE; 147 if(rc == 1) { 202 203 if( rc /*== 1 || pSlot->fEOI*/ ) { 204 205 *pulIrq = pSlot->irqNo; 206 // pSlot->fEOI = 0; 207 148 208 //ok, this interrupt was intended for us; notify the 16 bits MMPM/2 driver 149 209 OSS32_ProcessIRQ(); 150 eoiIrq[irq] = 0;151 210 return TRUE; 152 211 } 153 212 } 154 213 } 214 } 215 155 216 return FALSE; 156 217 } 218 219 157 220 //****************************************************************************** 158 221 //****************************************************************************** … … 161 224 return fInInterrupt; 162 225 } 226 227 163 228 //****************************************************************************** 164 229 //****************************************************************************** … … 167 232 dprintf(("disable_irq %d NOT implemented", irq)); 168 233 } 169 //****************************************************************************** 170 //****************************************************************************** 234 235 //****************************************************************************** 236 //****************************************************************************** 237 238 239
Note:
See TracChangeset
for help on using the changeset viewer.