Search This Blog

Friday, July 10, 2015

[圖文] LINE原創貼圖

最近畫了一組LINE原創貼圖,經過審查通過,在LINE正式上架了。
原創貼圖連結 http://line.me/S/sticker/1160144
希望大家可以多多支持Icey Creamy!
Icey Creamy


以下是貼圖內容


Tuesday, March 27, 2012

BIOS該怎麼換SCI的IRQ9變成IRQ11呢?


預設值SCI是透過IRQ9,
如何去改IRQ9到IRQ11呢?

要修改三個部分
1. BIOS部分是透過EFI CODE這部分可以去參考Intel的南橋spec[SCI_IRQ_SEL].
2. ASL CODE 這部分可以去參考ACPI spec[FADT SCT_INT] 從9設成11
3. ASL CODE 這部分可以去參考ACPI spec的[MADT EFI_ACPI_2_0_INTERRUPT_SOURCE_OVERRIDE]也是從9設成11


這樣就可以改用IRQ11去發SCI了。

Tuesday, March 6, 2012

How to create EDK2 enviornment?

以下是我個人電腦的設定,依據不同環境需要自行調整。

使用TortoiseSVN軟體download 位址https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2的source code
預設會下載到C:\EDK2的資料夾裡。

開啟Visual Studio 2008 Command Prompt
到指定的目錄夾,C:\EDK2
鍵入edksetup.bat


然後再到Conf的資料夾
鍵入edit target.txt
C:\EDK2\Conf\edit target.txt

ACTIVE_PLATFORM = Nt32Pkg/Nt32Pkg.dsc
TARGET = DEBUG
TARGET_ARCH = IA32
TOOL_CHAIN_CONF = Conf/toos_def.txt
TOOL_CHAIN_TAG = MYTOOLS
#MAX_CONCURRENT_THREAD_NUMBER = 1
MAX_CONCURRENT_THREAD_NUMBER = 8  # My CPU is Quad Core
BUILD_RULE_CONF = Conf/build_rule.txt

Build完後,可以到
鍵入secmain.exe
即可進入EDK2的模擬環境

Wednesday, November 30, 2011

PS2 Keyboard Malfunction Sometimes

最近遇到一個在POST過程中,隨意按鍵,有機率性的PS2 internal keyboard不能動的問題,所以為了解決這個問題,在BIOS logo出來時,去發一個keyboard reset給KBC controller。

以下的程式碼就是發keyboard reset給KBC controller

VOID
KeyBoardReset(
  VOID
  )
{
  UINT8 Data;

  //
  // Clear Output Buffer data
  //
  Data = IoInput8(0x64);
  while (Data & 0x01) {
    Data = IoInput8(0x60);
    Data = IoInput8(0x64);
  }
 
  //
  // Disalbe Aux Device
  //
  IoOutput8 (0x64, 0xA7);
  while (Data & 0x02) {
    Data = IoInput8(0x64);
  }

  //
  // Disalbe Keyboard
  //
  IoOutput8 (0x64, 0xAD);
  while (Data & 0x02) {
    Data = IoInput8(0x64);
  }

  //
  // Reset keyboard.
  //
  IoOutput8 (0x60, 0xFF);
  Data = IoInput8(0x64);
  while (!(Data & 0x01)) {
    Data = IoInput8(0x64);
  }
  Data = IoInput8(0x60);
  Data = IoInput8(0x64);
  while (!(Data & 0x01)) {
    Data = IoInput8(0x64);
  }
  Data = IoInput8(0x60);
}

Monday, November 28, 2011

Kindle Touch 連不上Wi-Fi?

在剛開始使用Kindle Touch時,有遇到無法透過家中的無線分享器連上Wi-Fi,怎麼會這樣子呢?上網找各種solution,使用了以下的方式,讓Kindle Touch可以順利連上Wi-Fi。

需求:一台安裝有Windows 7的電腦加上有一張無線網卡(若是筆電就是內建配備;
           桌上型電腦的話,可能要再買一張USB無線網卡)
軟體:額外安裝Connectify(用谷歌可以搜尋的到)

它的運作模式就是將你的電腦透過無線網卡,變成一個Hot Spot,讓你的Wi-Fi裝置可以透過它連上網路。簡單的方式就是,請記得密碼設定成10碼,編碼模式設成WEP。不然Kindle Touch可能會無法連上Wi-Fi。

