current->cnt++;
printl(MPL_TEST, "sysc_test cnt %u current %08x cnt %u",
cnt++, current, current->cnt);
+
+ return 0;
}
int sysc_debug(unsigned int v)
{
static unsigned int cnt=0;
-#if 1
- printl(MPL_DEBUG, "task debug syscall %u", cnt++);
-#else
printl(MPL_DEBUG, "task debug syscall %u value %08x", cnt++, v);
-#endif
+ return 0;
}
void init_sysc_handler_table()
void do_no_page(void *addr)
{
- printk("%s addr %08x\n", __func__, (unsigned long)addr);
-#if 1
+ //printk("%s addr %08x current %08x", __func__, (unsigned long)addr, current);
pde_t *page_dir = (pde_t *)current->cr3;
pte_t *page_tbl = 0;
page_tbl[npte] = va2pa(page) | PAGE_P | PAGE_WR | PAGE_US;
load_cr3(current);
-
-#else
- pde_t *pde = (pde_t *)current->cr3;
- pte_t *pte;
- unsigned long page = alloc_one_page(0);
- page = va2pa(page);
- if(page == 0)
- panic("failed alloc page");
-
- int npde = get_npd(addr);
- int npte = get_npt(addr);
-
- if(PAGE_ALIGN(pde[npde]) == 0)
- {
- pte = (pte_t*) alloc_one_page(0);
- memset((void*)pte, 0, PAGE_SIZE);
- if(pte == NULL)
- panic("failed alloc pte");
-
- pte[npte] = (pte_t) page | PAGE_P | PAGE_WR | PAGE_US;
- pde[npde] = va2pa(pte) | PAGE_P | PAGE_WR | PAGE_US;
- }
- else
- {
- pte = (pte_t*)(PAGE_ALIGN(pde[npde]));
- pte = pa2va(pte);
- pte[npte] = (u32) page | PAGE_P | PAGE_WR | PAGE_US;
- }
-#endif
}
void do_wp_page(void *addr)
{
- printk("%s addr %08x\n", __func__, (unsigned long)addr);
+ //printk("%s addr %08x current %08x\n", __func__, (unsigned long)addr, current);
if((unsigned long) addr >= PAGE_OFFSET)
{
panic("%s invalid addr", __func__);
}
-#if 1
+
int npde = get_npd(addr);
int npte = get_npt(addr);
unsigned long wp_pa_addr = PAGE_ALIGN(page_tbl[npte]);
page_t *page = pa2page(wp_pa_addr);
-
+ //printk("page count %u\n", page->count);
if(page->count > 0)
{
page->count --;
#endif
load_cr3(current);
-
-#else
- //printk("%s addr %08x\n", __func__, (unsigned long)addr);
- int npde = get_npd(addr);
- int npte = get_npt(addr);
-
- unsigned long *pd = (u32 *)(current->cr3);
- unsigned long *pt = NULL;
-
- pt = pa2va(PAGE_ALIGN(pd[npde]));
- assert(va2pa(pt) != 0);
-
- unsigned long src, dst;
-
- src = pt[npte];
-
- page_t *page = pa2page(src);
-
- if(page->count > 0)
- {
- unsigned long flags = PAGE_FLAGS(src);
-
- page->count--;
-
- src = (unsigned long) pa2va(PAGE_ALIGN(src));
-
- dst = alloc_one_page(0);
-
- if(0 == dst)
- panic("out of memory");
-
- dst = va2pa(dst);
-
- pt[npte] = dst | flags;
- pt[npte] |= PAGE_WR;
- pd[npde] |= PAGE_WR;
-
- dst = (unsigned long)pa2va(PAGE_ALIGN(dst));
-
- memcpy((void *)dst, (void *)src, PAGE_SIZE);
- }
- else
- {
- pd[npde] |= PAGE_WR;
- pt[npte] |= PAGE_WR;
- //pd[npde] |= PAGE_US;
- //pt[npte] |= PAGE_US;
- }
-
- load_cr3(current);
-#endif
}