亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
樓主: daidongly
打印 上一主題 下一主題

關(guān)于ROM BIOS的啟動(dòng)問題 [復(fù)制鏈接]

論壇徽章:
0
11 [報(bào)告]
發(fā)表于 2008-03-01 15:46 |只看該作者
原帖由 cainiao911 于 2008-2-29 23:25 發(fā)表
我還是認(rèn)為應(yīng)該是拷貝,我又找了一些證據(jù)。
award源代碼:
  ;-------------------------------;
  ;  Switch to Proctected Mode ;
  ;-------------------------------;
      cli   
      lgdt    f ...

這段代碼是拷貝VGA bios到0xc0000。VGA bios確實(shí)是拷貝的,它用于提供INT 10中斷的處理函數(shù),操作系統(tǒng)要拷調(diào)用這個(gè)中斷切換模式,例如從640*480的分辨率切換到高分辨率。
我的意思是開機(jī)上電的時(shí)候,BIOS本身的代碼是不是被拷貝到內(nèi)存的,如果是,誰做的這個(gè)拷貝工作。
唉,還是沒找到相關(guān)文章。


PS:CU討論技術(shù)問題不會(huì)有人生攻擊的,說的對(duì)就是對(duì),錯(cuò)就是錯(cuò)。所以兄臺(tái)不必太在意自己是不是剛開始研究,大家討論而已嘛:wink:

[ 本帖最后由 zx_wing 于 2008-3-1 15:48 編輯 ]

論壇徽章:
0
12 [報(bào)告]
發(fā)表于 2008-03-01 21:17 |只看該作者
找到證據(jù)了,先看一段:

ROM Shadowing

As described in the section on UMA ROM and RAM, in most PCs, there is a full 384 KB area of RAM in the UMA. When any addresses in the UMA region are used by ROMs, the RAM underlying them is hidden. However, that doesn't mean that it has to be wasted.

One problem with ROMs such as those used for the system BIOS and video BIOS, is that it is relatively slow. The access time of ROMs is usually between 120 and 200 ns, compared to system RAM which is typically 50 to 70 ns. Also, system RAM is accessed 32 bits at a time, while ROMs are usually 16 bits wide. The result of this is that accesses to the BIOS code are very slow relative to accesses to code in the system memory.

I'm sure you can see where this is heading. Since there is RAM hiding underneath the ROMs anyway, most systems have the ability to "mirror" the ROM code into this RAM to improve performance. This is called ROM Shadowing, and is controlled using a set of BIOS parameters. There is normally a separate parameter to control the shadowing of the system BIOS, the video BIOS and adapter ROM areas.

When shadowing of a region of memory is enabled, at boot time the BIOS copies the contents of the ROM into the underlying RAM, write-protects the RAM and then disables the ROM. To the system the shadow RAM appears as if it is ROM, and it is also write-protected the way ROM is. This write-protection is important to remember, because if you enable shadowing of memory addresses that are being used for RAM, the device using it will cease to function when the RAM can no longer be written to (it is locked out by the shadowing). Some network cards for example use parts of the memory region they occupy for both ROM and RAM functions. Enabling shadowing there will cause the card to hang up due to the write-protection. Similarly, you should never turn on shadowing of the regions of memory being used for an EMS frame buffer or for UMBs.

In normal circumstances, the system BIOS and video BIOS are the only areas shadowed. This can in theory cause problems with some operating systems, though I have never personally encountered this. I have also heard rumors of video cards that don't function correctly when video BIOS shadowing is off, but I haven't encountered that myself either.



從上面的論述我們可以看到,BIOS在最初階段是被映射的。BIOS代碼放到ROM里面,以write-protects的形式被映射執(zhí)行。為了提高效率,ROM里的代碼被允許拷貝到內(nèi)存(RAM)中執(zhí)行,并同時(shí)禁止調(diào)ROM的映射。這個(gè)就是ROM shadow的作用和原因。所以可以看出,最初上電執(zhí)行時(shí),BIOS代碼是被映射執(zhí)行的,而不是拷貝。

論壇徽章:
0
13 [報(bào)告]
發(fā)表于 2008-03-02 02:10 |只看該作者
偶的看法:
在整個(gè)物理地址空間中, 可以被劃分給 BIOS 的有4個(gè):