Kindle Touch 開箱文


期待已久的Kindle Touch WiFi 廣告版總算是入手了!  接下來就讓我來開箱吧。





































簡單又環保的設計採破壞式開箱方式,我想這樣才會願意把盒子拿去回收吧(笑)























主角登場了!!!  伴隨著淡淡的紙盒香味飄出~在Kindle Touch的螢幕上有讓人有看來像是擺上一張紙的感覺,但那其實就是電子紙的魔力啊!!!在Kindle Touch螢幕下方有四條線(好在不是設計成三條線冏rz),那就是Home鍵,在機身下方由左至右有micro USB孔、耳機孔、和開關鍵。





























側身設計很薄



























躺在Kindle Touch正下方的就是傳輸以及充電的micro USB線





















準備插上USB線來大展身手囉。







可以看到插上USB線後,橘燈亮起,它就自動開機了...





















接下來就會看到一連串的Kindle Touch的自我介紹。若迫不及待,可以按下方四條横線的Home鍵開始設定Kindle Touch吧。



























最重要的就是設定Kindle Touch的Wi-Fi,讓它連上網路。




























連上Wi-Fi後,就會看到有Wi-Fi字樣出現在右上角













設成完成後就註冊Amazon的帳號準備買書吧。



























背面的設計也是很有質感的。

























Kindle Touch優點:
1. 以觸控的電子書來說,紅外線觸控方式在Kindle Touch表現的很不錯
2. 即時英文長押螢幕單字來查詢,非常適合學習英文
3. 大小和重量適中,很適合帶出門喝咖啡邊看書,多愜意啊
4. 翻頁的反應速度似乎有比前一代進步
5. 由於是電子紙,電池續航力最長可以到兩個月
6. 最大優點是電子紙螢幕看再久,眼睛也不會痠

Kindle Touch缺點:
1. 資料夾管理系統不是很方便
2. 如果將機身横擺,也沒辦法將文件橫向顯示
3. 手指要乾淨,才不會把螢幕弄髒(笑)

Monday, November 21, 2011

Set PS2 KB LED Status (Num Lock/Cap Lock/Scroll Lock) in Code

1. Send keyboard command 0xED to KBC command port 0x64
2. Wait for the response 0xFA value from KBC data port 0x60
3. Send keyboard LED status command to KBC command port 0x64
     EDh nn       write LEDs. nn=
                                                 b2      Caps Lock
                                                 b1      Num Lock
                                                 b0      Scroll Lock
     Ex. 0x05 means Caps Lock and Scroll Lock is enabled, Num Lock is disabled
4. Wait for the response 0xFA value from KBC data port 0x60

Tuesday, November 1, 2011

Trigger SMI to Do CpuIo Cause System Hangs Up Under Windows

We would like to use CpuIo protocol and must locate it first.

Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, &CpuIo);
There is a question here, system is entered windows that has exited boot service.
Therefore, we locate this protocol will cause system hangs up.
To avoid this, we should create a global variable to save the CpuIo pointer when system during POST phase.

EFI_CPU_IO_PROTOCOL   *mCpuIo = NULL;

EFI_DRIVER_ENTRY_POINT (SctCpuIoPointSave)
EFI_STATUS
SctCpuIoPointSave (
  IN EFI_HANDLE ImageHandle,
  IN EFI_SYSTEM_TABLE *SystemTable
  )
{
  EFI_STATUS Status;
  EFI_HANDLE Handle;
  DxeInitializeDriverLib (ImageHandle, SystemTable);

  //
  // Locate CpuIo protocol.
  //
  Status = gBS->LocateProtocol ( &gEfiCpuIoProtocolGuid, NULL, &mCpuIo ) ;
       
  return Status;
} // EnteyPoint.


Just need to call your function in SMI code to use CpuIo.
For example,

VOID
ShowPort80 (VOID)
{
  EFI_STATUS    Status ;
  UINT8                Data ;
  Data = 0x99;
  Status = mCpuIo->Io.Write (
                        mCpuIo,
                        EfiCpuIoWidthUint8,
                        0x80,
                        1,
                        &Data);

  ASSERT_EFI_ERROR (Status);
}

Wednesday, October 26, 2011

How do I hide the "Devices and Printers" of hardware component in Windows 7

