pm.c
来自「适合KS8695X」· C语言 代码 · 共 1,051 行 · 第 1/3 页
C
1,051 行
loaded before the interrupt.
****************************************************************************/
int PMAPI PM_int86x(
int intno,
RMREGS *in,
RMREGS *out,
RMSREGS *sregs)
{
CRF saveRegs;
ushort oldDisable;
ULONG rc;
#if 0
/* Disable pass-up to our VxD handler so we directly call BIOS */
TRACE("SDDHELP: Entering PM_int86x()\n");
if (disableTSRFlag) {
oldDisable = *disableTSRFlag;
*disableTSRFlag = 0;
}
#endif
LoadV86Registers(SSToDS(&saveRegs), in, sregs);
VDHResetEventSem(hevIRet);
rc = VDHPushInt(intno);
/* set up return hook for interrupt */
rc = VDHArmReturnHook(hhookUserIRetHook, VDHARH_NORMAL_IRET);
VDHYield(0);
/* wait until the V86 IRETs - our return hook posts the semaphore */
rc = VDHWaitEventSem(hevIRet, 5000); /*SEM_INDEFINITE_WAIT); */
ReadV86Registers(SSToDS(&saveRegs), out, sregs);
#if 0
/* Re-enable pass-up to our VxD handler if previously enabled */
if (disableTSRFlag)
*disableTSRFlag = oldDisable;
#endif
TRACE("SDDHELP: Exiting PM_int86x()\n");
return out->x.ax;
}
void PMAPI PM_availableMemory(ulong *physical,ulong *total)
{ *physical = *total = 0; }
/****************************************************************************
REMARKS:
Allocates a block of locked physical memory.
****************************************************************************/
void * PMAPI PM_allocLockedMem(
uint size,
ulong *physAddr,
ibool contiguous,
ibool below16M)
{
ULONG flags = VDHAP_SYSTEM;
ULONG nPages = (size + 0xFFF) >> 12;
flags |= (physAddr != NULL) ? VDHAP_PHYSICAL : VDHAP_FIXED;
return VDHAllocPages(physAddr, nPages, VDHAP_SYSTEM | VDHAP_PHYSICAL);
}
/****************************************************************************
REMARKS:
Frees a block of locked physical memory.
****************************************************************************/
void PMAPI PM_freeLockedMem(
void *p,
uint size,
ibool contiguous)
{
if (p)
VDHFreePages((PVOID)p);
}
/****************************************************************************
REMARKS:
Lock linear memory so it won't be paged.
****************************************************************************/
int PMAPI PM_lockDataPages(void *p,uint len,PM_lockHandle *lh)
{
ULONG lockHandle;
/* TODO: the lock handle is essential for the unlock operation!! */
lockHandle = VDHLockMem(p, len, 0, (PVOID)VDHLM_NO_ADDR, NULL);
if (lockHandle != NULL)
return 0;
else
return 1;
}
/****************************************************************************
REMARKS:
Unlock linear memory so it won't be paged.
****************************************************************************/
int PMAPI PM_unlockDataPages(void *p,uint len,PM_lockHandle *lh)
{
/* TODO: implement - use a table of lock handles? */
/* VDHUnlockPages(lockHandle); */
return 0;
}
/****************************************************************************
REMARKS:
Lock linear memory so it won't be paged.
****************************************************************************/
int PMAPI PM_lockCodePages(void (*p)(),uint len,PM_lockHandle *lh)
{
return PM_lockDataPages((void*)p,len,lh);
}
/****************************************************************************
REMARKS:
Unlock linear memory so it won't be paged.
****************************************************************************/
int PMAPI PM_unlockCodePages(void (*p)(),uint len,PM_lockHandle *lh)
{
return PM_unlockDataPages((void*)p,len,lh);
}
/****************************************************************************
REMARKS:
OS specific shared libraries not supported inside a VDD
****************************************************************************/
PM_MODULE PMAPI PM_loadLibrary(
const char *szDLLName)
{
(void)szDLLName;
return NULL;
}
/****************************************************************************
REMARKS:
OS specific shared libraries not supported inside a VDD
****************************************************************************/
void * PMAPI PM_getProcAddress(
PM_MODULE hModule,
const char *szProcName)
{
(void)hModule;
(void)szProcName;
return NULL;
}
/****************************************************************************
REMARKS:
OS specific shared libraries not supported inside a VDD
****************************************************************************/
void PMAPI PM_freeLibrary(
PM_MODULE hModule)
{
(void)hModule;
}
/****************************************************************************
REMARKS:
Function to find the first file matching a search criteria in a directory.
****************************************************************************/
void *PMAPI PM_findFirstFile(
const char *filename,
PM_findData *findData)
{
/* TODO: This function should start a directory enumeration search */
/* given the filename (with wildcards). The data should be */
/* converted and returned in the findData standard form. */
(void)filename;
(void)findData;
return PM_FILE_INVALID;
}
/****************************************************************************
REMARKS:
Function to find the next file matching a search criteria in a directory.
****************************************************************************/
ibool PMAPI PM_findNextFile(
void *handle,
PM_findData *findData)
{
/* TODO: This function should find the next file in directory enumeration */
/* search given the search criteria defined in the call to */
/* PM_findFirstFile. The data should be converted and returned */
/* in the findData standard form. */
(void)handle;
(void)findData;
return false;
}
/****************************************************************************
REMARKS:
Function to close the find process
****************************************************************************/
void PMAPI PM_findClose(
void *handle)
{
/* TODO: This function should close the find process. This may do */
/* nothing for some OS'es. */
(void)handle;
}
/****************************************************************************
REMARKS:
Function to determine if a drive is a valid drive or not. Under Unix this
function will return false for anything except a value of 3 (considered
the root drive, and equivalent to C: for non-Unix systems). The drive
numbering is:
1 - Drive A:
2 - Drive B:
3 - Drive C:
etc
****************************************************************************/
ibool PMAPI PM_driveValid(
char drive)
{
/* Not applicable in a VDD */
(void)drive;
return false;
}
/****************************************************************************
REMARKS:
Function to get the current working directory for the specififed drive.
Under Unix this will always return the current working directory regardless
of what the value of 'drive' is.
****************************************************************************/
void PMAPI PM_getdcwd(
int drive,
char *dir,
int len)
{
/* Not applicable in a VDD */
(void)drive;
(void)dir;
(void)len;
}
/****************************************************************************
PARAMETERS:
base - The starting physical base address of the region
size - The size in bytes of the region
type - Type to place into the MTRR register
RETURNS:
Error code describing the result.
REMARKS:
Function to enable write combining for the specified region of memory.
****************************************************************************/
int PMAPI PM_enableWriteCombine(
ulong base,
ulong size,
uint type)
{
return MTRR_enableWriteCombine(base,size,type);
}
/****************************************************************************
REMARKS:
Function to change the file attributes for a specific file.
****************************************************************************/
void PMAPI PM_setFileAttr(
const char *filename,
uint attrib)
{
/* TODO: Implement this ? */
(void)filename;
(void)attrib;
PM_fatalError("PM_setFileAttr not implemented!");
}
/****************************************************************************
REMARKS:
Function to get the file attributes for a specific file.
****************************************************************************/
uint PMAPI PM_getFileAttr(
const char *filename)
{
/* TODO: Implement this ? */
(void)filename;
PM_fatalError("PM_getFileAttr not implemented!");
return 0;
}
/****************************************************************************
REMARKS:
Function to create a directory.
****************************************************************************/
ibool PMAPI PM_mkdir(
const char *filename)
{
/* TODO: Implement this ? */
(void)filename;
PM_fatalError("PM_mkdir not implemented!");
return false;
}
/****************************************************************************
REMARKS:
Function to remove a directory.
****************************************************************************/
ibool PMAPI PM_rmdir(
const char *filename)
{
/* TODO: Implement this ? */
(void)filename;
PM_fatalError("PM_rmdir not implemented!");
return false;
}
/****************************************************************************
REMARKS:
Function to get the file time and date for a specific file.
****************************************************************************/
ibool PMAPI PM_getFileTime(
const char *filename,
ibool gmTime,
PM_time *time)
{
/* TODO: Implement this ? */
(void)filename;
(void)gmTime;
(void)time;
PM_fatalError("PM_getFileTime not implemented!");
return false;
}
/****************************************************************************
REMARKS:
Function to set the file time and date for a specific file.
****************************************************************************/
ibool PMAPI PM_setFileTime(
const char *filename,
ibool gmTime,
PM_time *time)
{
/* TODO: Implement this ? */
(void)filename;
(void)gmTime;
(void)time;
PM_fatalError("PM_setFileTime not implemented!");
return false;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?