[BIOS] Boot Block introduction

Boot Block 本次學習目標: 瞭解 Boot Block 扮演的角色

Boot Block 學習大綱
  1.  What is Boot Block?
  2.  Boot Block main function block diagram
  3.  Boot Block POST Flowchart
  4.  Introduction to the AFUDOS

1. What is Boot Block?

Definition:
It is also a stand alone block in the ROM which allows the end users to recover the BIOS ROM in case of damages. (Power failure during flash update)

Summary: Boot Block = minimum BIOS + crisis recovery

Boot Block 是配合 EEPROM 的架構出現的產物。PC 用的 EEPROM 在 top block 有個獨立控制的 write protect 功能。BIOS vendor 利用這種架構,規劃 Boot Block 區域。可以利用這個硬體保護機制,來做一些應用。比方可以用來修復更新失敗的 BIOS。會用到 Boot Block 的情況是,假設使用者在 更新 BIOS 期間,PC 被切斷了電源,這樣 BIOS 是處於壞掉的情況 (更新失敗)。

如果 Boot Block 沒有被破壞掉的話,則 Boot Block 可以做到最精簡的開機,幫助你再次更新BIOS。至於怎樣修復更新 BIOS,跟 Book Block 能做到怎樣的開機,就要看各家的做法。
有些Book Block有點亮螢幕,有些沒點亮螢幕,不過通常是開到 Dos 之下,然後配合光碟/ usb 隨身碟裡面的 BIOS rom 檔,再次更新到正確的 BIOS。


Q: 比較一下沒有 Boot Block 的 BIOS ROM 做法?

Power on 時 CPU 第一個 code read 一定是FFFFFFF0;
在那邊有放一個 jmp 指令 (因為 FFFFFFF0 ~ FFFFFFFFh 只有16 byte 空間,無法放很多code),CPU 會再跳到其他固定的地方,若這固定的地方放的是 Boot Block code,則先跑 Boot Block,否則是進入 BIOS entry point (BIOS entry point 就是 POST code一開始的地方,而他的第一條指令都是 cli,且位址是固定的,也就是 F000:E05B,legacy BIOS基本上都是這樣設計。)



2. Boot Block main function block diagram








上面是兩種BIOS的block diagram,可以看得出來,大部分的Block都可以自己分配,

只有Boot Block 大家都會儘量把他放在第一個區塊(legacy BIOS 設計)。

下圖是可以看一下boot block包了哪些功能,但其實這些功能是看各家怎樣設計的。

比方不一定要點亮VGA,也不一定要support光碟機,都是有用到才加進去的概念。

別忘記了,這只是救援用的,所以當然越小越好,只要能達成開機,再次更新BIOS就好。












Note : 名詞解釋一下

If the BIOS were to assign resources to each PnP device on every boot, two problems would result. First, it would take time to do something that it has already done before, each boot, for no purpose. After all, most people change their system hardware relatively infrequently. Second and more importantly, it is possible that the BIOS might not always make the same decision when deciding how to allocate resources, and you might find them changing even when the hardware remains unchanged.

ESCD is designed to overcome these problems. The ESCD area is a special part of your BIOS's CMOS memory, where BIOS settings are held. This area of memory is used to hold configuration information for the hardware in your system. At boot time the BIOS checks this area of memory and if no changes have occurred since the last bootup, it knows it doesn't need to configure anything and skips that portion of the boot process.

ESCD is also used as a communications link between the BIOS and the operating system. Both use the ESCD area to read the current status of the hardware and to record changes. Windows 95 reads the ESCD to see if hardware has been changed and react accordingly. Windows 95 also allows users to override Plug and Play resource assignments by manually changing resources in the Device Manager. This information is recorded in the ESCD area so the BIOS knows about the change at the next boot and doesn't try to change the assignment back again.

The ESCD information is stored in a non-volatile CMOS memory area, the same way that standard BIOS settings are stored.





C.3. Boot Block POST Flowchart



下圖是早期A牌的BIOS的Boot Block 開機流程,因為他比較簡單易懂,所以就拿來參考一下。

可以看到只initialize一些需要用到的設備而已,然後就開到dos之下的crisis disk。

(這邊算check sum的點跟後來的BIOS有些不同,所以可以跳過不看沒關係)












C.4. Introduction to the AFUDOS

我比較熟悉的是AMI 的BIOS 所以在這邊介紹一下我常用的AFUDOS.

Summary

(1). AFUDOS is a BIOS update/flash utility with a command line interface.

(2). AFUDOS is supported by MS-DOS environment

(3). System BIOS should have the followings:

a. AMIBIOS CORE version 8.xx.xx.

b. SMIFlash eModule with “8.00.00_SMIFlash-1.00.07” label or later.

c. Token: SDSMGR_IN_RUNTIME = ON.

d. Token: SMI_INTERFACE_FOR_SDSMGR_FUNC = ON.

(4). We can copy the AFUDOS.EXE executable file to any storage location accessible by the host system and then run AFUDOS in command prompt.



AFUDOS 是一個 BIOS 更新工具,屬於“BIOS flash tool”類,使用 MS-DOS 的命令行介面。

使用物件必須為 AMIBIOS 核心 7.xx 或 AMIBIOS8,舊的 AMIBIOS 系統支援 AMIFLASH.COM 程式。

當然EFI的BIOS也是有AFUDOS for EFI BIOS,所以使用時要注意自己的版本是不是正確的。



Usage

