📄 dos386c.c
字号:
return UDIErrorIPCLimitation; } /* if */ /* Copy passed-by-reference information to parameter passing buffer. */ _fmemmove(rm_address,NEARPTR_TO_FARPTR(PId),sizeof(UDIPId)); /* Don't need to create structure since there is only one parameter. */ Err = REALCALL(UDICreateProcessAddr,rm_buffer_addr); CheckRealError(Err,"UDICreateProcess"); /* Copy "out" data back to protected mode program address. */ _fmemmove(NEARPTR_TO_FARPTR(PId),rm_address,sizeof(UDIPId)); return FUNC_VAL;} /* UDIPCreateProcess() */UDIError UDIPSetCurrentProcess( REALPTR UDISetCurrentProcessAddr, UDIPId PId /* In */ ){ UDIError Err; Err = REALCALL(UDISetCurrentProcessAddr,PId); CheckRealError(Err,"UDISetCurrentProcess"); return FUNC_VAL;} /* UDIPSetCurrentProcess() */UDIError UDIPInitializeProcess( REALPTR UDIInitializeProcessAddr, UDIMemoryRange ProcessMemory[], /* In */ UDIInt NumberOfRanges, /* In */ UDIResource EntryPoint, /* In */ CPUSizeT *StackSizes, /* In */ UDIInt NumberOfStacks, /* In */ char *ArgString /* In */ ){ _Packed struct { REALPTR ProcessMemory; UDIInt NumberOfRanges; UDIResource EntryPoint; REALPTR StackSizes; UDIInt NumberOfStacks; REALPTR ArgString; } params; /* Pointers to variables stored in the parameter passing buffer. */ CPUSizeT _far *StackSizesPtr; char _far *ArgStringPtr; UDIError Err; StackSizesPtr = (CPUSizeT _far *) (rm_address + NumberOfRanges*sizeof(UDIMemoryRange)); ArgStringPtr = (char _far *) (StackSizesPtr + NumberOfStacks * sizeof(CPUSizeT)); if (BufferSizeCheck((FARPTR)(ArgStringPtr + strlen(ArgString) + 1),"UDIPInitializeProcess",PRINT_ON)) { return UDIErrorIPCLimitation; } /* if */ /* Move things passed by reference into the parameter passing buffer. */ _fmemmove(rm_address,NEARPTR_TO_FARPTR(ProcessMemory),NumberOfRanges*sizeof(UDIMemoryRange)); _fmemmove(StackSizesPtr,NEARPTR_TO_FARPTR(StackSizes),NumberOfStacks * sizeof(CPUSizeT)); _fmemmove(ArgStringPtr, NEARPTR_TO_FARPTR(ArgString), strlen(ArgString)+1); /* Fill the packed array for passing to the real mode function. */ params.ProcessMemory = rm_buffer_addr; params.NumberOfRanges = NumberOfRanges; params.EntryPoint = EntryPoint; params.StackSizes = PROT_TO_REAL((FARPTR)StackSizesPtr); params.NumberOfStacks = NumberOfStacks; params.ArgString = PROT_TO_REAL((FARPTR)ArgStringPtr); /* Call the real mode function. */ Err = REALCALL(UDIInitializeProcessAddr,params); CheckRealError(Err,"UDIInitializeProcess"); /* Don't need to copy anything back since all of the parameters are * "in" only. */ return FUNC_VAL;} /* UDIPInitializeProcess() */UDIError UDIPDestroyProcess( REALPTR UDIDestroyProcessAddr, UDIPId PId /* In */ ){ UDIError Err; Err = REALCALL(UDIDestroyProcessAddr,PId); CheckRealError(Err,"UDIDestroyProcess"); return FUNC_VAL;} /* UDIPDestroyProcess() */UDIError UDIPRead( REALPTR UDIReadAddr, UDIResource From, /* In */ UDIHostMemPtr To, /* Out */ UDICount Count, /* In */ UDISizeT Size, /* In */ UDICount *CountDone, /* Out */ UDIBool HostEndian /* In */ ){ _Packed struct { UDIResource From; REALPTR To; UDICount Count; UDISizeT Size; REALPTR CountDone; UDIBool HostEndian; } params; UDIError Err; UDICount _far *CountDonePtr; /* Looping control variables */ UDICount TotalDone=0; /* Total number of items xfered so far */ UDICount CurrentCount; /* Number of items to be xfered this pass */ UDIResource CurrentFrom; /* Current pointer into From area */ char * CurrentTo; /* Current pointer into To area */ UDICount BufAdjust; /* size of buffer overflow in bytes */ UDICount CurrentDone; /* The actual number of items xfered this pass */ CurrentTo = (char *) To; CurrentFrom = From; CurrentCount = Count; do { CountDonePtr = (UDICount _far *) (rm_address + CurrentCount * Size); /* Check to see if transfer needs to be broken into smaller pieces */ BufAdjust = BufferSizeCheck((FARPTR)(CountDonePtr + sizeof(UDICount)),"UDIPRead",PRINT_OFF); if (BufAdjust) { CurrentCount = (rm_end_address - rm_address - sizeof(UDICount)) / Size ; CountDonePtr = (UDICount _far *) (rm_end_address - sizeof(UDICount)); } /* Copy parameters into packed structure. */ params.From = CurrentFrom; params.To = rm_buffer_addr; params.Count = CurrentCount; params.Size = Size; params.CountDone = PROT_TO_REAL((FARPTR)CountDonePtr); params.HostEndian = HostEndian; Err = REALCALL(UDIReadAddr,params); CheckRealError(Err,"UDIRead"); _fmemmove(NEARPTR_TO_FARPTR(&CurrentDone),CountDonePtr,sizeof(UDICount)); /* Increment the TotalDone by the actual number of items xfered as * returned from the function. */ TotalDone += CurrentDone; if ((CurrentDone <= CurrentCount) && (CurrentDone >= 0)) _fmemmove(NEARPTR_TO_FARPTR(CurrentTo),rm_address,CurrentDone * Size); else { _fmemmove(NEARPTR_TO_FARPTR(CurrentTo),rm_address, CurrentCount * Size); SIZE_ERROR(CurrentDone, CurrentCount, "UDIPRead"); } /* Update looping variables for possible next pass */ CurrentFrom.Offset += CurrentCount * Size; CurrentTo += CurrentCount * Size; CurrentCount = Count - TotalDone; } while ((TotalDone < Count) & (FUNC_VAL == UDINoError)); *CountDone = TotalDone; return FUNC_VAL;} /* UDIPRead() */UDIError UDIPWrite( REALPTR UDIWriteAddr, UDIHostMemPtr From, /* In */ UDIResource To, /* In */ UDICount Count, /* In */ UDISizeT Size, /* In */ UDICount *CountDone, /* Out */ UDIBool HostEndian /* In */ ){ _Packed struct { REALPTR From; UDIResource To; UDICount Count; UDISizeT Size; REALPTR CountDone; UDIBool HostEndian; } params; UDIError Err; UDICount _far *CountDonePtr; /* Looping control variables */ UDICount TotalDone=0; /* Total number of items xfered so far */ UDICount CurrentCount; /* Number of items to be xfered this pass */ char * CurrentFrom; /* Current pointer into From area */ UDIResource CurrentTo; /* Current pointer into To area */ UDICount BufAdjust; /* size of buffer overflow in bytes */ UDICount CurrentDone; /* The actual number of items xfered this pass */ CurrentTo = To; CurrentFrom = (char *) From; CurrentCount = Count; do { CountDonePtr = (UDICount _far *) (rm_address + Size * Count); /* Check to see if transfer needs to be broken into smaller pieces. */ BufAdjust = BufferSizeCheck((FARPTR)(CountDonePtr + sizeof(UDICount)),"UDIPWrite",PRINT_ON); if (BufAdjust) { CurrentCount = (rm_end_address - rm_address - sizeof(UDICount)) / Size; CountDonePtr = (UDICount _far *) (rm_end_address - sizeof(UDICount)); } /* if */ /* Move data passed by reference into the parameter passing buffer * area in conventional memory. */ _fmemmove(rm_address, NEARPTR_TO_FARPTR(CurrentFrom), Size * CurrentCount); /* Move data to packed structure for passing to real mode function. */ params.From = rm_buffer_addr; params.To = CurrentTo; params.Count = CurrentCount; params.Size = Size; params.CountDone = PROT_TO_REAL((FARPTR)CountDonePtr); params.HostEndian = HostEndian; Err = REALCALL(UDIWriteAddr,params); CheckRealError(Err,"UDIWrite"); /* Move "out" data back into protected mode memory area. */ _fmemmove(NEARPTR_TO_FARPTR(&CurrentDone),CountDonePtr,sizeof(UDICount)); /* Increment the ToralDone by the actual number of items xfered as * returned from the function. */ TotalDone += CurrentDone; /* Update looping variables for possible next pass */ CurrentFrom += CurrentCount * Size; CurrentTo.Offset += CurrentCount * Size; CurrentCount = Count - TotalDone; } while ((TotalDone < Count) & (FUNC_VAL == UDINoError)); /* Return the total number of items xfered */ *CountDone = TotalDone; return FUNC_VAL;} /* UDIPWrite() */UDIError UDIPCopy( REALPTR UDICopyAddr, UDIResource From, /* In */ UDIResource To, /* In */ UDICount Count, /* In */ UDISizeT Size, /* In */ UDICount *CountDone, /* Out */ UDIBool Direction /* In */ ){ _Packed struct { UDIResource From; UDIResource To; UDICount Count; UDISizeT Size; REALPTR CountDone; UDIBool Direction; } params; UDIError Err; /* Copy data into packed structure for passing to real mode funciton. */ params.From = From; params.To = To; params.Count = Count; params.Size = Size; params.CountDone= rm_buffer_addr; params.Direction= Direction; Err = REALCALL(UDICopyAddr,params); CheckRealError(Err,"UDICopy"); _fmemmove(NEARPTR_TO_FARPTR(CountDone), rm_address, sizeof(UDICount)); return FUNC_VAL;} /* UDIPCopy() */UDIError UDIPExecute( REALPTR UDIExecuteAddr ){ UDIError Err; Err = _dx_call_real(UDIExecuteAddr, &real_regs, 0); CheckRealError(Err,"UDIExecute"); return FUNC_VAL;} /* UDIPExecute() */UDIError UDIPStep( REALPTR UDIStepAddr, UDIUInt32 Steps, /* In */ UDIStepType StepType, /* In */ UDIRange Range /* In */ ){ UDIError Err; _Packed struct { UDIUInt32 Steps; UDIStepType StepType; UDIRange Range; } params; /* Since nothing is passed by reference, don't need to use * buffer transfer area. */ /* Copy passed parameters into packed structure */ params.Steps = Steps; params.StepType = StepType; params.Range = Range; Err = REALCALL(UDIStepAddr,params); CheckRealError(Err,"UDIStep"); return FUNC_VAL;} /* UDIPStep() */UDIError UDIPStop( REALPTR UDIStopAddr ){ UDIError Err; Err = _dx_call_real(UDIStopAddr, &real_regs, 0); CheckRealError(Err,"UDIStop"); return FUNC_VAL;} /* UDIPStop() */UDIError UDIPWait( REALPTR UDIWaitAddr, UDIInt32 MaxTime, /* In */ UDIPId *PId, /* Out */ UDIUInt32 *StopReason /* Out */ ){ UDIError Err; UDIUInt32 _far *StopReasonPtr; _Packed struct { UDIInt32 MaxTime; REALPTR PId; REALPTR StopReason; } params; /* Since only "out" parameters are passed by reference, don't * need to copy anything into the parameter passing buffer before * the call. Do need to set up pointer for StopReason though. */ StopReasonPtr = (UDIUInt32 _far *) (rm_address + sizeof(UDIPId)); if (BufferSizeCheck((FARPTR)(StopReasonPtr + sizeof(UDIUInt32)),"UDIPWait",PRINT_ON)) { return UDIErrorIPCLimitation; } /* if */ params.MaxTime = MaxTime; params.PId = rm_buffer_addr; params.StopReason = PROT_TO_REAL((FARPTR)StopReasonPtr); Err = REALCALL(UDIWaitAddr,params); CheckRealError(Err,"UDIWait"); /* Need to copy "out" parameter data back into protected mode * address space. */ _fmemmove(NEARPTR_TO_FARPTR(PId),rm_address,sizeof(UDIPId)); _fmemmove(NEARPTR_TO_FARPTR(StopReason),StopReasonPtr,sizeof(UDIUInt32)); return FUNC_VAL;} /* UDIPWait() */UDIError UDIPSetBreakpoint( REALPTR UDISetBreakpointAddr, UDIResource Addr, /* In */ UDIInt32 PassCount, /* In */ UDIBreakType Type, /* In */ UDIBreakId *BreakId /* Out */ ){ UDIError Err;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -