Changeset 152 for sbliveos2/trunk/drv16


Ignore:
Timestamp:
Jul 17, 2000, 8:37:33 PM (25 years ago)
Author:
sandervl
Message:

misc updates

Location:
sbliveos2/trunk/drv16
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • sbliveos2/trunk/drv16/commdbg.c

    r142 r152  
    3939#include <os2.h>
    4040#include "dbgos2.h"
     41#include "commdbg.h"
    4142
    4243BOOL fLineTerminate=TRUE;
    43 #ifdef  DEBUG
    4444
    4545#define CR 0x0d
     
    5050#define SIGNIFICANT_FIELD       0x0007
    5151
     52int dbglevel = 2;
    5253
    5354char hextab[]="0123456789ABCDEF";
    5455
    5556                                        //-------------------- DecWordToASCII -
    56 char far * DecWordToASCII(char far *StrPtr, USHORT wDecVal, USHORT Option)
     57char far * cdecl DecWordToASCII(char far *StrPtr, USHORT wDecVal, USHORT Option)
    5758{
    5859  BOOL fNonZero=FALSE;
     
    9798
    9899                                        //-------------------- DecLongToASCII -
    99 char far * DecLongToASCII(char far *StrPtr, ULONG lDecVal,USHORT Option)
     100char far * cdecl DecLongToASCII(char far *StrPtr, ULONG lDecVal,USHORT Option)
    100101{
    101102   BOOL  fNonZero=FALSE;
     
    148149}
    149150                                        //-------------------- HexWordToASCII -
    150 char far * HexWordToASCII(char far *StrPtr, USHORT wHexVal, USHORT Option)
     151char far * cdecl HexWordToASCII(char far *StrPtr, USHORT wHexVal, USHORT Option)
    151152{
    152153   BOOL fNonZero=FALSE;
     
    176177
    177178                                        //-------------------- HexLongToASCII -
    178 char far * HexLongToASCII(char far *StrPtr, ULONG wHexVal, USHORT Option)
     179char far * cdecl HexLongToASCII(char far *StrPtr, ULONG wHexVal, USHORT Option)
    179180{
    180181   BOOL  fNonZero=FALSE;
     
    217218}
    218219
     220#ifdef  DEBUG
    219221char BuildString[1024];
    220 #endif          // DEBUG
    221 #ifdef DEBUG
    222222
    223223                                        //------------------------- PrintfOut -
  • sbliveos2/trunk/drv16/init.cpp

    r151 r152  
    5555#include <include.h>                   // Pragmas and more.
    5656#include <sbversion.h>
     57#include "commdbg.h"
     58#include <dbgos2.h>
    5759
    5860#ifndef PCI_VENDOR_ID_CREATIVE
     
    7274static char NEWLINE[]     = "\r\n";
    7375static char szSBLiveNotFound[] = "SB Live! hardware not detected!";
    74 static char szAltF1[]     = "Reboot, press Alt-F1 during OS/2 startup and select Enable Hardware Detection";
     76static char szSBLiveConfig1[]  = "SB Live! configuration: IRQ ";
     77static char szSBLiveConfig2[]  = ", IO Port 0x";
     78
    7579
    7680//
     
    7882// Name is copied from header at runtime.
    7983//
    80 char  szPddName [9]  = {0};
     84char  szPddName[9]  = {0};
     85char  digit[16]     = {0};
    8186
    8287ResourceManager* pRM = 0;               // Resource manager object.
     
    122127
    123128        DosWrite(1, (VOID FAR*)NEWLINE, sizeof(NEWLINE)-1, &result);
    124         DosWrite(1, (VOID FAR*)szSBLive, strlen(szSBLive), &result);
     129        DosWrite(1, (VOID FAR*)szSBLive, sizeof(szSBLive)-1, &result);
    125130        DosWrite(1, (VOID FAR*)NEWLINE, sizeof(NEWLINE)-1, &result);
    126131
     
    137142      return;
    138143   }
    139    else if (pRM->getState() != rmDriverCreated) {
    140       return;
    141    }
    142144
    143145   //SvL: Check if SB Live hardware has been detected by the resource manager
    144    //     If not, tell user to reboot, press alt-f1 and enable hardware detection
    145    if(!pRM->bIsDevDetected(PCI_ID, SEARCH_ID_DEVICEID, TRUE)) {
     146   if(pRM->getState() != rmDriverCreated || !pRM->bIsDevDetected(PCI_ID, SEARCH_ID_DEVICEID, TRUE))
     147   {
     148hardware_notfound:
    146149        USHORT result;
    147150
    148         DosWrite(1, (VOID FAR*)szSBLiveNotFound, strlen(szSBLiveNotFound), &result);
    149         DosWrite(1, (VOID FAR*)NEWLINE, sizeof(NEWLINE)-1, &result);
    150         DosWrite(1, (VOID FAR*)szAltF1, sizeof(szAltF1), &result);
     151        DosWrite(1, (VOID FAR*)szSBLiveNotFound, sizeof(szSBLiveNotFound)-1, &result);
     152        DosWrite(1, (VOID FAR*)NEWLINE, sizeof(NEWLINE)-1, &result);
    151153        DosWrite(1, (VOID FAR*)NEWLINE, sizeof(NEWLINE)-1, &result);
    152154        return;
    153155   }
     156   LDev_Resources *pResources = pRM->pGetDevResources(PCI_ID, SEARCH_ID_DEVICEID, TRUE);
     157   if ((!pResources) || pResources->isEmpty()) {
     158        goto hardware_notfound;
     159   }
     160
     161   if (fVerbose) {
     162        USHORT result;
     163
     164        DecWordToASCII(digit, (USHORT)pResources->uIRQLevel[0], 0);
     165        DosWrite(1, (VOID FAR*)szSBLiveConfig1, sizeof(szSBLiveConfig1)-1, &result);
     166        DosWrite(1, (VOID FAR*)digit, strlen(digit), &result);
     167
     168        DosWrite(1, (VOID FAR*)szSBLiveConfig2, sizeof(szSBLiveConfig2)-1, &result);
     169        HexWordToASCII(digit, pResources->uIOBase[0], 0);
     170        DosWrite(1, (VOID FAR*)digit, strlen(digit), &result);
     171
     172        DosWrite(1, (VOID FAR*)NEWLINE, sizeof(NEWLINE)-1, &result);
     173        DosWrite(1, (VOID FAR*)NEWLINE, sizeof(NEWLINE)-1, &result);
     174   }
     175   delete pResources;
    154176
    155177   // Build the MPU401 object only if we got a good 2115 init.
  • sbliveos2/trunk/drv16/irq.cpp

    r142 r152  
    270270            cli();
    271271            if (_handlerList[i].pfnHandler(_usIRQLevel)) {  // Call handler.
     272               cli();
    272273               // We've cleared all service requests.  Send EOI and clear
    273274               // the carry flag (tells OS/2 kernel that Int was handled).
  • sbliveos2/trunk/drv16/ossidc16.cpp

    r151 r152  
    182182//******************************************************************************
    183183//******************************************************************************
     184ULONG OSS16_StreamGetSpace(STREAM *stream)
     185{
     186   return (BOOL)CallOSS32(IDC32_STREAM_GETSPACE, stream->ulSysFileNum, MMPMToOSSStreamType(stream->ulStreamType), stream->ulStreamId, 0, 0);
     187}
     188//******************************************************************************
     189//******************************************************************************
    184190ULONG CallOSS32(USHORT cmd, ULONG fileid, ULONG param1, ULONG param2, ULONG param3, ULONG param4)
    185191{
     
    292298                idcres->memlength[i] = pResources->uMemLength[i];
    293299        }
    294 
     300        delete pResources;
    295301        return 1;
    296302   }
     
    298304   {
    299305        LIN linaddr;
    300         ULONG far *addr = (ULONG far *)malloc((USHORT)packet->malloc.size+4);
    301 
    302         if(addr == NULL) {
     306        ULONG near *addr16 = (ULONG near *)malloc((USHORT)packet->malloc.size+4);
     307        ULONG far *addr = (ULONG far *)addr16;
     308
     309        if(addr16 == NULL) {
    303310                return 0;
    304311        }
  • sbliveos2/trunk/drv16/parse.c

    r142 r152  
    189189
    190190   switch (cParm) {
     191      case '3':
     192         fInt3BeforeInit = TRUE;
     193         break;
    191194      case 'J':            // which MIDI.  MPU by default, if /J then FMSYNTH
    192195         fFMforMIDI = TRUE;
  • sbliveos2/trunk/drv16/rm.cpp

    r151 r152  
    167167#if 1
    168168   //Manual detection in ResourceManager class constructor;
    169    return _state == rmDriverCreated;
     169   return (_state == rmDriverCreated || _state == rmAdapterCreated);
    170170#else
    171171   BOOL bReturn = FALSE;
     
    375375   if (_state != rmAdapterCreated) {
    376376      rc = _rmCreateAdapter();
    377    }
    378 
    379    // Register the device with OS/2 RM.
    380    _rmCreateDevice((unsigned char __far *)DeviceName, pahResources );
     377
     378      // Register the device with OS/2 RM.
     379      _rmCreateDevice((unsigned char __far *)DeviceName, pahResources );
     380   }
    381381
    382382exit:
  • sbliveos2/trunk/drv16/wavestrm.cpp

    r151 r152  
    3434#include "ioctl.h"
    3535
     36#ifndef min
     37#define min(a,b) (a>b) ? b : a
     38#endif
     39
    3640//
    3741//  _vRealignBuffer
     
    152156void WAVESTREAM::AddBuffers(void)
    153157{
     158 ULONG space, byteswritten;
     159
    154160   if (ulStreamType & STREAM_WRITE) {
    155161        if(!qhInProcess.Head() && !qhDone.Head()) {
     
    160166                return;
    161167        }
    162         AddBuffer();
    163         AddBuffer();
     168        space = OSS16_StreamGetSpace(this);
     169        if(space > 128) {
     170                space -= 128;
     171        }
     172        while(space) {
     173                byteswritten = AddBuffer(space);
     174                space -= byteswritten;
     175                if(byteswritten == 0) break;
     176        }       
    164177   }
    165178}
     
    171184// there are buffers on pHead... BEWARE
    172185//
    173 void WAVESTREAM::AddBuffer()
     186ULONG WAVESTREAM::AddBuffer(ULONG space)
    174187{
    175188   PSTREAMBUFFER pTemp = (PSTREAMBUFFER)qhDone.Head();
     
    180193        pTemp = (PSTREAMBUFFER)qhInProcess.Head();
    181194   }
    182    if(!pTemp) return;
     195   if(!pTemp) return 0;
    183196
    184197   // get the buffer pointer and amount of data remaining
     
    187200
    188201   // write the audio buffer
     202   Buff_left = min(Buff_left, space);
    189203   byteswritten = OSS16_StreamAddBuffer(this, pdataBuf, Buff_left);
    190204   if(byteswritten == 0) {
    191         return; //no more room
    192    }
    193 
    194 //   dprintf(("AddBuffer %lx size %d, bytes written %d", pdataBuf, (USHORT)Buff_left, (USHORT)byteswritten));
     205        return 0; //no more room
     206   }
    195207
    196208   // update the buffer pos counter
     
    200212      qhDone.PushOnTail(qhInProcess.PopHead());
    201213   }
     214   dprintf4(("AddBuffer %lx size %d, bytes written %d", pdataBuf, (USHORT)Buff_left, (USHORT)byteswritten));
     215   return byteswritten;
    202216}
    203217
     
    226240   }
    227241
    228 ////   dprintf(("_vReadAudioBuf %lx size %d, bytes read %d", pdataBuf, Buff_left, bytesread));
     242   dprintf4(("_vReadAudioBuf %lx size %d, bytes read %d", pdataBuf, Buff_left, bytesread));
    229243
    230244   // update the buffer pos counter
     
    236250   }
    237251   if(pTemp->ulBuffpos == pTemp->ulBuffsz) {
    238         dprintf(("_vReadAudioBuf return buffer %lx size %ld, bytes read %ld", (ULONG)pTemp->pBuffptr, pTemp->ulBuffsz, bytesread));
     252        dprintf4(("_vReadAudioBuf return buffer %lx size %ld, bytes read %ld", (ULONG)pTemp->pBuffptr, pTemp->ulBuffsz, bytesread));
    239253        ReturnBuffer();
    240254   }
     
    280294                        //calc position in next buffer
    281295                        bytesinc = ptemp->ulDonepos - ptemp->ulBuffsz;
    282 ////                    dprintf(("Process: Return buffer %lx size %d", ptemp->pBuffptr, ptemp->ulBuffsz));
     296                        dprintf3(("Process: Return buffer %lx size %d", ptemp->pBuffptr, ptemp->ulBuffsz));
    283297                        ReturnBuffer();
    284298                }
     
    309323{
    310324   qhInProcess.PushOnTail((PQUEUEELEMENT)new STREAMBUFFER(uLength, pbuf));
    311 ////   dprintf(("WAVESTREAM::Write: Push on tail %lx %d", ((PSTREAMBUFFER)qhInProcess.Head())->pBuffptr, ((PSTREAMBUFFER)qhInProcess.Head())->ulBuffsz));
     325   dprintf2(("WAVESTREAM::Write: Push on tail %lx %d", ((PSTREAMBUFFER)qhInProcess.Head())->pBuffptr, ((PSTREAMBUFFER)qhInProcess.Head())->ulBuffsz));
    312326   if(fUnderrun) {
    313327        fUnderrun = FALSE;
     
    323337{
    324338   qhInProcess.PushOnTail((PQUEUEELEMENT)new STREAMBUFFER(uLength, pbuf));
    325    dprintf(("WAVESTREAM::Read: Push on tail %lx %d", ((PSTREAMBUFFER)qhInProcess.Head())->pBuffptr, ((PSTREAMBUFFER)qhInProcess.Head())->ulBuffsz));
     339   dprintf2(("WAVESTREAM::Read: Push on tail %lx %d", ((PSTREAMBUFFER)qhInProcess.Head())->pBuffptr, ((PSTREAMBUFFER)qhInProcess.Head())->ulBuffsz));
    326340   return 0;
    327341}
     
    384398 ULONG         fragsize;
    385399
     400#ifdef DEBUG
     401   int oldlevel = dbglevel;
     402   dbglevel = 4;
     403#endif
    386404   // configure the wave device
    387405   ((PWAVEAUDIO)pahw)->ConfigDev(this, &_configinfo);
     
    421439        OSS16_StartStream(this);
    422440   }
     441#ifdef DEBUG
     442   dbglevel = oldlevel;
     443#endif
    423444
    424445   //Must set volume after adding buffers (voices inside sblive driver might not
  • sbliveos2/trunk/drv16/wavestrm.hpp

    r142 r152  
    6262   void    _vRealignPausedBuffers(ULONG endpos = 0);
    6363   void    AddBuffers();            // Initialize the audio buffer object
    64    void    AddBuffer();             // write one buffer to the audio buffer
     64   ULONG   AddBuffer(ULONG space);             // write one buffer to the audio buffer
    6565   BOOL    _vReadAudioBuf(void);    // read data from the audio buffer
    6666
Note: See TracChangeset for help on using the changeset viewer.