clear low address page table

This commit is contained in:
catfood 2023-11-22 22:07:59 +08:00
parent 4761724dca
commit 3e8bbc07e4
3 changed files with 14 additions and 12 deletions

View File

@ -39,11 +39,12 @@ int kernel_main()
} }
} }
vga_set_disppos(0); vga_set_disppos(0);
clear_kernel_pagepte_low();
kprintf("-----Kernel Initialization Begins-----\n"); kprintf("-----Kernel Initialization Begins-----\n");
kernel_initial = 1; //kernel is in initial state. added by xw, 18/5/31 kernel_initial = 1; //kernel is in initial state. added by xw, 18/5/31
init();//内存管理模块的初始化 add by liang init();//内存管理模块的初始化 add by liang
uart_kprintf("-----mem module init done-----\n");
//initialize PCBs, added by xw, 18/5/26 //initialize PCBs, added by xw, 18/5/26
error = initialize_processes(); error = initialize_processes();
@ -106,13 +107,12 @@ int kernel_main()
*/ */
disable_int(); disable_int();
kprintf("-----Processes Begin-----\n"); uart_kprintf("-----Processes Begin-----\n");
/* linear address 0~8M will no longer be mapped to physical address 0~8M. /* linear address 0~8M will no longer be mapped to physical address 0~8M.
* note that disp_xx can't work after this function is invoked until processes runs. * note that disp_xx can't work after this function is invoked until processes runs.
* add by visual 2016.5.13; moved by xw, 18/5/30 * add by visual 2016.5.13; moved by xw, 18/5/30
*/ */
clear_kernel_pagepte_low();
p_proc_current = proc_table; p_proc_current = proc_table;
kernel_initial = 0; //kernel initialization is done. added by xw, 18/5/31 kernel_initial = 0; //kernel initialization is done. added by xw, 18/5/31

View File

@ -27,7 +27,7 @@ void init() //初始化
u32 memstart = MEMSTART; //4M 开始初始化 u32 memstart = MEMSTART; //4M 开始初始化
u32 i,j; u32 i,j;
memcpy(MemInfo,(u32 *)FMIBuff,1024); //复制内存 memcpy(MemInfo,(u32 *)(K_PHY2LIN(FMIBuff)),1024); //复制内存
memman_init(memman); //初始化memman中frees,maxfrees,lostsize,losts memman_init(memman); //初始化memman中frees,maxfrees,lostsize,losts

View File

@ -107,26 +107,28 @@ void page_fault_handler(u32 vec_no, //异常编号此时应该是14
cr2_count++; cr2_count++;
if (cr2_count == 5) if (cr2_count == 5)
{ {
vga_set_disppos(0);
kprintf("\n"); kprintf("\n");
vga_write_str_color("Page Fault\n", 0x74); vga_write_str_color("Page Fault\n", 0x74);
vga_write_str_color("eip=", 0x74); //灰底红字 vga_write_str_color("eip=", 0x74); //灰底红字
kprintf("%d", eip); kprintf("%x", eip);
vga_write_str_color("eflags=", 0x74); vga_write_str_color("eflags=", 0x74);
kprintf("%d", eflags); kprintf("%x", eflags);
vga_write_str_color("cs=", 0x74); vga_write_str_color("cs=", 0x74);
kprintf("%d", cs); kprintf("%x", cs);
vga_write_str_color("err_code=", 0x74); vga_write_str_color("err_code=", 0x74);
kprintf("%d", err_code); kprintf("%x", err_code);
vga_write_str_color("Cr2=", 0x74); //灰底红字 vga_write_str_color("Cr2=", 0x74); //灰底红字
kprintf("%d", cr2); kprintf("%x", cr2);
vga_write_str_color("Cr3=", 0x74); vga_write_str_color("Cr3=", 0x74);
kprintf("%d", p_proc_current->task.cr3); kprintf("%x", p_proc_current->task.cr3);
//获取页目录中填写的内容 //获取页目录中填写的内容
vga_write_str_color("Pde=", 0x74); vga_write_str_color("Pde=", 0x74);
kprintf("%d", *((u32 *)K_PHY2LIN(pde_addr_phy_temp) + get_pde_index(cr2))); kprintf("%x", *((u32 *)K_PHY2LIN(pde_addr_phy_temp) + get_pde_index(cr2)));
//获取页表中填写的内容 //获取页表中填写的内容
vga_write_str_color("Pte=", 0x74); vga_write_str_color("Pte=", 0x74);
kprintf("%d", *((u32 *)K_PHY2LIN(pte_addr_phy_temp) + get_pte_index(cr2))); kprintf("%x", *((u32 *)K_PHY2LIN(pte_addr_phy_temp) + get_pte_index(cr2)));
asm volatile("cli");
halt(); halt();
} }
} }