Changeset 547 for GPL/trunk/drv32


Ignore:
Timestamp:
Mar 16, 2011, 10:31:12 PM (15 years ago)
Author:
David Azarewicz
Message:

APIC interrupt transition fixes

Location:
GPL/trunk/drv32
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk/drv32/idc.c

    r493 r547  
    3434#include <irqos2.h>
    3535#include <stacktoflat.h>
     36#include <dbgos2.h>
    3637
    3738//16:32 address of 16 bits pdd idc handler
     
    3940extern "C" int pcm_device;
    4041WORD32 OSS32IDC(ULONG cmd, PIDC32_PACKET pPacket);
     42extern "C" BOOL fRewired; //pci.c
    4143
    4244//packet pointer must reference a structure on the stack
     
    4951    ULONG  oldfileid;
    5052    OSSRET rc;
     53
     54        if (fRewired) {
     55                fRewired = FALSE;
     56                rprintf(("AlsaIDC: Resuming"));
     57                OSS32_APMResume();
     58        }
    5159
    5260    //Sets file id in current task structure
  • GPL/trunk/drv32/irq.cpp

    r545 r547  
    4646};
    4747
     48extern DBGINT DbgInt;
     49
    4850//******************************************************************************
    4951BOOL ALSA_SetIrq(ULONG ulIrq, ULONG ulSlotNo, BOOL fShared)
     
    6466
    6567    if (rc != 0) {                    // If error ...
    66        dprintf(("ERROR: RMSetIrq %d %d %x - failed to set shared - trying exclusive!!", ulIrq, fShared, ulSlotNo));
     68       rprintf(("ERROR: RMSetIrq %d %d %x - failed to set shared - trying exclusive!!", ulIrq, fShared, ulSlotNo));
    6769        rc = DevIRQSet((WORD16) *pISR[ulSlotNo],
    6870                       (WORD16)ulIrq,
     
    7173
    7274    if (rc != 0) {                    // If error ...
    73         dprintf(("ERROR: RMSetIrq %d %d %x FAILED shared and exclusive mode!!", ulIrq, fShared, ulSlotNo));
     75        rprintf(("ERROR: RMSetIrq %d %d %x FAILED shared and exclusive mode!!", ulIrq, fShared, ulSlotNo));
    7476        DebugInt3();
    7577        return FALSE;
     
    9698   sti();
    9799   if( process_interrupt(ulSlotNo, &ulIrqNo) ) {
     100                DbgInt.ulIntServiced[DbgInt.usState]++;
    98101       // We've cleared all service requests.
    99102       // Clear (disable) Interrupts, Send EOI
     
    104107       return TRUE;
    105108   }
     109        DbgInt.ulIntUnserviced[DbgInt.usState]++;
    106110   // Indicate Interrupt not serviced by setting carry flag before
    107111   // returning to OS/2 kernel.  OS/2 will then shut down the interrupt!
  • GPL/trunk/drv32/read.cpp

    r501 r547  
    1616
    1717}
     18
     19extern DBGINT DbgInt;
    1820
    1921ULONG StratRead(RP __far* _rp)
  • GPL/trunk/drv32/rmcalls.h

    r32 r547  
    6464APIRET CDECL RMDeallocResource(HDRIVER hDriver, HRESOURCE hResource);
    6565
    66 APIRET CDECL RMGetNodeInfo(RMHANDLE RMHandle,
     66APIRET CDECL RMModifyResources(HDRIVER hDriver, HADAPTER hAdapter, USHORT ModifyAction, HRESOURCE hResource);
     67
     68APIRET CDECL RMGetNodeInfo(RMHANDLE RMHandle,
    6769                           FARPTR16 pNodeInfo,
    6870                           USHORT   BufferSize);
    6971
    70 APIRET CDECL RMDevIDToHandleList(RMHANDLE RMHandle, 
     72APIRET CDECL RMDevIDToHandleList(RMHANDLE RMHandle,
    7173                                 DEVID DeviceID,
    7274                                 DEVID FunctionID,
  • GPL/trunk/drv32/rmhelp.cpp

    r545 r547  
    4040ULONG                   RMFlags;
    4141
    42 static HDRIVER          DriverHandle = (HDRIVER)-1;
    43 static ULONG            ctResHandles = 0;
    44 static HRESOURCE        arResHandles[MAX_RESHANDLES];
     42static HDRIVER DriverHandle = (HDRIVER)-1;
     43static HDEVICE DeviceHandle = 0;
     44static HADAPTER AdapterHandle = 0;
     45static ULONG ctResHandles = 0;
     46static HRESOURCE arResHandles[MAX_RESHANDLES];
    4547
    4648
     
    8082     rc = RMCreateDriver( FlatToSel((ULONG)&DriverStruct), FlatToSel((ULONG)&hDriver) );
    8183
    82      dprintf(("RMCreateDriver rc = %d\n", rc));
    83 
    8484     if( rc == RMRC_SUCCESS )   DriverHandle = hDriver;
     85     dprintf(("RMCreateDriver rc=%d DriverHandle=%x", rc, DriverHandle));
    8586  }
    8687
     
    113114  }
    114115
    115   dprintf(("RMAllocResource[%d] IO rc = %d\n", ctResHandles, rc));
     116  dprintf(("RMAllocResource[%d] IO rc = %d", ctResHandles, rc));
    116117
    117118  return FALSE;
     
    141142  }
    142143
    143   dprintf(("RMAllocResource[%d] MEM rc = %d\n", ctResHandles, rc));
     144  dprintf(("RMAllocResource[%d] MEM rc = %d", ctResHandles, rc));
    144145
    145146  return rc == 0;
     
    152153{
    153154        RESOURCESTRUCT  Resource;
    154         HRESOURCE               hres;
     155        HRESOURCE               hRes;
    155156        APIRET          rc;
    156157
     
    161162
    162163        rc = RMAllocResource(DriverHandle,                      // Handle to driver.
    163                        FlatToSel((ULONG)&hres),                 // OUT:  "allocated" resource node handle
     164                       FlatToSel((ULONG)&hRes),                 // OUT:  "allocated" resource node handle
    164165                       FlatToSel((ULONG)&Resource));    // Resource to allocate.
    165166
     167
    166168        if (rc == 0) {
    167                 if (ctResHandles < MAX_RESHANDLES ) arResHandles[ctResHandles++] = hres;
    168                 *phRes = hres;
     169                *phRes = hRes;
     170                if (DeviceHandle) {
     171                        dprintf(("RMRequestIRQ: DriverHandle=%x DeviceHandle=%x hRes=%x", DriverHandle, DeviceHandle, hRes));
     172                        rc = RMModifyResources(DriverHandle, DeviceHandle, RM_MODIFY_ADD, hRes);
     173                } else {
     174                        if (ctResHandles < MAX_RESHANDLES ) arResHandles[ctResHandles++] = hRes;
     175                }
    169176        }
    170177
    171         dprintf(("RMAllocResource[%d] IRQ rc = %d\n", ctResHandles, rc));
     178        dprintf(("RMAllocResource[%d] IRQ=%d rc=%d", ctResHandles, ulIrq, rc));
    172179
    173180        return rc == 0;
     
    178185BOOL RMDeallocateIRQ(HRESOURCE hRes)
    179186{
    180         ULONG ulI;
    181 
    182         RMDeallocResource(DriverHandle, hRes);
    183 
    184         for (ulI=0; ulI<ctResHandles; ulI++) {
    185                 if (arResHandles[ulI] == hRes) {
    186                         arResHandles[ulI] = 0;
    187                         break;
    188                 }               
    189         }
    190 
    191         return 0;
    192 }
    193 
    194 
    195 //******************************************************************************
    196 //******************************************************************************
    197 VOID RMDone(ULONG DevID)
     187        APIRET rc;
     188
     189        dprintf(("RMDeallocateIRQ: DriverHandle=%x DeviceHandle=%x hRes=%x", DriverHandle, DeviceHandle, hRes));
     190        rc = RMModifyResources(DriverHandle, DeviceHandle, RM_MODIFY_DELETE, hRes);
     191
     192        return rc == 0;
     193}
     194
     195
     196//******************************************************************************
     197//******************************************************************************
     198VOID RMDone(ULONG DevID, PHADAPTER phAdapter, PHDEVICE phDevice)
    198199{
    199200  APIRET        rc;
     
    205206  char          szDeviceName[128];
    206207  char          szMixerName[64];
    207   struct
    208   {
     208  struct {
    209209    ULONG       NumResource;
    210210    HRESOURCE   hResource[MAX_RESHANDLES];
     
    214214
    215215  if( DevID && OSS32_QueryNames(OSS32_DEFAULT_DEVICE,
    216                  szDeviceName, sizeof(szDeviceName),
    217                  szMixerName, sizeof(szMixerName), FALSE) == OSSERR_SUCCESS )
     216                szDeviceName, sizeof(szDeviceName),
     217                szMixerName, sizeof(szMixerName), FALSE) == OSSERR_SUCCESS )
    218218  {
    219219    switch(DevID) {
     
    285285        break;
    286286*/
    287     }
     287    } /* switch */
    288288
    289289
     
    317317                           NULL);                               // Allocated resources.
    318318
    319       dprintf(("RMCreateAdapter rc = %d\n", rc));
     319      dprintf(("RMCreateAdapter rc=%d", rc));
    320320
    321321      if( rc == 0 )
    322322      {
    323         if( !szDeviceName[0] )  strcpy(szDeviceName, "Unknown");
    324 
    325         //NOTE: Assumes szDeviceName is a stack pointer!!
    326         memset( (PVOID) &DeviceStruct, 0, sizeof(DeviceStruct) );
    327         DeviceStruct.DevDescriptName = FlatToSel((ULONG)szDeviceName);
    328         DeviceStruct.DevFlags        = DS_FIXED_LOGICALNAME;
    329         DeviceStruct.DevType         = DS_TYPE_AUDIO;
    330         DeviceStruct.pAdjunctList    = NULL;
    331 
    332         rc = RMCreateDevice(DriverHandle,                       // Handle to driver
     323                AdapterHandle = hAdapter;
     324                if (phAdapter) *phAdapter = hAdapter;
     325                if( !szDeviceName[0] )  strcpy(szDeviceName, "Unknown");
     326
     327                //NOTE: Assumes szDeviceName is a stack pointer!!
     328                memset( (PVOID) &DeviceStruct, 0, sizeof(DeviceStruct) );
     329                DeviceStruct.DevDescriptName = FlatToSel((ULONG)szDeviceName);
     330                DeviceStruct.DevFlags        = DS_FIXED_LOGICALNAME;
     331                DeviceStruct.DevType         = DS_TYPE_AUDIO;
     332                DeviceStruct.pAdjunctList    = NULL;
     333
     334                rc = RMCreateDevice(DriverHandle,                       // Handle to driver
    333335                            FlatToSel((ULONG)&hDevice),         // (OUT) Handle to device, unused.
    334336                            FlatToSel((ULONG)&DeviceStruct),    // Device structure
     
    336338                            FlatToSel((ULONG)&ahResource));     // Allocated resources
    337339
    338         dprintf(("RMCreateDevice rc = %d\n", rc));
    339 
    340         if( rc == 0 )
    341         {
    342           // no resource handles to be freed
    343           ctResHandles = 0;     return;
    344         }
    345 
    346 // !!! Not implemented in startup.asm
    347 //      RMDestroyAdapter(DriverHandle, hAdapter);
    348       }
    349     }
    350     else        dprintf(("No resources allocated !!!\n"));
    351   }
     340                dprintf(("RMCreateDevice rc=%d", rc));
     341
     342                if( rc == 0 )
     343                {
     344                  DeviceHandle = hDevice;
     345                  if (phDevice) *phDevice = hDevice;
     346                  ctResHandles = 0;  // no resource handles to be freed
     347                        dprintf(("RMDone: DriverHandle=%x DeviceHandle=%x", DriverHandle, DeviceHandle));
     348                  return;
     349                }
     350
     351                // !!! Not implemented in startup.asm
     352                //      RMDestroyAdapter(DriverHandle, hAdapter);
     353      } /* if rc == 0 */
     354    } /* ctResHandles */
     355    else        dprintf(("No resources allocated !!!"));
     356  } /* if DevID */
    352357
    353358
     
    358363
    359364
    360 
     365/* DAZ - dirty hack so that resource manager is updated correctly
     366 * when using APIC and multiple adapters */
     367VOID RMSetHandles(HADAPTER hAdapter, HDEVICE hDevice)
     368{
     369        AdapterHandle = hAdapter;
     370        DeviceHandle = hDevice;
     371}
     372
  • GPL/trunk/drv32/startup.asm

    r493 r547  
    473473                ret32
    474474_RMAllocResource16 endp
     475
     476                ALIGN 2
     477                PUBLIC  _RMModifyResourcesOrg
     478_RMModifyResourcesOrg proc far
     479                enter16
     480                test    byte ptr _RMFlags, 01H
     481                je      short ModifyL1
     482                lea     eax, [bp+6]
     483                push    ss
     484                push    ax
     485                push    001bH
     486                push    cs
     487                call    near ptr _CallRM
     488                mov     sp,bp
     489                ret16
     490ModifyL1:        test    byte ptr _RMFlags,02H
     491                je      short ModifyL2
     492                sub     ax,ax
     493                ret16
     494ModifyL2:        mov     ax,0001H
     495                ret16
     496_RMModifyResourcesOrg endp
     497
     498                ALIGN 2
     499                PUBLIC  _RMModifyResources16
     500_RMModifyResources16 proc far
     501                enter32
     502                xor     eax, eax
     503                push    dword ptr [bp+22]
     504                push    word ptr [bp+18]
     505                push    dword ptr [bp+14]
     506                push    dword ptr [bp+10]
     507                call    _RMModifyResourcesOrg
     508                add     sp, 14
     509                ret32
     510_RMModifyResources16 endp
    475511
    476512                ALIGN 2
     
    13981434;*******************************************************************************
    13991435        public _RMAllocResource
     1436        public _RMModifyResources
    14001437        public _RMDeallocResource
    14011438        public _RMCreateDevice
     
    14201457        retKEERM
    14211458_RMAllocResource endp
     1459
     1460        ALIGN 4
     1461_RMModifyResources proc near
     1462        enterKEERM
     1463        xor     eax, eax
     1464        push    dword ptr [edi+20]
     1465        push    dword ptr [edi+16]
     1466        push    dword ptr [edi+12]
     1467        push    dword ptr [edi+8]
     1468        call    fword ptr RMModifyResources1632
     1469        add     sp, 16
     1470        retKEERM
     1471_RMModifyResources endp
    14221472
    14231473        ALIGN   4
     
    15311581    public  _MSG_TABLE32
    15321582    public  RMAllocResource1632
     1583    public  RMModifyResources1632
    15331584    public  RMDeallocResource1632
    15341585    public  RMCreateDevice1632
     
    15921643    RMAllocResource1632  dd OFFSET CODE16:_RMAllocResource16
    15931644                         dw SEG CODE16:_RMAllocResource16
     1645                         dw 0
     1646    RMModifyResources1632  dd OFFSET CODE16:_RMModifyResources16
     1647                         dw SEG CODE16:_RMModifyResources16
    15941648                         dw 0
    15951649    RMDeallocResource1632 dd OFFSET CODE16:_RMDeallocResource16
  • GPL/trunk/drv32/strategy.c

    r545 r547  
    3333#include <ossidc32.h>
    3434#include <dbgos2.h>
     35#include <string.h>
    3536
    3637ULONG StratRead(RP __far *_rp);
     
    4142ULONG deviceOwner = DEV_NO_OWNER;
    4243ULONG numOS2Opens = 0;
     44extern "C" BOOL fRewired; //pci.c
     45
     46DBGINT DbgInt;
    4347
    4448//******************************************************************************
     
    6771        ULONG rc;
    6872
     73        memset(&DbgInt, 0, sizeof(DbgInt));
     74
    6975        RPInit __far* rp = (RPInit __far*)_rp;
    7076        rc = DiscardableInit(rp);
    7177        //dprintf(("StratInit End rc=%d", rc));
     78        DbgInt.usState = 1;
    7279        return rc;
    7380}
     
    8289#pragma on (unreferenced)
    8390{
     91        DbgInt.usState = 2;
    8492#ifdef ACPI
    8593        PciAdjustInterrupts();
    8694#endif
     95        rprintf(("StratInitComplete: Init=%ld/%ld Between=%ld/%ld Complete=%ld/%ld",
     96                DbgInt.ulIntServiced[0], DbgInt.ulIntUnserviced[0],
     97                DbgInt.ulIntServiced[1], DbgInt.ulIntUnserviced[1],
     98                DbgInt.ulIntServiced[2], DbgInt.ulIntUnserviced[2]));
    8799        //dprintf(("StratInitComplete"));
    88100        return(RPDONE);
     
    160172ULONG Strategy(RP __far* rp)
    161173{
    162   if (rp->Command < sizeof(StratDispatch)/sizeof(StratDispatch[0]))
     174        if (fRewired) {
     175                fRewired = FALSE;
     176                rprintf(("Strategy: Resuming"));
     177                OSS32_APMResume();
     178        }
     179
     180        if (rp->Command < sizeof(StratDispatch)/sizeof(StratDispatch[0]))
    163181                return(StratDispatch[rp->Command](rp));
    164   else  return(RPERR_COMMAND | RPDONE);
     182        else return(RPERR_COMMAND | RPDONE);
    165183}
    166184//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.