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

📄 bottom.c

📁 在DOS下进行PCI设备的操作。经过BC3.1编译。
💻 C
字号:

#include <stdio.h>
#include <dos.h>
#include <math.h>
#include "bottom.h"
 
#define  IntDataBaseAddress		0xa00000L

unsigned short int CheckMem(void)
{
	unsigned long  int 	WriteDataPointer, ReadDataPointer;
	unsigned short int	IsError=0;
	delay(1000);
	
	printf("first fill memory...\n");
	for(ReadDataPointer=0;ReadDataPointer<125L;ReadDataPointer++){//TST 500M memory
		for(WriteDataPointer=0;WriteDataPointer<(1024l*1024l);WriteDataPointer++){
			WriteDWord(IntDataBaseAddress+ReadDataPointer*(1024l*1024l*4l)+WriteDataPointer*4l,0x55555555);
		}
		printf("-");
	}
	printf("\nread and check memory...\n");	
	for(ReadDataPointer=0;ReadDataPointer<125l;ReadDataPointer++){
		for(WriteDataPointer=0;WriteDataPointer<(1024l*1024l);WriteDataPointer++){
			if(ReadDWord(IntDataBaseAddress+ReadDataPointer*1024l*1024l*4l+WriteDataPointer*4l)!=0x55555555){
				printf("memory check error\n");
				IsError=1;
				return IsError;
			}
		}
		printf("+");
	}
	printf("\nmemory check successful!\n");	
	return IsError;
}

unsigned long int SystemClockTick(void)
{
   unsigned long int far *p;  	//not far * !!! 1999.12.22 14:00 lsx
   unsigned long int ulTimeData;
   p=(unsigned long int far*)MK_FP(0,0x46c);
   _disable();    				//changed 2000.8.17 at chengdu
   ulTimeData=*p;
   _enable();
   return (ulTimeData);
}

void WriteDWord (unsigned long int Address,unsigned long int bAX)
{
//	_disable();
	asm db 0x66
	asm mov ax,word ptr bAX;
	asm db 0x66
	asm mov di,word ptr Address //MOV EDI, Address
	asm db 0x67
	asm db 0x66 				//32 bit Address Prefix
	asm db 0x64 				//FS:
	asm mov word ptr [BX],ax 	//=MOV FS: [EDI],AL
//	_enable();
//    asm pop di
//    asm sti
}

unsigned long int ReadDWord (unsigned long int Address)
{
//	asm cli
//    asm push di
	unsigned long int tmp;
//	_disable();
	asm db 0x66
	asm mov di,word ptr Address // MOV EDI, Address
	asm db 0x67 				//32 bit Address Prefix
	asm db 0x66    //32 bit register prefix in 16 bit instrction system
	asm db 0x64 				//FS:
	asm mov ax,word ptr [BX] 	// =MOV eax, FS: [EDI]
	
//	asm db 0x67
	asm db 0x66
	asm mov word ptr tmp,ax
//	_enable();
//    asm pop di
//    asm sti
	return tmp;
}

unsigned short int ReadWord (unsigned long Address)
{
//	asm cli
//    asm push di
//	_disable();
	asm db 0x66
	asm mov di,word ptr Address // MOV EDI, Address
	asm db 0x67 				//32 bit Address Prefix
	asm db 0x64 				//FS:
	asm mov ax,word ptr [BX] 	// =MOV AL, FS: [EDI]
//    asm pop di
//    asm sti
//	_enable();
	return _AX;
}

void WriteWord (unsigned long Address,unsigned short int bAX)
{
//    asm cli
//    asm push di
//	_disable();
	_AX=bAX;
	asm db 0x66
	asm mov di,word ptr Address //MOV EDI, Address
	asm db 0x67 				//32 bit Address Prefix
	asm db 0x64 				//FS:
	asm mov word ptr [BX],ax 	//=MOV FS: [EDI],AL
//	_enable();
//    asm pop di
//    asm sti
	
}

unsigned long int inpd (unsigned short int PortAddr)
{
   unsigned long int  EAXValue,ReturnValue;
   unsigned short int DXValue;

//	_disable();
	DXValue=_DX;
	EAXValue=_EAX;
	
	_DX =PortAddr;
	__emit__(0x66,0xed);  //input 32 bits from io port
	ReturnValue=_EAX;
	
	_EAX=EAXValue;
	_DX =DXValue;
//	_enable();

   return (ReturnValue);

}

void outpd (unsigned short int PortAddr,unsigned long int Value)
{
   unsigned long int EAXValue;
   unsigned short int DXValue;
   
//	_disable();
	DXValue=_DX;
	EAXValue=_EAX;
	_DX =PortAddr;
	_EAX=Value;
	__emit__(0x66,0xef);//output 32 bits to io port
	_EAX=EAXValue;
	_DX =DXValue;
//	_enable();
   
}

⌨️ 快捷键说明

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