For example: want to remove the camera device in devices and printers
Just need to add red part in device ASL code.

Device(PRT3) {  
     Name(_ADR, 0x00000003)
               Name(_UPC, package() {
                                       0x00,
                                              0xFF,
                              0x00000000,
                                           0x00000000
                })
                //
                // Using method _RMV remove component
                //
                Method(_RMV,0)
                {
                     Return(0x00)  // 0 : Unremovable 1: Removable
                }
          }

Thursday, August 25, 2011

Deep S3

Why do we need deep S3?
A: Deep S3 can save more power consumption for notebook battery life.

How does the deep S3 work?
A: Deep S3 will automatically activate when notebook only attach the battery without AC plug-in and during S3. System goes to sleep to S3 will check the AC adapt is present or not. If AC is plug-in, the system will enter normal S3. If system without AC plug-in, the system will enter deep S3.

More information can refer to "Intel Deep S3 Implementation Guide".

Sunday, August 21, 2011

AMD UMI and PCIe Bridge Register Access Method


If we want to access the UMI and the FCH/GPP link interface could through the following register spaces: ABCFG, AXCFG, AXINDC, AXINDP, RCINDC, and RCINDP

Change the register spaces must through the AB_INDX/AB_DATA register pair. You can get the AB_INDX through PM_REG that IO index port 0xCD6 and IO data port 0xCD7 offset 0xE0 register.
For example, if the PM_REG offset 0xE0 is 0xCD8 that means the AB_INDX is 0xCD8 and AB_DATA is equal to AB_INDX + 4.

========================================

AXINDC Registers:
AX_INDXC 0x30
AX_DATAC 0x34

Example 1: For Write Temp to AXINDC 20h
Out CD8h, 00000030h
Out CDCh, 00000020h
Out CD8h, 00000034h
Out CDCh, Temp

=========================================

AXINDP Registers:
AX_INDXP 0x38
AX_DATAP 0x3C

Example 2: For Write Temp to AXINDP 20h
Out CD8h, 40000030h
Out CDCh, 00000020h
Out CD8h, 40000034h
Out CDCh, Temp

=========================================

AXCFG Registers:

Example 3: For Write Temp to AXCFG 03h
Out CD8h, 80000003h
Out CDCh, Temp

=========================================

ABCFG Registers:

Example 4: For Write 0xFFFFFFFF to ABCFG 04h
Out CD8h, C0000004h
Out  CDCh, FFFFFFFFh

=========================================

RCINDC Registers:

Example 5: For Write Temp to RCINDC 14h
Out CD8h, 20000014h
Out CDCh, Temp

=========================================

RCINDP Registers:

Example 6: For Write Temp to RCINDP A0h(PortB)
Out CD8h, 610000A0h
Out  CDCh, Temp

Wednesday, August 10, 2011

How to know the notebook panel resolution during POST

The horizontal can get from EDID table bytes 0x38(lower 8 bits) and 0x3A(Upper 4:4 bits).
For example:
Bytes   Value
0x38      0xA0
0x3A     0x50

Horizotal = (Offset (0x3A) & 0xF0 << 4) + Offset (0x38)
               = (0x50 << 4) + 0xA0
               = 0x5A0 (Hex)
               = 1440 (Dec)

The vertical can get from EDID table bytes 0x3B(lower 8 bits) and 0x3D(Upper 4:4 bits).
For example:
Bytes   Value
0x3B      0x84
0x3D     0x30

Vertical = (Offset (0x3D) & 0xF0 << 4) + Offset (0x3B)
             = (0x30 << 4) + 0x84
             = 0x384 (Hex)
             = 900 (Dec)

Therefore, we can know the panel resoultion is 1440 * 900 for this example.

Wednesday, June 29, 2011

Library Compiler Error - don't know how to make

遇到 don't know how to make LibraryX.lib 的情況,可以用以下的方式排除
1. 確定LibraryX.lib 在 AAA.dsc裡面有去定義這個AAA.inf
2. 若在build這個AAA.inf的library的時候就遇到compiler error,請先解決這個compiler error (可能是LibraryX建的方式有問題,可以參照其他現成的library做法)
3. 若你在BBB的檔案要引用這個LibraryX的時候,請先確定在build出來的temp目錄層底下,有長出LibraryX.lib的檔案。
4. 若有,請在BBB.inf裡確定以下兩點
[includes.common]
  $(EFI_SOURCE)\(Library_ROOT)  //要指定路徑在library那一層
