2 2005.12 yhlu add linuxbios_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 #if (CONFIG_LB_MEM_TOPK>1024) && (_RAMBASE<0x100000) && ((CONFIG_CONSOLE_VGA==1) || (CONFIG_PCI_ROM_RUN == 1))
59 pgtbl is too big, so use last one 1M before CONFIG_LB_MEM_TOP, otherwise for 8 way dual core with vga support will push stack and heap cross 0xa0000,
60 and that region need to be used as vga font buffer. Please make sure set CONFIG_LB_MEM_TOPK=2048 in MB Config
62 struct pg_table *pgtbl = 0x100000; //1M
64 unsigned x_end = 0x100000 + sizeof(struct pg_table) * CONFIG_MAX_CPUS;
65 #if (0x100000+20480*CONFIG_MAX_CPU) > (CONFIG_LB_MEM_TOPK<<10)
66 #warning "We may need to increase CONFIG_LB_MEM_TOPK, it need to be more than (0x100000+20480*CONFIG_MAX_CPU)\n"
68 if(x_end > (CONFIG_LB_MEM_TOPK<<10)) {
69 printk_debug("map_2M_page: Please increase the CONFIG_LB_MEM_TOPK more than %dK\n", x_end>>10);
73 static struct pg_table pgtbl[CONFIG_MAX_CPUS] __attribute__ ((aligned(4096)));
75 static unsigned long mapped_window[CONFIG_MAX_CPUS];
81 if ((index < 0) || (index >= CONFIG_MAX_CPUS)) {
85 if (window != mapped_window[index]) {
89 /* Point the page directory pointers at the page directories */
90 memset(&pgtbl[index].pdp, 0, sizeof(pgtbl[index].pdp));
92 pdp = pgtbl[index].pdp;
93 pdp[0].addr_lo = ((uint32_t)&pd[512*0])|1;
94 pdp[1].addr_lo = ((uint32_t)&pd[512*1])|1;
95 pdp[2].addr_lo = ((uint32_t)&pd[512*2])|1;
96 pdp[3].addr_lo = ((uint32_t)&pd[512*3])|1;
97 /* The first half of the page table is identity mapped */
98 for(i = 0; i < 1024; i++) {
99 pd[i].addr_lo = ((i & 0x3ff) << 21)| 0xE3;
102 /* The second half of the page table holds the mapped page */
103 for(i = 1024; i < 2048; i++) {
104 pd[i].addr_lo = ((window & 1) << 31) | ((i & 0x3ff) << 21) | 0xE3;
105 pd[i].addr_hi = (window >> 1);
109 mapped_window[index] = window;
112 result = (void *)(page << 21);
114 result = (void *)(0x80000000 | ((page & 0x3ff) << 21));