Changeset 151 for sbliveos2/trunk/drv16


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

update

Location:
sbliveos2/trunk/drv16
Files:
9 edited

Legend:

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

    r147 r151  
    6363#define PCI_DEVICE_ID_CREATIVE_EMU10K1 0x0002UL
    6464#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)
    6666
    6767// Default MIDI timer interval, milliseconds.
     
    133133      memcpy(phdr->abName,szCL_DevName,8);   // yes, copy it to the dev header
    134134
    135    pRM = new ResourceManager();        // Create the RM object.
     135   pRM = new ResourceManager(PCI_ID);        // Create the RM object.
    136136   if (! pRM) {
    137137      return;
     
    156156   // First create a timer, then the HW object.
    157157   TIMER* pMPUTimer =
    158        new TIMER( NULL, MIDI_TimerInterval, STREAM_MPU401_PLAY );
     158       new TIMER(NULL, MIDI_TimerInterval, STREAM_MPU401_PLAY );
    159159   if (pMPUTimer->eState() != TIMER_Disabled)
    160160         new MPU_401(pMPUTimer);
  • sbliveos2/trunk/drv16/mpu401.cpp

    r147 r151  
    4040#include "parse.h"
    4141#include "ossidc.h"
     42#include <dbgos2.h>
     43
     44#define TIMEOUT   60000
    4245
    4346
     
    4750   MIDIAUDIO ( AUDIOHW_MPU401_PLAY, pTimer )
    4851{
    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.
    5053   static char szSuffix[] = "0";       // Printable char that is appended to szName.
    5154
    5255   // RTMIDI (MIDI.SYS) related stuff
    53    ++szSuffix[0];                      // Bump number in instance name.
     56////   ++szSuffix[0];                      // Bump number in instance name.
    5457   strcpy( szRTMIDI_Name, szName );    // Setup instance name.
    5558   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.
    5960
    6061   midiOutStreamId = 0;
     
    124125int MPU_401::writeByte(BYTE b)
    125126{
    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   }
    127139   return 0;
    128140}
     
    132144   //TODO:
    133145   return -1;
     146}
     147
     148void 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   }   
    134175}
    135176
     
    175216USHORT MPU_401::RTMIDI_OpenReceive(void)
    176217{
     218   if(midiOutStreamId == 0) {
     219          midiOutStreamId = OSS16_OpenMidiStream(MIDI_RECEIVE);
     220   }
     221   return (midiOutStreamId) ? 0 : MIDIERRA_HW_FAILED;
     222}
     223
     224USHORT MPU_401::RTMIDI_OpenSend(void)
     225{
    177226   if(midiInStreamId == 0) {
    178           midiInStreamId = OSS16_OpenMidiStream(MIDI_RECEIVE);
     227          midiInStreamId = OSS16_OpenMidiStream(MIDI_SEND);
    179228   }
    180229   return (midiInStreamId) ? 0 : MIDIERRA_HW_FAILED;
    181230}
    182231
    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 
    191232USHORT MPU_401::RTMIDI_CloseReceive(void)
    192233{
    193    OSS16_CloseMidiStream(MIDI_RECEIVE, midiInStreamId);
     234   if(midiOutStreamId) {
     235        OSS16_CloseMidiStream(MIDI_RECEIVE, midiOutStreamId);
     236        midiOutStreamId = 0;
     237   }
    194238   return 0;
    195239}
     
    197241USHORT MPU_401::RTMIDI_CloseSend(void)
    198242{
    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  
    4949   MPU_401( TIMER* pTimer );
    5050
     51   static void processIrq(unsigned long streamid);
     52
    5153   // Standard MIDI channel commands.
    5254   virtual void noteOff( BYTE mchan, BYTE note, BYTE velocity );
  • sbliveos2/trunk/drv16/ossidc16.cpp

    r147 r151  
    2424#include "stream.hpp"
    2525#include "wavestrm.hpp"
     26#include "mpu401.hpp"
    2627#include "malloc.h"
    2728#include <ossidc.h>
     
    8485ULONG OSS16_OpenMidiStream(MIDITYPE midiType)
    8586{
    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//******************************************************************************
     91BOOL OSS16_WriteMidiByte(ULONG streamid, BYTE midiByte)
     92{
     93   return CallOSS32(IDC32_MIDI_WRITE, 0x666, OSS_STREAM_MIDIOUT, streamid, midiByte, 0);
     94}
     95//******************************************************************************
     96//******************************************************************************
     97int OSS16_ReadMidiBytes(ULONG streamid, char far *buffer, int bufsize)
     98{
     99   return CallOSS32(IDC32_MIDI_READ, 0x666, OSS_STREAM_MIDIIN, streamid, (ULONG)buffer, bufsize);
    87100}
    88101//******************************************************************************
     
    90103void OSS16_CloseMidiStream(MIDITYPE midiType, ULONG streamid)
    91104{
    92    CallOSS32(IDC32_STREAM_CLOSE, 0x666, (midiType == MIDI_RECEIVE) ? OSS_STREAM_MIDIIN : OSS_STREAM_MIDIOUT, streamid, 0, 0);
     105   CallOSS32(IDC32_STREAM_CLOSE, 0x666, (midiType == MIDI_RECEIVE) ? OSS_STREAM_MIDIOUT : OSS_STREAM_MIDIIN, streamid, 0, 0);
    93106}
    94107//******************************************************************************
     
    309322        PWAVESTREAM pStream;
    310323
    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,
    312330                                                 packet->process.streamid);
    313331        if(pStream) {
  • 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
  • sbliveos2/trunk/drv16/rm.hpp

    r142 r151  
    8383
    8484
     85typedef 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
    85112// This value indicates an empty entry in an LDev_Resource data item.
    86113const USHORT NoIOValue = 0xffff;
     
    126153 public:                        // at bottom of file.
    127154
    128    ResourceManager ( void );
     155   ResourceManager ( ULONG pciId );
    129156        // Register the device driver (this activates the RM interface).
    130157        // Intention is that only one ResourceManager object is created
     
    185212   APIRET _rmCreateDevice( PSZ pszName, NPAHRESOURCE pahResource );
    186213
     214   BOOL   getPCIConfiguration(ULONG pciId);
     215
     216   ULONG          PCIConfig[64];
     217   PCIConfigData *pciConfigData;
     218
    187219};
    188220
  • sbliveos2/trunk/drv16/timer.cpp

    r142 r151  
    207207         }
    208208      }
     209#endif
    209210
    210211      // Timer IRQ hook didn't work for some reason, use system timer.
     
    215216         _eState = TIMER_Stopped;
    216217      }
    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.
    219219
    220220   // If good creation, add Timer to global timer list & reset all time vbls.
  • sbliveos2/trunk/drv16/vddentry.asm

    r142 r151  
    103103_OSSIDC_ENTRY ENDP
    104104
     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
    105123_TEXT   ENDS
    106124
  • sbliveos2/trunk/drv16/wavestrm.cpp

    r147 r151  
    258258        OSS16_StreamGetPos(this, &ulCurBytesProcessed);
    259259        if(ulCurBytesProcessed == 0) {
    260                 //shouldn't happen (TODO recording)
     260                //shouldn't happen
    261261                DebugInt3();
    262262                return;
Note: See TracChangeset for help on using the changeset viewer.