[libraries.common]
  LibraryX
5.記住呼叫的Libray名字不要打錯,不然就會造成complier "don't know how to make" 的error

Monday, June 27, 2011

SATA及USB介面傳輸速度比較表

SATA版本
頻寬
速度       傳輸一部6G高清電影
SATA 3.0
6Gb/s
600MB            10 (理想值)
SATA 2.0
3Gb/s
300MB            20 (理想值)
SATA 1.0
1.5Gb/s
150MB            40 (理想值)



USB版本
頻寬
速度       傳輸一部6G高清電影
USB 3.0
5 Gb/s
500MB            12 (理想值)
USB 2.0
480Mb/s
48MB              125 (理想值)
USB 1.1
120Mb/s
1.2MB             5000 (理想值)
 USB 1.0           1.5Mb/s        150KB              40000 (理想值)

Wednesday, June 22, 2011

How to make an EFI library?

1. 在inf檔裡修改
[defines]
  BASE_NAME       =  HelloLib
  COMPONENT_TYPE  =  LIBRARY

[sources.common]
  Hello\Hello.c
  Hello\Hello.h


2. 把你需要的library function加到hello.c及hello.h裡

3.在EFI driver去引用HelloLib的時候要去修改以下的檔案
   AbcDriver.inf
   AbcDriver.c


4.AbcDriver.c要加入
   #include "Hello.h"

   用extern的方式加入library的function名字
   並在你的function去呼叫你要用的library function即可

5.AbcDriver.inf要加入
[includes.common]
  $(EFI_SOURCE)\Library\Hello  <== 指到放Hello.h的那一層目錄

[libraries.common] 
   HelloLib

Monday, May 30, 2011

INT 15h E820 Query Memory Map Use Debug32.exe

;Input:
;       eax   - function code 0E820H
;       ebx   - continuation code, zero for first call
;       es:di - buffer pointer , point to an buffer for BIOS to fill in.
;       ecx   - buffer size , minimum is 20 bytes
;       edx   - signature 'SMAP'

C:\debug32
-r32
-a
  mov eax, 0000e820
  mov ebx, 0
  mov ecx, 14
  mov edx, 534d4150
  mov di, 200
  int 15
  int 3
  p
-go


;Output:
;       CF    - non-carry indicates no error
;       eax   - signature return 'SMAP'
;       es:di - buffer pointer, same as input
;       ecx   - real buffer size return
;       ebx   - continuation code , zero return if last run occured

Thursday, May 26, 2011

ACPI can't recogize OS type with Ubuntu operating system

ACPI can't recogize OS type with Ubuntu operating system

Remove "Linux" from supported _OSI strings.
The Linux OS no longer wants to respond true for this string.
The only safe strings are windows-related as they represent the tested path through the BIOS-provided ASL.
===========================================================================

現在Ubuntu不支援用_OSI strings的方式來回報OS類型

Monday, May 23, 2011

A20 Gate

1.   8086的系統,當初只設計20根位址線。透過Segment + Offset的方式來定址,Ex. F000 : 0010h = F0000+ 0010h = F0010h  那衍生了一個問題就是當CS : IP的值為FFFF : FFFFh = FFFF0 + FFFFh = 10FFEFh = 1M + 64K – 16 Bytes  但系統只能存取到1M以下,這該如何是好? 所以大於1M,系統會直接回繞。

2.   80286的系統,位址線變成了24根,但又要向下相容,就衍生了A20的模式,當A20disable,就等同於8086的架構,A20 Enable,系統就可以存取到2 ^ 24次方 = 16M byte,也就是Segment變成最大值為FFFFFh 而不是FFFFh

3.   開啟A20 Gate的方法,最簡單就是對IO Port 92h 的bit 1給設起來;反之關閉A20 Gate的方法,就是清掉IO Port 92h 的bit 1。

enable_A20:
        cli

        call    a20wait
        mov     al,0xAD  ; Disable Keyboard
        out     0x64,al

        call    a20wait
        mov     al,0xD0
        out     0x64,al

        call    a20wait2
        in      al,0x60
        push    eax

        call    a20wait
        mov     al,0xD1
        out     0x64,al

        call    a20wait
        pop     eax
        or      al,2
        out     0x60,al

        call    a20wait
        mov     al,0xAE   ; Enable Keyboard
        out     0x64,al

        call    a20wait
        sti
        ret

