星期日, 5月 25, 2025
Dump TCG log
Dump TCG log
一個簡易的方式在UEFI Shell底下,先找到TPM2 的ACPI Table ,再從Table中找到紀錄TCG log的記憶體位址(一般UEFI PCD目前都是設定0x10000 大小,但進入OS後,OS有可能會加大這塊的內容) ,然後分析TCG log中的每一筆紀錄的Event , 然後重新計算Digest ,這樣子可以呈現出BIOS交給OS前,TCG log中所記錄的TPM PCR可能的值會是甚麼. 底下是部分實作的程式碼,幫助大家了解流程.
// Loop through all ACPI tables to find TPM2
Status = GetAcpiTableBySignature(SIGNATURE_32('T','P','M','2'), &Table);
Tpm2Table = (EFI_TPM2_ACPI_TABLE_V4 *) Table;
if (Tpm2Table == NULL) {
Print(L"[Fail] TPM2 ACPI Table not found\n");
return EFI_NOT_FOUND;
}
Print(L"TPM2 ACPI Table found\n");
Print(L"Event Log Start Address: 0x%lx\n", Tpm2Table->Lasa);
Print(L"Event Log Length: %u bytes\n", Tpm2Table->Laml);
Print(L"******** TCG Log Dump ******** \n");
PrintHexAndAscii((UINT8 *) Tpm2Table->Lasa, (UINTN) Tpm2Table->Laml); // Print partial event data
Print(L"******** TCG Events ******** \n");
// 儲存 PCR0 到 PCR23 的最後 Digest
PCRDigest PcrDigests[PCR_COUNT];
ZeroMem(PcrDigests, sizeof(PCRDigest) * PCR_COUNT);
MY_ACPI_TCG2_EVENT *TcgEvent = (MY_ACPI_TCG2_EVENT *)(UINTN)Tpm2Table->Lasa;
UINT8 *LogEnd = (UINT8 *)(UINTN)(Tpm2Table->Lasa + Tpm2Table->Laml);
UINTN EventIndex = 0;
while ((UINT8 *)TcgEvent < LogEnd) {
UINT8 *EventStart = (UINT8 *)TcgEvent;
//TODO: 1. 處理EV_NO_ACTION
2.CalculateDigest (CombinedData, CombinedDataSize, PcrDigests[PcrIndex].Digest, AlgId);
星期二, 1月 21, 2025
星期四, 2月 13, 2020
Git Tag
1.搜尋遠端上面的特定字串的Tag:
C:\> git ls-remote --tags origin "00.02.04"
7dd870355e439cfb8a818b6cd31f3c77f2ce40dc refs/tags/BiosRelease/project1/00.02.04
88138555a49907d6935fe55a8261e226668ba770 refs/tags/BiosRelease/MockingbirdCmlH/00.02.04
a98bce225711b983d729fcdb25542c6e8fdebac8 refs/tags/BiosRelease/project2/00.02.04
3cd9b00479436f67fef2e44955571218e80b6046 refs/tags/BiosRelease/project3/00.02.04
c1286cb71e39bf869ae0d70208479c3683dd0989 refs/tags/BiosRelease/project4/00.02.04
星期三, 6月 12, 2019
星期三, 2月 20, 2019
紀錄一下好用的Git Alias
紀錄一下好用的Git Alias
C:\Users\<UserName>\.gitconfig
[alias]
lg1 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
lg = !"git lg1"
ccall=!git clean -ffdx && git submodule foreach --recursive git clean -xfd && git reset --hard && git submodule foreach --recursive git reset --hard && git submodule update --init --recursive && git remote prune origin && git remote update --prune
st=!git status
pp=!git pull && git clean -ffd && git submodule foreach --recursive git clean -fd && git reset --hard && git submodule foreach --recursive git reset --hard && git submodule update --init --recursive && git remote prune origin && git remote update --prune
[git version 2.22.0 and above]
cc=!git clean -ffd && git submodule foreach --recursive 'git clean -fd' && git reset --hard && git submodule foreach --recursive 'git reset --hard' && git submodule update --init --recursive && git remote prune origin && git remote update --prune
ccall=!git clean -ffdx && git submodule foreach --recursive 'git clean -xfd' && git reset --hard && git submodule foreach --recursive 'git reset --hard' && git submodule update --init --recursive && git remote prune origin && git remote update --prune
st=!git status
pp=!git pull && git clean -ffd && git submodule foreach --recursive 'git clean -fd' && git reset --hard && git submodule foreach --recursive 'git reset --hard' && git submodule update --init --recursive && git remote prune origin && git remote update --prune
Git Pull常遇到的問題 : error: cannot lock ref ‘xxx’: ref xxx is at
git gc --prune=now
git update-ref -d refs/remotes/origin/ccc/xxx/yyy
git remote update --prune
搜尋Tag
git tag -l '*Loki*'
星期一, 2月 05, 2018
UEFI Shell Utility - pwrtest.efi
最近在幫忙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(? 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