2013-07-03 59 views
0

如何獲得AHCI基地址(ABAR)?我怎樣才能知道,這是什麼內存地址?我知道,它從PCI基地址算起,但我不知道如何獲得PCI基地址。AHCI基地址

回答

0

AHCI基地址位於AHCI主控制器的BAR5中,AHCI主控制器也是PCI設備。這裏的「BAR5」表示PCI配置空間中的偏移量0x27〜0x24(DWORD)。爲了得到這個基地址,應該發出配置讀週期!

下面是代碼示例用匯編語言得到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

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