a20wait:
        in      al,0x64
        test    al,2
        jnz     a20wait
        ret


a20wait2:
        in      al,0x64
        test    al,1
        jz      a20wait2
        ret

Wednesday, May 18, 2011

8259 Control Word


RTC Lost Power

After remove RTC coin battery, system plug-in RTC coin battery the CMOS  register 0xE access by (index port 0x70/ data port 0x71) bit 7 will be set. After check this bit, we also need to clear this bit by code.















============================================================================

在移除RTC水銀電池後,然後再次插上,這時後CMOS register offset 0xE的位址,在(使用index port 0x70/ data port 0x71)方式存取,這時候的0xE的bit 7會被設起來,在code裡面,一檢查完,就需要清掉這個位元。

Tuesday, May 17, 2011

About IO Decode (AMD Chipset)

1.Set IO base address in south bridge register
2.Enable Alternative Wide IO Range in south bridge register
3.Enable Wide IO Port in south bridge register
if system still can't open IO decode, we need to check  is occupied by another device using the same IO resource or not. We can check the value in each of PCI bridge offset 0x1C.PCI bridger IO resource is aligned to a 4KB boundary.

============================================================================

1.設定要做IO decode去設定南橋暫存器的IO Base Adress
2.開啟南橋暫存器的Alternative Wide IO Range
3.開啟南橋暫存器的Wide IO Port
若還是無法開啟IO decode,這時候就要檢查是否有別的device佔用到相同的IO decode的位址,可以先檢查每個PCI bridge的offset 0x1C的值,PCI bridge一次就是佔4K的IO resource。

Monday, May 16, 2011

The Different Between LegacyBiosInt86 And LegacyBiosFarCall86

When we wanna issue a software interrupt, we need to call LegacyBiosInt86 thunk function call.
When we wanna jump to OPROM or other legacy address, we need to call LegacyBiosFarCall86 thunk function call.

========================================================================

LegacyBiosInt86是我們需要使用程式去呼叫INT時所使用到的thunk function ,像是CALL INT10...
LegacyBiosFarCall86是我們需要跳到option ROM address所需要用到的thunk function

Tuesday, May 10, 2011

Bring Up BIOS

1. Modify GPIO that depends on platform design
2. Modify FDLA (Firmware Device Linear Address)
3. Change VBIOS
4. Change SPI ROM size
5. Disable KSC

===========================================================================

做一個Bring-up BIOS主要的工作如下:
1. 依照platform的layout去修改GPIO
2. 修改FDLA (Firmware Device Linear Address)
3. 換掉VBIOS
4. 依照platform的設計改變SPI ROM大小
5. 移除KSC

Friday, May 6, 2011

Software SMI Behavior

ACPI Enable and Disable Behavior

ACPI Enable
OSPM performs this transition by writing the ACPI_ENABLE value to the SMI_CMD, which generates an event to the hardware to transition the platform into ACPI mode. When hardware has finished the transition, it sets the SCI_EN bit and returns control back to OSPM.

ACPI Disable
While in the G0 “working state,” OSPM can request a transition to Legacy mode by writing the ACPI_DISABLE value to the SMI_CMD register, which results in the hardware going into legacy mode and resetting the SCI_EN bit LOW.

=======================================================================

ACPI Enable
由OS去寫ACPI_ENABLE的值到SMI_CMD port,會由BIOS所註冊的ACPI Enable的SMI handler去處理將SCI_EN bit設起來,在這handler裡,OEM可以自行加入程式碼以達到一些特殊的需求,再將控制權交還給BIOS。

ACPI Disable
在ACPI_ENABLE下,也可由OS去寫ACPI_DISABLE的值到SMI_CMD port,會由BIOS所註冊的ACPI Disable的SMI handler去處理將SCI_EN bit清為零。

Can't Access PCIe Network IO Resource at early POST

Question:
Can't access PCIe network IO resource at early POST issue.

Solution:
The PCI command register set to 0x07 and assign IO resource forPCIe network device. It also needs to set the PCI command register set to 0x07 on PCIe bridge.

=======================================================================

問題:
最近有遇到一個要存取掛在PCIe Bridge底下的PCIe網卡設定問題,狀況是無法在early POST時存取到PCIe網卡底下的IO resource。

