2 2005.12 yhlu add coreboot_ram cross the vga font buffer handling
5 #include <console/console.h>
7 #include <cpu/x86/pae.h>
10 static void paging_off(void)
12 __asm__ __volatile__ (
14 "movl %%cr0, %%eax\n\t"
15 "andl $0x7FFFFFFF, %%eax\n\t"
16 "movl %%eax, %%cr0\n\t"
18 "movl %%cr4, %%eax\n\t"
19 "andl $0xFFFFFFDF, %%eax\n\t"
20 "movl %%eax, %%cr4\n\t"
27 static void paging_on(void *pdp)
30 /* Load the page table address */
33 "movl %%cr4, %%eax\n\t"
34 "orl $0x00000020, %%eax\n\t"
35 "movl %%eax, %%cr4\n\t"
37 "movl %%cr0, %%eax\n\t"
38 "orl $0x80000000, %%eax\n\t"
39 "movl %%eax, %%cr0\n\t"
46 void *map_2M_page(unsigned long page)
51 } __attribute__ ((packed));
55 } __attribute__ ((packed));
57 static struct pg_table pgtbl[CONFIG_MAX_CPUS] __attribute__ ((aligned(4096)));
58 static unsigned long mapped_window[CONFIG_MAX_CPUS];
64 if ((index < 0) || (index >= CONFIG_MAX_CPUS)) {
68 if (window != mapped_window[index]) {
72 /* Point the page directory pointers at the page directories */
73 memset(&pgtbl[index].pdp, 0, sizeof(pgtbl[index].pdp));
75 pdp = pgtbl[index].pdp;
76 pdp[0].addr_lo = ((uint32_t)&pd[512*0])|1;
77 pdp[1].addr_lo = ((uint32_t)&pd[512*1])|1;
78 pdp[2].addr_lo = ((uint32_t)&pd[512*2])|1;
79 pdp[3].addr_lo = ((uint32_t)&pd[512*3])|1;
80 /* The first half of the page table is identity mapped */
81 for(i = 0; i < 1024; i++) {
82 pd[i].addr_lo = ((i & 0x3ff) << 21)| 0xE3;
85 /* The second half of the page table holds the mapped page */
86 for(i = 1024; i < 2048; i++) {
87 pd[i].addr_lo = ((window & 1) << 31) | ((i & 0x3ff) << 21) | 0xE3;
88 pd[i].addr_hi = (window >> 1);
92 mapped_window[index] = window;
95 result = (void *)(page << 21);
97 result = (void *)(0x80000000 | ((page & 0x3ff) << 21));