UEFI应用与编程--IndexIo

本文档介绍了如何在UEFI环境中进行内存映射I/O(MMIO)的索引端口读写操作。通过示例函数`MmIndexIoWrite`和`MmIndexIoRead`,详细阐述了地址转换和端口操作的过程,以实现对特定硬件寄存器的高效访问。
摘要由CSDN通过智能技术生成
#include <Library/IoLib.h> 
#include "UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.h"
VOID
MmIndexIoWrite (
  IN UINT64 Address,
  IN UINT64 Value
)
{
  UINT64 IndexPort;
  UINT64 DataPort;
  UINT64 Index;
  //Address = iiiiddddrrrr i = indexport d = dataport r = offset
  DataPort  = (Address / 0x10000 - 0x10000 * (Address / 0x100000000));
  IndexPort = (Address / 0x100000000);
  Index     = (Address - IndexPort * 0x100000000 - DataPort * 0x10000);
  //Print (L"%lx %lx %lx\r\n",IndexPort, DataPort, Index);
  IoWrite16((UINT16)IndexPort, (UINT16)Index);
  IoWrite16((UINT16)DataPort, (UINT8)Value);
}
VOID
MmIndexIoRead (
  IN UINT64 Address,
  IN UINT64 Value
)
{
  UINT8                           Num;
  //UINT8                           Count;
  UINT64                          IndexPort;
  UINT64                          DataPort;
  UINT64                          Index;
  UINT8                    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值