解決方案:
PCIe網卡的PCI command register設成0x07以及指派IO resource外,注意也需要把PCIe Bridge的PCI command register設成0x07。

Set Watch Dog Timer for AMD chipset

WatchDogTimerConfig - RW - 8 bits [PM_Reg:4Ch]
WatchDogDisable         bit 0    -  0 / 1 Enable/Disable WatchDog function
WatchDogFreq             bit 2:1    00 / 11  32KHz/1Hz

WatchDogTimerEn - RW - 32 bits [PM_Reg:48h]
WatchDogDecodeEn    bit 0 - 1 to enable decoding of WatchDogTimer address
WatchDogBase             bit 31:3 - WatchDogTimer base address

WatchDogControl - RW - 32 bits - [WD_Mem_Reg:00h]
WatchDogRunStopB      bit 0 - 0/1 Watchdog is in the Stopped/Running state
WatchDogAction            bit 2 - 0/1 System reset/power off
WatchDogDisable           bit 3 - 0/1 Enable/Disable
WatchDogTrigger (WO) bit 7 - write one to trigger the watchdog

WatchDogCount - RW - 32 bits - [WD_Mem_Reg:04h]
WatchDogCount            bit 15:0 - Set Count

1. Set the WatchDogDisable to enable and WatchDogFreq in WatchDogTimerConfig register.
2. Get the WatchDogBase address
3. Set the WatchDogCount
4. Set the WatchDogRunStopB  to run
5. Trigger the WatchDogTrigger

=========================================================================

1. 設定WatchDogTimerConfig的WatchDogDisable位元及設定WatchDogFreq的頻率.
2. 讀取WatchDogBase的位址
3. 設定WatchDogCount去決定最大計數個數
4. 設定WatchDogRunStopB成執行模式
5. 設定WatchDogTrigger位元去啟動Watch Dog Timer

Thursday, April 28, 2011

Disable XHCI pme when enter sleep mode on AMD chipset

We can use the SciSleepDisable (SMI_REG : 20h) register to disable sleep SCI.
If XHCI pme use L Event 24, it should be set the SciSleepDisable bit 24 to 1.
The system enter sleep mode will not resume when L Event 24 be triggered.

======================================================================

最近遇到一個USB 3.0 port上接USB hub1.1後面再接Keyboard或Mouse進S3後會自動被喚醒的問題。為了解決這問題,當系統不支援USB喚醒的時候就去設定SciSleepDisable暫存器(SMI_REG : 20h)去禁止有任何event被觸發而讓系統自動喚醒。
當XHCI pme是使用L Event24時,就去設定SciSleepDisable的第24位元為1。
如此一來,當系統進入S3的時候,它就會自動擋掉來自於L Event 24的任何Evnet了。

Wednesday, April 20, 2011

Retrieve the index of the CPU to trigger SMI

We can know which CPU core (index) to trigger SMI as below.

EFI_STATUS
GetCpuCoreIndex (
  OUT UINTN *CpuIndex
  )
{
  UINT8 Index;
  EFI_STATUS Status;
  EFI_SMM_SAVE_STATE_IO_INFO *IoInfomation;
  Status = EFI_SUCCESS;
  Status = mSmst->SmmAllocatePool (EfiRuntimeServicesData,
                    sizeof (EFI_SMM_SAVE_STATE_IO_INFO),
                    (VOID **) &IoInfomation);
  if (EFI_ERROR (Status)) {
    return Status;
  }
  //
  // Find the CPU that triggered the software SMI.
  //
  for (Index = 0; Index < mSmst->NumberOfCpus; Index++) {
    Status = mSmmCpuSaveState->ReadSaveState (
                                 mSmmCpuSaveState,
                                 sizeof (IoInfo),
                                 EFI_SMM_SAVE_STATE_REGISTER_IO,
                                 Index,
                                 IoInfomation);
    if (Status == EFI_SUCCESS &&
        (IoInfo->IoPort  == (UINT16) mSwSmiCommandPort) &&
        * (UINT8*) IoInfo->IoData == (UINT8) mSmbiosPnpSwSmiValue) {
      *CpuIndex = Index;
      break;
    }
  }
  mSmst->SmmFreePool (IoInfo);
  if (EFI_ERROR (Status)) {
    return Status;
  }
  if (i == mSmst->NumberOfCpus) {
    return EFI_NOT_FOUND;
  } else {
    return EFI_SUCCESS;
  }
} // GetCpuCoreIndex

