小華的部落格: 2018

搜尋此網誌

網頁

星期一, 2月 05, 2018

UEFI Shell Utility - pwrtest.efi

The pwrtest.efi is an UEFI Shell tool that help developer to confirm RTC wake function from a system(Support on both Intel and AMD platform).

最近在幫忙ODM看一個RTC Wake 問題,所以就順便寫了一個TOOL來驗證一些東西。原本遇到的問題也解決了,所以就順便把這個小TOOL分享一下給有需要的人使用。

Usage:
    pwrtest -s3 -t 10 -w 60  ; 系統會在10 sec delay 後進入S3,然後在60 sec 後喚醒(Wake up) 
    pwrtest [-h|-s3|-s4|-s5|-s|-ss|-sx|-cb|-r]
                  -h help
                  -s3|-s4|-s5        ;選擇系統的Sx State (Intel platform)
                  -cb                   ;做coldboot ,我是透過 gRT->ResetSystem()  方式去做的
                  -ss                   ; 做Shutdown,我是透過 gRT->ResetSystem()  方式去做的
                  -sx value         ; 支援AMD platform去做Sx State,因為填的SLP_TYP值不同.
                                            value = 3/4/5 for AMD platform(S3/S4/S5)
                                            value = 5/6/7 for Intel Platform (S3/S4/S5)
e.g,
    pwrtest -sx 4 -t 5 -w 30 ; For AMD Platform,  Put system to S4 after 5 sec, then wake after 30 sec.
    pwrtest -sx 6 -t 5 -w 30 ; For INTEL Platform,  Put system to S4 after 5 sec, then wake after 30 sec.
    pwrtest -s3 -t 5 -w 30    ; For INTEL Platform,  Put system to S3 after 5 sec, then wake after 30 sec.
    pwrtest -r                       ; Warm boot
    pwrtest -cb                    ; Cold boot

[註]
    - S3 功能只能喚醒系統,喚醒後會當機,因為我沒有支援Reset Vector(Not support)
    - 有些系統S4/S5 並不支援RTC wake up,所以請跟你們的BIOS/EC確認,因為這個工具只是去填RTC Enable bit & RTC Alarm interrupt而已。


Download (Password: harrison):

version 1.1 : pwrtest



星期一, 1月 15, 2018

紀錄一下WinDbg裡面比較常用到的指令集

AMLI裡面比較常用到的指令集

AMLI(? for help)-> ?
?

Help                     - ? [<Cmd>]
Clear Breakpoints        - bc <bp list> | *
Disable Breakpoints      - bd <bp list> | *
Enable Breakpoints       - be <bp list> | *
List Breakpoints         - bl
Set Breakpoints          - bp <MethodName> | <CodeAddr> ...
Clear Event Log          - cl
Dump Event Log           - dl
Dump Object Count Table  - dc
Dump Heap                - dh [<Addr>]
Dump Stack               - ds [/v] [<Addr>]
Dump Name Space Object   - dns [[/s] [<NameStr> | <Addr>]]
Dump Data Object         - do <Addr>
Find NameSpace Object    - find <NameSeg>
Continue Execution       - g
Read Byte from Port      - i <Port>
Read Word from Port      - iw <Port>
Read DWord from Port     - id <Port>
List All Contexts        - lc
Display Nearest Method   - ln [<MethodName> | <CodeAddr>]
Notify NameSpace Object  - notify <Obj> <Value>
Write Byte to Port       - o <Port> <Byte>
Write Word to Port       - ow <Port> <Word>
Write DWord to Port      - od <Port> <DWord>
Step Over AML Code       - p
Quit to Kernel Debugger  - q
Display Context Info.    - r <Context>
Run Method               - run <MethodName> | <CodeAddr> [<ArgList>]
Set Debugger Options     - set [traceon | traceoff] [nesttraceon | nesttraceoff] [spewon | spewoff]
                               [dbgbrkon | dbgbrkoff] [lbrkon | lbrkoff] [errbrkon | errbrkoff] 
                               [verboseon | verboseoff] [logon | logoff] [logmuton | logmutoff] 
Trace Into AML Code      - t
Interpreter Trace Mode   - trace [trigon] [trigoff] [level=<n>]
                                 [add=<TrigPtStr] [zap=<TrigPtList>]
Unassemble AML code      - u [<MethodName> | <CodeAddr>]


AMLI(? for help)-> 

ACPI 裡面比較常用到的指令集
!acpicache displays all of the ACPI tables cached by the hardware application layer (HAL)

!acpiinf displays information on the configuration of the ACPI

!acpiirqarb displays the contents of the ACPI IRQ arbiter structure

!facs displays a Firmware ACPI Control Structure

!fadt displays a Fixed ACPI Description Table

!mapic displays an ACPI Multiple APIC Table

!nsobj displays an ACPI namespace object

!nstree displays a section of the ACPI namespace tree


!rsdt displays the ACPI Root System Description Table

!acpikd.help  For a complete list of ACPI-related extensions.

Reference
https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/acpi-debugging

星期三, 1月 10, 2018

如何透過DevCon.exe 去開跟關你的Device Manager內的設備


如何透過DevCon.exe 去開跟關你的Device Manager內的設備


  當你安裝WDK, Visual Studio 或是Windows SDK時,這些安裝檔裡面就會包含DevCon.exe。
 
  我的DevCon.exe是在底下這個路徑內找到的:

     C:\Program Files (x86)\Windows Kits\10\Tools\x64\DevCon.exe

 當然,如果你想要自己Build source code的話,你也可以從底下的路徑找到這個source code:

    https://github.com/Microsoft/Windows-driver-samples/tree/master/setup/devcon

我自己也用VS2013 成功建構出來這個執行檔,只是有個小地方要注意,就是你build code之前,要用command prompt(Build environment)先執行底下的指令,先把msg.h 建立出來,不然你沒辦法用專案檔案去compiler , 因為會出現會找不到msg.h的ERROR.

   C:\DevCon >  mc msg.mc   會產生msg.h

底下就是一些基本的指令操作:

1)先找你要開關的Device的HWID(我是存到一個文字檔慢慢找):
devcon hwids * > D:\hwids.txt  

2) 使用底下指令去disable , 記得在HW ID前面加@
devcon /r disable "@ACPI\DELL0812\3&31FF937C&0"

3) 使用底下指令去enable, 記得在HW ID前面加@,然後HWID要用" "包起來.
devcon /r enable "@ACPI\DELL0812\3&31FF937C&0"

4) 使用底下指令去重新scan hardware
devcon rescan

5) 使用底下指令可以做重新開機動作

devcon reboot

至於其他跟寫driver時會用到的指令功能,大家就看底下微軟的詳細說明囉~

Reference
https://docs.microsoft.com/en-us/windows-hardware/drivers/devtest/devcon-examples