資源簡介
自己編寫的基于edk2編寫的讀寫pci的小程序,模仿AMI RU工具,適合初學bios開發的developer

代碼片段和文件信息
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#define?HEX_KEY_INPUT(?x?)?(?(?(x?<=?‘9‘)?&&?(x?>=?‘0‘)?)?||?(?(x?<=?‘F‘)?&&?(x?>=?‘A‘)?)?||?(?(x?<=?‘f‘)?&&?(x?>=?‘a‘)?)?)
#define?CALC_EFI_PCI_ADDRESS(?Bus?Dev?Fun?Reg?)?\
(?(UINT64)?(?(?(?(UINTN)?Bus)?<24)?+?(?(?(UINTN)?Dev)?<16)?+?\
?????(?(?(UINTN)?Fun)?<8)?+?(?(UINTN)?Reg)?)?)
#define?SCAN_CODE_NULL 0x0000
#define?SCAN_CODE_UP 0x0001
#define?SCAN_CODE_DOWN 0x0002
#define?SCAN_CODE_RIGHT 0x0003
#define?SCAN_CODE_LEFT 0x0004
#define?SCAN_CODE_PAGE_UP 0x0009
#define?SCAN_CODE_PAGE_DOWN 0x000A
#define?SCAN_CODE_ESC 0x0017
#define?SCAN_CODE_F1 0x000B
#define?CHAR_CR 0x000D
EFI_STATUS?PCI_Reg(?UINT8?UINT8?UINT8?);
UINTN
Xtoi(
IN?CHAR16??*Str
)
{
return(StrHexToUintn(?Str?)?);
}
EFI_STATUS
EFIAPI
UefiMain
(?IN?EFI_HANDLE?ImageHandle?IN?EFI_SYSTEM_TABLE??*SystemTable?)
{
EFI_INPUT_KEY Key;
EFI_STATUS Status;
UINT8 Addr;
UINT8 Bus;
UINT8 Dev;
UINT8 Fun;
UINTN Index3;
UINT8 InPutKeyFlag;
CHAR16 *InPutKey;
InPutKey?=?AllocatePool(?2?*?9?);
Status =?EFI_SUCCESS;
InPutKeyFlag =?0;
Bus =?0;
Dev =?0;
Fun =?0;
Addr =?0;
gST->ConOut->ClearScreen(?gST->ConOut?);
Print(?L“Bus:00“?);
for?(;;?)
{
gST->ConOut->EnableCursor(?gST->ConOut?TRUE?);
gST->ConOut->SetCursorPosition(?gST->ConOut?4?0?);
Status =?gBS->WaitForEvent(?1?&gST->ConIn->WaitForKey?&Index3?);
Status =?gST->ConIn->ReadKeyStroke(?gST->ConIn?&Key?);
if?(?HEX_KEY_INPUT(?Key.UnicodeChar?)?)
{
if?(?InPutKeyFlag?>=?2?)
InPutKeyFlag?=?0;
InPutKey[InPutKeyFlag] =?Key.UnicodeChar;
InPutKey[InPutKeyFlag?+?1] =?L‘\0‘;
InPutKeyFlag++;
if?(?InPutKeyFlag?!=?0?)
{
Addr?=?(UINT8)?Xtoi(?InPutKey?);
if?(?Addr?0x10?)
{
Print(?L“0%x“?Addr?);
}?else?{
Print(?L“%x“?Addr?);
}
}
continue;
}
if?(?Key.UnicodeChar?==?CHAR_CR?)
{
Bus =?Addr;
InPutKeyFlag =?0;
Addr =?0;
break;
}
if?(?Key.ScanCode?==?SCAN_CODE_ESC?)
{
break;
}
}
if?(?Bus?0x10?)
{
Print(?L“0%x“?Bus?);
}?else?{?Print(?L“%x“?Bus?);?}
Print(?L“?“?);
Print(?L“Dev:00“?);
for?(;;?)
{
gST->ConOut->EnableCursor(?gST->ConOut?TRUE?);
gST->ConOut->SetCursorPosition(?gST->ConOut?11?0?);
Status =?gBS->WaitForEvent(?1?&gST->ConIn->WaitForKey?&Index3?);
Status =?gST->ConIn->ReadKeyStroke(?gST->ConIn?&Key?);
if?(?HEX_KEY_INPUT(?Key.UnicodeChar?)?)
{
if?(?InPutKeyFlag?>=?2?)
InPutKeyFlag?=?0;
InPutKey[InPutKeyFlag] =?Key.UnicodeChar;
InPutKey[InPutKeyFlag?+?1] =?L‘\0‘;
InPutKeyFlag++;
if?(?InPutKeyFlag?!=?0?)
{
Addr?=?(UINT8)?Xtoi(?InPutKey?);
if?(?Addr?0x1
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2016-08-07?13:19??pciRW\
?????文件???????10360??2016-08-07?11:50??pciRW\pci.c
?????文件?????????567??2016-08-07?12:03??pciRW\pci.info
- 上一篇:類似知乎的圖文編輯器
- 下一篇:tex2word破解版).rar
評論
共有 條評論