Monday, April 18, 2011

SVID and SSID

What is the SVID and SSID?
SVID - Subsystem Vendor ID
SSID - Subsystem ID

Where is the SVID and SSID?
The SVID will be filled in PCI device register offset 0x2C to 0x2D (2 Bytes) by BIOS.
The SSID will be filled in PCI device register offset 0x2E to 0x2F (2 Bytes) by BIOS.

What can the SVID and SSID do?
The SVID and SSID can provide device driver to recongize in order to determine what driver function needs to be supported.

=========================================================================

什麼是SVID和SSID?
SVID - Subsystem Vendor ID
SSID - Subsystem ID

BIOS要在哪裡去填SVID和SSID?
BIOS應該在PCI裝置上的0x2C到0x2D (2 Bytes)去填SVID
BIOS應該在PCI裝置上的0x2E到0x2F (2 Bytes)去填SSID

SVID和SSID的功用?
SVID和SSID可以提供裝置的驅動程式去辦別什麼功能是需要被支援(使用)的,如此一來裝置製造商也可以為很多裝置提供共用的驅動程式。

Friday, April 15, 2011

Disable EC SMI (GPI) on AMD Chipset

How to disable EC SMI on AMD Chipset?
We can set the SMI registers to turn off EC SMI in FCH specification.
SMI registers are accessed by memory-mapped IO or IO-mapped, the range from "AcpiMMioAddr" + 0x200 to "AcpiMMioAddr" + 0x2FF offset 0x14 that register name is SmiSciEn. Every bit presents every GEvent. If Gevent 23 is EC SMI pin, we need to clear the value of SmiSciEn bit 23 that can disable EC SMI. When SmiSciStatus bit 23 is set and SmiSciEn bit 23 is set, it will trigger a SMI to call the BIOS to do SMI function.

=========================================================================

如何禁能AMD chipset的EC SMI?
透過設定FCH的SMI暫存器去關掉EC SMI。
SMI暫存器可以使用記憶體映對IO或IO映對的方式存取,其範圍從"AcpiMMioAddr" + 0x200 to "AcpiMMioAddr" + 0x2FF offset 0x14的SmiSciEn暫存器名稱,每一個位元都代表一個GEevent。
如果EC SMI腳位是使用GEvent 23,我們可以透過清掉SmiSciEn的位元23去禁能EC SMI。當SmiSciStatus bit23被設成1且SmiSciEn bit23被設定成1,將會觸發一個SMI去呼叫BIOS的SMI function。

Thursday, April 14, 2011

What is the BIOS?

What is the BIOS?
BIOS - Basic Input/Output System
When user pressed the power button, the main job of BIOS is let platform to enter operating system.

Where is the BIOS?
The BIOS is stored in flash ROM on the mother board. The ROM size is depended on BIOS binary size.

What is the legacy BIOS? What is the EFI BIOS?
The legacy BIOS is written by assembly code.
The EFI(Extensible Firmware Interface) BIOS is written by C code.
The legacy BIOS is replaced by EFI BIOS little by little.
The EFI BIOS is more easy to write for progarmmer.

How to boot to operating system by the EFI BIOS?
The EFI BIOS has four phases to boot to OS.
1. SEC phase: Check security and cache as RAM in order to build the PEI foundation to provide interface
2. PEI phase: CPU/chipset early initial and most important thing is memory sizing then enter DXE IPL.
3. DXE phase: Execute all the driver in order to let system has full function.
4. BDS phase: Connent all boot device and let system boot to be selected boot device.
System Power On -> SEC -> PEI -> DXE -> BDS -> OS

=======================================================================

何謂BIOS?
BIOS - 基本輸入輸出系統
當使用者按下電源鈕之後,讓系統能順利進到OS,並且達到客製化的需求,這就是BIOS的主要職責。

BIOS放在那裡?
BIOS被存放在主機板上的快閃記憶體內。快閃記憶體的容量大小是取決於BIOS的執行檔大小。
何謂legacy BIOS? 何謂EFI BIOS?
Lgacy BIOS的原始碼是使用組合語言來撰寫。
EFI(Extensible Firmware Interface) BIOS的原始碼是使用C語言來撰寫。
現今,legacy BIOS已漸漸地被EFI BIOS所取代。
EFI BIOS對於程式設計師來說,比較容易看懂,不需要碰到太多硬體底層的程式。

