AHCI基地址

时间:2013-07-03 06:15:31

标签: assembly memory-address

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

2 个答案:

答案 0 :(得分:0)

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

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

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

答案 1 :(得分:0)

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

 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

相关问题