日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux有读EC RAM的工具吗,Step to UEFI (179)Shell下 EC Ram 读取工具

發布時間:2025/3/15 linux 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux有读EC RAM的工具吗,Step to UEFI (179)Shell下 EC Ram 读取工具 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

最近工作需要在 UEFI? Shell 下Check EC Ram 的設定,發現手上只有 Windows 下的讀取工具(RW Everything)。于是研究了一下如何在Shell 讀取 EC Ram。

根據【參考1】讀取的流程如下:

Port 66 Commands

There are also some EC commands that use ports 0x66 and

0x62. Some of these are standard ACPI commands as defined in the external ACPI

spec, others are custom.

The port 66 protocol is essentially the standard ACPI EC

interface protocol.

1. Wait for port66.IBF = 0

2. Write command byte to port 66.

3. For each outgoing data or address byte:

3a. Wait for port66.IBF = 0

3b. Write data or address byte to port 62.

4. For each incoming data byte:

4a. Wait for port66.OBF = 1

4b. Read data byte from port 62.

5. If the command requires no data or address bytes, you can

determine when the command was accepted/executed by waiting for port66.IBF=0.

同時 ACPI 定義的通用 Command如下:

ACPI-defined port 66 commands

0x80 Read EC (write 0x80 to port 66, write address byte to

port 62, read data byte from port 62)

0x81 Write EC (write 0x81 to port 66, write address byte to

port 62, write data byte to port 62)

0x82 Burst Enable (write 0x82 to port 66, read data byte

from port 62 - the data byte is "burst ACK", value 0x90)

0x83 Burst Disable (write 0x83 to port 66, wait for

port66.IBF=0)

0x84 Query EC (i.e. read SCI event queue) (write 0x84 to

port 66, read data byte from port 62). When the data byte is 0, it means that

the SCI event queue is empty.

最終根據上述資料,編寫一個 Application 如下:

#include

#include

#include

#include

extern EFI_SYSTEM_TABLE *gST;

extern EFI_BOOT_SERVICES *gBS;

#define TIMEOUT 0xFFFF

#define ECCOMMAND 0x66

#define ECSTATUS 0x66

#define ECDATA 0x62

#define EC_S_OBF BIT0

#define EC_S_IBF BIT1

#define ECREADCMD 0x80

UINT8 MemBuffer[16][16];

void WaitIBF() {

UINT32 Status;

UINTN Count;

Count = 0;

Status = 0;

Status = IoRead8 (ECSTATUS);

while (((Status & EC_S_IBF) != 0)||(Count>TIMEOUT)) {

Status = IoRead8 (ECSTATUS);

Count++;

}

}

void WaitOBF() {

UINT32 Status;

UINTN Count;

Count = 0;

Status = 0;

Status = IoRead8 (ECSTATUS);

while (((Status & EC_S_OBF) == 0)||(Count>TIMEOUT)) {

Status = IoRead8 (ECSTATUS);

Count++;

}

}

UINT8 ReadECRam(UINT8 Index) {

WaitIBF(); //1

IoWrite8(ECCOMMAND,0x80);//2

WaitIBF(); //3a

IoWrite8(ECDATA, Index); //3b

WaitOBF(); //4a

return IoRead8(ECDATA); //4b

}

void GetData()

{

UINT8 i,j;

for (i=0;i<16;i++)

for (j=0;j<16;j++) {

MemBuffer[i][j]=ReadECRam(i*16+j);

}

}

void ShowData()

{

UINT8 i,j;

Print(L" ");

for (i=0;i<16;i++) Print(L"%02X ",i);

Print(L"\n");

for (i=0;i<16;i++) {

Print(L"%02X: ",i);

for (j=0;j<16;j++) {

Print(L"%02X ",MemBuffer[i][j]);

}

Print(L"\n");

}

Print(L"\n");

}

/***

Print a welcoming message.

Establishes the main structure of the application.

@retval 0 The application exited normally.

@retval Other An error occurred.

***/

INTN

EFIAPI

ShellAppMain (

IN UINTN Argc,

IN CHAR16 **Argv

)

{

EFI_INPUT_KEY Key;

Key.ScanCode=SCAN_NULL;

while (SCAN_UP!=Key.ScanCode)

{

gST->ConOut->ClearScreen(gST->ConOut);

GetData();

ShowData();

gST -> ConIn -> ReadKeyStroke(gST->ConIn,&Key);

Print(L"Press Arrow-Up to exit\n");

gBS->Stall(1000000UL);

}

return(0);

}

在實體機上運行結果如下(按向上鍵退出):

源代碼和Application(X64)下載:

參考:

1. http://wiki.laptop.org/go/Ec_specification

總結

以上是生活随笔為你收集整理的linux有读EC RAM的工具吗,Step to UEFI (179)Shell下 EC Ram 读取工具的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。