AFUDOS [Option 1] [Option 2]...

AFUDOS

AFUDOS /M

AFUDOS /MAI



基本的指令格式

Rules:

Any parameter encolsed by < > is a mandatory field.

Any parameter enclosed by [ ] is an optional field.

cannot co-exist with any [Options].

Main BIOS image is default flashing area if no any option present.

[/C], [/Q], [/REBOOT], [/X], [/Ln] and [/S] will enable [/P] function automatically.

If [/B] present alone, there is only the Boot Block area to be updated.

If [/N] present alone, there is only the NVRAM area to be updated.

If [/E] present alone, there is only the Embedded Controller block to be updated.

If [/E] and [/ECUF] co-exist, [/ECUF] will be no function.

If [/Kn] present alone, there is only non-critical block to be updated.

When [/Ln] is co-exist with [/C], [/C] will be no function.

[/M] can be used as a command for backward compatible



Commands:

/O - Save current BIOS into file

/U - Display ROM file's ROMID

/Ln - Refer to Options: /Ln

/M - Refer to Options: /M

/MAI - Disaply System ROM and ROM file's MA information.

/HOLE: - Update specific ROM Hole according to given name.

/HOLEOUT: - Save specific ROM Hole according to given name.

/D - Verification test of given ROM File without flashing BIOS.

/EC - Flash EC firmware BIOS (Refer to OFBD Spec)

/NCB - Flash NCB Area (Refer to OFBD Spec)

/NCBOUT - Output NCB Data according to given name.



Options:

/P - Program main BIOS image

/B - Program Boot Block

/N - Program NVRAM

/C - Destroy CMOS checksum

/E - Program Embedded Controller Block

/K - Program all non-critical blocks

/Kn - Program n'th non-critical block only(n=0-7)

/Q - Silent execution

/REBOOT - Reboot after programming

/X - Don't Check ROM ID

/S - Display current system's ROMID

/Ln - Load CMOS defaults:(n=0-3)

L0: Load current optimal

L1: Load current failsafe

L2: Load optimal from ROM file

L3: Load failsafe from ROM file

/M - Update bootblock MAC address if it exists

Example: /M1234ABCD will update MAC to 1234ABCD

/R - Preserve ALL SMBIOS structure during NVRAM programming

/ECUF - Update EC BIOS when newer version is detected.

/SHUTDOWN - Shutdown after programming.



命令行模式的用法和示例(AFUDOS 和 AFUWIN):

用法: AFUWIN [選項 1] [選項 2]...



AFUWIN <輸入或輸出檔案名> <命令>



AFUWIN <命令>

命令:

/O - 保存當前 BIOS 到文件

/U - 顯示 ROM 檔的 ROMID

/Ln - 參考選項: /Ln

/M - 參考選項: /M

/MAI - 顯示系統 ROM 和 ROM 檔的 MA 資訊

/HOLE: - 根據給出的名稱更新具體的保留區 ROMHole

NewRomHole1.BIN /HOLE:RomH1

/HOLEOUT: - 根據給出的名稱保存具體的保留區 ROMHole

NewRomHole1.BIN /HOLE:RomH1

/D - 不刷寫 BIOS 情況下,驗證測試給出的 ROM 檔

/EC - 刷寫嵌入式控制器 EC 固件 BIOS(參考 OFBD 說明)

/NCB - 刷寫非關鍵塊 NCB 區域(參考 OFBD 說明)

/NCBOUT - 根據給出的名稱輸出 NCB 資料

選項:

/P - 刷寫 BIOS 主程序映射

/B - 刷寫引導塊 BootBlock

/N - 刷寫非易失隨機訪問記憶體 NVRAM

/C - 清除 CMOS 校驗和

/E - 刷寫嵌入式控制器 EC 塊

/K - 刷寫所有非關鍵塊 NCB

/Kn - 僅刷寫第n個非關鍵塊 NCB(n=0-7)

/Q - 靜默執行

/REBOOT - 刷寫後重新啟動

/X - 強制刷寫,不檢查 ROM ID

/S - 顯示當前系統的 ROMID

/Ln - 載入 CMOS 預設值: (n=0-3)

L0: 載入當前優化值 Load current optimal

L1: 載入當前安全值 Load current failsafe

L2: 從 ROM 檔載入優化值

L3: 從 ROM 檔載入安全值

/M - 更新引導塊 Bootblock MAC 位址(若存在)

例: /M1234ABCD 將更新 MAC 為 1234ABCD

/R - 在 NVRAM 刷寫時保留所有 SMBIOS 結構

/ECUF - 發現新版本時更新嵌入式控制器 EC BIOS

/SHUTDOWN - 刷寫後關機



Examples

Examples on how to update BIOS using the command prompt are shown in following:

來點範例。

Goal: Save current BIOS ROM to file

把現在ROM上的 BIOS 保存到磁碟。

Command: AFUDOS /O

Screenshot: Fig. 2.1






Fig. 2.1 Save current BIOS ROM to file



Goal: Get and display ROM ID from BIOS ROM file

秀ROM ID

Command: AFUDOS /U

Screenshot: Fig. 2.2






Fig. 2.2 Get and display ROM ID from BIOS ROM file



Goal: Update main BIOS image only

更新BIOS的主程式區

Command: AFUDOS /p

Screenshot: Fig. 2.3






Fig. 2.3 Update main BIOS image only



D. Reference

AMIBIOS ROM Utilities User Guide

留言