[coreboot-gerrit] Change in libgfxinit[master]: gma registers: Add Read_GTT() procedure

Nico Huber (Code Review) gerrit at coreboot.org
Wed Jun 13 01:27:37 CEST 2018


Nico Huber has uploaded this change for review. ( https://review.coreboot.org/27057


Change subject: gma registers: Add Read_GTT() procedure
......................................................................

gma registers: Add Read_GTT() procedure

Change-Id: I0f8091b8958d0c228430fad4b8343fc362a2dbb7
Signed-off-by: Nico Huber <nico.h at gmx.de>
---
M common/hw-gfx-gma-registers.adb
M common/hw-gfx-gma-registers.ads
M common/hw-gfx-gma.adb
M common/hw-gfx-gma.ads
4 files changed, 54 insertions(+), 6 deletions(-)



  git pull ssh://review.coreboot.org:29418/libgfxinit refs/changes/57/27057/1

diff --git a/common/hw-gfx-gma-registers.adb b/common/hw-gfx-gma-registers.adb
index 368b259..c0187f6 100644
--- a/common/hw-gfx-gma-registers.adb
+++ b/common/hw-gfx-gma-registers.adb
@@ -69,7 +69,7 @@
       Index_T     => GTT_Range,
       Array_T     => GTT_Registers_64);
 
-   GTT_PTE_Valid : constant Word32 := 1;
+   GTT_PTE_Valid : constant := 1;
 
    ----------------------------------------------------------------------------
 
@@ -177,6 +177,33 @@
       end if;
    end Write_GTT;
 
+   procedure Read_GTT
+     (Device_Address :    out GTT_Address_Type;
+      Valid          :    out Boolean;
+      GTT_Page       : in     GTT_Range)
+   is
+   begin
+      if Config.Has_64bit_GTT then
+         declare
+            PTE : GTT_PTE_32;
+         begin
+            GTT_32.Read (PTE, GTT_Page);
+            Valid := (PTE and GTT_PTE_Valid) /= 0;
+            Device_Address := GTT_Address_Type
+              (Shift_Left (Word64 (PTE and 16#07f0#), 32 - 4) or
+               Word64 (PTE and 16#ffff_f000#));
+         end;
+      else
+         declare
+            PTE : GTT_PTE_64;
+         begin
+            GTT_64.Read (PTE, GTT_Page);
+            Valid := (PTE and GTT_PTE_Valid) /= 0;
+            Device_Address := GTT_Address_Type (PTE and 16#7f_ffff_f000#);
+         end;
+      end if;
+   end Read_GTT;
+
    ----------------------------------------------------------------------------
 
    package Rep is
diff --git a/common/hw-gfx-gma-registers.ads b/common/hw-gfx-gma-registers.ads
index 99efba9..3be2ec7 100644
--- a/common/hw-gfx-gma-registers.ads
+++ b/common/hw-gfx-gma-registers.ads
@@ -1720,17 +1720,21 @@
 
    procedure Remove_Fence (First_Page, Last_Page : GTT_Range);
 
-   pragma Warnings (Off, "declaration of ""Write_GTT"" hides one at *");
    procedure Write_GTT
      (GTT_Page       : GTT_Range;
       Device_Address : GTT_Address_Type;
       Valid          : Boolean)
    with
       Global  => (In_Out => GTT_State),
-      Depends => (GTT_State =>+ (GTT_Page, Device_Address, Valid)),
-      Pre     => True,
-      Post    => True;
-   pragma Warnings (On, "declaration of ""Write_GTT"" hides one at *");
+      Depends => (GTT_State =>+ (GTT_Page, Device_Address, Valid));
+
+   procedure Read_GTT
+     (Device_Address :    out GTT_Address_Type;
+      Valid          :    out Boolean;
+      GTT_Page       : in     GTT_Range)
+   with
+      Global  => (In_Out => GTT_State),
+      Depends => ((Device_Address, Valid, GTT_State) => (GTT_State, GTT_Page));
 
    procedure Set_Register_Base (Base : Word64; GTT_Base : Word64 := 0)
    with
diff --git a/common/hw-gfx-gma.adb b/common/hw-gfx-gma.adb
index ad686c3..48b211e 100644
--- a/common/hw-gfx-gma.adb
+++ b/common/hw-gfx-gma.adb
@@ -585,6 +585,15 @@
       Registers.Write_GTT (GTT_Page, Device_Address, Valid);
    end Write_GTT;
 
+   procedure Read_GTT
+     (Device_Address :    out GTT_Address_Type;
+      Valid          :    out Boolean;
+      GTT_Page       : in     GTT_Range)
+   is
+   begin
+      Registers.Read_GTT (Device_Address, Valid, GTT_Page);
+   end Read_GTT;
+
    procedure Setup_Default_GTT (FB : Framebuffer_Type; Phys_Base : Word32)
    with
       Pre => Is_Initialized and Valid_Phys_FB (FB, Phys_Base)
diff --git a/common/hw-gfx-gma.ads b/common/hw-gfx-gma.ads
index 7f44a0f..dcb3975 100644
--- a/common/hw-gfx-gma.ads
+++ b/common/hw-gfx-gma.ads
@@ -163,6 +163,14 @@
       Global => (In_Out => Device_State, Proof_In => Init_State),
       Pre => Is_Initialized;
 
+   procedure Read_GTT
+     (Device_Address :    out GTT_Address_Type;
+      Valid          :    out Boolean;
+      GTT_Page       : in     GTT_Range)
+   with
+      Global => (In_Out => Device_State, Proof_In => Init_State),
+      Pre => Is_Initialized;
+
    procedure Setup_Default_FB
      (FB       : in     Framebuffer_Type;
       Clear    : in     Boolean := True;

-- 
To view, visit https://review.coreboot.org/27057
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: libgfxinit
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0f8091b8958d0c228430fad4b8343fc362a2dbb7
Gerrit-Change-Number: 27057
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h at gmx.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180612/2ca08630/attachment-0001.html>


More information about the coreboot-gerrit mailing list