[coreboot-gerrit] Change in libgfxinit[master]: gma: Implement automatic CPU detection

Nico Huber (Code Review) gerrit at coreboot.org
Sun Jun 17 17:42:38 CEST 2018


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


Change subject: gma: Implement automatic CPU detection
......................................................................

gma: Implement automatic CPU detection

In dynamic CPU configurations, Config.Detect_CPU() sets the CPU
variables according to the given PCI device id. In static confi-
gurations it does nothing.

Change-Id: I8ce31c867f97c8d6ef99ca096cb45f7719e78a19
Signed-off-by: Nico Huber <nico.h at gmx.de>
---
M common/Makefile.inc
A common/dyncpu/hw-gfx-gma-config.adb
M common/hw-gfx-gma-config.ads.template
M common/hw-gfx-gma.adb
4 files changed, 39 insertions(+), 0 deletions(-)



  git pull ssh://review.coreboot.org:29418/libgfxinit refs/changes/38/27138/1

diff --git a/common/Makefile.inc b/common/Makefile.inc
index 815de90..50834fd 100644
--- a/common/Makefile.inc
+++ b/common/Makefile.inc
@@ -79,6 +79,7 @@
 	    -e's/<\(ilk\|hsw\|skl\)\(...\)\?var>/$(_GEN_CONST_TARGET)/' \
 	    -e's/\(.*: *<cpufunc>.*:=\) *\(.*\);/\1\n     (\2);/' \
 	    -e's/\([^ ]\+\) *: *<cpufunc> \+\([^ ]*\) *:=/function \1 return \2 is/' \
+	    -e's/<cpunull>//' \
 	    $< >$@
 else
 $(hw-gfx-gma-config-ads): $(dir)/hw-gfx-gma-config.ads.template $(cnf)
@@ -92,9 +93,11 @@
 	    -e'/Dyn_CPU\(_Var\)\?/d' \
 	    -e's/<\(gen\|\(ilk\|hsw\|skl\)\(...\)\?\)bool>/constant Boolean/' \
 	    -e's/<\(\(ilk\|hsw\|skl\)\(...\)\?\)var>/constant/' \
+	    -e's/<cpunull>/ is null/' \
 	    $< >$@
 endif
 gfxinit-gen-y += $(hw-gfx-gma-config-ads)
+gfxinit-$(CONFIG_GFX_GMA_DYN_CPU) += dyncpu/hw-gfx-gma-config.adb
 
 ifneq ($(filter G45,$(CONFIG_GFX_GMA_CPU)),)
 subdirs-y += g45
diff --git a/common/dyncpu/hw-gfx-gma-config.adb b/common/dyncpu/hw-gfx-gma-config.adb
new file mode 100644
index 0000000..762ff6f
--- /dev/null
+++ b/common/dyncpu/hw-gfx-gma-config.adb
@@ -0,0 +1,31 @@
+--
+-- Copyright (C) 2018 Nico Huber <nico.h at gmx.de>
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 2 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+-- GNU General Public License for more details.
+--
+
+package body HW.GFX.GMA.Config
+is
+
+   procedure Detect_CPU (Device : Word16) is
+   begin
+      for CPU in Gen_CPU_Type loop
+         for CPU_Var in Gen_CPU_Variant loop
+            if Is_GPU (Device, CPU, CPU_Var) then
+               Config.CPU := CPU;
+               Config.CPU_Var := CPU_Var;
+               exit;
+            end if;
+         end loop;
+      end loop;
+   end Detect_CPU;
+
+end HW.GFX.GMA.Config;
diff --git a/common/hw-gfx-gma-config.ads.template b/common/hw-gfx-gma-config.ads.template
index 0cd1f89..c92f420 100644
--- a/common/hw-gfx-gma-config.ads.template
+++ b/common/hw-gfx-gma-config.ads.template
@@ -363,4 +363,8 @@
    function Compatible_GPU (Device_Id : Word16) return Boolean is
      (Is_GPU (Device_Id, CPU, CPU_Var));
 
+   pragma Warnings (GNATprove, Off, "subprogram ""Detect_CPU"" has no effect",
+                    Reason => "only effective in dynamic cpu config");
+   procedure Detect_CPU (Device : Word16)<cpunull>;
+
 end HW.GFX.GMA.Config;
diff --git a/common/hw-gfx-gma.adb b/common/hw-gfx-gma.adb
index 885072c..19eb42b 100644
--- a/common/hw-gfx-gma.adb
+++ b/common/hw-gfx-gma.adb
@@ -425,6 +425,7 @@
          Dev.Read16 (Vendor, PCI.Vendor_Id);
          Dev.Read16 (Device, PCI.Device_Id);
 
+         Config.Detect_CPU (Device);
          Success := Vendor = 16#8086# and Config.Compatible_GPU (Device);
       end Check_Platform_PCI;
    begin

-- 
To view, visit https://review.coreboot.org/27138
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: I8ce31c867f97c8d6ef99ca096cb45f7719e78a19
Gerrit-Change-Number: 27138
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/20180617/69fbb6ed/attachment-0001.html>


More information about the coreboot-gerrit mailing list