FFE00000 ~ FFFFFFFF: 被映射到 flash 類型的存儲(chǔ)介質(zhì)的 ROM,存放 BIOS
000F0000 ~ 000FFFFF: 在 1M 范圍下,典型被映射到 RAM,若想從 flash 拷貝到 RAM ,就拷貝到此區(qū)域
000E0000 ~ 000EFFFF: 這個(gè)地址空間可以映射到 RAM 或 ROM,典型地可以復(fù)制 BIOS 中擴(kuò)展代碼
000C0000 ~ 000DFFFF: 某些 PCI 設(shè)備的 BIOS 可以映射到這個(gè)區(qū)域。

對(duì)于 000F0000 ~ 000FFFFF 這個(gè)區(qū)域是比較有疑問的。processor 復(fù)位后執(zhí)行第一條的指令 [FFFFFFF0] 就是一條跳轉(zhuǎn)指令,結(jié)果就是跳轉(zhuǎn)到 000F0000 ~ 000FFFFF 這個(gè)區(qū)域里,偶不太認(rèn)可 bios 復(fù)制到這里一說。偶傾向于bios代碼映射到這里這種觀點(diǎn)。
偶想花時(shí)間好好研究BIOS代碼,希望能有更清晰的答案

論壇徽章:
0
14 [報(bào)告]
發(fā)表于 2008-03-02 12:41 |只看該作者
原帖由 mik 于 2008-3-2 02:10 發(fā)表
偶的看法:
在整個(gè)物理地址空間中, 可以被劃分給 BIOS 的有4個(gè):

FFE00000 ~ FFFFFFFF: 被映射到 flash 類型的存儲(chǔ)介質(zhì)的 ROM,存放 BIOS
000F0000 ~ 000FFFFF: 在 1M 范圍下,典型被映射到 RAM,若想從 ...

贊同。mik研究好了把成果發(fā)出來共享哈

論壇徽章:
0
15 [報(bào)告]
發(fā)表于 2008-03-02 14:58 |只看該作者
不好意思各位,可能我前面的一些回答,表達(dá)方式不對(duì)。下面再次予以闡述。
1,首先CPU執(zhí)行第一條指令(jmp far f000:e05b)的時(shí)候,0xFFFFFFFF---FFFF0000, 0xFFFFF---0xF0000的都是映射的,并且都是映射到相同的Flash Rom,關(guān)于這一點(diǎn)我們可以在Intel的MCH DataSheet的System Address Map這一章節(jié)看到。
2,Cpu執(zhí)行這條指令后,將導(dǎo)致CS隱藏寄存器中基地址從0xFFFF0000變成000F0000。所以物理地址將落在0x000FE05B,也就是在1M以下那個(gè)Bios。
3,地址的映射是可以通過配置PCI總線來完成的,可以配置給Flash Rom, 也可以是DRAM.
4,Memory Shadow肯定是發(fā)生在第一條指令之后,到底是在之后的什么時(shí)候我暫時(shí)不清楚。
5這條可能假設(shè)性比較強(qiáng),抱歉,我只是談?wù)効捶。在Shadow之前,肯定要映射一部分DRAM(記為DRAM1),這樣我們才可以將flash bios拷貝到臨時(shí)區(qū)域,拷貝到臨時(shí)區(qū)域之后,我們命令pci總線將0xFFFFF---0xF0000分配給另一部分DRAM(記為DRAM2),分配之后,因?yàn)镈RAM2中沒有數(shù)據(jù),所以我們將臨時(shí)區(qū)域中的BIOS拷貝到DRAM2)中。至于為什么不從4G高地址拷貝,而是使用臨時(shí)區(qū)域,或者4G那個(gè)部分是否和Shadow有關(guān),暫時(shí)不知道。

有一篇在2007韓國(guó)poc大會(huì)上發(fā)表的文檔(BIOS Boot Hijacking And VMware Vulnerabilities Digging),估計(jì)是國(guó)人寫的,有關(guān)于Memory Shadow的一些信息,有興趣的可以看看。

下面摘錄幾句:
Right after machine power-on and the very beginning of the Boot
stage, the E_segment (0xE0000~0xEFFFF) and F_segment
(0xF0000~0xFFFFF) are not claimed by North Bridge, and all
accesses to these ranges are actually forwarded to South Bridge
and decoded by Firmware Hub (FWH) until subsequently North
Bridge RAM shadowing function will be enabled by BIOS code.

􀂄 E_segment/F_segment and their counterparts in High BIOS Area
(topmost 2M in the whole accessible 4G physical memory space)
are both decoded by FWH into the last two 64k of BIOS ROM chip,
so we can say that E_segment and F_segment alias to
0xFFFE0000~0xFFFEFFFF and 0xFFFF0000~0xFFFFFFFF respectively.

