Changeset 151 for sbliveos2/trunk/drv16/rm.cpp
- Timestamp:
- May 28, 2000, 6:50:46 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sbliveos2/trunk/drv16/rm.cpp
r142 r151 40 40 #include <string.h> // _fmemset() 41 41 #include "malloc.h" // malloc() 42 42 #include <dbgos2.h> 43 43 44 44 char DeviceName[64] = "Creative Labs SoundBlaster Live"; … … 96 96 * allocate resources. 97 97 */ 98 ResourceManager::ResourceManager ()98 ResourceManager::ResourceManager(ULONG pciId) 99 99 { 100 100 APIRET rc; … … 141 141 ((pGIS->uchMajorVersion == 20) && (pGIS->uchMinorVersion > 30)) ); 142 142 } 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) 151 bool ResourceManager::bIsDevDetected( DEVID DevID , ULONG ulSearchFlags, bool fPciDevice) 152 #pragma on (unreferenced) 146 153 /* 147 154 ; PURPOSE: Search the Resource Manager's "current detected" tree for … … 158 165 */ 159 166 { 167 #if 1 168 //Manual detection in ResourceManager class constructor; 169 return _state == rmDriverCreated; 170 #else 160 171 BOOL bReturn = FALSE; 161 172 NPHANDLELIST pHandleList = 0; … … 173 184 174 185 return bReturn ; 186 #endif 175 187 } 176 188 … … 190 202 * @return NULL on error situations. 191 203 */ 204 #pragma off (unreferenced) 192 205 LDev_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 194 228 LDev_Resources* pResources = 0; // Used to return result. 195 229 NPRM_GETNODE_DATA pNode = 0; // Node resource data for spec'd DEVID's. … … 254 288 delete pResources; 255 289 return NULL; 290 #endif 256 291 } 257 292 … … 723 758 } 724 759 760 761 #define PCI_CONFIG_ENABLE 0x80000000 762 #define PCI_CONFIG_ADDRESS 0xCF8 763 #define PCI_CONFIG_DATA 0xCFC 764 765 unsigned long _inpd(unsigned short); 766 #pragma aux _inpd "_inpd" \ 767 parm [dx] \ 768 value [dx ax]; 769 770 //COMPILER BUG: bx cx == cx bx 771 void _outpd(unsigned short, unsigned long); 772 #pragma aux _outpd "_outpd" \ 773 parm [dx] [cx bx] \ 774 modify [ax dx]; 775 776 BOOL 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.