Changeset 151 for sbliveos2/trunk/drv16
- Timestamp:
- May 28, 2000, 6:50:46 PM (25 years ago)
- Location:
- sbliveos2/trunk/drv16
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
sbliveos2/trunk/drv16/init.cpp
r147 r151 63 63 #define PCI_DEVICE_ID_CREATIVE_EMU10K1 0x0002UL 64 64 #endif 65 #define PCI_ID ((PCI_ VENDOR_ID_CREATIVE<<16UL)|PCI_DEVICE_ID_CREATIVE_EMU10K1)65 #define PCI_ID ((PCI_DEVICE_ID_CREATIVE_EMU10K1<<16UL)|PCI_VENDOR_ID_CREATIVE) 66 66 67 67 // Default MIDI timer interval, milliseconds. … … 133 133 memcpy(phdr->abName,szCL_DevName,8); // yes, copy it to the dev header 134 134 135 pRM = new ResourceManager( ); // Create the RM object.135 pRM = new ResourceManager(PCI_ID); // Create the RM object. 136 136 if (! pRM) { 137 137 return; … … 156 156 // First create a timer, then the HW object. 157 157 TIMER* pMPUTimer = 158 new TIMER( 158 new TIMER(NULL, MIDI_TimerInterval, STREAM_MPU401_PLAY ); 159 159 if (pMPUTimer->eState() != TIMER_Disabled) 160 160 new MPU_401(pMPUTimer); -
sbliveos2/trunk/drv16/mpu401.cpp
r147 r151 40 40 #include "parse.h" 41 41 #include "ossidc.h" 42 #include <dbgos2.h> 43 44 #define TIMEOUT 60000 42 45 43 46 … … 47 50 MIDIAUDIO ( AUDIOHW_MPU401_PLAY, pTimer ) 48 51 { 49 static char szName[] = "SBLive #"; // Instance name for RTMIDI. A number will be appended.52 static char szName[] = "SBLive RTMIDI #"; // Instance name for RTMIDI. A number will be appended. 50 53 static char szSuffix[] = "0"; // Printable char that is appended to szName. 51 54 52 55 // RTMIDI (MIDI.SYS) related stuff 53 ++szSuffix[0]; // Bump number in instance name.56 //// ++szSuffix[0]; // Bump number in instance name. 54 57 strcpy( szRTMIDI_Name, szName ); // Setup instance name. 55 58 strcat( szRTMIDI_Name, szSuffix ); // Append ASCII number to instance name. 56 ulRTMIDI_Caps = MIDICAPSA_INPUT; // Set RTMIDI caps. 57 // When we have an IRQ and a send capability, add next line. 58 // ulCapabilities |= MIDICAPSA_OUTPUT; 59 ulRTMIDI_Caps = MIDICAPSA_INPUT | MIDICAPSA_OUTPUT; // Set RTMIDI caps. 59 60 60 61 midiOutStreamId = 0; … … 124 125 int MPU_401::writeByte(BYTE b) 125 126 { 126 //TODO: 127 if(!midiOutStreamId) { 128 DebugInt3(); 129 return 0; 130 } 131 unsigned int i; 132 133 for (i=0; i<TIMEOUT; i++) { 134 if(OSS16_WriteMidiByte(midiOutStreamId, b)) { 135 return 1; 136 } 137 iodelay(1); 138 } 127 139 return 0; 128 140 } … … 132 144 //TODO: 133 145 return -1; 146 } 147 148 void MPU_401::processIrq(unsigned long streamid) 149 { 150 char buffer[64]; 151 int bufsize; 152 153 MIDIAUDIO* pma = (MIDIAUDIO *) pAudioHWList->Head(); 154 while (pma) { 155 if((pma->ulDeviceType == AUDIOHW_MPU401_CAPTURE) || 156 (pma->ulDeviceType == AUDIOHW_MPU401_PLAY)) { 157 break; 158 } 159 pma = (MIDIAUDIO *) pma->pNext; 160 } 161 if(pma == NULL) { 162 dprintf(("MPU_401::processIrq: mpu device found!!")); 163 return; 164 } 165 166 while(TRUE) { 167 bufsize = OSS16_ReadMidiBytes(streamid, &buffer[0], sizeof(buffer)); 168 for(int i=0;i<bufsize;i++) { 169 pma->pfnSendByte(pma->ulRTMIDI_Handle, buffer[i]); 170 } 171 if(bufsize != sizeof(buffer)) { 172 break; 173 } 174 } 134 175 } 135 176 … … 175 216 USHORT MPU_401::RTMIDI_OpenReceive(void) 176 217 { 218 if(midiOutStreamId == 0) { 219 midiOutStreamId = OSS16_OpenMidiStream(MIDI_RECEIVE); 220 } 221 return (midiOutStreamId) ? 0 : MIDIERRA_HW_FAILED; 222 } 223 224 USHORT MPU_401::RTMIDI_OpenSend(void) 225 { 177 226 if(midiInStreamId == 0) { 178 midiInStreamId = OSS16_OpenMidiStream(MIDI_ RECEIVE);227 midiInStreamId = OSS16_OpenMidiStream(MIDI_SEND); 179 228 } 180 229 return (midiInStreamId) ? 0 : MIDIERRA_HW_FAILED; 181 230 } 182 231 183 USHORT MPU_401::RTMIDI_OpenSend(void)184 {185 if(midiOutStreamId == 0) {186 midiOutStreamId = OSS16_OpenMidiStream(MIDI_SEND);187 }188 return (midiOutStreamId) ? 0 : MIDIERRA_HW_FAILED;189 }190 191 232 USHORT MPU_401::RTMIDI_CloseReceive(void) 192 233 { 193 OSS16_CloseMidiStream(MIDI_RECEIVE, midiInStreamId); 234 if(midiOutStreamId) { 235 OSS16_CloseMidiStream(MIDI_RECEIVE, midiOutStreamId); 236 midiOutStreamId = 0; 237 } 194 238 return 0; 195 239 } … … 197 241 USHORT MPU_401::RTMIDI_CloseSend(void) 198 242 { 199 OSS16_CloseMidiStream(MIDI_SEND, midiOutStreamId); 200 return 0; 201 } 202 243 if(midiInStreamId) { 244 OSS16_CloseMidiStream(MIDI_SEND, midiInStreamId); 245 midiInStreamId = 0; 246 } 247 return 0; 248 } 249 -
sbliveos2/trunk/drv16/mpu401.hpp
r147 r151 49 49 MPU_401( TIMER* pTimer ); 50 50 51 static void processIrq(unsigned long streamid); 52 51 53 // Standard MIDI channel commands. 52 54 virtual void noteOff( BYTE mchan, BYTE note, BYTE velocity ); -
sbliveos2/trunk/drv16/ossidc16.cpp
r147 r151 24 24 #include "stream.hpp" 25 25 #include "wavestrm.hpp" 26 #include "mpu401.hpp" 26 27 #include "malloc.h" 27 28 #include <ossidc.h> … … 84 85 ULONG OSS16_OpenMidiStream(MIDITYPE midiType) 85 86 { 86 return CallOSS32(IDC32_STREAM_OPEN, 0x666, (midiType == MIDI_RECEIVE) ? OSS_STREAM_MIDIIN : OSS_STREAM_MIDIOUT, 0, 0, 0); 87 return CallOSS32(IDC32_STREAM_OPEN, 0x666, (midiType == MIDI_RECEIVE) ? OSS_STREAM_MIDIOUT: OSS_STREAM_MIDIIN, 0, 0, 0); 88 } 89 //****************************************************************************** 90 //****************************************************************************** 91 BOOL OSS16_WriteMidiByte(ULONG streamid, BYTE midiByte) 92 { 93 return CallOSS32(IDC32_MIDI_WRITE, 0x666, OSS_STREAM_MIDIOUT, streamid, midiByte, 0); 94 } 95 //****************************************************************************** 96 //****************************************************************************** 97 int OSS16_ReadMidiBytes(ULONG streamid, char far *buffer, int bufsize) 98 { 99 return CallOSS32(IDC32_MIDI_READ, 0x666, OSS_STREAM_MIDIIN, streamid, (ULONG)buffer, bufsize); 87 100 } 88 101 //****************************************************************************** … … 90 103 void OSS16_CloseMidiStream(MIDITYPE midiType, ULONG streamid) 91 104 { 92 CallOSS32(IDC32_STREAM_CLOSE, 0x666, (midiType == MIDI_RECEIVE) ? OSS_STREAM_MIDI IN : OSS_STREAM_MIDIOUT, streamid, 0, 0);105 CallOSS32(IDC32_STREAM_CLOSE, 0x666, (midiType == MIDI_RECEIVE) ? OSS_STREAM_MIDIOUT : OSS_STREAM_MIDIIN, streamid, 0, 0); 93 106 } 94 107 //****************************************************************************** … … 309 322 PWAVESTREAM pStream; 310 323 311 pStream = (PWAVESTREAM)FindActiveStream((packet->process.type) ? STREAM_WAVE_PLAY : STREAM_WAVE_CAPTURE, 324 if(packet->process.type == IDC16_MIDI_IRQ) { 325 MPU_401::processIrq(packet->process.streamid); 326 break; 327 } 328 329 pStream = (PWAVESTREAM)FindActiveStream((packet->process.type == IDC16_WAVEOUT_IRQ) ? STREAM_WAVE_PLAY : STREAM_WAVE_CAPTURE, 312 330 packet->process.streamid); 313 331 if(pStream) { -
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 -
sbliveos2/trunk/drv16/rm.hpp
r142 r151 83 83 84 84 85 typedef struct 86 { 87 USHORT VendorID; 88 USHORT DeviceID; 89 USHORT Command; 90 USHORT Status; 91 UCHAR RevisionID; 92 UCHAR filler1[7]; 93 ULONG Bar0; 94 ULONG Bar1; 95 ULONG filler2[5]; 96 USHORT SubsystemVendorID; 97 USHORT SubsystemID; 98 ULONG filler3[3]; 99 UCHAR InterruptLine; 100 UCHAR InterruptPin; 101 UCHAR Max_Gnt; 102 UCHAR Max_Lat; 103 UCHAR TRDY_Timeout; 104 UCHAR Retry_Timeout; 105 UCHAR filler4[0x9a]; 106 UCHAR CapabilityID; 107 UCHAR NextItemPtr; 108 USHORT PowerMgtCapability; 109 USHORT PowerMgtCSR; 110 } PCIConfigData; 111 85 112 // This value indicates an empty entry in an LDev_Resource data item. 86 113 const USHORT NoIOValue = 0xffff; … … 126 153 public: // at bottom of file. 127 154 128 ResourceManager ( void );155 ResourceManager ( ULONG pciId ); 129 156 // Register the device driver (this activates the RM interface). 130 157 // Intention is that only one ResourceManager object is created … … 185 212 APIRET _rmCreateDevice( PSZ pszName, NPAHRESOURCE pahResource ); 186 213 214 BOOL getPCIConfiguration(ULONG pciId); 215 216 ULONG PCIConfig[64]; 217 PCIConfigData *pciConfigData; 218 187 219 }; 188 220 -
sbliveos2/trunk/drv16/timer.cpp
r142 r151 207 207 } 208 208 } 209 #endif 209 210 210 211 // Timer IRQ hook didn't work for some reason, use system timer. … … 215 216 _eState = TIMER_Stopped; 216 217 } 217 } // End of setup for interrupt operation, executed for 1st Timer only. 218 #endif 218 // } // End of setup for interrupt operation, executed for 1st Timer only. 219 219 220 220 // If good creation, add Timer to global timer list & reset all time vbls. -
sbliveos2/trunk/drv16/vddentry.asm
r142 r151 103 103 _OSSIDC_ENTRY ENDP 104 104 105 PUBLIC _inpd 106 _inpd proc near 107 in eax, dx 108 mov dx, ax 109 shr eax, 16 110 xchg ax, dx 111 ret 112 _inpd endp 113 114 PUBLIC _outpd 115 _outpd proc near 116 mov ax, cx 117 shl eax, 16 118 mov ax, bx 119 out dx, eax 120 ret 121 _outpd endp 122 105 123 _TEXT ENDS 106 124 -
sbliveos2/trunk/drv16/wavestrm.cpp
r147 r151 258 258 OSS16_StreamGetPos(this, &ulCurBytesProcessed); 259 259 if(ulCurBytesProcessed == 0) { 260 //shouldn't happen (TODO recording)260 //shouldn't happen 261 261 DebugInt3(); 262 262 return;
Note:
See TracChangeset
for help on using the changeset viewer.