From: Jacob Potter Date: Thu, 4 Dec 2008 20:35:10 +0000 (-0500) Subject: fixed merge X-Git-Url: http://git.joshuawise.com/netwatch.git/commitdiff_plain/15521f07dc09a276839c46168201d31ee1ae4a97?hp=8ceb05150562e3b953f4846d0b82ca2026cf4560 fixed merge --- diff --git a/aseg-paging/pagingstub.c b/aseg-paging/pagingstub.c index 7d430b9..678f2ea 100644 --- a/aseg-paging/pagingstub.c +++ b/aseg-paging/pagingstub.c @@ -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; diff --git a/aseg-paging/smi.c b/aseg-paging/smi.c index bc0960f..f2b574f 100644 --- a/aseg-paging/smi.c +++ b/aseg-paging/smi.c @@ -34,7 +34,6 @@ void smi_entry(void) /* wee! */ if (fb && !fb->curmode.text) { - output("not text! nope nope nope"); int ass[][2] = { {1,0}, {4,0},{5,0},{6,0}, {8,0},{9,0},{10,0}, {0,1}, {2,1}, {4,1}, {8,1}, @@ -50,10 +49,10 @@ void smi_entry(void) 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; - *(unsigned long *)p2v(a) = 0xFF0000FF; + unsigned long *a = + (unsigned long*) fb->fbaddr + + ((y+ass[p][1]*8) * fb->curmode.xres + ass[p][0]*8 + x); + *a = 0xFF0000FF; } } } diff --git a/grubload/multiboot_c.c b/grubload/multiboot_c.c index 372363c..5e30dde 100644 --- a/grubload/multiboot_c.c +++ b/grubload/multiboot_c.c @@ -61,9 +61,9 @@ void c_start(unsigned int magic, struct mb_info *mbinfo) pci_write16(0, 31, 2, 0xC0, 0); pci_write16(0, 31, 4, 0xC0, pci_read16(0, 31, 4, 0xC0)); pci_write16(0, 31, 4, 0xC0, 0); - +/* pci_bus_enum(); - +*/ /* Open the SMRAM aperture and load our ELF. */ old_smramc = smram_save_state(); diff --git a/include/paging.h b/include/paging.h index 90c44e9..0f864d8 100644 --- a/include/paging.h +++ b/include/paging.h @@ -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 diff --git a/video/tnt2.c b/video/tnt2.c index 5ab5f02..32e646a 100644 --- a/video/tnt2.c +++ b/video/tnt2.c @@ -3,6 +3,7 @@ #include #include #include +#include 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; }