📄 pcirw.c
字号:
// Keyboard input PCI bus, device and function number, for get the pci function register values.
//
switch (KeyStep) {
case 0:
if (Cflag == CHANGE_DIGITAL_MARK) {
PrintAt (14, PCI_ADD_INPUT_BAR, L":");
}
break;
case 1:
if (Cflag == CHANGE_DIGITAL_MARK) {
PrintAt (42, PCI_ADD_INPUT_BAR, L":");
}
break;
case 2:
if (Cflag == CHANGE_DIGITAL_MARK) {
PrintAt (69, PCI_ADD_INPUT_BAR, L":");
}
break;
default:;
}
if (Cflag == CHANGE_DIGITAL_MARK) Cflag = FIRST_DIGITAL_MARK;
if (Iflag != FIRST_RUN_MARK) WaitForSingleEvent (In->WaitForKey, 0);
Status = In->ReadKeyStroke (In, &Key);
if (!EFI_ERROR (Status) || (Iflag == FIRST_RUN_MARK)) {
if (IS_HEXCODE_KEY(Key.UnicodeChar)) {
//
// If key in hexadecimal-formatted code.
//
//Print(L"%c", Key.UnicodeChar);
DigitalString[Cflag-1] = Key.UnicodeChar;
DigitalString[Cflag] = L'\0';
Cflag++;
switch (KeyStep) {
case 0:
Bus = (UINT8)Xtoi(DigitalString);
ValueToHex(DigitalString, (UINT64)Bus);
if (Bus < 0x10) {
PrintAt (15, PCI_ADD_INPUT_BAR, L"0%s", DigitalString);
} else {
PrintAt (15, PCI_ADD_INPUT_BAR, L"%s", DigitalString);
}
break;
case 1:
Dev = (UINT8)Xtoi(DigitalString);
if (Dev >= 32) {
Dev = 31;
}
ValueToHex(DigitalString, (UINT64)Dev);
if (Dev < 0x10) {
PrintAt (43, PCI_ADD_INPUT_BAR, L"0%s", DigitalString);
} else {
PrintAt (43, PCI_ADD_INPUT_BAR, L"%s", DigitalString);
}
break;
case 2:
Func = (UINT8)Xtoi(DigitalString);
if (Func >= 8) {
Func = 7;
}
ValueToHex(DigitalString, (UINT64)Func);
if (Func < 0x10) {
PrintAt (70, PCI_ADD_INPUT_BAR, L"0%s", DigitalString);
} else {
PrintAt (70, PCI_ADD_INPUT_BAR, L"%s", DigitalString);
}
break;
default:;
}
//PrintAt (0, 20, L"Digital String:%s", DigitalString);
if (Cflag >= END_DIGITAL_MARK) {
Cflag = CHANGE_DIGITAL_MARK;
KeyStep++;
if (KeyStep>=3) {
KeyStep = 0;
}
}
}
//
// Register read & write mode.
//
if ((Key.UnicodeChar == CHAR_CR) || (Iflag == FIRST_RUN_MARK)) {
//
//Get&Set PCI function register values, and format to screen.
//
Iflag = 0;
IndexCell = 0;
Cflag = FIRST_DIGITAL_MARK;
SetFrmMode(0);
PrintAt (0, PCI_REG_NOTE_BAR, L"Above registers of Bus :%2x device:%2x function:%2x", Bus, Dev, Func);
Address = CALC_EFI_PCI_ADDRESS(Bus, Dev, Func, 0);
PrintAt (0, PCI_ADD_NOTE_BAR, L"Read Pci Address = %X", Address);
Status = PciIo->Pci.Read (
PciIo,
EfiPciWidthUint16,
Address,
1,
&Reg16
);
PrintAt (PCI_INFO_COL, PCI_INFO_VENDOR_BAR, L"Vendor ID: %x", Reg16);
Status = PciIo->Pci.Read (
PciIo,
EfiPciWidthUint16,
Address+2,
1,
&Reg16
);
PrintAt (PCI_INFO_COL, PCI_INFO_VENDOR_BAR+1, L"Device ID: %x", Reg16);
do {
//
// Format register value to screen
//
SetFrmMode(2);
PrintAt (0, PCI_REG_VALUE_BAR, L" 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F \n ");
for (Index = 0; Index <= 0xFF; Index++){
if ((Index % 0x10) == 0) {
if (Index == 0) {
Print(L"%x0", Index);
} else {
Print(L"\n %x", Index);
}
Print(L": ");
} else {
if ((Index % 8) == 0 ) Print(L"- ");
}
Status = PciIo->Pci.Read (
PciIo,
EfiPciWidthUint8,
Address+Index,
1,
&Reg8
);
if (Index == IndexCell) {
SetFrmMode(1);
if (Iflag == 1) IndexRegOld = Reg8;
if (Iflag == 2) Reg8 = (UINT8)Xtoi(DigitalString);
}
if (Reg8 < 0x10){
Print (L"0%x", Reg8);
} else {
Print (L"%x", Reg8);
}
if (Index == IndexCell) SetFrmMode(2);
Print(L" ");
Status = In->ReadKeyStroke (In, &Key);
if (Iflag > 0) {
switch (Key.ScanCode) {
//
// Response user choice register in cell.
//
case SCAN_CODE_UP:
Iflag = 1;
Cflag = 1;
IndexCell = IndexCell - 0x10;
break;
case SCAN_CODE_DOWN:
Iflag = 1;
Cflag = 1;
IndexCell = IndexCell + 0x10;
break;
case SCAN_CODE_RIGHT:
Iflag = 1;
Cflag = 1;
IndexCell = IndexCell + 1;
break;
case SCAN_CODE_LEFT:
Iflag = 1;
Cflag = 1;
IndexCell = IndexCell - 1;
break;
default:;
}
if (IS_HEXCODE_KEY(Key.UnicodeChar)) {
//
// If key in hexadecimal-formatted code.
//
Iflag = 2;
DigitalString[Cflag-1] = Key.UnicodeChar;
DigitalString[Cflag] = L'\0';
Cflag++;
if (Cflag >= END_DIGITAL_MARK) Cflag = FIRST_DIGITAL_MARK;
}
if (Key.UnicodeChar == CHAR_CR) {
//
// Modify confirm
//
if (Iflag == 2) {
//
// Save value to register
//
Iflag = 1;
Reg8 = (UINT8)Xtoi(DigitalString);
PciIo->Pci.Write (PciIo, EfiPciIoWidthUint8, Address+IndexCell, 1, &Reg8);
}
}
if (Key.ScanCode == SCAN_CODE_ESC || Key.ScanCode == KEY_EXIT_CODE) break;
}
if (Index == 0xFF) break;
}
if (Iflag == 0) Iflag = 1;
//PrintAt (0, 22, L"Read Pci Status = %x", Status);
} while ((Key.ScanCode != SCAN_CODE_ESC) && (Key.ScanCode != KEY_EXIT_CODE));
SetFrmMode(0);
Status = EFI_SUCCESS;
KeyStep = 0;
Cflag = CHANGE_DIGITAL_MARK;
}
} else {
//
// ReadkeyStroke error then break. (some times..)
//
//break;
}
} while ( Key.ScanCode != KEY_EXIT_CODE);
SetFrmMode(0);
FreePool(DigitalString);
Out->ClearScreen (Out);
return Status;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -