Friday, May 16, 2008

Baseboard management controller(BMC)

A baseboard management controller (BMC) is a specialized microcontroller embedded on the motherboard of many computers, especially servers. The BMC is the intelligence in the Intelligent Platform Management Interface (IPMI) architecture. The BMC manages the interface between system management software and platform hardware.Different types of sensors built into the computer system report to the BMC on parameters such as temperature, cooling fan speeds, power mode, operating system (OS) status, etc. The BMC monitors the sensors and can send alerts to a system administrator via the network if any of the parameters do not stay within preset limits, indicating a potential failure of the system. The administrator can also remotely communicate with the BMC to take some corrective action such as resetting or power cycling the system to get a hung OS running again. These abilities save on the total cost of ownership of a system.Physical interfaces to the BMC include SMBus busses, an RS-232 serial console, address and data lines and an Intelligent Platform Management Bus (IPMB), that enables the BMC to accept IPMI request messages from other management controllers in the system.The BMC communicates with a BMC management utility (BMU) on a remote client using IPMI protocols. The BMU is usually a command line interface (CLI) application. The BMU usually requires a password to gain access to the BMC. A direct serial connection to the BMC is not encrypted as the connection itself is secure. Connection to the BMC over LAN may or may not use encryption depending on the security concerns of the user.

Big Real Mode (大真實模式)

“大真實模式”, 什個跟什麼!! 好好的英文名詞變的這麼好笑 (這是我亂翻的).
一般有興趣寫 OS Kernel 的 Developer, 通常對於如何 Enable 32-bit protected mode 感到興趣.而進入 protected mode 後, 在記憶體管理方面, 又可分為 FLAT 及 Paging.
BIOS 及 DOS 大部分都是 Real Mode 的程式, 其最高可存取的位址為 0 到 FFFFFh, 也就是 1MB.
什麼! 1MB! 我的電腦插的可是 1GB/2GB/4GB, 難道 BIOS 開機時一直跳的數字是 “顯示給使用看爽的” ?
到底 BIOS 是怎麼樣, 在不進入 32-bit protected mode, 卻又可以初始化存取 1MB 以上的記憶體呢?
答案就是……”大真實模式”!!! (請原諒我使用中文:p)
所以要存取 1MB ~ 4GB 的 Memory Space, 32-bit protected mode 並不是唯一的選擇.
但要如何 Enable 呢?
先簡單的描述一下, 改天再附個範例上來.
一般 Enable 32-bit protected mode 會需要先在 16-bit Real Mode 中, 設定兩個 GDT Segment Descriptors(for Code and Data), Privilege Level 0, Base 為 0×00000000, Limit 為 0xFFFFFFFF(4GB).
後將 GDT Pointer 載入 GDT Register, 打開 A20 及 CR0 protected mode bit 後, 需作一個 FAR Jump(同時 load CS 及 EIP) 到 32-bit protected mode 的程式碼.
而進入 32-bit 程式碼後的第一件事, 就是要重新 Load DS, ES, FS, GS 等 Segment Selectors 成為 GDT Segment Descriptors 的 Offset 值後, 即完成了 protected mode switch.
而 Big Real Mode 怎麼打開?
其實很簡單, 但改為FAR Jump 到一樣是 16-bit 的程式碼 (重 Load CS and IP), 設定好 DS, ES, FS, GS 為 GDT Segment Descriptors 的 Offset 值後, 關閉 CR0 內的 protected mode bit, 保持 A20 在開啟狀態, “大真實模式” 就完成了, 接下來 4GB Memory Space 隨你存取.
mov ebx, 0f1230000hmov al, [ebx]
愛怎麼弄就怎麼弄, 隨你高興啦~那怎麼返回 Real Mode 呢? ……對不起, 請重開機……
沒啦, 開玩笑的! 其實只要在 Enable Big Real Mode 之前, 將 DS, ES, FS, GS 的值 push 進入 stack. 使用完畢後 pop 回來, 並 Disable A20 就行啦.
請服用吧!
Note: Big Real Mode 有些地方稱為 Unreal Mode 或 Flat Real Mode. from http://osdevr.olux.org/

