在VORTEX86上可供使用的CMOS RAM的预留空间为48字节,用户可用汇编或C语言编程来<BR> 使用这些空间。端口地址为70H~71H。<BR> 在VORTEX86中,因端口70H的第7位为NMI的屏蔽位,所以最大的定址范围为7FH (128 bytes)。<BR> 另一个128bytes,我们可通过PCI BIOS的功能来使用位于RTC SRAM高端的128 bytes,以下演示<BR> 程式介绍如何打开、关闭高端的128 bytes。<BR> 使能高端的128 bytes<BR> 在使用RTC SRAM高端的128 bytes时,我们需要设置RTC控制暂存器第7位的LPC桥控制暂存<BR> 器。LPC桥控制暂存器的端口号是1039H,驱动位址为0008H,RTC控制暂存器的端口为48H。<BR> ReadCMOS()/WriteCMOS()<BR> 我们提供两个函数ReadCMOS()/WriteCMOS(),方便用户读写CMOS RAM。在VORTEX86<BR> 的CMOS RAM中还剩余48 bytes,地址从0~47,可供用户编程自由读写。<BR> C 语言源代码<BR> #include <stdio.h><BR> #include <conio.h><BR> #define PCI_BIOS_INTERRUPT 0x1A<BR> #define PCI_BIOS_FUNCTION_ID 0xB1<BR> #define PCI_BIOS_PRESENT 0x01<BR> #define PCI_BIOS_FIND_DEVICE 0x02<BR> #define PCI_BIOS_READ_CONFIG_BYTE 0x08<BR> #define PCI_BIOS_READ_CONFIG_WORD 0x09<BR> #define PCI_BIOS_WRITE_CONFIG_BYTE 0x0B<BR> #define PCI_BIOS_WRITE_CONFIG_WORD 0x0C<BR> unsigned char _cBusNum;<BR> unsigned char _cDeviceNum;<BR> char IsPciBiosPresent();<BR> char PciBios_FindDevice(unsigned nVenderID, unsigned nDeviceID, int nIndex,<BR> unsigned char *pcBusNum, unsigned char *pcDeviceNum);<BR> unsigned int PciBios_ReadWord (char cBusNum, char cDeviceNum, int nOffset);<BR> unsigned char PciBios_ReadByte (char cBusNum, char cDeviceNum, int nOffset);<BR> char PciBios_WriteByte(char cBusNum, char cDeviceNum, int nOffset,<BR> unsigned char cvalue);<BR> /*<BR> 可供使用的VORTEX86 CMOS RAM的预留空间为48 bytes<BR> 用ReadCmos() 和 WriteCmos()函数来操作48 bytes,地址从(00h-2fh)<BR> 使用函数将帮助你读写CMOS RAM,共48 bytes .<BR> */<BR> unsigned char ReadCMOS(unsigned char cIdx)<BR> {<BR> unsigned char c;<BR> if(cIdx>=0x2f)<BR> return 0;<BR> /* 设置RTC控制暂存器,使能RTC SRAM高端的128 bytes */<BR> PciBios_WriteByte(_cBusNum,_cDeviceNum,0x48,PciBios_ReadByte(_cBusNum,_cDeviceNum,0x4<BR> 8)|0x80);<BR> outp(0x70,0x50+cIdx);<BR> c = inp(0x71);<BR> /*清除RTC控制暂存器的第7位,关闭RTC SRAM 高端的128 bytes */<BR> PciBios_WriteByte(_cBusNum,_cDeviceNum,0x48,PciBios_ReadByte(_cBusNum,_cDeviceNum,0x4<BR> 8)&0x7f);<BR> return c;<BR> }<BR> void WriteCMOS(unsigned char cIdx,unsigned char cvalue)<BR> {<BR> if(cIdx>=0x2f)<BR> return;<BR> /*设置RTC控制暂存器的第7位,使能RTC SRAM 高端的128 bytes */<BR> PciBios_WriteByte(_cBusNum,_cDeviceNum,0x48,PciBios_ReadByte(_cBusNum,_cDeviceNum,0x4<BR> 8)|0x80);<BR> outp(0x70,0x50+cIdx);<BR> outp(0x71,cvalue);<BR> /* Clear bit 7 of RTC control register to disable upper 128 bytes RTC SRAM */<BR> PciBios_WriteByte(_cBusNum,_cDeviceNum,0x48,PciBios_ReadByte(_cBusNum,_cDeviceNum,0x4<BR> 8)&0x7f);<BR> }<BR> void main()<BR> {<BR> int i;<BR> unsigned char cBusNum, cDeviceNum;<BR> /* 检测 PCI BIOS */<BR> if(!IsPciBiosPresent())<BR> {<BR> printf("Unable to find PCI BIOS.\n");<BR> return;<BR> }<BR> /*找端口号和驱动器地址 */<BR> PciBios_FindDevice(0x1039,0x0008,0,&cBusNum,&cDeviceNum);<BR> /* 测试函数*/<BR> WriteCMOS(13,0x55);<BR> printf("Read the value we wrote: %x\n",ReadCMOS(13));<BR> }<BR> char IsPciBiosPresent()<BR> {<BR> char cRet;<BR> asm {<BR> mov ah, PCI_BIOS_FUNCTION_ID<BR> mov al, PCI_BIOS_PRESENT<BR> int PCI_BIOS_INTERRUPT<BR> mov cRet, ah<BR> }<BR> return !cRet;<BR> }<BR> char PciBios_FindDevice(unsigned nVenderID, unsigned nDeviceID, int nIndex,<BR> unsigned char *pcBusNum, unsigned char *pcDeviceNum)<BR> {<BR> unsigned char cRet, cBus, cDevice;<BR> asm {<BR> mov ah, PCI_BIOS_FUNCTION_ID<BR> mov al, PCI_BIOS_FIND_DEVICE<BR> mov cx, nDeviceID<BR> mov dx, nVenderID<BR> mov si, nIndex<BR> int PCI_BIOS_INTERRUPT<BR> mov cRet, ah<BR> mov cBus, bh<BR> mov cDevice, bl<BR> }<BR> *pcBusNum = cBus;<BR> *pcDeviceNum = cDevice;<BR> return !cRet;<BR> }<BR> unsigned int PciBios_ReadWord(char cBusNum, char cDeviceNum, int nOffset)<BR> {<BR> unsigned char cRet;<BR> unsigned int nData;<BR> nOffset &= 0xFFFE;<BR> asm {<BR> mov ah, PCI_BIOS_FUNCTION_ID<BR> mov al, PCI_BIOS_READ_CONFIG_WORD<BR> mov bh, cBusNum<BR> mov bl, cDeviceNum<BR> mov di, nOffset<BR> int PCI_BIOS_INTERRUPT<BR> mov cRet, ah<BR> mov nData, cx<BR> }<BR> if(cRet)<BR> return -1;<BR> return nData;<BR> }<BR> unsigned char PciBios_ReadByte(char cBusNum, char cDeviceNum, int nOffset)<BR> {<BR> unsigned char data, cRet;<BR> asm{<BR> mov ah, PCI_BIOS_FUNCTION_ID<BR> mov al, PCI_BIOS_READ_CONFIG_BYTE<BR> mov bh, cBusNum<BR> mov bl, cDeviceNum<BR> mov di, nOffset<BR> int PCI_BIOS_INTERRUPT<BR> mov cRet, ah<BR> mov data, cl<BR> }<BR> if(cRet)<BR> return -1;<BR> return data;<BR> }<BR> char PciBios_WriteByte(char cBusNum, char cDeviceNum, int nOffset, unsigned char cvalue)<BR> {<BR> unsigned char cRet;<BR> asm {<BR> mov ah, PCI_BIOS_FUNCTION_ID<BR> mov al, PCI_BIOS_WRITE_CONFIG_BYTE<BR> mov bh, cBusNum<BR> mov bl, cDeviceNum<BR> mov di, nOffset<BR> mov cl, cvalue<BR> int PCI_BIOS_INTERRUPT<BR> mov cRet, ah<BR> }<BR> return !cRet;<BR> }<BR> 技术支持<BR> 如果你想获得更多的技术支持,请登陆我们的网站:<img align=absmiddle src=pic/url.gif border=0><a target=_blank href=http://www.dmp.com.cn> http://www.dmp.com.cn</a>。<BR> 或给我们发邮件:mailto:tech@dmp.com.cn。</P><P> 详情点击:<img align=absmiddle src=pic/url.gif border=0><a target=_blank href=http://www.icop.com.cn/tech/dmp-hw/bios/Use_Free_Space_in_AMI_BIOS_on_M6117D.pdf> http://www.icop.com.cn/tech/dmp-hw/bios/Use_Free_Space_in_AMI_BIOS_on_M6117D.pdf</a>
|