<p>Nico Huber has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/20598">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">gfx_test: Update to use *libhwbase* new PCI interface<br><br>Thereby, move `gfx_test` into HW.GFX.GMA to make package dependencies<br>easier to handle.<br><br>Change-Id: Ie8a1251354b4fff57eef8c4bada8b49aa04ef382<br>Signed-off-by: Nico Huber <nico.h@gmx.de><br>---<br>M README.md<br>M gfxtest/Makefile.inc<br>D gfxtest/gfx_test.ads<br>M gfxtest/gfx_test_main.adb<br>R gfxtest/hw-gfx-gma-gfx_test.adb<br>A gfxtest/hw-gfx-gma-gfx_test.ads<br>6 files changed, 58 insertions(+), 78 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/libgfxinit refs/changes/98/20598/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/README.md b/README.md<br>index 998b8cc..7bfb504 100644<br>--- a/README.md<br>+++ b/README.md<br>@@ -40,16 +40,16 @@<br> You can either write your own `.config`, link one of the shipped files<br> in `configs/`, e.g.:<br> <br>- $ ln -s configs/posix libhwbase/.config<br>+ $ ln -s configs/linux libhwbase/.config<br> <br> or overwrite the config filename by specifying `cnf=<configfile>` on<br> the make command line.<br> <br>-Let's install *libhwbase*. We'll need `configs/posix` to build regular<br>+Let's install *libhwbase*. We'll need `configs/linux` to build regular<br> Linux executables:<br> <br> $ cd libhwbase<br>- $ make cnf=configs/posix install<br>+ $ make cnf=configs/linux install<br> <br> By default this installs into a new subdirectory `dest`. You can however<br> overwrite this decision by specifying `DESTDIR=`.<br>@@ -80,11 +80,12 @@<br> command line or with *i915* blacklisted). After running *i915* it<br> only works by chance.<br> <br>-When running `gfx_test` (as root), it will ask for a single argument:<br>-The path to a sysfs PCI-device node, where it will find the graphics<br>-hardware. Usually this is PCI device 00:02.0:<br>+When running `gfx_test` (as root), it will access the graphics hard-<br>+ware through the sysfs PCI interface. The path is<br> <br>- $ sudo build/gfx_test /sys/devices/pci0000:00/0000:00:02.0/<br>+ /sys/devices/pci0000:00/0000:00:02.0/<br>+<br>+for all supported platforms.<br> <br> If you chose the right config above, you should be presented with a<br> nice test image. However, `gfx_test` is one-way only: The graphics<br>diff --git a/gfxtest/Makefile.inc b/gfxtest/Makefile.inc<br>index 158665a..ff7fa8e 100644<br>--- a/gfxtest/Makefile.inc<br>+++ b/gfxtest/Makefile.inc<br>@@ -1,4 +1,4 @@<br>-gfxinit-y += gfx_test.adb<br>-gfxinit-y += gfx_test.ads<br>+gfxinit-y += hw-gfx-gma-gfx_test.adb<br>+gfxinit-y += hw-gfx-gma-gfx_test.ads<br> <br> gfxinit-main-y = gfx_test_main.adb<br>diff --git a/gfxtest/gfx_test.ads b/gfxtest/gfx_test.ads<br>deleted file mode 100644<br>index 52e268e..0000000<br>--- a/gfxtest/gfx_test.ads<br>+++ /dev/null<br>@@ -1,5 +0,0 @@<br>-package GFX_Test is<br>-<br>- procedure Main;<br>-<br>-end GFX_Test;<br>diff --git a/gfxtest/gfx_test_main.adb b/gfxtest/gfx_test_main.adb<br>index d3666c9..2e1d5da 100644<br>--- a/gfxtest/gfx_test_main.adb<br>+++ b/gfxtest/gfx_test_main.adb<br>@@ -1,6 +1,6 @@<br>-with GFX_Test;<br>+with HW.GFX.GMA.GFX_Test;<br> <br> procedure GFX_Test_Main is<br> begin<br>- GFX_Test.Main;<br>+ HW.GFX.GMA.GFX_Test.Main;<br> end GFX_Test_Main;<br>diff --git a/gfxtest/gfx_test.adb b/gfxtest/hw-gfx-gma-gfx_test.adb<br>similarity index 69%<br>rename from gfxtest/gfx_test.adb<br>rename to gfxtest/hw-gfx-gma-gfx_test.adb<br>index e7fb80c..b7060ec 100644<br>--- a/gfxtest/gfx_test.adb<br>+++ b/gfxtest/hw-gfx-gma-gfx_test.adb<br>@@ -1,24 +1,18 @@<br>-with System.Storage_Elements;<br>+with Ada.Unchecked_Conversion;<br> with Ada.Command_Line;<br> with Interfaces.C;<br> <br>-with HW.File;<br> with HW.Debug;<br>+with HW.PCI.Dev;<br>+with HW.MMIO_Range;<br> with HW.GFX.GMA;<br> with HW.GFX.GMA.Display_Probing;<br> <br>-use HW;<br>-use HW.GFX;<br>+package body HW.GFX.GMA.GFX_Test<br>+is<br>+ pragma Disable_Atomic_Synchronization;<br> <br>-package body GFX_Test is<br>-<br>- MMIO_Size : constant := 2 * 1024 * 1024;<br>- subtype MMIO_Range is Natural range 0 .. MMIO_Size - 1;<br>- subtype MMIO_Buffer is Buffer (MMIO_Range);<br>- MMIO_Dummy : MMIO_Buffer<br>- with<br>- Alignment => 16#1000#,<br>- Volatile;<br>+ package Dev is new PCI.Dev (PCI.Address'(0, 2, 0));<br> <br> type Pixel_Type is record<br> Red : Byte;<br>@@ -34,16 +28,23 @@<br> Alpha at 3 range 0 .. 7;<br> end record;<br> <br>+ function Pixel_To_Word (P : Pixel_Type) return Word32<br>+ with<br>+ SPARK_Mode => Off<br>+ is<br>+ function To_Word is new Ada.Unchecked_Conversion (Pixel_Type, Word32);<br>+ begin<br>+ return To_Word (P);<br>+ end Pixel_To_Word;<br>+<br> Max_W : constant := 4096;<br> Max_H : constant := 2160;<br> FB_Align : constant := 16#0004_0000#;<br>- type Screen_Type is<br>- array (0 .. 3 * (Max_W * Max_H + FB_Align / 4) - 1) of Pixel_Type;<br>+ subtype Screen_Index is Natural range<br>+ 0 .. 3 * (Max_W * Max_H + FB_Align / 4) - 1;<br>+ type Screen_Type is array (Screen_Index) of Word32;<br> <br>- Screen : Screen_Type<br>- with<br>- Alignment => 16#1000#,<br>- Volatile;<br>+ package Screen is new MMIO_Range (0, Word32, Screen_Index, Screen_Type);<br> <br> Pipes : GMA.Pipe_Configs;<br> <br>@@ -76,7 +77,6 @@<br> (Framebuffer : Framebuffer_Type;<br> Pipe : GMA.Pipe_Index)<br> is<br>- use type HW.Word32;<br> P : Pixel_Type;<br> -- We have pixel offset wheras the framebuffer has a byte offset<br> Offset_Y : Natural := Natural (Framebuffer.Offset / 4);<br>@@ -90,7 +90,7 @@<br> else<br> P := Fill (X, Y, Framebuffer, Pipe);<br> end if;<br>- Screen (Offset) := P;<br>+ Screen.Write (Offset, Pixel_To_Word (P));<br> Offset := Offset + 1;<br> end loop;<br> Offset_Y := Offset_Y + Natural (Framebuffer.Stride);<br>@@ -102,8 +102,6 @@<br> Mode : in Mode_Type;<br> Offset : in out Word32)<br> is<br>- use type HW.Int32;<br>- use type HW.Word32;<br> begin<br> Offset := (Offset + FB_Align - 1) and not (FB_Align - 1);<br> FB :=<br>@@ -119,7 +117,7 @@<br> is<br> use type HW.GFX.GMA.Port_Type;<br> <br>- Offset : HW.Word32 := 0;<br>+ Offset : Word32 := 0;<br> begin<br> GMA.Display_Probing.Scan_Ports (Pipes);<br> <br>@@ -135,65 +133,46 @@<br> GMA.Dump_Configs (Pipes);<br> end Prepare_Configs;<br> <br>- procedure Print_Usage is<br>- begin<br>- Debug.Put_Line<br>- ("Usage: " & Ada.Command_Line.Command_Name & " <sysfs-pci-path>");<br>- Debug.New_Line;<br>- end Print_Usage;<br>-<br> procedure Main<br> is<br>- use System.Storage_Elements;<br>-<br> use type HW.GFX.GMA.Port_Type;<br>+ use type HW.Word64;<br> use type Interfaces.C.int;<br> <br>- MMIO_Mapped,<br>- Screen_Mapped,<br>+ Res_Addr : Word64;<br>+<br>+ Dev_Init,<br> Initialized : Boolean;<br> <br> function iopl (level : Interfaces.C.int) return Interfaces.C.int;<br> pragma Import (C, iopl, "iopl");<br> begin<br>- if Ada.Command_Line.Argument_Count /= 1 then<br>- Print_Usage;<br>- return;<br>- end if;<br>-<br> if iopl (3) /= 0 then<br> Debug.Put_Line ("Failed to change i/o privilege level.");<br> return;<br> end if;<br> <br>- File.Map<br>- (Path => Ada.Command_Line.Argument (1) & "/resource0",<br>- Addr => Word64 (To_Integer (MMIO_Dummy'Address)),<br>- Len => MMIO_Dummy'Size / 8,<br>- Readable => True,<br>- Writable => True,<br>- Success => MMIO_Mapped);<br>- if not MMIO_Mapped then<br>- Debug.Put_Line<br>- ("Failed to map '" & Ada.Command_Line.Argument (1) & "/resource0'.");<br>+ Dev.Initialize (Dev_Init);<br>+ if not Dev_Init then<br>+ Debug.Put_Line ("Failed to map PCI config.");<br> return;<br> end if;<br> <br>- File.Map<br>- (Path => Ada.Command_Line.Argument (1) & "/resource2",<br>- Addr => Word64 (To_Integer (Screen'Address)),<br>- Len => Screen'Size / 8,<br>- Readable => True,<br>- Writable => True,<br>- Success => Screen_Mapped);<br>- if not Screen_Mapped then<br>- Debug.Put_Line<br>- ("Failed to map '" & Ada.Command_Line.Argument (1) & "/resource2'.");<br>+ Dev.Map (Res_Addr, PCI.Res2, WC => True);<br>+ if Res_Addr = 0 then<br>+ Debug.Put_Line ("Failed to map PCI resource2.");<br>+ return;<br>+ end if;<br>+ Screen.Set_Base_Address (Res_Addr);<br>+<br>+ Dev.Map (Res_Addr, PCI.Res0);<br>+ if Res_Addr = 0 then<br>+ Debug.Put_Line ("Failed to map PCI resource0.");<br> return;<br> end if;<br> <br> GMA.Initialize<br>- (MMIO_Base => Word64 (To_Integer (MMIO_Dummy'Address)),<br>+ (MMIO_Base => Res_Addr,<br> Clean_State => True,<br> Success => Initialized);<br> <br>@@ -212,4 +191,4 @@<br> end if;<br> end Main;<br> <br>-end GFX_Test;<br>+end HW.GFX.GMA.GFX_Test;<br>diff --git a/gfxtest/hw-gfx-gma-gfx_test.ads b/gfxtest/hw-gfx-gma-gfx_test.ads<br>new file mode 100644<br>index 0000000..71da057<br>--- /dev/null<br>+++ b/gfxtest/hw-gfx-gma-gfx_test.ads<br>@@ -0,0 +1,5 @@<br>+package HW.GFX.GMA.GFX_Test is<br>+<br>+ procedure Main;<br>+<br>+end HW.GFX.GMA.GFX_Test;<br></pre><p>To view, visit <a href="https://review.coreboot.org/20598">change 20598</a>. To unsubscribe, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/20598"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: libgfxinit </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ie8a1251354b4fff57eef8c4bada8b49aa04ef382 </div>
<div style="display:none"> Gerrit-Change-Number: 20598 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Nico Huber <nico.h@gmx.de> </div>