Changeset 507 for OCO/trunk/drv16/ssm_idc.cpp
- Timestamp:
- Jul 11, 2010, 5:31:02 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
OCO/trunk/drv16/ssm_idc.cpp
r483 r507 33 33 extern "C" int open_strategy; 34 34 35 #ifdef DEBUG 36 unsigned long DbgU16IdcCnt = 0; 37 extern "C" void dumpheap(void); 38 #endif 39 35 40 extern "C" ULONG __far __loadds __cdecl DDCMD_EntryPoint(PDDCMDCOMMON pCommon) 36 41 { 37 ULONG ulReturnCode = NO_ERROR; 38 PSTREAM pstream=FindStream(pCommon->hStream); 42 ULONG ulReturnCode = NO_ERROR; 43 PSTREAM pstream=FindStream(pCommon->hStream); 44 45 if(!pstream && (pCommon->ulFunction != DDCMD_REG_STREAM)) { 46 dprintf(("DDCMD_EntryPoint: invalid stream handle %x for cmd %ld", (USHORT)pCommon->hStream, pCommon->ulFunction)); 47 return ERROR_INVALID_STREAM; 48 } 39 49 40 50 #ifdef DEBUG 41 if(pstream == NULL && pCommon->ulFunction != DDCMD_REG_STREAM) { 42 dprintf(("DDCMD_EntryPoint: invalid stream handle %x for cmd %ld", (USHORT)pCommon->hStream, pCommon->ulFunction)); 43 } 51 DbgU16IdcCnt++; 44 52 #endif 45 switch (pCommon->ulFunction) {46 53 47 case DDCMD_SETUP: { 48 ddprintf(("DDCMD_SETUP")); 49 if (!pstream) 50 { 51 dprintf(("DDCMD_SETUP err pstream")); 52 return ERROR_INVALID_STREAM; 53 } 54 PDDCMDSETUP p = (PDDCMDSETUP) pCommon; 55 SETUP_PARM __far *psp = (SETUP_PARM __far *) p->pSetupParm; 56 pstream->SetCurrentTime(psp->ulStreamTime); 54 switch (pCommon->ulFunction) { 55 case DDCMD_SETUP: { 56 PDDCMDSETUP p = (PDDCMDSETUP) pCommon; 57 SETUP_PARM __far *psp = (SETUP_PARM __far *) p->pSetupParm; 57 58 58 // if there is a flags field in the SETUP_PARM 59 // the tell MMPM it can send us 'RECURRING' events.... 60 if (p->ulSetupParmSize > sizeof(ULONG)) 61 { 59 dprintf(("DDCMD_SETUP")); 60 pstream->SetCurrentTime(psp->ulStreamTime); 61 62 // if there is a flags field in the SETUP_PARM 63 // the tell MMPM it can send us 'RECURRING' events.... 64 if (p->ulSetupParmSize > sizeof(ULONG)) { 62 65 // dprintf(("DDCMD_SETUP ParmSize %ld", p->ulSetupParmSize)); 63 64 65 66 67 68 ddprintf(("DDCMD_READ"));69 66 psp->ulFlags = SETUP_RECURRING_EVENTS; 67 } 68 break; 69 } 70 case DDCMD_READ: { 71 dprintf(("DDCMD_READ")); 72 PDDCMDREADWRITE p=(PDDCMDREADWRITE) pCommon; 70 73 71 if (!pstream) 72 return ERROR_INVALID_STREAM; 73 ulReturnCode = 74 pstream->Read((PSTREAMBUF) p->pBuffer,(unsigned) p->ulBufferSize); 75 if (ulReturnCode) 76 return ulReturnCode; 77 break; 78 } 79 // Task time 80 case DDCMD_WRITE: 81 { 82 PDDCMDREADWRITE p=(PDDCMDREADWRITE) pCommon; 74 ulReturnCode = pstream->Read((PSTREAMBUF) p->pBuffer,(unsigned) p->ulBufferSize); 75 break; 76 } 77 // Task time 78 case DDCMD_WRITE: { 79 PDDCMDREADWRITE p=(PDDCMDREADWRITE) pCommon; 83 80 84 if (!pstream) 85 { 86 dprintf(("DDCMD_WRITE err stream %x", (USHORT)pstream)); 87 return ERROR_INVALID_STREAM; 88 } 89 ulReturnCode = pstream->Write((PSTREAMBUF) p->pBuffer,(unsigned) p->ulBufferSize); 90 ddprintf(("DDCMD_WRITE %lx %lx rc=%ld", p->pBuffer, p->ulBufferSize, ulReturnCode)); 91 if (ulReturnCode) 92 return ulReturnCode; 93 break; 94 } 95 case DDCMD_STATUS: { 81 ulReturnCode = pstream->Write((PSTREAMBUF) p->pBuffer,(unsigned) p->ulBufferSize); 82 dprintf(("DDCMD_WRITE %lx %lx rc=%ld", p->pBuffer, p->ulBufferSize, ulReturnCode)); 83 break; 84 } 85 case DDCMD_STATUS: { 96 86 PDDCMDSTATUS p = (PDDCMDSTATUS) pCommon; 97 87 PSTATUS_PARM p2 = (PSTATUS_PARM) p->pStatus; 98 if (!pstream) 99 return ERROR_INVALID_STREAM; 88 100 89 p2->ulTime = pstream->GetCurrentTime(); 101 ddprintf(("DDCMD_STATUS time:%lx", p2->ulTime));90 //dprintf(("DDCMD_STATUS time:%lx", p2->ulTime)); 102 91 break; 103 } 104 case DDCMD_CONTROL: 105 { 106 PDDCMDCONTROL p = (PDDCMDCONTROL) pCommon; 107 if (!pstream) 108 { 109 dprintf(("DDCMD_CONTROL err stream %x", (USHORT)pstream)); 110 return ERROR_INVALID_STREAM; 111 } 92 } 93 case DDCMD_CONTROL: { 94 PDDCMDCONTROL p = (PDDCMDCONTROL) pCommon; 112 95 113 switch (p->ulCmd) 114 { 115 case DDCMD_START: 116 ddprintf(("DDCMD_START")); 117 ulReturnCode = pstream->StartStream(); 118 //ddprintf(("DDCMD_START End rc=%ld",ulReturnCode)); 119 return ulReturnCode; 120 case DDCMD_STOP: 121 ddprintf(("DDCMD_STOP")); 96 switch (p->ulCmd) { 97 case DDCMD_START: 98 dprintf(("DDCMD_START")); 99 ulReturnCode = pstream->StartStream(); 100 //dprintf(("DDCMD_START End rc=%ld",ulReturnCode)); 101 break; 102 case DDCMD_STOP: 103 dprintf(("DDCMD_STOP")); 122 104 //DevHelp_ProcBlock ((ULONG)p, 2, 0); 123 p->ulParmSize=sizeof(ULONG); 124 return pstream->StopStream((PCONTROL_PARM)p->pParm); 125 case DDCMD_PAUSE: 126 ddprintf(("DDCMD_PAUSE")); 127 p->ulParmSize=sizeof(ULONG); 128 return pstream->PauseStream((PCONTROL_PARM)p->pParm); 129 case DDCMD_RESUME: 130 ddprintf(("DDCMD_RESUME")); 131 return pstream->ResumeStream(); 132 case DDCMD_ENABLE_EVENT: 133 ddprintf(("DDCMD_ENABLE_EVENT")); 134 return pstream->EnableEvent(p); 135 case DDCMD_DISABLE_EVENT: 136 ddprintf(("DDCMD_DISABLE_EVENT")); 137 return pstream->DisableEvent(p); 138 case DDCMD_PAUSE_TIME: 139 ddprintf(("DDCMD_PAUSE_TIME")); 140 return pstream->PauseStreamTime(); 141 case DDCMD_RESUME_TIME: 142 ddprintf(("DDCMD_RESUME_TIME")); 143 return pstream->ResumeStreamTime(); 144 default: 145 ddprintf(("DDCMD INVALID REQUEST\n")); 146 return ERROR_INVALID_REQUEST; 147 } /* endswitch */ 148 } 149 case DDCMD_REG_STREAM: 150 { 151 ddprintf(("DDCMD_REG_STREAM size:%lx countbuf:%lx",((PDDCMDREGISTER) pCommon)->ulBufSize, ((PDDCMDREGISTER) pCommon)->ulNumBufs)); 152 if (pstream) 153 { 154 dprintf(("DDCMD_REG_STREAM err stream %x", (USHORT)pstream)); 155 return ERROR_HNDLR_REGISTERED; 156 } 157 pstream = FindStream_fromFile(((PDDCMDREGISTER) pCommon)->ulSysFileNum); 158 if (!pstream) 159 { 160 dprintf(("DDCMD_REG_STREAM1 err stream %x", (USHORT)pstream)); 161 return ERROR_STREAM_CREATION; 162 } 163 ulReturnCode = pstream->Register((PDDCMDREGISTER) pCommon); 164 if (ulReturnCode) 165 { 166 dprintf(("DDCMD_REG_STREAM err stream %x returned %d", (USHORT)pCommon->hStream, (USHORT)ulReturnCode)); 167 return ERROR_STREAM_CREATION; 168 } 169 ddprintf(("DDCMD_REG_STREAM end size:%lx countbuf:%lx",((PDDCMDREGISTER) pCommon)->ulBufSize, ((PDDCMDREGISTER) pCommon)->ulNumBufs)); 170 break; 171 } 172 case DDCMD_DEREG_STREAM: 173 ddprintf(("DDCMD_DEREG_STREAM")); 174 if (!pstream) 175 return ERROR_INVALID_STREAM; 176 if ((USHORT)pCommon->hStream == 1) 177 open_strategy = 1UL; // close it really 178 pstream->DeRegister(); 179 //dprintf(("DDCMD_EntryPoint: DDCMD_DEREG_STREAM stream %x, %ld", (USHORT)pCommon->hStream, open_strategy)); 180 break; 181 default: 182 ddprintf(("INVALID DDCMD\n")); 183 return ERROR_INVALID_FUNCTION; 184 } 105 p->ulParmSize=sizeof(ULONG); 106 ulReturnCode = pstream->StopStream((PCONTROL_PARM)p->pParm); 107 break; 108 case DDCMD_PAUSE: 109 dprintf(("DDCMD_PAUSE")); 110 p->ulParmSize=sizeof(ULONG); 111 ulReturnCode = pstream->PauseStream((PCONTROL_PARM)p->pParm); 112 break; 113 case DDCMD_RESUME: 114 dprintf(("DDCMD_RESUME")); 115 ulReturnCode = pstream->ResumeStream(); 116 break; 117 case DDCMD_ENABLE_EVENT: 118 dprintf(("DDCMD_ENABLE_EVENT")); 119 ulReturnCode = pstream->EnableEvent(p); 120 break; 121 case DDCMD_DISABLE_EVENT: 122 dprintf(("DDCMD_DISABLE_EVENT")); 123 ulReturnCode = pstream->DisableEvent(p); 124 break; 125 case DDCMD_PAUSE_TIME: 126 dprintf(("DDCMD_PAUSE_TIME")); 127 ulReturnCode = pstream->PauseStreamTime(); 128 break; 129 case DDCMD_RESUME_TIME: 130 dprintf(("DDCMD_RESUME_TIME")); 131 ulReturnCode = pstream->ResumeStreamTime(); 132 break; 133 default: 134 rprintf(("DDCMD INVALID REQUEST\n")); 135 ulReturnCode = ERROR_INVALID_REQUEST; 136 break; 137 } /* endswitch */ 138 break; 139 } 140 case DDCMD_REG_STREAM: { 141 dprintf(("DDCMD_REG_STREAM size:%lx countbuf:%lx",((PDDCMDREGISTER) pCommon)->ulBufSize, ((PDDCMDREGISTER) pCommon)->ulNumBufs)); 142 if (pstream) { 143 dprintf(("DDCMD_REG_STREAM err stream %x", (USHORT)pstream)); 144 ulReturnCode = ERROR_HNDLR_REGISTERED; 145 break; 146 } 147 pstream = FindStream_fromFile(((PDDCMDREGISTER) pCommon)->ulSysFileNum); 148 if (!pstream) { 149 dprintf(("DDCMD_REG_STREAM1 err stream %x", (USHORT)pstream)); 150 ulReturnCode = ERROR_STREAM_CREATION; 151 break; 152 } 153 ulReturnCode = pstream->Register((PDDCMDREGISTER) pCommon); 154 if (ulReturnCode) { 155 dprintf(("DDCMD_REG_STREAM err stream %x returned %d", (USHORT)pCommon->hStream, (USHORT)ulReturnCode)); 156 ulReturnCode = ERROR_STREAM_CREATION; 157 break; 158 } 159 //dprintf(("DDCMD_REG_STREAM end size:%lx countbuf:%lx",((PDDCMDREGISTER) pCommon)->ulBufSize, ((PDDCMDREGISTER) pCommon)->ulNumBufs)); 160 break; 161 } 162 case DDCMD_DEREG_STREAM: 163 dprintf(("DDCMD_DEREG_STREAM")); 164 if ((USHORT)pCommon->hStream == 1) open_strategy = 1UL; // close it really 165 pstream->DeRegister(); 166 //dprintf(("DDCMD_EntryPoint: DDCMD_DEREG_STREAM stream %x, %ld", (USHORT)pCommon->hStream, open_strategy)); 167 break; 168 default: 169 rprintf(("INVALID DDCMD\n")); 170 ulReturnCode = ERROR_INVALID_FUNCTION; 171 break; 172 } 185 173 186 return NO_ERROR; 174 #ifdef DEBUG 175 DbgU16IdcCnt--; 176 #endif 177 return ulReturnCode; 187 178 }
Note:
See TracChangeset
for help on using the changeset viewer.