]> xenbits.xensource.com Git - seabios.git/commitdiff
Add framebuffer size detection
authorChristian Gmeiner <christian.gmeiner@gmail.com>
Sat, 1 Sep 2012 15:12:56 +0000 (17:12 +0200)
committerKevin O'Connor <kevin@koconnor.net>
Mon, 3 Sep 2012 16:04:56 +0000 (12:04 -0400)
It is possible to read out the framebuffer size via msr. The size
information is needed for VESA later.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
vgasrc/geodevga.c
vgasrc/geodevga.h

index ae606a76e0d614bc5790ffdb3580fa37c3ea254e..636d55bb294c13b21ef3b1b2a17d3fc21daddbe9 100644 (file)
@@ -106,6 +106,30 @@ static int legacyio_check(void)
     return ret;
 }
 
+static u32 framebuffer_size(void)
+{
+    u32 val;
+    union u64_u32_u msr;
+
+    /* We use the P2D_R0 msr to read out the number of pages.
+     * One page has a size of 4k
+     *
+     * Bit      Name    Description
+     * 39:20    PMAX    Physical Memory Address Max
+     * 19:0     PMIX    Physical Memory Address Min
+     *
+     */
+    msr = geode_msrRead(GLIU0_P2D_RO);
+
+    u32 pmax = ((msr.hi & 0xff) << 12) | ((msr.lo & 0xfff00000) >> 20);
+    u32 pmin = (msr.lo & 0x000fffff);
+    
+    val = pmax - pmin;
+    val += 1;
+
+    /* The page size is 4k */
+    return (val << 12);
+}
 
 /****************************************************************
 * Init Functions
@@ -140,6 +164,9 @@ static int dc_setup(void)
 
     geode_memWrite(dc_base + DC_UNLOCK, 0x0, DC_LOCK_LOCK);
 
+    u32 fb_size = framebuffer_size(); // in byte
+    dprintf(1, "%d KB of video memory at 0x%08x\n", fb_size / 1024, fb);
+    
     return 0;
 }
 
index 70980373e6f6511bfcc9c962dc22cd8cc24554f8..14e33d63b2c312853a1d13949646588d0a53a1be 100644 (file)
@@ -26,6 +26,7 @@
 #define MSR_GLIU0                       (1 << 28)
 #define MSR_GLIU0_BASE4                 (MSR_GLIU0 + 0x23)  /* LX */
 #define GLIU0_P2D_BM_4                  (MSR_GLIU0 + 0x24)  /* GX2 */
+#define GLIU0_P2D_RO                   (MSR_GLIU0 + 0x29)
 #define GLIU0_IOD_BM_0                  (MSR_GLIU0 + 0xE0)
 #define GLIU0_IOD_BM_1                  (MSR_GLIU0 + 0xE1)
 #define DC_SPARE                        0x80000011