01. bios introduction

16
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 InputOutput System ), 學學學 學 ROM 學 學學 ,,、Post 學學學 1

Upload: certain310

Post on 28-Nov-2014

7.018 views

Category:

Technology


1 download

DESCRIPTION

 

TRANSCRIPT

Page 1: 01. Bios Introduction

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 Definition1.3 System Memory Map1.4 BIOS Category1.5 BIOS Vendor1.6 Vendors of Flash ROM1.7 First Instruction Executed

2. BIOS Develop and Debug Tools: ADU& RW3. What is SF100?

C. BIOS Introduction1. BIOS Brief Introduction1.1. What is BIOS?Acronym: Basic Input Output SystemFunction: 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 DefinitionBIOS -- 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會將自己解壓縮到電腦的主記憶體中繼續執行。

1

Page 2: 01. Bios Introduction

BIOS的基本功能:

(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。

2

Page 3: 01. Bios Introduction

系統在完成 POST自檢後, ROM BIOS 就首先按照系統 CMOS設置中儲存的啟動順序搜尋軟硬碟驅動器及 CD-ROM、網路服務器等有效地啟動驅動器,讀入操作系統啟始記錄,然後將系統控制權交給啟始記錄,並由啟始記錄來完成系統的順利啟動

(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

Page 4: 01. Bios Introduction

這是一張DOS下的 System Memory Map,看起來非常簡單,但是他有一些重要的資訊,很值得一開始學習 BIOS的我們仔細去看一看。(1.) Interrupt Vector Table 內中放 4byte為一組的 pointer 指到真正 interrupt code存放的

memory位置,所以根據這個範圍 0000:0000h~0000:0400h 我們可以知道,DOS下最多只能有 100個 Interrupt。

(2.) BIOS Data Area 放有關於 PC的一些 information(沒有固定的放置方法)。(3.) System BIOS、Extended BIOS 範圍內放 runtime service。(4.) C000:0000放VGA相關的資料

Note:個人電腦的 RAM共可分為 5種記憶體..

傳統記憶體(Conventional Memory):640k以下。延伸式記憶體(Extended Memory):1M 以上。擴展式記憶體( Expanded Memory):另一種添加記憶體的方式,但是它不像延伸記憶體般線性地排列在 1MB之後,而是獨立於一旁,只要透過一塊 640K~1MB間的位址空間,大小64KB的頁框(Page Frame),就可以將我們想要存放的資料或程式碼映射(Mapping)到擴展記憶體上。早期的擴展記憶體是附在一張擴展記憶體擴充卡上。UMB (Upper Memory Block):640K到 1M之間的記憶體稱為UPPER MEMORY AREA

(A0000H – FFFFFH),保留做為 ROM BIOS及視訊等使用未被使用的記憶空間稱為Upper

Memory Block ,簡稱UMB。HMA (High Memory Area): 早期 cpu的 register是 16bits所能定址的記憶空間為 0000:0000

– FFFF:FFFF,但位址線只有 20條,所以當超過 1MEGA就會繞回(wrapping)。現在的 CPU

其位址線都已超過 20條,我們可以令A20 enable,使wrapping的現象不再發生,如此即可控制 1M以上的記憶空間了。此塊區域(FFFF:0010 – FFFF:FFFF)約 64K稱為HMA(High

Memory Area)。

4

Page 5: 01. Bios Introduction

1.4 BIOS Category(1.) System BIOS(2.) Video BIOS(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 ExecutedThe 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

5

Page 6: 01. Bios Introduction

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 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-Everything

ADU Award Doctor Utility

ADU is Award Doctor Utility Acronym. This utility access hardware including:

PCI

Memory(Normal/Flat Mode)

CMOS(IO)

ISA(IO)

IO Space(IO)

Winbond(IO)

ITE(IO)

SMSC(IO)

SPD(SMBus)

ClockGen(SMBus)

Read Byte(SMBus)

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

Page 7: 01. Bios Introduction

Memory

Flat mode

Normal mode

Flat mode and Normal mode is mean different memory address mode.

I set start address in 000FFFF0h

(F000:FFF0). We can see “EA

5B”. This is BIOS first

instruction executed.

CMOS

RTCDump CMOS data, for

example: RTC, record the

system time/data.

Page 8: 01. Bios Introduction

RW-EverythingThis utility access almost all the computer hardware, including:

PCI (PCI Express) PCI Index/Data MemoryMemory Index/DataI/O SpaceI/O Index/DataSuper I/OClock Generator DIMM SPD SMBus Device

CPU MSR Registers

ATA/ATAPI Identify Data

ACPI Tables Dump (include AML decode)

Embedded Controller

USB Information

SMBIOS Structures

PCI Option ROMs

MP Configuration Table

Remote Acce

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

Page 9: 01. Bios Introduction

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

Device summary

Mapping register, show device

summary follow PCI

specification.

Page 10: 01. Bios Introduction

Memory DumpDump 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 functionSearch function:We can set a

range and key-in a keyword to

search in memory.

Answer

Set rangeEx. We search signature “RSD

PTR” (find ACPI table), set

Rang in E&F segments. After

search we can get a string (in

FA8C0).

Page 11: 01. Bios Introduction

ACPIShow all about ACPI table.

RSDP address

RSDP is ACPI table entry

pointer, it record RSDT address.

Point to RSDT address

RSDT is ACPI table root,

record all ACPI table address.

List of all ACPI table

RSDT address

In top, we could select different

ACPI table to watch each

table’s detail information.

Point to all of ACPI table

Ex. check DSDT table

could get ASL code

Page 12: 01. Bios Introduction

USB

Work mode (USB2.0)

USB2.0 EHCI

USB DeviceDevice Name

SMBIOS

SMBIOS Entry

SMBIOS structure point and length

System information

Device info

Page 13: 01. Bios Introduction

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?(1.) PreprepareationConnect 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.(2.) The Toolbar FunctionChip 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 memoryVerify Icon: Verify the checksum value of the selected image and the programmed imageView Icon: When click on View, the programmer will read both the content of 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 ofthe screen menu. The configuration will not be changed until it is reconfigured.(3.) Flash Rom Operation Principle

Page 14: 01. Bios Introduction

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.