Ignore:
Timestamp:
Feb 10, 2017, 2:50:49 AM (8 years ago)
Author:
David Azarewicz
Message:

Build system cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GPL/branches/uniaud32-2.1.x/drv32/dispatch.c

    r543 r588  
    3030#include <devhelp.h>
    3131#include <devtype.h>
    32 #include <devrp.h>
     32#include <strategy.h>
    3333#include "devown.h"
    3434#include <ossidc.h>
     
    3636#include <version.h>
    3737
    38 extern "C" int cdecl printk(const char * fmt, ...);
     38extern int cdecl printk(const char * fmt, ...);
    3939//******************************************************************************
    4040// Dispatch IOCtl requests received from the Strategy routine
    4141//******************************************************************************
    42 extern "C" int GetUniaudCardInfo(ULONG deviceid, void *info);
    43 extern "C" int GetUniaudControlNum(ULONG deviceid);
    44 extern "C" int GetUniaudControls(ULONG deviceid, void *pids);
    45 extern "C" int GetUniaudControlInfo(ULONG deviceid, ULONG id, void *info);
    46 extern "C" int GetUniaudControlValueGet(ULONG deviceid, ULONG id, void *value);
    47 extern "C" int GetUniaudControlValuePut(ULONG deviceid, ULONG id, void *value);
    48 extern "C" int GetNumberOfPcm(int card_id);
    49 extern "C" int GetUniaudPcmCaps(ULONG deviceid, void *caps);
    50 extern "C" int SetPCMInstance(int card_id, int pcm);
    51 extern "C" int WaitForControlChange(int card_id, int timeout);
    52 extern "C" int GetNumberOfCards(void);
    53 extern "C" OSSRET OSS32_WaveOpen(ULONG deviceid, ULONG streamtype, OSSSTREAMID *pStreamId, int pcm, USHORT fileid);
    54 extern "C" OSSRET OSS32_WaveClose(OSSSTREAMID streamid);
    55 extern "C" int UniaudIoctlHWRefine(OSSSTREAMID streamid, void *pHwParams);
    56 extern "C" int UniaudIoctlHWParamSet(OSSSTREAMID streamid, void *pHwParams);
    57 extern "C" int UniaudIoctlSWParamSet(OSSSTREAMID streamid, void *pSwParams);
    58 extern "C" int UniaudIoctlPCMStatus(OSSSTREAMID streamid, void *pstatus);
    59 extern "C" int UniaudIoctlPCMWrite(OSSSTREAMID streamid, char *buf, int size);
    60 extern "C" int UniaudIoctlPCMRead(OSSSTREAMID streamid, char *buf, int size);
    61 extern "C" int UniaudIoctlPCMPrepare(OSSSTREAMID streamid);
    62 extern "C" int UniaudIoctlPCMStart(OSSSTREAMID streamid);
    63 extern "C" int UniaudIoctlPCMDrop(OSSSTREAMID streamid);
    64 extern "C" int UniaudIoctlPCMResume(OSSSTREAMID streamid, int pause);
    65 extern "C" void UniaudCloseAll(USHORT fileid);
    66 extern "C" int WaitForPCMInterrupt(void *file, int timeout);
    67 extern "C" int unlock_all;
    68 extern "C" int OSS32_CloseUNI16(void);
    69 extern "C" int UniaudCtlGetPowerState(ULONG deviceid, void *state);
    70 extern "C" int UniaudCtlSetPowerState(ULONG deviceid, void *state);
     42extern int GetUniaudCardInfo(ULONG deviceid, void *info);
     43extern int GetUniaudControlNum(ULONG deviceid);
     44extern int GetUniaudControls(ULONG deviceid, void *pids);
     45extern int GetUniaudControlInfo(ULONG deviceid, ULONG id, void *info);
     46extern int GetUniaudControlValueGet(ULONG deviceid, ULONG id, void *value);
     47extern int GetUniaudControlValuePut(ULONG deviceid, ULONG id, void *value);
     48extern int GetNumberOfPcm(int card_id);
     49extern int GetUniaudPcmCaps(ULONG deviceid, void *caps);
     50extern int SetPCMInstance(int card_id, int pcm);
     51extern int WaitForControlChange(int card_id, int timeout);
     52extern int GetNumberOfCards(void);
     53extern OSSRET OSS32_WaveOpen(ULONG deviceid, ULONG streamtype, OSSSTREAMID *pStreamId, int pcm, USHORT fileid);
     54extern OSSRET OSS32_WaveClose(OSSSTREAMID streamid);
     55extern int UniaudIoctlHWRefine(OSSSTREAMID streamid, void *pHwParams);
     56extern int UniaudIoctlHWParamSet(OSSSTREAMID streamid, void *pHwParams);
     57extern int UniaudIoctlSWParamSet(OSSSTREAMID streamid, void *pSwParams);
     58extern int UniaudIoctlPCMStatus(OSSSTREAMID streamid, void *pstatus);
     59extern int UniaudIoctlPCMWrite(OSSSTREAMID streamid, char *buf, int size);
     60extern int UniaudIoctlPCMRead(OSSSTREAMID streamid, char *buf, int size);
     61extern int UniaudIoctlPCMPrepare(OSSSTREAMID streamid);
     62extern int UniaudIoctlPCMStart(OSSSTREAMID streamid);
     63extern int UniaudIoctlPCMDrop(OSSSTREAMID streamid);
     64extern int UniaudIoctlPCMResume(OSSSTREAMID streamid, int pause);
     65extern void UniaudCloseAll(USHORT fileid);
     66extern int WaitForPCMInterrupt(void *file, int timeout);
     67extern int unlock_all;
     68extern int OSS32_CloseUNI16(void);
     69extern int UniaudCtlGetPowerState(ULONG deviceid, void *state);
     70extern int UniaudCtlSetPowerState(ULONG deviceid, void *state);
    7171
    7272typedef UCHAR LOCKHANDLE[12];
     
    8585#pragma pack()
    8686
    87 ULONG StratIOCtl(RP __far* _rp)
     87ULONG StratIOCtl(REQPACKET __far* rp)
    8888{
    89     RPIOCtl __far* rp = (RPIOCtl __far*)_rp;
    9089    USHORT rc = 0;;
    9190    LOCKHANDLE lhParm, lhData;
     
    9695    ULONG ctl_id;
    9796
    98     if (rp->Category != CAT_IOCTL_OSS32)
    99     {
    100 //        printk("not our cat %x. func %x\n", rp->Category, rp->Function);
     97    if (rp->ioctl.bCategory != CAT_IOCTL_OSS32)
     98    {
     99        //printk("not our cat %x. func %x\n", rp->Category, rp->Function);
    101100        // not our category, exit with error
    102         return (RPERR_COMMAND | RPDONE);
     101        return (RPERR_BADCOMMAND | RPDONE);
    103102    }
    104103
    105 #ifdef DEBUG
     104    #ifdef DEBUG
    106105    //printk("StratIOCtl 0x%x\n", rp->Function);
    107 #endif
    108 //    printk("cmd: %x, len: %i, pack: %x\n",rp->Function, rp->ParmLength, rp->ParmPacket);
     106    #endif
     107    //    printk("cmd: %x, len: %i, pack: %x\n",rp->Function, rp->ioctl.usParmLen, rp->ParmPacket);
    109108    // work with Parm Packet
    110     if ((rp->ParmLength != 0 ||
    111          rp->Function == IOCTL_OSS32_ATTACH /*16 bit ioctl*/) &&
    112         ((rp->ParmPacket & 0xfffcffff) != 0))
     109    if ((rp->ioctl.usParmLen != 0 ||
     110         rp->ioctl.bFunction == IOCTL_OSS32_ATTACH /*16 bit ioctl*/) &&
     111        ((rp->ioctl.pvParm & 0xfffcffff) != 0))
    113112    {
    114113        // got Parm Packet
    115         rc = DevVirtToLin((USHORT)((ULONG)(rp->ParmPacket) >> 16),
    116                           (ULONG)((USHORT)(rp->ParmPacket)),
     114        rc = DevVirtToLin((USHORT)((ULONG)(rp->ioctl.pvParm) >> 16),
     115                          (ULONG)((USHORT)(rp->ioctl.pvParm)),
    117116                          (UCHAR * __far *)&linParm);
    118117
    119118        if (rc == 0)
    120119        {
    121             if (rp->Function == IOCTL_OSS32_ATTACH)
    122             {
    123                 rc = DevVMLock(VMDHL_LONG,
    124                            (ULONG)linParm,
    125                            4,
    126                            (LINEAR)-1L,
    127                            lhParm,
    128                                (UCHAR*)&pages);
    129             }else
    130             {
    131                 rc = DevVMLock(VMDHL_LONG,
    132                            (ULONG)linParm,
    133                            rp->ParmLength,
    134                            (LINEAR)-1L,
    135                                lhParm,
    136                                (UCHAR*)&pages);
     120            if (rp->ioctl.bFunction == IOCTL_OSS32_ATTACH)
     121            {
     122                rc = DevVMLock(VMDHL_LONG, (ULONG)linParm, 4, (LINEAR)-1L, lhParm, (UCHAR*)&pages);
     123            }
     124            else
     125            {
     126                rc = DevVMLock(VMDHL_LONG, (ULONG)linParm, rp->ioctl.usParmLen, (LINEAR)-1L, lhParm, (UCHAR*)&pages);
    137127            }
    138128
     
    154144
    155145    // work with Data Packet
    156     if ((rp->DataLength != 0) &&
    157         ((rp->DataPacket & 0xfffcffff) != 0))
     146    if ((rp->ioctl.usDataLen != 0) &&
     147        ((rp->ioctl.pvData & 0xfffcffff) != 0))
    158148    {
    159149        // got Data Packet
    160         rc = DevVirtToLin((USHORT)((ULONG)(rp->DataPacket) >> 16),
    161                           (ULONG)((USHORT)(rp->DataPacket)),
     150        rc = DevVirtToLin((USHORT)((ULONG)(rp->ioctl.pvData) >> 16),
     151                          (ULONG)((USHORT)(rp->ioctl.pvData)),
    162152                          (UCHAR * __far *)&linData);
    163153        if (rc == 0)
    164154        {
    165             rc = DevVMLock(VMDHL_LONG,
    166                            (ULONG)linData,
    167                            rp->DataLength,
    168                            (LINEAR)-1L,
    169                            lhData,
     155            rc = DevVMLock(VMDHL_LONG, (ULONG)linData, rp->ioctl.usDataLen, (LINEAR)-1L, lhData,
    170156                           (UCHAR*)&pages);
    171157        } else
     
    193179    rc = RPDONE; // ok by default
    194180
    195     switch(rp->Function)
     181    switch(rp->ioctl.bFunction)
    196182    {
    197183    case IOCTL_OSS32_ATTACH:
     
    199185            card_id = (ULONG) *linParm;
    200186            // Check if audio init was successful
    201             if (OSS32_QueryNames(card_id, NULL, 0,
    202                                  NULL, 0, FALSE) != OSSERR_SUCCESS)
     187            if (OSS32_QueryNames(card_id, NULL, 0, NULL, 0, FALSE) != OSSERR_SUCCESS)
    203188            {
    204189                rc = RPERR_GENERAL | RPDONE;
     
    208193    case IOCTL_OSS32_VERSION:
    209194        {
    210             if (rp->DataLength < sizeof(ULONG))
     195            if (rp->ioctl.usDataLen < sizeof(ULONG))
    211196            {
    212197                // invalid Data Pkt
     
    221206    case IOCTL_OSS32_GET_PCM_NUM:
    222207        {
    223             if (rp->DataLength < sizeof(ULONG))
     208            if (rp->ioctl.usDataLen < sizeof(ULONG))
    224209            {
    225210                // invalid Data Pkt
     
    234219
    235220    case IOCTL_OSS32_CARDS_NUM:
    236         if (rp->DataLength < sizeof(ULONG))
     221        if (rp->ioctl.usDataLen < sizeof(ULONG))
    237222        {
    238223            // invalid Data Pkt
     
    246231    case IOCTL_OSS32_PCM_CAPS:
    247232        {
    248             if (rp->DataLength < sizeof(ULONG))
     233            if (rp->ioctl.usDataLen < sizeof(ULONG))
    249234            {
    250235                // invalid Data Pkt
     
    259244    case IOCTL_OSS32_CARD_INFO:
    260245        {
    261             if (rp->DataLength < sizeof(ULONG))
     246            if (rp->ioctl.usDataLen < sizeof(ULONG))
    262247            {
    263248                // invalid Data Pkt
     
    272257    case IOCTL_OSS32_GET_POWER_STATE:
    273258        {
    274             if (rp->DataLength < sizeof(ULONG))
     259            if (rp->ioctl.usDataLen < sizeof(ULONG))
    275260            {
    276261                // invalid Data Pkt
     
    285270    case IOCTL_OSS32_SET_POWER_STATE:
    286271        {
    287             if (rp->DataLength < sizeof(ULONG))
     272            if (rp->ioctl.usDataLen < sizeof(ULONG))
    288273            {
    289274                // invalid Data Pkt
     
    298283    case IOCTL_OSS32_GET_CNTRLS_NUM:
    299284        {
    300             if (rp->DataLength < sizeof(ULONG))
     285            if (rp->ioctl.usDataLen < sizeof(ULONG))
    301286            {
    302287                // invalid Data Pkt
     
    313298    case IOCTL_OSS32_GET_CNTRLS:
    314299        {
    315             if (rp->DataLength < sizeof(ULONG))
     300            if (rp->ioctl.usDataLen < sizeof(ULONG))
    316301            {
    317302                // invalid Data Pkt
     
    327312        {
    328313
    329             if (rp->DataLength < sizeof(ULONG))
    330             {
    331                 // invalid Data Pkt
    332                 rc = RPERR_PARAMETER | RPDONE;
    333                 break;
    334             }
    335 
    336             if (rp->ParmLength < sizeof(ULONG))
     314            if (rp->ioctl.usDataLen < sizeof(ULONG))
     315            {
     316                // invalid Data Pkt
     317                rc = RPERR_PARAMETER | RPDONE;
     318                break;
     319            }
     320
     321            if (rp->ioctl.usParmLen < sizeof(ULONG))
    337322            {
    338323                // invalid Data Pkt
     
    351336    case IOCTL_OSS32_CNTRL_GET:
    352337        {
    353             if (rp->DataLength < sizeof(ULONG))
    354             {
    355                 // invalid Data Pkt
    356                 rc = RPERR_PARAMETER | RPDONE;
    357                 break;
    358             }
    359 
    360             if (rp->ParmLength < sizeof(ULONG))
     338            if (rp->ioctl.usDataLen < sizeof(ULONG))
     339            {
     340                // invalid Data Pkt
     341                rc = RPERR_PARAMETER | RPDONE;
     342                break;
     343            }
     344
     345            if (rp->ioctl.usParmLen < sizeof(ULONG))
    361346            {
    362347                // invalid Data Pkt
     
    376361        {
    377362
    378             if (rp->DataLength < sizeof(ULONG)) {
    379                 // invalid Data Pkt
    380                 rc = RPERR_PARAMETER | RPDONE;
    381                 break;
    382             }
    383 
    384             if (rp->ParmLength < sizeof(ULONG)) {
     363            if (rp->ioctl.usDataLen < sizeof(ULONG)) {
     364                // invalid Data Pkt
     365                rc = RPERR_PARAMETER | RPDONE;
     366                break;
     367            }
     368
     369            if (rp->ioctl.usParmLen < sizeof(ULONG)) {
    385370                // invalid Data Pkt
    386371                rc = RPERR_PARAMETER | RPDONE;
     
    399384        {
    400385
    401             if (rp->ParmLength < sizeof(ULONG))
     386            if (rp->ioctl.usParmLen < sizeof(ULONG))
    402387            {
    403388                // invalid Data Pkt
     
    414399    case IOCTL_OSS32_CNTRL_WAIT:
    415400        {
    416             if (rp->DataLength < sizeof(ULONG))
     401            if (rp->ioctl.usDataLen < sizeof(ULONG))
    417402            {
    418403                // invalid Data Pkt
     
    430415            ioctl_pcm *pcm = (ioctl_pcm *)linParm;
    431416            // close all pcms from uniaud16 first
    432             pcm->ret = OSS32_WaveOpen(pcm->deviceid, pcm->streamtype, pData,  pcm->pcm, rp->FileID);
     417            pcm->ret = OSS32_WaveOpen(pcm->deviceid, pcm->streamtype, pData,  pcm->pcm, rp->ioctl.usSysFileNum);
    433418        }
    434419        break;
     
    536521    default:
    537522        {
    538             printk("invalid function code %i\n",rp->Function);
     523            printk("invalid function code %i\n",rp->ioctl.bFunction);
    539524            // invalid function code
    540525            rc = RPERR_PARAMETER | RPDONE;
     
    561546// Dispatch Close requests received from the strategy routine
    562547//******************************************************************************
    563 ULONG StratClose(RP __far* _rp)
     548ULONG StratClose(REQPACKET __far* rp)
    564549{
    565   RPOpenClose __far* rp = (RPOpenClose __far*)_rp;
    566 
    567550  // only called if device successfully opened
    568 //  printk("strat close\n");
     551  //  printk("strat close\n");
    569552  numOS2Opens--;
    570553
    571   UniaudCloseAll(rp->FileID);
     554  UniaudCloseAll(rp->open_close.usSysFileNum);
    572555
    573556  if (numOS2Opens == 0) {
    574         deviceOwner = DEV_NO_OWNER;
     557          deviceOwner = DEV_NO_OWNER;
    575558  }
    576559  return(RPDONE);
    577560}
    578 //******************************************************************************
    579 //******************************************************************************
     561
Note: See TracChangeset for help on using the changeset viewer.