EFI BIOS是如何開機至作業系統的?
EFI BIOS需要經過四個階段的開機流程到作業系統。
1. SEC階段: 檢查系統安全性並將快取記憶體當作記憶體來使用以利建構PEI 環境並轉移至PEI 階段。
2. PEI 階段: CPU/chipset初始化及記憶體初始化讓系統進入到DXE IPL。
3. DXE階段: 執行所有driver為了讓系統能有完整的功能。
4. BDS階段: 連接所有可開機的裝置且讓系統開機到被選中的可開機裝置。
系統Power on -> SEC -> PEI -> DXE -> BDS -> 作業系統

Wednesday, April 13, 2011

AMD GPIO Setting Guide

Setting multi-function pin register in AMD FCH IoMux register(AcpiMMioAddr + 0xD00 ~ 0xDFF).
According to hardware setting to set what kind of function that BIOS should set to FCH IoMux register.

For example





    

    

     Function 0: CLK_REQ1#
     Function 1: FANOUT4
     Function 2: GPIO61
     That means IoMux<61> register should set to 0x00(CLK_REQ1#)

     If this pin isn't for GPIO use, we don't care the GPIO register setting.

According to hardware design some pins to GPI or GPO,
we should set GPIO<0 ~ 228> register to GPI or GPO, pull-up or pull down and sticky or not.

The GPIO registers also control the GEvent pins. The GEvent<X> pins,
where the X is in the range of 0 ~ 23, map to the offset range 60h ~ 77h (or 96 ~119 in decimal).


Between BIOS and EC

When system enter POST phase, the BIOS should send EC command to notify EC now is in POST.
Before system enter Windows, the BIOS should send EC command to notify EC now is in ACPI mode.

EC is in ACPI mode:
For example
In Windows --> Unplug AC Adaptor --> Trigger EC SCI Pin --> Notify OS Acpi Driver --> Do Q Event (AC unplug ASL code)

EC is not in ACPI mode:
For example
In DOS --> Unplug AC Adaptor --> Trigger EC SMI Pin --> Enter SMM Mode --> Do SMI Handler (AC unplug SMI code)




 








======================================================================

當系統在POST階段,BIOS需要送EC command告訴EC現在在POST階段。
在系統進入到Windows之前,BIOS需要送EC command告訴EC現在要進入ACPI mode, 去服務SCI。

EC在ACPI mode:
例如:
在Windows環境裡 --> 移除AC電源 --> 觸發EC SCI Pin --> 告訴OS Acpi 的驅動程式 --> 執行Q Event (AC unplug ASL code)

EC不在ACPI mode:
例如:
在DOS環境裡 --> --> 移除AC電源 --> 觸發EC SMI Pin --> 進入SMM Mode --> 執行SMI Handler (AC unplug SMI code)

Tuesday, April 12, 2011

Keyboard Buffer Concept and Tool

Location
Description
Size
40:1Ah
Keyboard, Head of Buffer Pointer
word
40:1Ch
Keyboard, End of Buffer Pointer
word
40:1Eh
Keyboard, Buffer
16 words

If the value of location 40:1Ah points to the same address as in location 40:1Ch, there are no keys in the buffer.

40:1Ah as a key is removed from the buffer, that pointer is incremented by 2, until the last word of the buffer is reached. At the point it is reset to the start of the keyboard buffer area.

40:1Ch as a key is added from the buffer, that pointer is incremented by 2, until the last word of the buffer is reached. At the point it is reset to the start of the keyboard buffer area.

40:1Eh is 16 words FIFO buffer holds up to 15 keys.
The scan code is in the upper byte of the word.
The ASCII conversion of the scan code is in the lower byte of the word.

In the BIOS code, the keyboard buffer should be cleared before end of INT19h.


Keyboard Buffer Tool (for DOS)














>> Click Here to Download <<

Monday, April 11, 2011

KBC Command

KBC Command
Function Description
0xAD
Disable keyboard interface
0xAE
Enable keyboard interface
0xED
Update keyboard LED status(Caps Lock/Scroll Lock/Num Lock)
0xAA
8042 controller self test
0xAB
Keyboard interface test