[coreboot-gerrit] Change in libgfxinit[master]: gma: Add Map_Linear_FB()

Nico Huber (Code Review) gerrit at coreboot.org
Sun Jul 16 21:45:56 CEST 2017


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


Change subject: gma: Add Map_Linear_FB()
......................................................................

gma: Add Map_Linear_FB()

Change-Id: Ia8850256b3a679e3b76567a6e3146e4c3dc38960
Signed-off-by: Nico Huber <nico.h at gmx.de>
---
M common/hw-gfx-gma.adb
M common/hw-gfx-gma.ads
2 files changed, 55 insertions(+), 18 deletions(-)



  git pull ssh://review.coreboot.org:29418/libgfxinit refs/changes/09/20609/1

diff --git a/common/hw-gfx-gma.adb b/common/hw-gfx-gma.adb
index 5f7cafe..f6ddb84 100644
--- a/common/hw-gfx-gma.adb
+++ b/common/hw-gfx-gma.adb
@@ -43,7 +43,8 @@
          Registers.Address_State,
          PLLs.State, Panel.Panel_State,
          Cur_Configs, Allocated_PLLs,
-         HPD_Delay, Wait_For_HPD),
+         HPD_Delay, Wait_For_HPD,
+         Linear_FB_Addr),
       Init_State => Initialized,
       Config_State => Config.Valid_Port_GPU,
       Device_State =>
@@ -77,6 +78,8 @@
    HPD_Delay : HPD_Delay_Type;
    Wait_For_HPD : HPD_Type;
    Initialized : Boolean := False;
+
+   Linear_FB_Addr : Word64;
 
    ----------------------------------------------------------------------------
 
@@ -312,7 +315,8 @@
             Registers.Address_State,
             PLLs.State, Panel.Panel_State,
             Cur_Configs, Allocated_PLLs,
-            HPD_Delay, Wait_For_HPD, Initialized))
+            HPD_Delay, Wait_For_HPD,
+            Linear_FB_Addr, Initialized))
    is
       use type HW.Word64;
 
@@ -346,6 +350,7 @@
 
       pragma Debug (Debug.Set_Register_Write_Delay (Write_Delay));
 
+      Linear_FB_Addr := 0;
       Wait_For_HPD := HPD_Type'(others => False);
       HPD_Delay := HPD_Delay_Type'(others => Now);
       Allocated_PLLs := (others => PLLs.Invalid);
@@ -545,6 +550,25 @@
       end case;
    end Decode_Stolen;
 
+   procedure Validate_FB (FB : Framebuffer_Type; Valid : out Boolean)
+   with
+      Post => (if Valid then Valid_Phys_FB (FB))
+   is
+      GTT_Size : Natural;
+      Stolen_Size : Stolen_Size_Range;
+   begin
+      Valid := Valid_FB (FB);
+
+      if Valid then
+         Decode_Stolen (GTT_Size, Stolen_Size);
+         Valid :=
+            FB_Last_Page (FB) < GTT_Size / Config.GTT_PTE_Size and
+            FB_Last_Page (FB) < Natural (Stolen_Size / GTT_Page_Size);
+         pragma Debug (not Valid, Debug.Put
+           ("Stolen memory too small to hold framebuffer."));
+      end if;
+   end Validate_FB;
+
    procedure Setup_Default_FB
      (FB       : in     Framebuffer_Type;
       Clear    : in     Boolean := True;
@@ -554,19 +578,8 @@
       GMA_Phys_Base_Mask : constant := 16#fff0_0000#;
 
       Phys_Base : Word32;
-      GTT_Size : Natural;
-      Stolen_Size : Stolen_Size_Range;
    begin
-      Success := Valid_FB (FB);
-
-      if Success then
-         Decode_Stolen (GTT_Size, Stolen_Size);
-         Success :=
-            FB_Last_Page (FB) < GTT_Size / Config.GTT_PTE_Size and
-            FB_Last_Page (FB) < Natural (Stolen_Size / GTT_Page_Size);
-         pragma Debug (not Success, Debug.Put
-           ("Stolen memory too small to hold framebuffer."));
-      end if;
+      Validate_FB (FB, Success);
 
       if Success then
          Dev.Read32 (Phys_Base, GMA_Phys_Base);
@@ -584,16 +597,36 @@
             use type HW.Word64;
             Linear_FB : Word64;
          begin
-            Dev.Map (Linear_FB, PCI.Res2);
+            Map_Linear_FB (Linear_FB, FB);
             if Linear_FB /= 0 then
-               Framebuffer_Filler.Fill (Linear_FB + Word64 (FB.Offset), FB);
+               Framebuffer_Filler.Fill (Linear_FB, FB);
             end if;
-            pragma Debug
-              (Linear_FB = 0, Debug.Put_Line ("Failed to map resource2."));
          end;
       end if;
    end Setup_Default_FB;
 
+   procedure Map_Linear_FB (Linear_FB : out Word64; FB : in Framebuffer_Type)
+   is
+      use type HW.Word64;
+
+      Valid : Boolean;
+   begin
+      Linear_FB := 0;
+
+      if Linear_FB_Addr = 0 then
+         Dev.Map (Linear_FB_Addr, PCI.Res2);
+         pragma Debug
+           (Linear_FB_Addr = 0, Debug.Put_Line ("Failed to map resource2."));
+      end if;
+
+      if Linear_FB_Addr /= 0 then
+         Validate_FB (FB, Valid);
+         if Valid then
+            Linear_FB := Linear_FB_Addr + Word64 (FB.Offset);
+         end if;
+      end if;
+   end Map_Linear_FB;
+
    ----------------------------------------------------------------------------
 
    procedure Dump_Configs (Configs : Pipe_Configs)
diff --git a/common/hw-gfx-gma.ads b/common/hw-gfx-gma.ads
index b693ff4..30dc45e 100644
--- a/common/hw-gfx-gma.ads
+++ b/common/hw-gfx-gma.ads
@@ -101,6 +101,10 @@
    with
       Pre => Is_Initialized and HW.Config.Dynamic_MMIO;
 
+   procedure Map_Linear_FB (Linear_FB : out Word64; FB : in Framebuffer_Type)
+   with
+      Pre => Is_Initialized and HW.Config.Dynamic_MMIO;
+
 private
 
    ----------------------------------------------------------------------------

-- 
To view, visit https://review.coreboot.org/20609
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-Project: libgfxinit
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia8850256b3a679e3b76567a6e3146e4c3dc38960
Gerrit-Change-Number: 20609
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/20170716/2a3a421b/attachment-0001.html>


More information about the coreboot-gerrit mailing list