]> Zhao Yanbai Git Server - kernel.git/commitdiff
fix bug in put_paging
authorAceVest <zhaoyanbai@126.com>
Mon, 28 Jul 2014 15:24:39 +0000 (23:24 +0800)
committerAceVest <zhaoyanbai@126.com>
Mon, 28 Jul 2014 15:24:39 +0000 (23:24 +0800)
bin/shell.c
include/page.h
kernel/exec.c
kernel/init.c
kernel/innerint.c
mm/buddy.c

index 3640d9ed5ac80c490dc5f5721b91e81a61884a39..9631d97ec7beae8976302b321c37cc43ee5d5c13 100644 (file)
@@ -42,7 +42,7 @@ int main()
             sysdebug(0x0A0B0C0D);
         }
     }
+
     if(pid > 0)
     {
         printf("prarent child pid %u\n", pid);
index 8624991e2401f515d5c85136a5193eeb1d7fe325..96cdec56a04094380e7b8c786ca3e419df0ab55f 100644 (file)
@@ -98,9 +98,11 @@ typedef struct page
 } page_t;
 
 void *page2va(page_t *page);
-page_t *va2page(unsigned long addr);
+page_t *_va2page(unsigned long addr);
+page_t *_pa2page(unsigned long addr);
 
-#define pa2page(addr) va2page((unsigned long)pa2va(PAGE_ALIGN(addr)))
+#define va2page(addr) _va2page(PAGE_ALIGN(addr))
+#define pa2page(addr) _pa2page(PAGE_ALIGN(addr))
 
 static inline page_t *get_head_page(page_t *page) { return page->head_page; }
 
index 04e84de2f47c9fe5f5c5145183e866b59d54839e..d76a35b8578903d5ef6b63e045343d58f34812e6 100644 (file)
@@ -37,7 +37,9 @@ void put_paging(unsigned long vaddr, unsigned long paddr, unsigned long flags)
 
     if(page_table == 0)
     {
-        page_table = (pte_t *) va2pa(alloc_one_page(0));
+        page_table = (pte_t *) alloc_one_page(0);
+        memset(page_table, 0, PAGE_SIZE);
+        page_table = (pte_t *) va2pa(page_table);
         assert(page_table != 0);
     }
 
@@ -110,8 +112,10 @@ int sysc_exec(const char *path, char *const argv[])
 
     load_cr3(current);
 
+    disable_irq();
 
     pt_regs_t *regs = ((pt_regs_t *)(TASK_SIZE+(unsigned long)current)) - 1;
+#if 0
     memset((void*)regs, 0, sizeof(pt_regs_t));
     regs->ss    = SELECTOR_USER_DS;
     regs->ds    = SELECTOR_USER_DS;
@@ -121,6 +125,7 @@ int sysc_exec(const char *path, char *const argv[])
     regs->esp   = (KRNLADDR-4*sizeof(unsigned long));
     regs->eflags= 0x200;
     regs->cs    = SELECTOR_USER_CS;
+#endif
     regs->eip   = (unsigned long)ehdr->e_entry;
     regs->edx   = regs->eip;
     regs->ecx   = (0xC0000000 - 16);
index d84bd196f73bfc52339e6c52de253e88e64bc1f5..391e59256c5b14e76c244ec5a973c296b800daac 100644 (file)
@@ -61,8 +61,6 @@ void kernel_task(void *entry)
 void root_task_entry()
 {
 
-    kernel_task(init_task_entry);
-    kernel_task(init_task_entry);
     kernel_task(init_task_entry);
     kernel_task(user_task_entry);
 
index 77feb174b8b437145d8b350a601941da7db5f5f9..7e064e8d885a0db9b7260852f0a8537a3f52b1d6 100644 (file)
@@ -104,7 +104,7 @@ US RW  P - Description
 
     asm("movl %%cr2,%%eax":"=a"(addr));
 
-    printk("do page fault errcode %x addr %08x [%08x]\n", errcode, addr, current);
+    //printk("do page fault errcode %x addr %08x [%08x]\n", errcode, addr, current);
 
     //assert(errcode != 2 && errcode != 6);
 
index 596666f31c533f97f047d46f6170d166fb059c3a..cf4abe6b844ec3eea513a0e54063e34116228b9b 100644 (file)
@@ -27,15 +27,27 @@ int buddy_is_free(page_t *page, unsigned int order)
     return 0;
 }
 
-page_t *va2page(unsigned long addr)
+page_t *_va2page(unsigned long addr)
 {
     page_t *page = buddy_system.page_map + va2pfn(addr);
 
     assert(page >= buddy_system.page_map);
-    assert(page < buddy_system.page_map_end);
+    //assert(page < buddy_system.page_map_end);
+    if(page >= buddy_system.page_map_end)
+    {
+        printk("buddy_system.page_map %08x buddy_system.page_map_end %08x\n", buddy_system.page_map, buddy_system.page_map_end);
+        printk("error %s page %08x addr %08x\n", __func__, page, addr);
+        panic("error");
+    }
 
     return page;
 }
+page_t *_pa2page(unsigned long paddr)
+{
+    unsigned long vaddr = (unsigned long) pa2va(paddr);
+    printk("%s paddr %08x vaddr %08x\n", __func__, paddr, vaddr);
+    return va2page(vaddr);
+}
 
 void *page2va(page_t *page)
 {
@@ -90,7 +102,7 @@ found:
         p->order = order;
     }
 
-    page->count = 1;
+    page->count = 0;
 
     return page;
 }