首页
学习
活动
专区
圈层
工具
发布

AHCI基址
EN

Stack Overflow用户
提问于 2013-07-03 14:15:31
回答 2查看 594关注 0票数 0

如何获取AHCI基址(ABAR)?我怎么才能知道这是哪个内存地址?我知道,它从PCI基地址开始计算,但我不知道如何也能获得PCI基地址。

EN

回答 2

Stack Overflow用户

发布于 2013-10-28 17:15:09

AHCI基址位于AHCI主机控制器的BAR5中,AHCI主机控制器也是PCI设备。这里的"BAR5“表示PCI配置空间中的偏移量0x27~0x24(DWORD)。为了获得这个基地址,s/w应该发出配置读取周期!

下面是使用汇编语言获取BAR5的代码示例(假设AHCI主机控制器位于总线3,设备0,函数0)

代码语言:javascript
复制
mov eax, 80030024h  ; PCI function address
mov dx, 0cf8h       ; config address io port
out dx, eax
mov dx, 0cfch       ; get data from config data port
in eax, dx          ; read DWORD into register eax

也许你应该做的第一件事就是学习PCI规范。然后你可以查看下面的链接:

PCI configuration spaceAccess registers in a PCI config space

票数 0
EN

Stack Overflow用户

发布于 2013-11-12 16:37:35

我最近正在尝试从AHCI基址读取内存。我刚刚找到了三种可以帮助你的方法。方法1。你可以通过winring0读取pci基址。这里有很多你可以下载的演示。链接是http://bbs.aau.cn/forum.php?mod=viewthread&tid=4914。方法2.我只需运行第三个工具(lspci.exe)来读取ahci基址。

代码语言:javascript
复制
 private string getAhciBaseAddress()
    {
        string output = "";      

        ProcessStartInfo StartInfo = new ProcessStartInfo();

        StartInfo.FileName = @"C:\pciutils-3.2.0\lspci.exe";
        StartInfo.Arguments = "-v -s.2";    
        StartInfo.UseShellExecute = false;    
        StartInfo.RedirectStandardInput = false;//不重定向输入      
        StartInfo.RedirectStandardOutput = true; //重定向输出 
        StartInfo.CreateNoWindow = true; //不创建窗口 
        StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
        Process myProcess = null;
        try
        {
            myProcess = Process.Start(StartInfo);
            while (!myProcess.HasExited)
            {
                myProcess.WaitForExit(3000);
            }
            output = myProcess.StandardOutput.ReadToEnd();//读取进程的输出 
            Console.WriteLine("output==" + output);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.StackTrace);
        }
        finally
        {
            if (myProcess != null)  myProcess.Close();    

        }
        string key = "Memory at ";
        int index = output.IndexOf(key);
        string addressString = "";
        int length = IntPtr.Size == 4 ? 8 : 16;
        if (index!= -1)
        {
            addressString = output.Substring(index + +key.Length, length);
        }
        return addressString;
    }

链接为http://blog.csdn.net/shmily453397/article/details/13767599

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17440921

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档