􀂄 The first instruction that CPU executes upon power-on is at
0xFFFFFFF0 (alias to 0xFFFF0 and both are within BIOS ROM chip)
where usually a far jump instruction resides (mostly JMP
F000:E05B, and after this jump CS base 0xFFFF0000 will get
flushed) , so the next instruction will be fetched from 0xFE05B
(alias to 0xFFFFE05B) which is also decoded into BIOS ROM.

論壇徽章:
0
16 [報(bào)告]
發(fā)表于 2008-03-02 15:21 |只看該作者
下面再摘錄一點(diǎn)東西。出處:http://www.programmer-club.com/p ... ssembly&id=6277

[Why shadow BIOS ?]
在此之前所提的BIOS tasks,都是循著 CPU->NB->SB->SIO->ROM的路徑來達(dá)成的;意即: CPU是去BIOS ROM里面抓code來執(zhí)行 ! 明顯的一件事是: ROM access time > DRAM access time ! 且RAM access width is 32bits,而 ROM access width 通常為 16 bits. 因此,便有了所謂" BIOS Shadowing"的觀念產(chǎn)生 ! <- "performance consideration" !!!

[What is shadowing]
意即: 將部分BIOS CODE(in ROM)拷貝至DRAM中 ! (此后, CPU將從DRAM中抓code來執(zhí)行...)這樣的動(dòng)作便稱做 "Shadowing" ! 而該處的DRAM即稱為 shadow memory.

Shadowing 在BIOS 中是極為復(fù)雜的 kernel code part ! 想深入了解的人最好有 source code可 trace.

[When to shadow BIOS]
=> 當(dāng)然是等內(nèi)存穩(wěn)定了,可以使用后,才做 ^_^

*因此,假如 DRAM sizing 有問題, BIOS shadowing必定有問題 !!!


以下是之前在其他文章中發(fā)表關(guān)于 shadow 的文章,再次節(jié)錄以供參考 !

[System Behavior before & after shadow]
說 的更白話一點(diǎn)就是 : 當(dāng) Power On后, 跑完 system power-on sequence后, CPU會(huì)被 reset ( reset 指的是 CPU 的 內(nèi)容會(huì)回到 "初始值" ); 而 CPU內(nèi)部的 EIP (32-bit )的初值是 FFFFFFF0h, 所以, CPU的 第一個(gè) code read 就是到 FFFFFFF0h fetch code...

這個(gè) memory cycle 從 CPU發(fā)出, 先會(huì)經(jīng)過 North bridge ; 此時(shí), north bridge會(huì)說 "這不是我的"...然后,往 south bridge 丟 ; south bridge 會(huì)說, "這是我的",收下后丟給 ROM ! 所以, FFFFFFF0h 會(huì)被 ROM 接走 !!! ( 所以 前人才說 "硬件初始值要把0xFFFFFFF0 和 0x000FFFF0 要mapping到同一個(gè)地方", 這個(gè)地方就是.....ROM !!! )

之后, CPU所發(fā)的 cycle 都會(huì)照上述的方式一路抵達(dá) ROM...由 CPU循著 fetch, decode, execute, store的順序作事情...

但 到某一個(gè)階段前, BIOS的 code 會(huì)指示 " 要將 BIOS data 從 ROM 搬到 DRAM" ! 而在此階段之后, BIOS會(huì)設(shè)定 north bridge 緩存器, 告訴 north bridge "之后 CPU所發(fā)的 cycle 不可以不收而傳到 south bridge"....

自此之后, CPU 所發(fā)的 cycle 全部轉(zhuǎn)到 DRAM 中,由 CPU循著 fetch, decode, execute, store的順序作事情...

<Summary> 總而言之, BIOS 一開始是CPU讀取 ROM content來執(zhí)行,之后是CPU 讀取 DRAM content 執(zhí)行 ^_^










-------------------------------------------------------------------------------------------------------------------------------------------------

[補(bǔ)充][以提問的方式^_^]

[Q]: shadow memory到底是那一塊 ?
[A]: 以現(xiàn)在的計(jì)算機(jī)系統(tǒng)而言, shadow memory 是在UMA(upper memory area;傳統(tǒng)內(nèi)存 640K以上至1M之間) "里面"(part of it) ;在此UMA內(nèi)可以分為 6 segments(64kB/each), total 384KB.

其中 C0000h~DFFFFh: for VGA BIOS and other devices' Option ROMs
     E0000h~FFFFFh: BIOS ROM code

