]> Joshua Wise's Git repositories - netwatch.git/commitdiff
paging for fb
authorJoshua Wise <joshua@nyus.joshuawise.com>
Thu, 4 Dec 2008 20:32:01 +0000 (15:32 -0500)
committerJoshua Wise <joshua@nyus.joshuawise.com>
Thu, 4 Dec 2008 20:32:01 +0000 (15:32 -0500)
aseg-paging/pagingstub.c
aseg-paging/smi.c
include/paging.h
video/tnt2.c

index 7d430b92c5e200d1efb2d61d3f3b9510833972fb..678f2ea11d3279a39c996e62984a1bb05ba2da47 100644 (file)
@@ -23,14 +23,26 @@ void ps_switch_stack (void (*call)(), int stack);
         asm volatile("mov %%cr0, %0" : "=r" (_temp__)); \
         _temp__; \
     })
-
-
 #define set_cr3(value) \
     { \
         register unsigned int _temp__ = (value); \
         asm volatile("mov %0, %%cr3" : : "r" (_temp__)); \
      }
+
+#define get_cr4() \
+    ({ \
+        register unsigned int _temp__; \
+        asm volatile("mov %%cr4, %0" : "=r" (_temp__)); \
+        _temp__; \
+    })
+#define set_cr4(value) \
+    { \
+        register unsigned int _temp__ = (value); \
+        asm volatile("mov %0, %%cr4" : : "r" (_temp__)); \
+     }
+
 #define        CR0_PG  0x80000000
+#define CR4_PSE        0x00000010
 
 #define MAP_FLAGS      (PTE_PRESENT | PTE_READ_WRITE)
 
@@ -97,6 +109,15 @@ int addmap(unsigned long vaddr, unsigned long paddr)
        return 0;
 }
 
+int addmap_4m(unsigned long vaddr, unsigned long paddr)
+{
+       /* PDE_PAGE_SIZE = (1 << 7) */
+       ((unsigned long *)p2v((unsigned long)pd))[PDE_FOR(vaddr)] =
+               paddr | PDE_PRESENT | PDE_READ_WRITE | PDE_PAGE_SIZE;
+       
+       return 0;
+}
+
 void *demap(unsigned long client_pd, unsigned long vaddr)
 {
        unsigned long pde = ((unsigned long *)p2v(client_pd))[PDE_FOR(vaddr)];
@@ -158,6 +179,7 @@ void c_entry(void)
                
        /* Enable paging. */
        set_cr3((unsigned long)pd);
+       set_cr4(get_cr4() | CR4_PSE);   /* ITT, we 4MByte page. */ 
        set_cr0(get_cr0() | CR0_PG);
        outb(0x80, 0x03);
        paging_enb = 1;
index e1304f3fcb9604dda3ef60c3571d8c65653d1a40..f2b574fabe4347b3e33ffa9c7bb7b752276e5724 100644 (file)
@@ -46,20 +46,13 @@ void smi_entry(void)
                for (p = 0; ass[p][0] != -1; p++)
                {
                        int x, y;
-                       unsigned long lasta = 0;
-                       unsigned long *lastmap;
                        for (y = 0; y < 8; y++)
                                for (x = 0; x < 8; x++)
                                {
-                                       unsigned long a =
-                                               (unsigned long) fb->fbaddr +
-                                               ((y+ass[p][1]*8) * fb->curmode.xres + ass[p][0]*8 + x) * 4;
-                                       if ((a & ~4095) != (lasta & ~4095))
-                                       {
-                                               lastmap = (unsigned long *)((unsigned long)p2v(a) & ~4095);
-                                               lasta = a;
-                                       }
-                                       lastmap[(a & 4095) / 4] = 0xFF0000FF;
+                                       unsigned long *a =
+                                               (unsigned long*) fb->fbaddr +
+                                               ((y+ass[p][1]*8) * fb->curmode.xres + ass[p][0]*8 + x);
+                                        *a = 0xFF0000FF;
                                }
                }
        }
index 90c44e95513ebdf37f35b5ec0b8a3d852510d36b..0f864d889c85062c5bbf92af91252aaab8aa238d 100644 (file)
@@ -4,6 +4,7 @@
 extern unsigned long v2p(void *virt);
 extern void *p2v(unsigned long phys);
 extern int addmap(unsigned long vaddr, unsigned long paddr);
+extern int addmap_4m(unsigned long vaddr, unsigned long paddr);
 extern void *demap(unsigned long _pd, unsigned long vaddr);
 
 #endif
index 5ab5f0219b25faa43e3f79e032206a0f5a530b6f..32e646a407989ecd17ed35739de95d5f0502d0d4 100644 (file)
@@ -3,6 +3,7 @@
 #include <pci.h>
 #include <output.h>
 #include <fb.h>
+#include <paging.h>
 
 static void tnt2_getvmode(void *priv);
 
@@ -39,14 +40,21 @@ static void tnt2_getvmode(void *priv)
 
 static int tnt2_probe(struct pci_dev *pci, void *data)
 {
+       unsigned int p;
+
        if (pci->bars[1].type != PCI_BAR_MEMORY32)
        {
                output("TNT2 BAR1 is not memory32?");
                return 0;
        }
-       tnt2_fb.fbaddr = (void *)pci->bars[1].addr;
+       
+       /* Map 32M of memory. */
+       for (p = 0; p < 32; p += 4)
+               addmap_4m(0x40000000 + p*1024*1024, pci->bars[1].addr + p*1024*1024);
+       tnt2_fb.fbaddr = (void *)0x40000000;
+       
        fb = &tnt2_fb;
-       outputf("Found TNT2 with FB at %08x", tnt2_fb.fbaddr);
+       outputf("Found TNT2 with FB at %08x, mapped to %08x", pci->bars[1].addr, tnt2_fb.fbaddr);
        return 1;
 }
 
This page took 0.037938 seconds and 4 git commands to generate.