Enable Protected Mode 的第一項基本功 - Global Descriptor Table 與 Segment Descriptor

如果你不會寫 Assembly 的話, 可能對 Segment 這個觀念會比較陌生.建議先練好基本的 Assembly 功夫, 並參閱相關書籍以熟悉 x86 CPU 的軟體架構.
中文資料的話推薦可以到小木偶的組合語言教學網頁看看.
Overview:一般傳統 Real Mode Segment Register 的可定址範圍都是 64KB, 也就是 16 bits. (例如: 0000h ~ FFFFh)
而 x86 CPU 進入 32bit Protected Mode 後, 原來的 DS, ES, FS, GS, SS 等 Segment Register (區段暫存器), 並不是像通用暫存器 (如: EAX, EBX, ECX, EDX) 那樣, 前面加個 ‘E’ (錯誤示範如: EDS, EES, EFS, EGS, ESS) 就可以直接定址到 4GB 的 Memory.
而是換了一個角色與名稱, 叫做 Segment Selector. (本身依然保持 16 Bit, DS, ES, FS, GS, SS)
但 16 bit Real Mode 的 Segment Register 與 32 bit Protected Mode 的 Segment Selector 在使用上有什麼差別呢?
有的. 傳統的 Segment Register 你只要直接載入想存取的區段的位址即可, 不需要有額外的配套措施.
例如你想存取 Memory 上的第 18000h Bytes (也就是 Linear Address 18000h),你只需要將 DS 載入為 1000h, 並將 BX 載入為 8000h, 如此便可存取到 Linear Address 18000h.
Ex:; 設定想存取的位址mov ax, 1000hmov ds, axmov bx, 8000h
; 從 18000h 讀取資料mov eax, ds:[bx]
但使用 Protected Mode 的 Segment Selector 則需要一些配套措施.就是必須先在 Memory 中建立一個 Global Descriptor Table (GDT) 後才能使用.
正確的說, Segment Selector 並不像 Real Mode 那樣是直接寫入想存取位置的位址.而是改為 “載入 Global Descriptor Table (GDT) 內, Segment Descriptor 的索引值”.
假設像這樣 (以下不是真實的範例):
<第零個 Segment Descriptor><第一個 Segment Descriptor><第二個 Segment Descriptor><第三個 Segment Descriptor>
; 將 DS 載入第二個 Segment Descriptor, 假設其範圍是 0 ~ 4GBmov ax, 02hmov ds, ax
; 設定想存取的位址mov ebx, 18000h
; 存取記憶體 18000hmov eax, ds:[ebx]
from http://osdevr.olux.org/

Thursday, May 15, 2008

c function ,strcmp and stricmp

strcmp

input: string S1,string S1

output: 0:if S1==S1 , 1 :otherwise

stricmp same but stricmp let "Abc" identity to "abc"

e.g.

printf("%d\n",strcmp("abc", "abc")); 0:identity

printf("%d\n",strcmp("abc", "Abc")); 1:distinct

printf("%d\n",stricmp("abc", "abc")); 0:identity

printf("%d\n",stricmp("abc", "Abc")); 0:identity

Intelligent Platform Management Interface (IPMI)

The Intelligent Platform Management Interface (IPMI) specification defines a set of common interfaces to computer hardware and firmware which system administrators can use to monitor system health and manage the system.

Thursday, May 08, 2008

how create length of a data or data block

(1)
data1 DB "T&D Research MEMORY.COM"
data1_length EQU $-data1 ; //upper string length

(2)
GDT_TABLE GDT <0,0,0,93h,0>
.............
.............
GDT_LEN = $ - OFFSET GDT_TABLE ;length of GDT

Tuesday, May 06, 2008

delay for I/O instruction

JMP SHORT $+2 ;I/O delay ;$ the address of this line instruction
; + 2 (byte) to go to next instruction

Sunday, May 04, 2008

[code segment] Dump AL

push ax

mov dl,al

mov cl,4

shr dl,cl

cmp dl,9

jbe label1

add dl,7

label1:

add dl,30h

mov ah,2h int 21H


pop ax

mov dl,al

and dl,0fh

cmp dl,9 jbe

label2

add dl,7

label2:

add dl,30h

mov ah,2

int 21h