Angel Pons has uploaded this change for review.

View Change

gma: Use a full `case` statement in Decode_Stolen

Hopefully, this will cause a `missing case` warning when adding support
for a new platform, instead of silently using the wrong functions.

Change-Id: I39f37e931977f4f437b619188436c37752f6b915
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
---
M common/hw-gfx-gma.adb
1 file changed, 13 insertions(+), 14 deletions(-)

git pull ssh://review.coreboot.org:29418/libgfxinit refs/changes/34/44934/1
diff --git a/common/hw-gfx-gma.adb b/common/hw-gfx-gma.adb
index 9157bbe..f36470e 100644
--- a/common/hw-gfx-gma.adb
+++ b/common/hw-gfx-gma.adb
@@ -739,20 +739,19 @@
GGC : Word16;
begin
Dev.Read16 (GGC, GGC_Reg);
- if Config.Gen_G45 or Config.CPU_Ironlake then
- GTT_Size := GTT_Size_Gen4 (GGC);
- Stolen_Size := Stolen_Size_Gen4 (GGC);
- elsif Config.CPU_Sandybridge or Config.CPU_Ivybridge or Config.CPU_Haswell
- then
- GTT_Size := GTT_Size_Gen6 (GGC);
- Stolen_Size := Stolen_Size_Gen6 (GGC);
- elsif Config.CPU_Broadwell then
- GTT_Size := GTT_Size_Gen8 (GGC);
- Stolen_Size := Stolen_Size_Gen8 (GGC);
- else
- GTT_Size := GTT_Size_Gen8 (GGC);
- Stolen_Size := Stolen_Size_Gen9 (GGC);
- end if;
+
+ -- Upcasting is necessary to cover all cases
+ GTT_Size :=
+ (case CPU_Type (Config.CPU) is
+ when G45 .. Ironlake => GTT_Size_Gen4 (GGC),
+ when Sandybridge .. Haswell => GTT_Size_Gen6 (GGC),
+ when Broadwell .. Kabylake => GTT_Size_Gen8 (GGC));
+ Stolen_Size :=
+ (case CPU_Type (Config.CPU) is
+ when G45 .. Ironlake => Stolen_Size_Gen4 (GGC),
+ when Sandybridge .. Haswell => Stolen_Size_Gen6 (GGC),
+ when Broadwell => Stolen_Size_Gen8 (GGC),
+ when Broxton .. Kabylake => Stolen_Size_Gen9 (GGC));
end Decode_Stolen;

-- Additional runtime validation that FB fits stolen memory and aperture.

To view, visit change 44934. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: libgfxinit
Gerrit-Branch: master
Gerrit-Change-Id: I39f37e931977f4f437b619188436c37752f6b915
Gerrit-Change-Number: 44934
Gerrit-PatchSet: 1
Gerrit-Owner: Angel Pons <th3fanbus@gmail.com>
Gerrit-MessageType: newchange