這兩個(gè) blocks 本質(zhì)是 memory;之后會(huì)被載以ROM content;因此,便稱為 shadow memory(好像: ROM在上面, memory在下面,是ROM的 "shadow"...)

[Q]: shadow memory 的內(nèi)容 完全 "=" ROM content ?
[A]: of course NOT ! 除了 UMA不大以外,BIOS ROM因?yàn)楸仨歴upport more and more functions/features,size已經(jīng)越長(zhǎng)越大;除此之外,BIOS ROM中也有部分module是經(jīng)過壓縮的.(UMA不夠放...)

當(dāng)BIOS shadow時(shí),只會(huì) copy necessary code(Ex. run-time要用的...etc)至 shadow memory ! 另外,已經(jīng)執(zhí)行過后的code也不會(huì)被加載. 因此,不是 1-1的copy...

[Q]: what Shadow enabled/disable mean in chipset ?
[A]: 前面提過, CPU要 fetch的code由 shadow memory 提供 or ROM提供,其根本關(guān)鍵在于 chipset's behavior ! 意即,NB必須做此決定 ! 所以,這機(jī)制一般是由NB來實(shí)現(xiàn)的.

NB內(nèi)有所謂的 shadow registers. 當(dāng) shadow register enable時(shí), memory cycle由 shadow memory 來回應(yīng);若 shadow disable,則由ROM回應(yīng).

意即:
000E0000h~000FFFFFh由 shadow memory replies if (shadow enabled)
000E0000h~000FFFFFh由 ROM chip replies if (shadow disabled)

若FFFE000h~FFFFFFFFh呢 ? 必定由ROM chip來回應(yīng)(不然一開機(jī)怎么辦?). 與 shadow disable/enable無關(guān) !!!

*若使用 ru.exe 并檢視 memory space,可發(fā)現(xiàn)上述的情況.

[Q]: shadow有何好處 ?
[A]: 因?yàn)?slower ROM v.s faster RAM,所以放在RAM可以增加 system performance.

*各位可以發(fā)現(xiàn),同樣的code放在 rom & dram中執(zhí)行速度將大不相同 !

[Q]: shadow memory的 issue ?
[A]: 被 shadowed 的 memory area都會(huì)被設(shè)成 write-protected ! 因此,這塊area是不能 write 的.所以,若有程序會(huì) "write"這塊,則會(huì)有問題 !!!

其實(shí), BIOS shadow這段code大家不太會(huì)碰觸到...了解基本information即可.

有錯(cuò)誤請(qǐng)指正 !!!

論壇徽章:
0
17 [報(bào)告]
發(fā)表于 2008-03-02 15:27 |只看該作者
原帖由 cainiao911 于 2008-3-2 14:58 發(fā)表
不好意思各位,可能我前面的一些回答,表達(dá)方式不對(duì)。下面再次予以闡述。
1,首先CPU執(zhí)行第一條指令(jmp far f000:e05b)的時(shí)候,0xFFFFFFFF---FFFF0000, 0xFFFFF---0xF0000的都是映射的,并且都是映射到相同的F ...


要徹底明白這些問題,看 Intel 北橋芯片 datasheet 是不夠的。 intel 的 mch 的 datasheet 也沒能說得明白。

搞清問題只有結(jié)合二個(gè)途徑: pci 總線規(guī)范和 BIOS 代碼(或者 BIOS 的開發(fā)手冊(cè)),研究 BIOS 相關(guān)的開發(fā)手冊(cè)猶為重要,會(huì)提及 PCI 總線的初始配置情況。從而得出 pc 系統(tǒng)未上電時(shí)的初始配置。

論壇徽章:
0
18 [報(bào)告]
發(fā)表于 2008-03-02 15:44 |只看該作者
Intel的MCH DataSheet確實(shí)只是說到了映射,沒說過程。
不知閣下有無PCI System Architecture電子版,能否共享?

[ 本帖最后由 cainiao911 于 2008-3-2 15:50 編輯 ]

論壇徽章:
0
19 [報(bào)告]
發(fā)表于 2008-03-02 16:43 |只看該作者
原帖由 cainiao911 于 2008-3-2 15:44 發(fā)表
Intel的MCH DataSheet確實(shí)只是說到了映射,沒說過程。
不知閣下有無PCI System Architecture電子版,能否共享?

給個(gè)郵箱,發(fā)給你吧

論壇徽章:
0
20 [報(bào)告]
發(fā)表于 2008-03-02 17:22 |只看該作者
mytoolsdisk1@126.com,先行謝過!
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP