关键词不能为空

当前您在: 主页 > 英语 >

戏说BIOS之CMOS

作者:高考题库网
来源:https://www.bjmy2z.cn/gaokao
2021-02-13 11:18
tags:

-

2021年2月13日发(作者:configure)


戏说


BIOS



CMO S





1. Introduction






CMOS


全称为

< p>
complementary metal oxide semiconductor,


翻译成中


文就是互补金属氧化物半导体,它是由一颗小的纽扣电池供电 的


128/256


bytes ram(

现在的


chipset


通常提供


2 56 bytes


或者更大的空间


)



它主要用


于存放


RTC


以及一些


oem


的系统配置信息,所以除了

< p>
RTC


等部分其它的很


多信息都是


undocumented& non- standard



RTC


标准的


(documented&standard) ram bank


如下表



1


所示:





Index



00h



01h



02h



03h



04h



05h



06h



07h



08h



Seconds



Seconds Alarm



Minutes



Minutes Alarm



Hours



Hours Alarm



Day of Week



Day of Month



Month



Name



09h



0Ah



0Bh



0Ch



0Dh



0Eh-7Fh



Year



Register A



Register B



Register C



Register D



114 Bytes of User RAM






1





2. Access Cmos






访问


cmos


通常是透过


70h,71h


这两个

< br>IO port


实现的,有些


chipset

< p>
支援


256 bytes



cmos ram



访问


128bytes


以后的空间需要开启


chipset


的始能


registe r


,有些


chipset


使用


72h



73h


访问扩 展的空间如


intel


chipset


,有些仍然使用


70h



71h



sis chipset


,因为这部分是 非标准的,


故后面的练习程序就不去读写这部分


ram spa ce


。读写


cmos


的过程非常简


单,读特定的


index


的内容只需要将< /p>


index


送给


70h

< br>,然后就可以从


71h



出对应 的数据,具体过程如下述


code


所示:



;------------------------------------ -------------------------



;



read_cmos



;


read the contents of a specific CMOS register



;


call with:


al = CMOS address to read



;


returns:


ah = Contents of register



;


used registers: ax


;----------------------------------------------- --------------




read_cmos


proc


near






cli




or


al,80h disable NMI




out


70h, al




call


io_delay




in


al, 71h




call


io_delay




mov


ah, al




xor


al,al




out



70h,al ;enable


NMI




sti




ret





read_cmos


endp



写操作和读类似,只是要将 待写入的数据送给


71h


即可代码如下所示:

< br>


;---------------------------------- ---------------------------



;


write_cmos



;


write the contents of a specific CMOS register



;


call with:


al = CMOS address to write



;




ah = Contents of register



;


returns:


NULL



;


used registers: ax


;----------------------------------------------- --------------



write_cmos


proc


near






cli




or


al,80h disable NMI




out


70h,al




call


io_delay




mov


al,ah




out


71h,al




call


io_delay




xor


al,al




out



70h,al enable


NMI




sti




ret





write_cmos


endp





另外有些细节需要注意


:a.


读写过程中都需要关掉中断以防止,中断处理程序


访问


CMOS


以及


RTC


更新过程 中可能会导致并发访问。


(non-maskable interrupt)


是一种中断向量为


2


的中断,但是与常规


中断不同的是它不能通过


mask register


屏蔽掉而且


sti



cli< /p>


指令也对它无



;NMI


通常用于一些无法恢复的硬件错误,访问


CMOS


时也 可能产生


NMI



所以需要关掉。


NMI


可以通过


70h bit7


做开关。


c.


状态寄存器


A bit7


记录了


RTC


是否正在 更新,


如果正在更新则等到更新结束再去读


RTC


(我写



cmosdump


因为偷懒没有检查这一个


bit


?


)。





3. Msg Based Event Driven






知道了以上的知识,我们 就有能力写一个类似


RU



dump cmos


的工具


了,下图


1

< p>
就是我写的








我 觉得访问


cmos


本身并不困难,


画个


UI


倒是挺费劲的,


一个劲狂


call vbios



在完成这支

< p>
tool


的过程中我更深刻的体会到知识是相通的了,

windows


编程


的经验在这里发挥了优势,

< p>
为了能够动态更新,


实时修改我就借鉴了


wind ows









,< /p>









< p>
Mainloop->GetMsg->TranslateMsg->DispatchMsg< /p>


一路下来好不快活!这


部分的代码如下所示:

-


-


-


-


-


-


-


-



本文更新与2021-02-13 11:18,由作者提供,不代表本网站立场,转载请注明出处:https://www.bjmy2z.cn/gaokao/649692.html

戏说BIOS之CMOS的相关文章