sysdebug(0x0A0B0C0D);
}
}
-
+
if(pid > 0)
{
printf("prarent child pid %u\n", pid);
} 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; }
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);
}
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;
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);
void root_task_entry()
{
- kernel_task(init_task_entry);
- kernel_task(init_task_entry);
kernel_task(init_task_entry);
kernel_task(user_task_entry);
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);
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)
{
p->order = order;
}
- page->count = 1;
+ page->count = 0;
return page;
}