Ignore:
Timestamp:
May 28, 2000, 6:50:46 PM (25 years ago)
Author:
sandervl
Message:

update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sbliveos2/trunk/drv16/rm.cpp

    r142 r151  
    4040#include <string.h>                    // _fmemset()
    4141#include "malloc.h"                    // malloc()
    42 
     42#include <dbgos2.h>
    4343
    4444char DeviceName[64] = "Creative Labs SoundBlaster Live";
     
    9696 *  allocate resources.
    9797 */
    98 ResourceManager::ResourceManager ( )
     98ResourceManager::ResourceManager(ULONG pciId)
    9999{
    100100   APIRET rc;
     
    141141           ((pGIS->uchMajorVersion == 20) && (pGIS->uchMinorVersion > 30)) );
    142142   }
    143 }
    144 
    145 bool ResourceManager::bIsDevDetected ( DEVID DevID , ULONG ulSearchFlags, bool fPciDevice)
     143
     144   if(getPCIConfiguration(pciId) == FALSE) {
     145      _state = rmDriverFailed;
     146   }
     147
     148}
     149
     150#pragma off (unreferenced)
     151bool ResourceManager::bIsDevDetected( DEVID DevID , ULONG ulSearchFlags, bool fPciDevice)
     152#pragma on (unreferenced)
    146153/*
    147154;  PURPOSE: Search the Resource Manager's "current detected" tree for
     
    158165*/
    159166{
     167#if 1
     168   //Manual detection in ResourceManager class constructor;
     169   return _state == rmDriverCreated;
     170#else
    160171   BOOL bReturn = FALSE;
    161172   NPHANDLELIST pHandleList = 0;
     
    173184
    174185   return bReturn ;
     186#endif
    175187}
    176188
     
    190202 * @return NULL on error situations.
    191203 */
     204#pragma off (unreferenced)
    192205LDev_Resources* ResourceManager::GetRMDetectedResources ( DEVID DevID , ULONG ulSearchFlags, bool fPciDevice)
    193 {
     206#pragma on (unreferenced)
     207{
     208#if 1
     209   LDev_Resources* pResources = 0;     // Used to return result.
     210
     211   pResources = new LDev_Resources();
     212   if (!pResources) return NULL;
     213
     214   pResources->vClear();
     215
     216   //Fill in resources read from PCI Configuration space
     217   pResources->uIRQLevel[0]  = pciConfigData->InterruptLine;
     218   if(pResources->uIRQLevel[0] == 0 || pResources->uIRQLevel[0] > 15)  {
     219        dprintf(("Invalid PCI irq %x", (int)pResources->uIRQLevel[0]));
     220        DebugInt3();
     221        return NULL;
     222   }
     223   pResources->uIOBase[0]   = (USHORT)(pciConfigData->Bar0 & 0xFFFFFF00);
     224   pResources->uIOLength[0] = 0x20;
     225
     226   return pResources;
     227#else
    194228   LDev_Resources* pResources = 0;     // Used to return result.
    195229   NPRM_GETNODE_DATA pNode = 0;        // Node resource data for spec'd DEVID's.
     
    254288   delete pResources;
    255289   return NULL;
     290#endif
    256291}
    257292
     
    723758}
    724759
     760
     761#define PCI_CONFIG_ENABLE       0x80000000
     762#define PCI_CONFIG_ADDRESS      0xCF8
     763#define PCI_CONFIG_DATA         0xCFC
     764
     765unsigned long _inpd(unsigned short);
     766#pragma aux _inpd "_inpd" \
     767  parm   [dx] \
     768  value  [dx ax];
     769
     770//COMPILER BUG: bx cx == cx bx
     771void _outpd(unsigned short, unsigned long);
     772#pragma aux _outpd "_outpd" \
     773  parm   [dx] [cx bx] \
     774  modify [ax dx];
     775
     776BOOL ResourceManager::getPCIConfiguration(ULONG pciId)
     777{
     778 ULONG devNr, busNr, funcNr, temp, cfgaddrreg, detectedId;
     779 BOOL  found = FALSE;
     780
     781        cfgaddrreg = _inpd(PCI_CONFIG_ADDRESS);
     782        for(busNr=0;busNr<255;busNr++)     //BusNumber<255
     783        {
     784                for(devNr=0;devNr<32;devNr++)
     785                {
     786                        for(funcNr=0;funcNr<8;funcNr++)
     787                        {
     788                                temp = ((ULONG)((ULONG)devNr<<11UL) + ((ULONG)busNr<<16UL) + ((ULONG)funcNr << 8UL));
     789
     790                                _outpd(PCI_CONFIG_ADDRESS, PCI_CONFIG_ENABLE|temp);
     791                                detectedId = _inpd(PCI_CONFIG_DATA);
     792                                if(detectedId == pciId)
     793                                {
     794                                        found = TRUE;
     795                                        break;
     796                                }
     797                        }
     798                        if(found) break;
     799                }
     800                if(found) break;
     801        }
     802
     803        if(!found) {
     804                _outpd(PCI_CONFIG_ADDRESS, cfgaddrreg);
     805                return FALSE;
     806        }
     807
     808        for(int i=0;i<64;i++)
     809        {
     810                temp = ((ULONG)((ULONG)devNr<<11UL) + ((ULONG)busNr<<16UL) + ((ULONG)funcNr << 8UL) + (i << 2));
     811                _outpd(PCI_CONFIG_ADDRESS, PCI_CONFIG_ENABLE|temp);
     812
     813                PCIConfig[i] = _inpd(PCI_CONFIG_DATA);
     814        }
     815        _outpd(PCI_CONFIG_ADDRESS, cfgaddrreg);
     816
     817        pciConfigData = (PCIConfigData *)&PCIConfig[0];
     818
     819        if(pciConfigData->Bar0 == 0 || pciConfigData->Bar0 == 0xFFFFFFFF)
     820        {
     821                DebugInt3();
     822                return(FALSE);
     823        }
     824        return TRUE;
     825}
     826
Note: See TracChangeset for help on using the changeset viewer.