[SeaBIOS] [PATCH v3 1/3] atiext: Implement ATI tables in atiext.c

Chad Jablonski posted 3 patches 1 month, 2 weeks ago
[SeaBIOS] [PATCH v3 1/3] atiext: Implement ATI tables in atiext.c
Posted by Chad Jablonski 1 month, 2 weeks ago
From: Kevin O'Connor <kevin@koconnor.net>

Move the definitions in ati-tables.S to atiext.c .

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Signed-off-by: Chad Jablonski <chad@jablonski.xyz>
---
 vgasrc/ati-tables.S | 43 --------------------------------
 vgasrc/atiext.c     | 61 +++++++++++++++++++++++++++++++++++++++++++++
 vgasrc/vgaentry.S   |  6 ++++-
 3 files changed, 66 insertions(+), 44 deletions(-)
 delete mode 100644 vgasrc/ati-tables.S

diff --git a/vgasrc/ati-tables.S b/vgasrc/ati-tables.S
deleted file mode 100644
index cdbde2fa..00000000
--- a/vgasrc/ati-tables.S
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// Fake ati bios tables.
-//
-// aty128fb and radeonfb try to gather informations from these tables,
-// so add some stuff here to make the drivers happy.  Specifically
-// radeonfb needs the pll information, otherwise it'll crash with a
-// division by zero ...
-//
-	.org 0x48
-	.word _ati_main
-
-	// main info
-	.org 0x50
-_ati_main:
-	.org 0x50 + 0x30
-	.word _ati_pll
-	.org 0x50 + 0x50
-	.word _ati_connector
-
-	// pll info
-	.org 0x100
-_ati_pll:
-	.word	0		// ??? (not used by radeonfb)
-	.word	0
-	.word	0
-	.word	0
-	.word	23000		// sclk
-	.word	23000		// mclk
-	.word	0
-	.word	2700		// ref_clk
-	.word	4		// ref_div
-	.long	12000		// ppll_min
-	.long	35000		// ppll_max
-
-	// connector info
-	.org 0x140
-_ati_connector:
-	.byte 0x10		// one chip
-	.byte 0x01		// one connector
-	.word 0x3000		// type DVI-I
-	.word 0			// end of list
-
-	.org 0x200
diff --git a/vgasrc/atiext.c b/vgasrc/atiext.c
index 69dfd46e..f003eea8 100644
--- a/vgasrc/atiext.c
+++ b/vgasrc/atiext.c
@@ -338,6 +338,65 @@ static void ati_i2c_edid_rage128(void)
     dprintf(1, "ati: ... %s\n", valid ? "good" : "invalid");
 }
 
+/****************************************************************
+ * Fake ati bios tables
+ ****************************************************************/
+
+// aty128fb and radeonfb try to gather informations from these tables,
+// so add some stuff here to make the drivers happy.  Specifically
+// radeonfb needs the pll information, otherwise it'll crash with a
+// division by zero ...
+struct ati_main_table_s {
+    u8 pad_0[48];
+    u16 pll_table;
+    u8 pad_50[30];
+    u16 connector_table;
+    u8 pad_82[94];
+} PACKED;
+
+struct ati_pll_table_s {
+    u8 pad_0[8];
+    u16 sclk;
+    u16 mclk;
+    u8 pad_12[2];
+    u16 ref_clk;
+    u16 ref_div;
+    u32 ppll_min;
+    u32 ppll_max;
+    u8 pad_26[38];
+} PACKED;
+
+struct ati_connector_table_s {
+    u8 num_chip;
+    u8 num_connector;
+    u16 flags;
+    u16 next;
+} PACKED;
+
+extern u16 _rom_header_ati_table_anchor;
+static struct ati_main_table_s ati_main_table VAR16 __aligned(16);
+static struct ati_pll_table_s ati_pll_table VAR16 __aligned(16) = {
+    .sclk = 23000,
+    .mclk = 23000,
+    .ref_clk = 2700,
+    .ref_div = 4,
+    .ppll_min = 12000,
+    .ppll_max = 35000,
+};
+static struct ati_connector_table_s ati_connector_table VAR16 __aligned(16) = {
+    .num_chip = 0x10,
+    .num_connector = 1,
+    .flags = 0x3000,
+};
+
+static void
+ati_table_setup(void)
+{
+    SET_VGA(ati_main_table.pll_table, (u32)&ati_pll_table);
+    SET_VGA(ati_main_table.connector_table, (u32)&ati_connector_table);
+    SET_VGA(_rom_header_ati_table_anchor, (u32)&ati_main_table);
+}
+
 /****************************************************************
  * init
  ****************************************************************/
@@ -379,6 +438,8 @@ ati_setup(void)
     SET_VGA(VBE_total_memory, totalmem);
     SET_VGA(ati_io_addr, io_addr);
 
+    ati_table_setup();
+
     // Validate modes
     struct generic_svga_mode *m = svga_modes;
     unsigned int mcount = GET_GLOBAL(svga_mcount);
diff --git a/vgasrc/vgaentry.S b/vgasrc/vgaentry.S
index f9624fce..14e557a1 100644
--- a/vgasrc/vgaentry.S
+++ b/vgasrc/vgaentry.S
@@ -41,7 +41,11 @@ _rom_header_signature:
         .asciz "IBM"
 
 #if CONFIG_VGA_ATI
-#include "ati-tables.S"
+	.org 0x48
+        .global _rom_header_ati_table_anchor
+_rom_header_ati_table_anchor:
+	.word 0
+        .align 16
 #endif
 
 /****************************************************************
-- 
2.54.0

_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org