1. A.學習目標 (BIOS Introduction)
a.瞭解 BIOS 在 PC 中扮演的角色及相關的解釋名詞。
b.瞭解基本的 System Memory Map。
c.關於 BIOS Training Course 接下來課程的基本介紹。
B.大綱
1. BIOS Brief Introduction
1.1. What is BIOS?
1.2. BIOS Definition
1.3 System Memory Map
1.4 BIOS Category
1.5 BIOS Vendor
1.6 Vendors of Flash ROM
1.7 First Instruction Executed
2. BIOS Develop and Debug Tools: ADU& RW
3. What is SF100?
C. BIOS Introduction
1. BIOS Brief Introduction
1.1. What is BIOS?
Acronym: Basic Input Output System
Function: Perform all necessary functions
Properly initialize the system's hardware (POST-Power on Self Test)
Keyboard, video display, communications ports, and disk drives
Store medium: Flash ROM (Read Only Memory)
Interface: Between OS/AP and H/W (Firmware 韌體)
Language: Assembler or C (EFI BIOS)
1.2. BIOS Definition
BIOS -- Basic Input and Output System, is used for initializing, testing and putting the PC into
the ready state so that an OS may be started. Part of the BIOS remains in the system main
memory after POST (Power on Self Test). BIOS provides a consistent software interface to
varying types of the hardware devices. It also provides the basic system level services to OS.
The BIOS is also used for helping IHV to fix their hardware design bugs by using the SMM
mode of the IA architecture.
BIOS,基本輸入輸出系統(Basic Input-Output System),其內容儲存在主機板上的一個
ROM 內,主要儲存著有關系統最重要的基本輸入輸出程式,系統訊息設置、Post 程式和
Boot to OS 程式等。
所有會在 BIOS 之前發生的操作就只有 Power On,也就是按下電腦上電源開關的那
一瞬間。在 Power On 階段一開始,會進入 BIOS 的啟動流程,當使用者按下電源開
關,CPU 會先被啟動去尋找 BIOS 中的第一道指令,接著 BIOS 會在 Flash Memory
中執行,配合著 CMOS 中使用者所喜好的設置,然後 BIOS 會將自己解壓縮到電腦
的主記憶體中繼續執行。
BIOS 的基本功能:
1
2. (1) POST (Power On Self Test) 開機自我測試
包括對 CPU 各項暫存器、Memory、ROM、Main board、CMOS 記憶體,video
display、communications ports、disk drives 及 Keyboard 進行測試。
(2) Initialize
初始化硬體,設置其基本狀態,使得整個計算機達到所謂的 Ready State,使得硬體能
夠按照 PC 的架構工作,BIOS 必須要按照由 IHV 提供的手冊將硬體設置好,比如寫
幾個必須的 register 之類的,做一些 enable 的工作。
初始化立的內容大致上有:
(a) Build up Interrupt Vector Table (建立中斷向量表)
(b) System Resources Allocation
(c) Register
(d) I/O Device
Note:
IVH (Independent Hardware Vendor) An organization that makes electronic equipment. It
implies a company that specializes in a niche area, such as display adapters or disk
controllers, rather than a computer systems manufacturer.
(3) 系統設置程式
記錄系統的設定值,並且儲存在 CMOS or FLASH Memory 的 ESCD 區域,主要
儲存著系統基本情況 CPU 特性 軟硬碟驅動器 顯示器 鍵盤等部件的訊息 在 BIOS
、 、 、 、 。
ROM 晶片中裝有"系統設置程式",主要用來設置 CMOS RAM 中的各項參數。這個
程式在開機時按下某個特定鍵即可進入設置狀態,並提供了良好的介面供操作人員
使用 事實上 這個設置 CMOS 參數的過程,習慣上也稱為" BIOS 設置"。一旦 CMOS
。 ,
RAM 晶片中關於微機的配置訊息不正確時,輕者會使得系統整體執行性能降低、軟
硬碟驅動器等部件不能識別,嚴重時就會由此引發系統的軟硬體故障。
CMOS 設置程式:當 BIOS 啟動時會先去確認 CMOS 中的資料是否正確。如果正
確,便會將之前使用者存儲在 CMOS 的資料,加上已存或找到的硬體資訊,整
合成一個表格,寫到記憶體中,也就是所謂的 SMBIOS。如果發現錯誤,則會
自動以預設值取代 CMOS 提供的資料。所以這份寫入記憶體的 SMBIOS 表格,
就是使用者進入 BIOS 選項後,可以看到或選擇的所有資訊。
(4) Boot to OS
啟動 OS Loader 引導載入作業系統。
啟動操作系統,這也是 BIOS 必須要做的事情之一。啟動的方式是由 BIOS 規定,操
作系統必須按照 BIOS 的要求來設計。這也是為什麼操作系統從 DOS 一直到 Vista,
都只能把自己的 loader 放在 MBR,因為 BIOS 只讀 MBR。當然,在 EFI 時代,這一
點有所改變,EFI 支援的 Boot From File 不在需要 MBR。
系統在完成 POST 自檢後, ROM BIOS 就首先按照系統 CMOS 設置中儲存的啟動
順序搜尋軟硬碟驅動器及 CD-ROM、網路服務器等有效地啟動驅動器,讀入操作系
統啟始記錄,然後將系統控制權交給啟始記錄,並由啟始記錄來完成系統的順利啟動
2
3. (Between OS/AP and H/W)
(5)程式服務處理和中斷服務程式 *(提供常駐程式庫)
在 OS 啟動起來以後,BIOS 的一部分繼續常駐於記憶體,提供 OS 以及其他軟體基本
的系統服務,這兩部分是兩個獨立的內容,但在使用上密切相關。
程式服務處理程式主要是為應用程式和作業系統服務,這些服務主要與輸入 輸出
設備有關,例如讀磁片、檔輸出到印表機等。為了完成這些操作,BIOS 必須直接與
電腦的 I/O 設備打交道,它通過 I/O Port 發出命令,向各種外部設備傳送資料以及
接收資料,使程式能夠脫離具體的硬體操作,而硬體中斷處理則分別處理 PC 硬體的
需求,因此這兩部分分別為軟體和硬體服務,組合到一起,使電腦系統正常運行。
BIOS 的服務功能是通過調用中斷服務程式來實現的,這些服務分為很多組,每組有
一個專門的中斷。例如視頻服務(10H);螢幕列印(05H);磁片及串列口服務(14H)等。
每一組又根據具體功能細分為不同的服務號。應用程式需要進行操作只需要在程式中
用相應的指令說明即可,無需直接控制。
BIOS 會告訴 CPU 各硬體設備的 IRQ,當周邊裝置、介面卡,或零件有狀況,
就會發出 IRQ 中斷通知,接著 CPU 就會根據 IRQ 訊號使用相對應的硬體完成工
作,之後該設備再送出 EOI(end of interrupt)的訊號方式通知 CPU,然後返回原
先被中斷的程式繼續執行。
(6)修復硬體缺陷
IA32e 有個模式叫 System Management Mode,BIOS 在每次開機時進 SMM,利用 BIOS
中的 Microcode 修正 CPU 硬體上的 bug,這叫做 CPU Microcode update。這樣 CPU 不
用回收出問題 CPU。
1.3 System Memory Map
3
5. (3) KBC BIOS
(4) I/O BIOS - SCSI BIOS or BOOT ROM (PXE ROM)
1.5 BIOS Vendor
(1)Phoenix BIOS (Award BIOS 被這家併購了)
(2)AMI BIOS
(3)Insyde Software
1.6 Vendors of Flash ROM
(1) SST
(2) Winbond
(3) MXIC
(4) Atmel
1.7 First Instruction Executed
The first instruction that is fetched and executed following a hardware reset is located at
physical address FFFFFFF0H. This address is 16 bytes below the processor supper most
physical address. The EPROM contains the software-initialization code must be located at this
address. The address FFFFFFF0H is beyond the 1-M Byte addressable range of the processor
while in real-address mode.
hardware reset 後第一條指令的抓取和執行定址在 FFFFFFF0H 物理位址。
這一位址是處理器能定址到的最高的 16 位元組物理位址,
EPROM 包含的軟體初始化代碼正是定位在這裡(即 FFFFFFF0H) 。
FFFFFFF0H 已經超出了處理器在實模式下可定址的 1M 位元組範圍。
The processor is initialized to this starting address as flows.
The CS register has two parts: the visible segment selector part and the hidden base address part.
In real-address mode, the base address is normally formed by shifting the 16-bit segment
selector value 4 bits to the left to produce a 20-bit base address.
However, during a hardware reset, the segment selector in the CS register is loaded with F000H
and the base address is loaded with FFFF0000H.
The starting address is thus formed by adding the base address to the value in the EIP register
(that is, FFFF0000+FFF0H=FFFFFFF0H)
處理器是這樣初始化這個開始位址的:
CS register 有兩個部分:可見的段選擇器部分和隱藏的基底位址部分。
在 Real mode 下,正常是把 segment selector 左移 4 位而得到 20 位的 base address。(CS base
address = CS segment selector*16)
然而,在 hardware reset 期間 CS register 被載入為 F000H 並且 base address 被載入為
FFFF0000H。所以開始位址是通過 base address + EIP register 的值得到的也就是,FFFF0000
+FFFF0H=(FFFFFFF0H)
The first time the CS register is loaded with a new value after a hardware reset, the processor
will follow the normal rule for address translation in real-address mode (that is ,[CS base
address=CS segment selector*16]).
To insure that the base address in the CS register remains unchanged until the EPROM based
5
6. software-initialization code is completed, the code must not contain a far jump or allow an
interrupt to occur(which would cause the CS selector value to be changed).
在 hardware reset 後,CS register 第一次被載入了一個新值,處理器會依照一般的 real
address mode 轉換規則(也就是,CS base address =CS selector * 16)。
為了確保在 CS register 存放的 base address 不被改變,直到 EPROM 的軟體初始化代碼完
成,代碼千萬不要包含 far jump 或者允許中斷發生 (這樣會導致 CS selector value 改變)。
2. BIOS Develop and Debug Tools: ADU & RW
ADU Award Doctor Utility
ADU is Award Doctor Utility Acronym. This utility access hardware including:
PCI ITE(IO)
Memory(Normal/Flat Mode) SMSC(IO)
CMOS(IO) SPD(SMBus)
ISA(IO) ClockGen(SMBus)
IO Space(IO) Read Byte(SMBus)
Winbond(IO) Read Block(SMBus)
main function of ADU utility.
PCI
Get PCI register show device
information.
Ex. We show VIA IEEE1394
controller, and we can see INT
IRQ line is 07h locate in 3Ch.
6
7. Memory
Flat mode
I set start address in 000FFFF0h
(F000:FFF0). We can see “EA
5B”. This is BIOS first
instruction executed.
Normal mode
Flat mode and Normal mode is mean different memory address mode.
CMOS
Dump CMOS data, for
RTC example: RTC, record the
system time/data.
7
8. RW Read & Write
This utility access almost all the computer hardware, including:
PCI (PCI Express) CPU MSR Registers
PCI Index/Data ATA/ATAPI Identify Data
Memory ACPI Tables Dump (include AML decode)
Memory Index/Data Embedded Controller
I/O Space USB Information
I/O Index/Data SMBIOS Structures
Super I/O PCI Option ROMs
Clock Generator MP Configuration Table
DIMM SPD Remote Acce
SMBus Device
Now I explain the main function of RW utility.
PCI (PCI Express)
To dump PCI register (256Bytes).
Select different PCI device
To express the info which be
selected
Binary to Text expression
PCI device summary
8
9. Info
When I select first two bytes
that I can to know it is Vendor
ID form info.
11hex >> 17dec
Text
Hex value mapping to ASCII
code.
Hex ASCII
Summary
Mapping register, show device
summary follow PCI
specification.
Device summary
9
10. Memory Dump
Dump all data of main memory.
Dump memory, we must set a
star address and will show a
block value (FFh 256Byte).
Set star address
Hex ASCII
Range search
Search function
:
Search function We can set a range
and key-in a keyword to
search in memory.
Set range
Ex. We search signature “RSD
PTR” (find ACPI table), set
Rang in E&F segments. After
Answer search we can get a string (in
FA8C0).
10
11. ACPI
Show all about ACPI table.
RSDP is ACPI table entry
pointer, it record RSDT address.
RSDP address
Point to RSDT address
RSDT is ACPI table root,
record all ACPI table address.
List of all ACPI table In top, we could select different
ACPI table to watch each
RSDT address
table’s detail information.
Point to all of ACPI table
Ex. check DSDT table
could get ASL code
11
12. USB
Work mode (USB2.0)
USB2.0 EHCI
Device Name
USB Device
SMBIOS
SMBIOS Entry
SMBIOS structure
point and length
System
information
Device info
12
13. 3. What is SF100?
SF100 is used to program the SPI flash memory soldered on application board. SF100
must be a coworker with Dediprog SF software. As below is the application window of
Dediprog SF software.
2. How to use Dediprog SF software?
Preprepareation
Connect the SF100 to the PC through a USB cable.
Insert the flash card (face in when inserting) into the flash card header on the
programmer.
The Toolbar Function
Chip Icon: It is used to detect the type of flash memory.
File Icon: It is used to select the file that user want to program. The file can not be larger
than the memory.
Blank Icon: Check the flash memory is blank or not.
Erase Icon: Erase the full content in a memory. After “Erase” the application memory
shall be blank.
Prog Icon: Program the selected image into the memory
Verify Icon: Verify the checksum value of the selected image and the programmed
image
View Icon: When click on View, the programmer will read both the content of
13
14. the selected image and the content in the application memory.
Batch Icon: The programmer will perform a pre-configured set of operations such as
(reload file+blank check+erase+program+verify) all together in one click. The
configuration can be done by clicking on the “option” on the top of
the screen menu. The configuration will not be changed until it is reconfigured.
3. Flash Rom Operation Principle
Program
Flash programming always writes 0 into memory. Flash memory can not be
programmed with 1. So we have to erase the flash memory before program it. Erase:
The operation of erase is always writing 1 into flash memory. The basic unit erased is
block.
14