gma: Add Intel i945 (Gen3) graphics init support

Add i945G (desktop) and i945GM (mobile) generation support, modeled
after the existing G45 generation code with hardware-specific
adaptations based on the Linux i915 DRM driver and coreboot.

Key hardware differences from G45 (Gen4):
- GTT on separate PCI BAR3 (not within BAR0)
- Simple 32-bit GTT PTEs (addr[31:12] | valid[0])
- No DSPSURF register (uses DSPADDR/DSPLINOFF instead)
- Gen3 fence registers: 32-bit at split 0x2000/0x3000 addresses
- Different PLL limits (VCO 1400-2800 MHz, 96 MHz refclk)
- SDVO multiplier in DPLL register bits[7:4]
- LVDS restricted to Pipe B (pre-i965 requirement)
- CDClk: fixed 400 MHz (desktop) or GCFGC-based (mobile)
- No HDMI/DP, only VGA, LVDS, and SDVO outputs
- PCI IDs: 0x2772 (I945G), 0x27a2/0x27ae (I945GM)

TESTED with thinkpad x60: LVDS & VGA works with a linear framebuffer.

Change-Id: Ib67b3d0ee5e06df427869dce4db926ba57a80fd8
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-on: https://review.sourcearcade.org/c/libgfxinit/+/476
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: Nico Huber <nico.h@gmx.de>
diff --git a/gfxtest/hw-gfx-gma-gfx_test.adb b/gfxtest/hw-gfx-gma-gfx_test.adb
index 6a10657..716f994 100644
--- a/gfxtest/hw-gfx-gma-gfx_test.adb
+++ b/gfxtest/hw-gfx-gma-gfx_test.adb
@@ -33,11 +33,17 @@
       Valid : Boolean;
    end record;
    GTT_Backup : array (GTT_Range) of GTT_Entry;
+   GTT_Backup_Count : Natural;
 
    procedure Backup_GTT
    is
    begin
-      for Idx in GTT_Range loop
+      GMA.GTT_Entry_Count (GTT_Backup_Count);
+      if GTT_Backup_Count = 0 then
+         Debug.Put_Line ("WARNING: GTT size is 0, skipping GTT backup.");
+         return;
+      end if;
+      for Idx in GTT_Range range 0 .. GTT_Backup_Count - 1 loop
          Read_GTT (GTT_Backup (Idx).Addr, GTT_Backup (Idx).Valid, Idx);
       end loop;
    end Backup_GTT;
@@ -45,7 +51,10 @@
    procedure Restore_GTT
    is
    begin
-      for Idx in GTT_Range loop
+      if GTT_Backup_Count = 0 then
+         return;
+      end if;
+      for Idx in GTT_Range range 0 .. GTT_Backup_Count - 1 loop
          Write_GTT (Idx, GTT_Backup (Idx).Addr, GTT_Backup (Idx).Valid);
       end loop;
    end Restore_GTT;