本文整理汇总了C++中page_remove函数的典型用法代码示例。如果您正苦于以下问题:C++ page_remove函数的具体用法?C++ page_remove怎么用?C++ page_remove使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了page_remove函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: env_free
//
// Frees env e and all memory it uses.
//
void
env_free(struct Env *e)
{
pte_t *pt;
uint32_t pdeno, pteno;
physaddr_t pa;
// If freeing the current environment, switch to boot_pgdir
// before freeing the page directory, just in case the page
// gets reused.
if (e == curenv)
lcr3(boot_cr3);
// Note the environment's demise.
cprintf("[%08x] free env %08x\n", curenv ? curenv->env_id : 0, e->env_id);
// Flush all mapped pages in the user portion of the address space
static_assert(UTOP % PTSIZE == 0);
for (pdeno = 0; pdeno < PDX(UTOP); pdeno++) {
// only look at mapped page tables
if (!(e->env_pgdir[pdeno] & PTE_P))
continue;
// find the pa and va of the page table
pa = PTE_ADDR(e->env_pgdir[pdeno]);
pt = (pte_t*) KADDR(pa);
// unmap all PTEs in this page table
for (pteno = 0; pteno <= PTX(~0); pteno++) {
if (pt[pteno] & PTE_P)
page_remove(e->env_pgdir, PGADDR(pdeno, pteno, 0));
}
// free the page table itself
e->env_pgdir[pdeno] = 0;
page_decref(pa2page(pa));
}
// free the page directory
pa = e->env_cr3;
e->env_pgdir = 0;
e->env_cr3 = 0;
page_decref(pa2page(pa));
// return the environment to the free list
e->env_status = ENV_FREE;
LIST_INSERT_HEAD(&env_free_list, e, env_link);
}
开发者ID:sunuslee,项目名称:sunus_jos,代码行数:52,代码来源:env+-sunus.c
示例2: page_insert
int page_insert(pgd_t* pgdir, page_t *pf,viraddr_t va, uint32_t perm)
{
assert(pgdir && pf);
pte_t* pte = _page_walk(pgdir, va,true);
if (!pte) return -ENOMEM;
atomic_inc(&pf->_count);
if (pte_present(*pte)) page_remove(pgdir, va);
pte_val(*pte) = page2phys(pf) | perm | _PAGE_PRESENT;
refresh_tlb(pgdir, va);
return 0;
}
开发者ID:Zhang626,项目名称:miniOS,代码行数:15,代码来源:page.c
示例3: sys_page_alloc
// Allocate a page of memory and map it at 'va' with permission
// 'perm' in the address space of 'envid'.
// The page's contents are set to 0.
// If a page is already mapped at 'va', that page is unmapped as a
// side effect.
//
// perm -- PTE_U | PTE_P must be set, PTE_AVAIL | PTE_W may or may not be set,
// but no other bits may be set.
//
// Return 0 on success, < 0 on error. Errors are:
// -E_BAD_ENV if environment envid doesn't currently exist,
// or the caller doesn't have permission to change envid.
// -E_INVAL if va >= UTOP, or va is not page-aligned.
// -E_INVAL if perm is inappropriate (see above).
// -E_NO_MEM if there's no memory to allocate the new page,
// or to allocate any necessary page tables.
static int
sys_page_alloc(envid_t envid, void *va, int perm)
{
// Hint: This function is a wrapper around page_alloc() and
// page_insert() from kern/pmap.c.
// Most of the new code you write should be to check the
// parameters for correctness.
// If page_insert() fails, remember to free the page you
// allocated!
// LAB 4: Your code here.
struct Env *env;
if(envid2env(envid, &env, 1) == -E_BAD_ENV)
{
//cprintf("bad environment envid in sys page alloc:%08x\n",envid);
return -E_BAD_ENV;
}
else if((uintptr_t)va >= UTOP || (uint32_t)va % PGSIZE)
return -E_INVAL;
else if((perm & PTE_U) && (perm & PTE_P))
{
if(perm & ((~(PTE_U|PTE_P|PTE_W|PTE_AVAIL) & 0xfff)))
return -E_INVAL;
}
if((vpd[PDX(va)] & PTE_P) && (vpt[VPN(va)] & PTE_P))
page_remove(env->env_pgdir,va);
//cprintf("env id:%08x\n",env->env_id);
struct Page * page;
if(page_alloc(&page) == -E_NO_MEM)
return -E_NO_MEM;
//cprintf("page alloc kva:%08x\n",page2kva(page));
// At this time, we use the page table of the kernel
// so we clear the phsical page according to the kernel virtual address
memset(page2kva(page),0x0,PGSIZE);
//cprintf("page insert,env_id:%08x,env_pgdir:%08x,page:%08x,va:%08x\n",
// env->env_id,env->env_pgdir,page,va);
if(page_insert(env -> env_pgdir, page, va, perm) != 0)
{
page_free(page);
return -E_NO_MEM;
}
//cprintf("page insert success\n");
return 0;
//panic("sys_page_alloc not implemented");
}
开发者ID:gzs715,项目名称:JOS,代码行数:64,代码来源:syscall.c
示例4: sys_page_unmap
// Unmap the page of memory at 'va' in the address space of 'envid'.
// If no page is mapped, the function silently succeeds.
//
// Return 0 on success, < 0 on error. Errors are:
// -E_BAD_ENV if environment envid doesn't currently exist,
// or the caller doesn't have permission to change envid.
// -E_INVAL if va >= UTOP, or va is not page-aligned.
static int
sys_page_unmap(envid_t envid, void *va)
{
// Hint: This function is a wrapper around page_remove().
// LAB 4: Your code here.
struct Env *e = NULL;
int res = envid2env(envid, &e, 1);
if (res < 0) return res;
if (((int)va >= UTOP) || ((int)va % PGSIZE != 0)) return -E_INVAL;
page_remove(e->env_pgdir, va);
return 0;
// panic("sys_page_unmap not implemented");
}
开发者ID:Cai41,项目名称:mit-6.828,代码行数:23,代码来源:syscall.c
示例5: page_insert
/**
* @brief Map the physical page 'pp' into the virtual address 'va' in page
* directory 'pgdir'
*
* Map the physical page 'pp' at virtual address 'va'.
* The permissions (the low 12 bits) of the page table
* entry should be set to 'perm|PTE_P'.
*
* Details:
* - If there is already a page mapped at 'va', it is page_remove()d.
* - If necessary, on demand, allocates a page table and inserts it into
* 'pgdir'.
* - page_incref() should be called if the insertion succeeds.
* - The TLB must be invalidated if a page was formerly present at 'va'.
* (this is handled in page_remove)
*
* No support for jumbos here. We will need to be careful when trying to
* insert regular pages into something that was already jumbo. We will
* also need to be careful with our overloading of the PTE_PS and
* PTE_PAT flags...
*
* @param[in] pgdir the page directory to insert the page into
* @param[in] pp a pointr to the page struct representing the
* physical page that should be inserted.
* @param[in] va the virtual address where the page should be
* inserted.
* @param[in] perm the permition bits with which to set up the
* virtual mapping.
*
* @return ESUCCESS on success
* @return -ENOMEM if a page table could not be allocated
* into which the page should be inserted
*
*/
int page_insert(pde_t *pgdir, struct page *page, void *va, int perm)
{
pte_t* pte = pgdir_walk(pgdir, va, 1);
if (!pte)
return -ENOMEM;
/* Two things here: First, we need to up the ref count of the page we want
* to insert in case it is already mapped at va. In that case we don't want
* page_remove to ultimately free it, and then for us to continue as if pp
* wasn't freed. (moral = up the ref asap) */
kref_get(&page->pg_kref, 1);
/* Careful, page remove handles the cases where the page is PAGED_OUT. */
if (!PAGE_UNMAPPED(*pte))
page_remove(pgdir, va);
*pte = PTE(page2ppn(page), PTE_P | perm);
return 0;
}
开发者ID:kstraube,项目名称:hysim,代码行数:50,代码来源:pmap.c
示例6: sys_page_unmap
// Unmap the page of memory at 'va' in the address space of 'envid'.
// If no page is mapped, the function silently succeeds.
//
// Return 0 on success, < 0 on error. Errors are:
// -E_BAD_ENV if environment envid doesn't currently exist,
// or the caller doesn't have permission to change envid.
// -E_INVAL if va >= UTOP, or va is not page-aligned.
static int
sys_page_unmap(envid_t envid, void *va)
{
// Hint: This function is a wrapper around page_remove().
// LAB 4: Your code here.
if (va>=(void*)UTOP || ROUNDDOWN(va,PGSIZE)!=va)
return -E_INVAL;
struct Env *e;
int ret = envid2env(envid, &e, 1);
if (ret) return ret; //bad_env
page_remove(e->env_pgdir, va);
return 0;
panic("sys_page_unmap not implemented");
}
开发者ID:1060351485,项目名称:jos,代码行数:23,代码来源:syscall.c
示例7: sys_mem_unmap
// (if no page is mapped, the function silently succeeds)
//
// Return 0 on success, < 0 on error.
//
// Cannot unmap pages above UTOP.
int sys_mem_unmap(int sysno,u_int envid, u_int va)
{
// Your code here.
int ret;
struct Env *env;
struct Page *ppage;
Pte *ppte;
ret = 0;
if((ret = envid2env(envid, &env, 0))<0)
return ret;
page_remove(env->env_pgdir, va);
return ret;
// panic("sys_mem_unmap not implemented");
}
开发者ID:fmars,项目名称:MIPS_OS_Kernel,代码行数:21,代码来源:syscall_all.c
示例8: sys_page_unmap
// Unmap the page of memory at 'va' in the address space of 'envid'.
// If no page is mapped, the function silently succeeds.
//
// Return 0 on success, < 0 on error. Errors are:
// -E_BAD_ENV if environment envid doesn't currently exist,
// or the caller doesn't have permission to change envid.
// -E_INVAL if va >= UTOP, or va is not page-aligned.
static int
sys_page_unmap(envid_t envid, void *va)
{
// Hint: This function is a wrapper around page_remove().
// LAB 4: Your code here.
struct Env *env;
int r;
if ((r=envid2env(envid,&env,1))<0)
return -E_BAD_ENV;
if ((uint32_t)va>=UTOP || ROUNDUP(va,PGSIZE)!=va)
return -E_INVAL;
page_remove(env->env_pgdir,va);
return 0;
// panic("sys_page_unmap not implemented");
}
开发者ID:binghe2001021,项目名称:joslabs,代码行数:23,代码来源:syscall.c
示例9: sys_ipc_try_send
// Try to send 'value' to the target env 'envid'.
// If srcva < UTOP, then also send page currently mapped at 'srcva',
// so that receiver gets a duplicate mapping of the same page.
//
// The send fails with a return value of -E_IPC_NOT_RECV if the
// target has not requested IPC with sys_ipc_recv.
//
// Otherwise, the send succeeds, and the target's ipc fields are
// updated as follows:
// env_ipc_recving is set to 0 to block future sends;
// env_ipc_from is set to the sending envid;
// env_ipc_value is set to the 'value' parameter;
// env_ipc_perm is set to 'perm' if a page was transferred, 0 otherwise.
// The target environment is marked runnable again, returning 0
// from the paused ipc_recv system call.
//
// If the sender sends a page but the receiver isn't asking for one,
// then no page mapping is transferred, but no error occurs.
// The ipc only happens when no errors occur.
//
// Returns 0 on success where no page mapping occurs,
// 1 on success where a page mapping occurs, and < 0 on error.
// Errors are:
// -E_BAD_ENV if environment envid doesn't currently exist.
// (No need to check permissions.)
// -E_IPC_NOT_RECV if envid is not currently blocked in sys_ipc_recv,
// or another environment managed to send first.
// -E_INVAL if srcva < UTOP but srcva is not page-aligned.
// -E_INVAL if srcva < UTOP and perm is inappropriate
// (see sys_page_alloc).
// -E_INVAL if srcva < UTOP but srcva is not mapped in the caller's
// address space.
// -E_INVAL if (perm & PTE_W), but srcva is read-only in the
// current environment's address space.
// -E_NO_MEM if there's not enough memory to map srcva in envid's
// address space.
static int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, unsigned perm)
{
// LAB 4: Your code here.
struct Env *env;
int err, ret = 0;
pte_t *pte;
struct Page *pp = NULL;
if ((err = envid2env(envid, &env, 0)) < 0)
return err;
if (env->env_ipc_recving == 0)
return -E_IPC_NOT_RECV;
env->env_ipc_perm = 0;
if ((uint32_t)srcva < UTOP && (uint32_t)env->env_ipc_dstva < UTOP) {
if (((perm & (~PTE_USER)) != 0) || ((perm & (PTE_U | PTE_P)) != (PTE_U | PTE_P)))
return -E_INVAL;
pp = page_lookup(curenv->env_pgdir, srcva, &pte);
if ((*pte & PTE_P) == 0 || pp == NULL)
return -E_INVAL;
if (((*pte & PTE_W) == 0) && (perm & PTE_W))
return -E_INVAL;
env->env_ipc_perm = perm;
page_lookup(env->env_pgdir, env->env_ipc_dstva, &pte);
if ((*pte & PTE_P) == 0) {
if ((err = page_insert(env->env_pgdir, pp, env->env_ipc_dstva, perm)) < 0)
return err;
} else {
page_remove(env->env_pgdir, env->env_ipc_dstva);
if ((err = page_insert(env->env_pgdir, pp, env->env_ipc_dstva, perm)) < 0)
return err;
}
ret = 1;
}
env->env_ipc_recving = 0;
env->env_ipc_from = curenv->env_id;
env->env_ipc_value = value;
env->env_status = ENV_RUNNABLE;
return ret;
}
开发者ID:kay21s,项目名称:JOS-Lab,代码行数:83,代码来源:syscall.c
示例10: sys_page_unmap
// Unmap the page of memory at 'va' in the address space of 'envid'.
// If no page is mapped, the function silently succeeds.
//
// Return 0 on success, < 0 on error. Errors are:
// -E_BAD_ENV if environment envid doesn't currently exist,
// or the caller doesn't have permission to change envid.
// -E_INVAL if va >= UTOP, or va is not page-aligned.
static int
sys_page_unmap(envid_t envid, void *va)
{
// Hint: This function is a wrapper around page_remove().
// LAB 4: Your code here.
if(va >= (void *)UTOP || ROUNDUP(va, PGSIZE) != va) {
return -E_INVAL;
}
struct Env *env;
int ret;
if((ret = envid2env(envid, &env, 1)) < 0) {
return -E_INVAL;
}
page_remove(env->env_pgdir, va);
return 0;
}
开发者ID:chapter09,项目名称:CSDI_JOS,代码行数:24,代码来源:syscall.c
示例11: sys_page_unmap
// Unmap the page of memory at 'va' in the address space of 'envid'.
// If no page is mapped, the function silently succeeds.
//
// Return 0 on success, < 0 on error. Errors are:
// -E_BAD_ENV if environment envid doesn't currently exist,
// or the caller doesn't have permission to change envid.
// -E_INVAL if va >= UTOP, or va is not page-aligned.
static int
sys_page_unmap(envid_t envid, void *va)
{
// Hint: This function is a wrapper around page_remove().
// LAB 4: Your code here.
struct Env *task;
if (envid2env(envid, &task, 1) < 0)
return -E_BAD_ENV;
if ((unsigned int)va >= UTOP || va != ROUNDDOWN(va, PGSIZE))
return -E_INVAL;
page_remove(task->env_pgdir, va);
return 0;
}
开发者ID:AlexandrSalin,项目名称:mit-jos,代码行数:24,代码来源:syscall.c
示例12: page_insert
//
// Map the physical page 'pp' at virtual address 'va'.
// The permissions (the low 12 bits) of the page table entry
// should be set to 'perm|PTE_P'.
//
// Requirements
// - If there is already a page mapped at 'va', it should be page_remove()d.
// - If necessary, on demand, a page table should be allocated and inserted
// into 'pgdir'.
// - pp->pp_ref should be incremented if the insertion succeeds.
// - The TLB must be invalidated if a page was formerly present at 'va'.
//
// Corner-case hint: Make sure to consider what happens when the same
// pp is re-inserted at the same virtual address in the same pgdir.
// However, try not to distinguish this case in your code, as this
// frequently leads to subtle bugs; there's an elegant way to handle
// everything in one code path.
//
// RETURNS:
// 0 on success
// -E_NO_MEM, if page table couldn't be allocated
//
// Hint: The TA solution is implemented using pgdir_walk, page_remove,
// and page2pa.
//
int
page_insert(pde_t *pgdir, struct PageInfo *pp, void *va, int perm)
{
// Fill this function in
pte_t *tmp = pgdir_walk(pgdir, va, 1);
if( tmp == NULL )
return -E_NO_MEM;
pp->pp_ref += 1;
if( (*tmp & PTE_P) != 0 )
page_remove(pgdir, va);
*tmp = page2pa(pp) | perm | PTE_P;
pp->pp_link = NULL;
return 0;
}
开发者ID:liuxu1005,项目名称:Operating-System-Engineering,代码行数:42,代码来源:pmap.c
示例13: sys_page_unmap
// Unmap the page of memory at 'va' in the address space of 'envid'.
// If no page is mapped, the function silently succeeds.
//
// Return 0 on success, < 0 on error. Errors are:
// -E_BAD_ENV if environment envid doesn't currently exist,
// or the caller doesn't have permission to change envid.
// -E_INVAL if va >= UTOP, or va is not page-aligned.
static int
sys_page_unmap(envid_t envid, void *va)
{
// Hint: This function is a wrapper around page_remove().
struct Env* envnow;
int r = envid2env(envid, &envnow, 1);
if(r < 0) {
cprintf("\n envid2env error %e sys_page_map\n", r);
return r;
}
if ((uint64_t)va >= UTOP || PGOFF(va))
return -E_INVAL;
page_remove(envnow->env_pml4e, va);
return 0;
// LAB 4: Your code here.
//panic("sys_page_unmap not implemented");
}
开发者ID:scau,项目名称:JOS,代码行数:24,代码来源:syscall.c
示例14: page_insert
//
// Map the physical page 'pp' at virtual address 'va'.
// The permissions (the low 12 bits) of the page table entry
// should be set to 'perm|PTE_P'.
//
// Requirements
// - If there is already a page mapped at 'va', it should be page_remove()d.
// - If necessary, on demand, a page table should be allocated and inserted
// into 'pgdir'.
// - pp->pp_ref should be incremented if the insertion succeeds.
// - The TLB must be invalidated if a page was formerly present at 'va'.
//
// Corner-case hint: Make sure to consider what happens when the same
// pp is re-inserted at the same virtual address in the same pgdir.
// However, try not to distinguish this case in your code, as this
// frequently leads to subtle bugs; there's an elegant way to handle
// everything in one code path.
//
// RETURNS:
// 0 on success
// -E_NO_MEM, if page table couldn't be allocated
//
// Hint: The TA solution is implemented using pgdir_walk, page_remove,
// and page2pa.
//
int
page_insert(pde_t *pgdir, struct PageInfo *pp, void *va, int perm)
{
// Fill this function in
pte_t* pg_entry = pgdir_walk(pgdir, va, 1);
if (!pg_entry) {
return -E_NO_MEM;
}
pp->pp_ref++;
if (*pg_entry & PTE_P){
tlb_invalidate(pgdir, va);
page_remove(pgdir, va);
}
*pg_entry = page2pa(pp) | perm | PTE_P;
pgdir[PDX(va)] |= perm | PTE_P;
return 0;
}
开发者ID:1060351485,项目名称:6.828-JOS,代码行数:42,代码来源:pmap.c
示例15: check_pgfault
// check_pgfault - check correctness of pgfault handler
static void
check_pgfault(void) {
size_t nr_free_pages_store = nr_free_pages();
size_t slab_allocated_store = slab_allocated();
check_mm_struct = mm_create();
assert(check_mm_struct != NULL);
struct mm_struct *mm = check_mm_struct;
pgd_t *pgdir = mm->pgdir = boot_pgdir;
assert(pgdir[0] == 0);
struct vma_struct *vma = vma_create(0, PTSIZE, VM_WRITE);
assert(vma != NULL);
insert_vma_struct(mm, vma);
uintptr_t addr = 0x100;
assert(find_vma(mm, addr) == vma);
int i, sum = 0;
for (i = 0; i < 100; i ++) {
*(char *)(addr + i) = i;
sum += i;
}
for (i = 0; i < 100; i ++) {
sum -= *(char *)(addr + i);
}
assert(sum == 0);
page_remove(pgdir, ROUNDDOWN(addr, PGSIZE));
free_page(pa2page(PMD_ADDR(*get_pmd(pgdir, addr, 0))));
free_page(pa2page(PUD_ADDR(*get_pud(pgdir, addr, 0))));
free_page(pa2page(PGD_ADDR(*get_pgd(pgdir, addr, 0))));
pgdir[0] = 0;
mm->pgdir = NULL;
mm_destroy(mm);
check_mm_struct = NULL;
assert(nr_free_pages_store == nr_free_pages());
assert(slab_allocated_store == slab_allocated());
cprintf("check_pgfault() succeeded!\n");
}
开发者ID:spinlock,项目名称:ucore,代码行数:46,代码来源:vmm.c
示例16: sys_page_unmap
// Unmap the page of memory at 'va' in the address space of 'envid'.
// If no page is mapped, the function silently succeeds.
//
// Return 0 on success, < 0 on error. Errors are:
// -E_BAD_ENV if environment envid doesn't currently exist,
// or the caller doesn't have permission to change envid.
// -E_INVAL if va >= UTOP, or va is not page-aligned.
static int
sys_page_unmap(envid_t envid, void *va)
{
// Hint: This function is a wrapper around page_remove().
// LAB 4: Your code here.
int ret;
struct Env *env;
if((uintptr_t)va >= UTOP)
return -E_INVAL;
if((uintptr_t)va % PGSIZE)
return -E_INVAL;
if((ret = envid2env(envid, &env, 1)) < 0)
return ret;
page_remove(env->env_pgdir, va);
return 0;
// panic("sys_page_unmap not implemented");
}
开发者ID:ldaochen,项目名称:JOS2011,代码行数:25,代码来源:syscall.c
示例17: sys_page_unmap
// Unmap the page of memory at 'va' in the address space of 'envid'.
// If no page is mapped, the function silently succeeds.
//
// Return 0 on success, < 0 on error. Errors are:
// -E_BAD_ENV if environment envid doesn't currently exist,
// or the caller doesn't have permission to change envid.
// -E_INVAL if va >= UTOP, or va is not page-aligned.
static int
sys_page_unmap(envid_t envid, void *va)
{
// Hint: This function is a wrapper around page_remove().
// LAB 4: Your code here.
struct Env *env;
if (envid2env(envid, &env, 1) != 0)
return -E_BAD_ENV;
if ((uint32_t) va >= UTOP || (uint32_t) va % PGSIZE != 0)
return -E_INVAL;
page_remove(env->env_pgdir, va);
return 0;
}
开发者ID:bdmalab,项目名称:6.828,代码行数:25,代码来源:syscall.c
示例18: sys_page_unmap
// Unmap the page of memory at 'va' in the address space of 'envid'.
// If no page is mapped, the function silently succeeds.
//
// Return 0 on success, < 0 on error. Errors are:
// -E_BAD_ENV if environment envid doesn't currently exist,
// or the caller doesn't have permission to change envid.
// -E_INVAL if va >= UTOP, or va is not page-aligned.
static int
sys_page_unmap(envid_t envid, void *va)
{
// Hint: This function is a wrapper around page_remove().
// LAB 4: Your code here.
if (va >= (void *)UTOP || PGOFF(va))
return -E_INVAL;
struct Env *env;
if (envid2env(envid, &env, 1)) {
return -E_BAD_ENV;
}
page_remove(env->env_pgdir, va);
return 0;
// panic("sys_page_unmap not implemented");
}
开发者ID:130B848,项目名称:JOS-labs,代码行数:25,代码来源:syscall.c
示例19: sys_page_unmap
// Unmap the page of memory at 'va' in the address space of 'envid'.
// If no page is mapped, the function silently succeeds.
//
// Return 0 on success, < 0 on error. Errors are:
// -E_BAD_ENV if environment envid doesn't currently exist,
// or the caller doesn't have permission to change envid.
// -E_INVAL if va >= UTOP, or va is not page-aligned.
static int
sys_page_unmap(envid_t envid, void *va)
{
// Hint: This function is a wrapper around page_remove().
// LAB 4: Your code here.
int ret;
struct Env *e;
ret = envid2env(envid, &e, 1);
if (ret < 0) {
return ret;
}
if ((uint32_t)va >= UTOP || (uint32_t)va % PGSIZE != 0) {
return -E_INVAL;
}
page_remove(e->env_pgdir, va);
return 0;
}
开发者ID:macfij,项目名称:macfij_jos,代码行数:25,代码来源:syscall.c
示例20: sys_page_unmap
// Unmap the page of memory at 'va' in the address space of 'envid'.
// If no page is mapped, the function silently succeeds.
//
// Return 0 on success, < 0 on error. Errors are:
// -E_BAD_ENV if environment envid doesn't currently exist,
// or the caller doesn't have permission to change envid.
// -E_INVAL if va >= UTOP, or va is not page-aligned.
static int
sys_page_unmap(envid_t envid, void *va)
{
// Hint: This function is a wrapper around page_remove().
// LAB 4: Your code here.
struct Env *env;
if(envid2env(envid, &env, 1) == -E_BAD_ENV)
return -E_BAD_ENV;
else if((uint32_t)va >= UTOP || (uint32_t)va % PGSIZE)
return -E_INVAL;
else
{
page_remove(env->env_pgdir,va);
return 0;
}
//panic("sys_page_unmap not implemented");
}
开发者ID:gzs715,项目名称:JOS,代码行数:25,代码来源:syscall.c
注:本文中的page_remove函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论