⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pm.c

📁 BIOS emulator and interface to Realmode X86 Emulator Library Can emulate a PCI Graphic Controller V
💻 C
📖 第 1 页 / 共 3 页
字号:
{	DWORD	inBuf[2];	/* Buffer to send data to VxD		*/	DWORD	count;		/* Count of bytes returned from VxD	*/	if (!inited)		PM_init();	inBuf[0] = intno;	inBuf[1] = (ulong)regs;	DeviceIoControl(_PM_hDevice, PMHELP_DPMIINT8632, inBuf, sizeof(inBuf),		NULL, 0, &count, NULL);}/****************************************************************************REMARKS:Issue a real mode interrupt.****************************************************************************/int PMAPI PM_int86(	int intno,	RMREGS *in,	RMREGS *out){	DWORD	inBuf[3];	/* Buffer to send data to VxD		*/	DWORD	outBuf[1];	/* Buffer to receive data from VxD	*/	DWORD	count;		/* Count of bytes returned from VxD	*/	if (!inited)		PM_init();	inBuf[0] = intno;	inBuf[1] = (ulong)in;	inBuf[2] = (ulong)out;	if (DeviceIoControl(_PM_hDevice, PMHELP_INT8632, inBuf, sizeof(inBuf),			outBuf, sizeof(outBuf), &count, NULL))		return outBuf[0];	return 0;}/****************************************************************************REMARKS:Issue a real mode interrupt.****************************************************************************/int PMAPI PM_int86x(	int intno,	RMREGS *in,	RMREGS *out,	RMSREGS *sregs){	DWORD	inBuf[4];	/* Buffer to send data to VxD		*/	DWORD	outBuf[1];	/* Buffer to receive data from VxD	*/	DWORD	count;		/* Count of bytes returned from VxD	*/	if (!inited)		PM_init();	inBuf[0] = intno;	inBuf[1] = (ulong)in;	inBuf[2] = (ulong)out;	inBuf[3] = (ulong)sregs;	if (DeviceIoControl(_PM_hDevice, PMHELP_INT86X32, inBuf, sizeof(inBuf),			outBuf, sizeof(outBuf), &count, NULL))		return outBuf[0];	return 0;}/****************************************************************************REMARKS:Call a real mode far function.****************************************************************************/void PMAPI PM_callRealMode(	uint seg,	uint off,	RMREGS *in,	RMSREGS *sregs){	DWORD	inBuf[4];	/* Buffer to send data to VxD		*/	DWORD	count;		/* Count of bytes returned from VxD	*/	if (!inited)		PM_init();	inBuf[0] = seg;	inBuf[1] = off;	inBuf[2] = (ulong)in;	inBuf[3] = (ulong)sregs;	DeviceIoControl(_PM_hDevice, PMHELP_CALLREALMODE32, inBuf, sizeof(inBuf),		NULL, 0, &count, NULL);}/****************************************************************************REMARKS:Return the amount of available memory.****************************************************************************/void PMAPI PM_availableMemory(	ulong *physical,	ulong *total){	/* We don't support this under Win32 at the moment */	*physical = *total = 0;}/****************************************************************************REMARKS:Allocate a block of locked, physical memory for DMA operations.****************************************************************************/void * PMAPI PM_allocLockedMem(	uint size,	ulong *physAddr){	DWORD	inBuf[2];	/* Buffer to send data to VxD		*/	DWORD	outBuf[1];	/* Buffer to receive data from VxD	*/	DWORD	count;		/* Count of bytes returned from VxD	*/	if (!inited)		PM_init();	inBuf[0] = size;	inBuf[1] = (ulong)physAddr;	if (DeviceIoControl(_PM_hDevice, PMHELP_ALLOCLOCKED32, inBuf, sizeof(inBuf),			outBuf, sizeof(outBuf), &count, NULL))		return (void*)outBuf[0];	return 0;}/****************************************************************************REMARKS:Free a block of locked physical memory.****************************************************************************/void PMAPI PM_freeLockedMem(	void *p,	uint size){	DWORD	inBuf[2];	/* Buffer to send data to VxD		*/	DWORD	count;		/* Count of bytes returned from VxD	*/	if (!inited)		PM_init();	inBuf[0] = (ulong)p;	inBuf[1] = size;	DeviceIoControl(_PM_hDevice, PMHELP_FREELOCKED32, inBuf, sizeof(inBuf),		NULL, 0, &count, NULL);}/****************************************************************************REMARKS:Lock linear memory so it won't be paged.****************************************************************************/int PMAPI PM_lockDataPages(void *p,uint len){	DWORD	inBuf[2];	/* Buffer to send data to VxD		*/	DWORD	outBuf[1];	/* Buffer to receive data from VxD	*/	DWORD	count;		/* Count of bytes returned from VxD	*/	inBuf[0] = (ulong)p;	inBuf[1] = len;	if (DeviceIoControl(_PM_hDevice, PMHELP_LOCKDATAPAGES32, inBuf, sizeof(inBuf),			outBuf, sizeof(outBuf), &count, NULL))		return outBuf[0];	return 0;}/****************************************************************************REMARKS:Unlock linear memory so it won't be paged.****************************************************************************/int PMAPI PM_unlockDataPages(void *p,uint len){	DWORD	inBuf[2];	/* Buffer to send data to VxD		*/	DWORD	outBuf[1];	/* Buffer to receive data from VxD	*/	DWORD	count;		/* Count of bytes returned from VxD	*/	inBuf[0] = (ulong)p;	inBuf[1] = len;	if (DeviceIoControl(_PM_hDevice, PMHELP_UNLOCKDATAPAGES32, inBuf, sizeof(inBuf),			outBuf, sizeof(outBuf), &count, NULL))		return outBuf[0];	return 0;}/****************************************************************************REMARKS:Lock linear memory so it won't be paged.****************************************************************************/int PMAPI PM_lockCodePages(void (*p)(),uint len){	DWORD	inBuf[2];	/* Buffer to send data to VxD		*/	DWORD	outBuf[1];	/* Buffer to receive data from VxD	*/	DWORD	count;		/* Count of bytes returned from VxD	*/	inBuf[0] = (ulong)p;	inBuf[1] = len;	if (DeviceIoControl(_PM_hDevice, PMHELP_LOCKCODEPAGES32, inBuf, sizeof(inBuf),			outBuf, sizeof(outBuf), &count, NULL))		return outBuf[0];	return 0;}/****************************************************************************REMARKS:Unlock linear memory so it won't be paged.****************************************************************************/int PMAPI PM_unlockCodePages(void (*p)(),uint len){	DWORD	inBuf[2];	/* Buffer to send data to VxD		*/	DWORD	outBuf[1];	/* Buffer to receive data from VxD	*/	DWORD	count;		/* Count of bytes returned from VxD	*/	inBuf[0] = (ulong)p;	inBuf[1] = len;	if (DeviceIoControl(_PM_hDevice, PMHELP_UNLOCKCODEPAGES32, inBuf, sizeof(inBuf),			outBuf, sizeof(outBuf), &count, NULL))		return outBuf[0];	return 0;}/****************************************************************************REMARKS:Call the VBE/Core software interrupt to change display banks.****************************************************************************/void PMAPI PM_setBankA(	int bank){	RMREGS	regs;	regs.x.ax = 0x4F05;	regs.x.bx = 0x0000;	regs.x.dx = bank;	PM_int86(0x10,&regs,&regs);}/****************************************************************************REMARKS:Call the VBE/Core software interrupt to change display banks.****************************************************************************/void PMAPI PM_setBankAB(	int bank){	RMREGS	regs;	regs.x.ax = 0x4F05;	regs.x.bx = 0x0000;	regs.x.dx = bank;	PM_int86(0x10,&regs,&regs);	regs.x.ax = 0x4F05;	regs.x.bx = 0x0001;	regs.x.dx = bank;	PM_int86(0x10,&regs,&regs);}/****************************************************************************REMARKS:Call the VBE/Core software interrupt to change display start address.****************************************************************************/void PMAPI PM_setCRTStart(	int x,	int y,	int waitVRT){	RMREGS	regs;	regs.x.ax = 0x4F07;	regs.x.bx = waitVRT;	regs.x.cx = x;	regs.x.dx = y;	PM_int86(0x10,&regs,&regs);}/****************************************************************************REMARKS:Enable write combining for the memory region.****************************************************************************/ibool PMAPI PM_enableWriteCombine(	ulong base,	ulong length,	uint type){	DWORD	inBuf[3];	/* Buffer to send data to VxD		*/	DWORD	outBuf[1];	/* Buffer to receive data from VxD	*/	DWORD	count;		/* Count of bytes returned from VxD	*/	if (!inited)		PM_init();	inBuf[0] = base;	inBuf[1] = length;	inBuf[2] = type;	if (DeviceIoControl(_PM_hDevice, PMHELP_ENABLELFBCOMB32, inBuf, sizeof(inBuf),			outBuf, sizeof(outBuf), &count, NULL))		return outBuf[0];	return false;}/****************************************************************************REMARKS:Execute the POST on the secondary BIOS for a controller.****************************************************************************/ibool PMAPI PM_doBIOSPOST(	ushort axVal,	ulong BIOSPhysAddr,	void *mappedBIOS){	/* This is never done by Win32 programs, but rather done by the VxD	 * when the system boots.	 */	(void)axVal;	(void)BIOSPhysAddr;	(void)mappedBIOS;	return false;}/****************************************************************************REMARKS:Load an OS specific shared library or DLL. If the OS does not supportshared libraries, simply return NULL.****************************************************************************/PM_MODULE PMAPI PM_loadLibrary(	const char *szDLLName){	return (PM_MODULE)LoadLibrary(szDLLName);}/****************************************************************************REMARKS:Get the address of a named procedure from a shared library.****************************************************************************/void * PMAPI PM_getProcAddress(	PM_MODULE hModule,	const char *szProcName){	return (void*)GetProcAddress((HINSTANCE)hModule,szProcName);}/****************************************************************************REMARKS:Unload a shared library.****************************************************************************/void PMAPI PM_freeLibrary(	PM_MODULE hModule){	FreeLibrary((HINSTANCE)hModule);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -