[gnu-efi]:当我想调用CMOS读/写时,如何调用InitializeGlobalIoDevice函数?<



下面是初始化IO设备的代码,我想调用一个函数来做CMOS读/写,但我不知道DevicePath和协议?有人知道吗?非常感谢;

/*

Routine Description:

Check to see if DevicePath exists for a given Protocol. Return Error if it
exists. Return GlobalIoFuncs set match the DevicePath

Arguments:

DevicePath      - to operate on
Protocol        - to check the DevicePath against
ErrorStr        - ASCII string to display on error
GlobalIoFncs    - Returned with DeviceIoProtocol for the DevicePath

Returns:

Pass or Fail based on  wether GlobalIoFncs where found

*/
EFI_STATUS 
InitializeGlobalIoDevice (
IN  EFI_DEVICE_PATH             *DevicePath,
IN  EFI_GUID                    *Protocol,
IN  CHAR8                       *ErrorStr EFI_UNUSED,
OUT EFI_DEVICE_IO_INTERFACE     **GlobalIoFncs
)
{
EFI_STATUS      Status;
EFI_HANDLE      Handle;

//
// Check to see if this device path already has Protocol on it.
//  if so we are loading recursivly and should exit with an error
//
Status = uefi_call_wrapper(BS->LocateDevicePath, 3, Protocol, &DevicePath, &Handle);
if (!EFI_ERROR(Status)) {
DEBUG ((D_INIT, "Device Already Loaded for %a devicen", ErrorStr));
return EFI_LOAD_ERROR;
}

Status = uefi_call_wrapper(BS->LocateDevicePath, 3, &DeviceIoProtocol, &DevicePath, &Handle);
if (!EFI_ERROR(Status)) {
Status = uefi_call_wrapper(BS->HandleProtocol, 3, Handle, &DeviceIoProtocol, (VOID*)GlobalIoFncs);
}

ASSERT (!EFI_ERROR(Status));
return Status;
}

需要您的帮助....

在UEFI规范中,没有为CMOS定义的协议或设备路径。

如果你想读/写CMOS RTC,在运行时服务中定义了GetTime()SetTime()api。它们可以直接从gnu-efi的RT中调用。

如果你想读/写其他CMOS寄存器,只需访问I/O端口0x70/0x71与inb/outb指令与c中的内联汇编。这也是EDK2如何访问CMOS。

https://github.com/tianocore/edk2/blob/master/OvmfPkg/Library/PlatformInitLib/Cmos.chttps://github.com/tianocore/edk2/blob/master/MdePkg/Library/BaseIoLibIntrinsic/IoLib.c

相关内容

  • 没有找到相关文章

最新更新