本文整理汇总了C++中page_lookup函数的典型用法代码示例。如果您正苦于以下问题:C++ page_lookup函数的具体用法?C++ page_lookup怎么用?C++ page_lookup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了page_lookup函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: page_remove
//
// Unmaps the physical page at virtual address 'va'.
// If there is no physical page at that address, silently does nothing.
//
// Details:
// - The ref count on the physical page should decrement.
// - The physical page should be freed if the refcount reaches 0.
// - The pg table entry corresponding to 'va' should be set to 0.
// (if such a PTE exists)
// - The TLB must be invalidated if you remove an entry from
// the page table.
//
// Hint: The TA solution is implemented using page_lookup,
// tlb_invalidate, and page_decref.
//
void
page_remove(pde_t *pgdir, uintptr_t va)
{
pte_t *pte;
Page *pp = page_lookup(pgdir, va, &pte);
if (pp != NULL) {
page_decref(pp);
*pte = *pte & ~0x1;
tlb_invalidate(pgdir, va);
}
}
开发者ID:aaandrewww,项目名称:authcontrol,代码行数:26,代码来源:pmap.c
示例2: sys_page_map
// Map the page of memory at 'srcva' in srcenvid's address space
// at 'dstva' in dstenvid's address space with permission 'perm'.
// Perm has the same restrictions as in sys_page_alloc, except
// that it also must not grant write access to a read-only
// page.
//
// Return 0 on success, < 0 on error. Errors are:
// -E_BAD_ENV if srcenvid and/or dstenvid doesn't currently exist,
// or the caller doesn't have permission to change one of them.
// -E_INVAL if srcva >= UTOP or srcva is not page-aligned,
// or dstva >= UTOP or dstva is not page-aligned.
// -E_INVAL is srcva is not mapped in srcenvid's address space.
// -E_INVAL if perm is inappropriate (see sys_page_alloc).
// -E_INVAL if (perm & PTE_W), but srcva is read-only in srcenvid's
// address space.
// -E_NO_MEM if there's no memory to allocate any necessary page tables.
static int
sys_page_map(envid_t srcenvid, void *srcva,
envid_t dstenvid, void *dstva, int perm)
{
// Hint: This function is a wrapper around page_lookup() and
// page_insert() from kern/pmap.c.
// Again, most of the new code you write should be to check the
// parameters for correctness.
// Use the third argument to page_lookup() to
// check the current permissions on the page.
// LAB 4: Your code here.
struct Env *srcenv;
struct Env *dstenv;
pte_t *pte;
struct Page *pp;
// Env Ids valid and caller has perms to access them
if (envid2env(srcenvid, &srcenv, 1) < 0 ||
envid2env(dstenvid, &dstenv, 1) < 0) {
return -E_BAD_ENV;
}
// VAs below UTOP and page aligned
if ((uintptr_t)srcva >= UTOP || (uintptr_t)srcva % PGSIZE ||
(uintptr_t)dstva >= UTOP || (uintptr_t)dstva % PGSIZE) {
return -E_INVAL;
}
if ((pp = page_lookup(srcenv->env_pgdir, srcva, &pte)) == NULL) {
return -E_INVAL;
}
// PTE_U | PTE_P must be set
if ((perm & PTE_U) == 0 || (perm & PTE_P) == 0) {
return -E_INVAL;
}
// Only U, P, W and AVAIL can be set
if ((perm & ~(PTE_U | PTE_P | PTE_W | PTE_AVAIL)) != 0) {
return -E_INVAL;
}
// Dest page writable but source isn't
if ((perm & PTE_W) && ((*pte & PTE_W) == 0)) {
return -E_INVAL;
}
if (page_insert(dstenv->env_pgdir, pp, dstva, perm) < 0) {
return -E_NO_MEM;
}
return 0;
}
开发者ID:bosswissam,项目名称:djos,代码行数:70,代码来源:syscall.c
示例3: sys_page_map
// Map the page of memory at 'srcva' in srcenvid's address space
// at 'dstva' in dstenvid's address space with permission 'perm'.
// Perm has the same restrictions as in sys_page_alloc, except
// that it also must not grant write access to a read-only
// page.
//
// Return 0 on success, < 0 on error. Errors are:
// -E_BAD_ENV if srcenvid and/or dstenvid doesn't currently exist,
// or the caller doesn't have permission to change one of them.
// -E_INVAL if srcva >= UTOP or srcva is not page-aligned,
// or dstva >= UTOP or dstva is not page-aligned.
// -E_INVAL is srcva is not mapped in srcenvid's address space.
// -E_INVAL if perm is inappropriate (see sys_page_alloc).
// -E_INVAL if (perm & PTE_W), but srcva is read-only in srcenvid's
// address space.
// -E_NO_MEM if there's no memory to allocate any necessary page tables.
static int
sys_page_map(envid_t srcenvid, void *srcva,
envid_t dstenvid, void *dstva, int perm)
{
// Hint: This function is a wrapper around page_lookup() and
// page_insert() from kern/pmap.c.
// Again, most of the new code you write should be to check the
// parameters for correctness.
// Use the third argument to page_lookup() to
// check the current permissions on the page.
// LAB 4: Your code here.
/* lj */
struct Env *senv = NULL, *denv = NULL;
int ret = 0;
struct Page *p = NULL;
pte_t *spte = NULL, *dpte = NULL;
//cprintf("0 0x%x 0x%x 0x%x 0x%x \n",srcenvid, srcva, dstenvid, dstva);
if((ret = envid2env(srcenvid, &senv, 1)) < 0) {
return ret;
}
if((ret = envid2env(dstenvid, &denv, 1)) < 0) {
return ret;
}
else if((size_t)dstva > UTOP || (size_t)srcva > UTOP) {
return -E_INVAL;
}
else if(((size_t)dstva & (PGSIZE-1)) || ((size_t)srcva & (PGSIZE - 1))) {
return -E_INVAL;
}
else if(NULL == (p = page_lookup(senv->env_pgdir, srcva, &spte))) {
return -E_INVAL;
}
else if(0 == (perm & (PTE_U | PTE_P))) {
return -E_INVAL;
}
else if(perm & ~(PTE_U | PTE_P | PTE_W | PTE_AVAIL)) {
return -E_INVAL;
}
else if((perm & PTE_W) && !(*spte & PTE_W)) {
return -E_INVAL;
}
assert(senv);
assert(denv);
assert(*spte & PTE_P);
if((ret = page_insert(denv->env_pgdir, p, dstva, perm)) < 0) {
}
return ret;
//panic("sys_page_map not implemented");
}
开发者ID:dannoy,项目名称:JOS,代码行数:70,代码来源:syscall.c
示例4: value_stack_int
/* this function reads out a value from esp +offset and checks if it is a valid pointer */
int * value_stack_int (void * esp, int offset) {
void * ptr = (void *)(esp + offset);
void * result;
if (is_user_vaddr((int *)ptr) && (int *)ptr != NULL ) {
result = page_lookup((int *)ptr, thread_current());
if (result != NULL) return (int *) ptr;
}
exit_mythread(-1);
return NULL;
}
开发者ID:c22dunbar,项目名称:sven-pintos-code,代码行数:12,代码来源:syscall.c
示例5: page_remove
//
// Unmaps the physical page at virtual address 'va'.
// If there is no physical page at that address, silently does nothing.
//
// Details:
// - The ref count on the physical page should decrement.
// - The physical page should be freed if the refcount reaches 0.
// - The pg table entry corresponding to 'va' should be set to 0.
// (if such a PTE exists)
// - The TLB must be invalidated if you remove an entry from
// the page table.
//
// Hint: The TA solution is implemented using page_lookup,
// tlb_invalidate, and page_decref.
//
void
page_remove(pde_t *pgdir, void *va)
{
// Fill this function in
pte_t *tmppte;
struct PageInfo *tmp = page_lookup(pgdir, va, &tmppte);
if( tmp != NULL && (*tmppte & PTE_P)) {
page_decref(tmp);
*tmppte = 0;
}
tlb_invalidate(pgdir, va);
}
开发者ID:liuxu1005,项目名称:Operating-System-Engineering,代码行数:27,代码来源:pmap.c
示例6: page_remove
//
// Unmaps the physical page at virtual address 'va'.
// If there is no physical page at that address, silently does nothing.
//
// Details:
// - The ref count on the physical page should decrement.
// - The physical page should be freed if the refcount reaches 0.
// - The pg table entry corresponding to 'va' should be set to 0.
// (if such a PTE exists)
// - The TLB must be invalidated if you remove an entry from
// the page table.
//
// Hint: The TA solution is implemented using page_lookup,
// tlb_invalidate, and page_decref.
//
void
page_remove(pde_t *pgdir, void *va)
{
pte_t *pte;
struct Page* pp = page_lookup(pgdir, va, &pte);
if (pp) {
page_decref(pp);
*pte = 0;
tlb_invalidate(pgdir, va);
}
}
开发者ID:bosswissam,项目名称:djos,代码行数:27,代码来源:pmap.c
示例7: page_remove
//
// Unmaps the physical page at virtual address 'va'.
// If there is no physical page at that address, silently does nothing.
//
// Details:
// - The ref count on the physical page should decrement.
// - The physical page should be freed if the refcount reaches 0.
// - The pg table entry corresponding to 'va' should be set to 0.
// (if such a PTE exists)
// - The TLB must be invalidated if you remove an entry from
// the page table.
//
// Hint: The TA solution is implemented using page_lookup,
// tlb_invalidate, and page_decref.
//
void
page_remove(pde_t *pgdir, void *va)
{
// Fill this function in
pte_t * pte_page;
struct Page * page = page_lookup(pgdir, va, &pte_page);
if(page) {
page_decref(page);
(* pte_page) = 0;
tlb_invalidate(pgdir, va);
}
}
开发者ID:taylorr7732,项目名称:os_dev_tcr,代码行数:27,代码来源:pmap.c
示例8: page_remove
//
// Unmaps the physical page at virtual address 'va'.
// If there is no physical page at that address, silently does nothing.
//
// Details:
// - The ref count on the physical page should decrement.
// - The physical page should be freed if the refcount reaches 0.
// - The pg table entry corresponding to 'va' should be set to 0.
// (if such a PTE exists)
// - The TLB must be invalidated if you remove an entry from
// the page table.
//
// Hint: The TA solution is implemented using page_lookup,
// tlb_invalidate, and page_decref.
//
void
page_remove(pde_t *pgdir, void *va)
{
pte_t *table_entry;
struct PageInfo *page = page_lookup(pgdir, va, &table_entry);
if (page) {
// Decrement/free page, reset table entry, and invalidate TLB entry.
page_decref(page);
*table_entry = 0x0;
tlb_invalidate(pgdir, va);
}
}
开发者ID:eshyong,项目名称:MIT-JOS,代码行数:27,代码来源:pmap.c
示例9: page_remove
//
// Unmaps the physical page at virtual address 'va'.
// If there is no physical page at that address, silently does nothing.
//
// Details:
// - The ref count on the physical page should decrement.
// - The physical page should be freed if the refcount reaches 0.
// - The pg table entry corresponding to 'va' should be set to 0.
// (if such a PTE exists)
// - The TLB must be invalidated if you remove an entry from
// the page table.
//
// Hint: The TA solution is implemented using page_lookup,
// tlb_invalidate, and page_decref.
//
void
page_remove(pml4e_t *pml4e, void *va)
{
// Fill this function in
pte_t* pte = NULL;
struct Page *page = page_lookup(pml4e, va, &pte);
if(page != 0){
page_decref(page);
*pte = 0;
tlb_invalidate(pml4e, va);
}
}
开发者ID:ajsbu,项目名称:cse506,代码行数:27,代码来源:pmap.c
示例10: page_remove
//
// Unmaps the physical page at virtual address 'va'.
// If there is no physical page at that address, silently does nothing.
//
// Details:
// - The ref count on the physical page should decrement.
// - The physical page should be freed if the refcount reaches 0.
// - The pg table entry corresponding to 'va' should be set to 0.
// (if such a PTE exists)
// - The TLB must be invalidated if you remove an entry from
// the page table.
//
// Hint: The TA solution is implemented using page_lookup,
// tlb_invalidate, and page_decref.
//
void
page_remove(pde_t *pgdir, void *va)
{
// Fill this function in
pte_t* pte_store = NULL;
struct PageInfo* pg = page_lookup(pgdir, va, &pte_store);
if (!pg)
return;
page_decref(pg);
tlb_invalidate(pgdir, va);
*pte_store = 0;
}
开发者ID:1060351485,项目名称:6.828-JOS,代码行数:27,代码来源:pmap.c
示例11: sys_page_map
// Map the page of memory at 'srcva' in srcenvid's address space
// at 'dstva' in dstenvid's address space with permission 'perm'.
// Perm has the same restrictions as in sys_page_alloc, except
// that it also must not grant write access to a read-only
// page.
//
// Return 0 on success, < 0 on error. Errors are:
// -E_BAD_ENV if srcenvid and/or dstenvid doesn't currently exist,
// or the caller doesn't have permission to change one of them.
// -E_INVAL if srcva >= UTOP or srcva is not page-aligned,
// or dstva >= UTOP or dstva is not page-aligned.
// -E_INVAL is srcva is not mapped in srcenvid's address space.
// -E_INVAL if perm is inappropriate (see sys_page_alloc).
// -E_INVAL if (perm & PTE_W), but srcva is read-only in srcenvid's
// address space.
// -E_NO_MEM if there's no memory to allocate the new page,
// or to allocate any necessary page tables.
static int
sys_page_map(envid_t srcenvid, void *srcva,
envid_t dstenvid, void *dstva, int perm)
{
// Hint: This function is a wrapper around page_lookup() and
// page_insert() from kern/pmap.c.
// Again, most of the new code you write should be to check the
// parameters for correctness.
// Use the third argument to page_lookup() to
// check the current permissions on the page.
// LAB 4: Your code here.
int errno;
pte_t *pte;
struct Page *page;
struct Env *srcEnv, *dstEnv;
if (((uint32_t)srcva >= UTOP) || ((uint32_t)srcva % PGSIZE) ||
((uint32_t)dstva >= UTOP) || ((uint32_t)dstva % PGSIZE)) {
dbg_print("invalid address");
return -E_INVAL;
}
if ((errno = envid2env(srcenvid, &srcEnv, 1)) < 0) {
dbg_print("env %d does not exist", srcenvid);
return errno;
}
if ((errno = envid2env(dstenvid, &dstEnv, 1)) < 0) {
dbg_print("env %d does not exist", dstenvid);
return errno;
}
if (!(perm & PTE_U) || !(perm & PTE_P)) {
dbg_print("invalid perm 0x%08x", perm);
return -E_INVAL;
}
page = page_lookup(srcEnv->env_pgdir, srcva, &pte);
if (!page || ((perm & PTE_W) && !(*pte & PTE_W))) {
dbg_print("invalid page 0x%p, perm=0x%08x, *pte=0x%08x", page, perm, *pte);
return -E_INVAL;
}
if ((errno = page_insert(dstEnv->env_pgdir, page, dstva, perm)) < 0) {
dbg_print("Env %d page_insert error: va=0x%08x");
page_free(page);
return errno;
}
return 0;
//panic("sys_page_map not implemented");
}
开发者ID:cutecheng,项目名称:zcjos,代码行数:70,代码来源:syscall.c
示例12: sys_page_map
static int
sys_page_map(envid_t srcenvid, void *srcva,
envid_t dstenvid, void *dstva, int perm)
{
// Hint: This function is a wrapper around page_lookup() and
// page_insert() from kern/pmap.c.
// Again, most of the new code you write should be to check the
// parameters for correctness.
// Use the third argument to page_lookup() to
// check the current permissions on the page.
// LAB 4: Your code here.
struct Env *srcenv=NULL;
struct Env *destenv=NULL;
struct Page *p=NULL;
if(envid2env(srcenvid,&srcenv,1)<0 || envid2env(dstenvid,&destenv,1)<0)
return -E_BAD_ENV;
if(srcva>= (void *)UTOP || dstva>= (void *)UTOP || ((uint32_t)srcva)%PGSIZE!=0 ||((uint32_t)dstva)%PGSIZE!=0)
return -E_INVAL;
pte_t *srcPageToMap=NULL;
p = page_lookup(srcenv->env_pgdir,srcva,&srcPageToMap);
if(p==NULL)
return -E_INVAL;
else
{
if( (perm & PTE_P)!=0 && (perm & PTE_U)!=0)
{
if((perm & ((~(PTE_USER)) & 0xFFF))!=0)
return -E_INVAL;
}
else
return -E_INVAL;
int srcperm = (*(srcPageToMap) & 0xFFF);
if ((srcperm & PTE_W) == 0)
{
if((perm & PTE_W)!=0)
return -E_INVAL;
}
//else
{
if (page_insert(destenv->env_pgdir,p,dstva,perm)<0)
return -E_NO_MEM;
else return 0;
}
}
return -E_NO_MEM;
}
开发者ID:Insecurity-plan15,项目名称:JOS-Microkernel,代码行数:52,代码来源:syscall.c
示例13: sys_page_map
// Map the page of memory at 'srcva' in srcenvid's address space
// at 'dstva' in dstenvid's address space with permission 'perm'.
// Perm has the same restrictions as in sys_page_alloc, except
// that it also must not grant write access to a read-only
// page.
//
// Return 0 on success, < 0 on error. Errors are:
// -E_BAD_ENV if srcenvid and/or dstenvid doesn't currently exist,
// or the caller doesn't have permission to change one of them.
// -E_INVAL if srcva >= UTOP or srcva is not page-aligned,
// or dstva >= UTOP or dstva is not page-aligned.
// -E_INVAL is srcva is not mapped in srcenvid's address space.
// -E_INVAL if perm is inappropriate (see sys_page_alloc).
// -E_INVAL if (perm & PTE_W), but srcva is read-only in srcenvid's
// address space.
// -E_NO_MEM if there's no memory to allocate any necessary page tables.
static int
sys_page_map(envid_t srcenvid, void *srcva,
envid_t dstenvid, void *dstva, int perm)
{
// Hint: This function is a wrapper around page_lookup() and
// page_insert() from kern/pmap.c.
// Again, most of the new code you write should be to check the
// parameters for correctness.
// Use the third argument to page_lookup() to
// check the current permissions on the page.
// LAB 4: Your code here.
struct Env *env1,*env2;
struct PageInfo *pg;
pte_t *pte;
int ret;
ret = envid2env(srcenvid, &env1, 1);
if(ret < 0){
cprintf("sys page map error in screnvid \n");
return -E_BAD_ENV;
}
ret = envid2env(dstenvid, &env2, 1);
if(ret < 0){
cprintf("sys page map error in dstenvid \n");
return -E_BAD_ENV;
}else if((uint64_t)srcva >= UTOP || ((uint64_t)srcva)%PGSIZE != 0){
cprintf("sys page map error. srcva is > utop or srcva is not alligned \n");
return -E_INVAL;
}else if((uint64_t)dstva >= UTOP || ((uint64_t)dstva)%PGSIZE != 0){
cprintf("sys page map error. dstva is > utop or dstva is not alligned \n");
return -E_INVAL;
}else if(!(perm & PTE_U) && !(perm & PTE_P) && (perm & ~PTE_SYSCALL)){ //now unchanged in the end
cprintf("sys page map error. permission mismatch \n");
return -E_INVAL;
}
if(!(pg = page_lookup(env1->env_pml4e, srcva, &pte))){
cprintf("sys page map error. Page lookup failed for env1 \n");
return -E_INVAL;
}else if(((perm & PTE_W) != 0) && ((*pte & PTE_W) == 0)){
cprintf("sys page map error. Write permission error \n");
return -E_INVAL;
}else if(page_insert(env2->env_pml4e, pg, dstva, perm)){
cprintf("sys page map error. Page insert failed for env2 \n");
page_free(pg);
return -E_NO_MEM;
}
return 0;
// panic("sys_page_map not implemented");
}
开发者ID:deepakkumar-b,项目名称:JOS-Labs_Project,代码行数:68,代码来源:syscall.c
示例14: 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 is not blocked, waiting for an IPC.
//
// The send also can fail for the other reasons listed below.
//
// 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 sys_ipc_recv system call. (Hint: does the
// sys_ipc_recv function ever actually return?)
//
// If the sender wants to send 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, < 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* dstenv;
int ret;
pte_t *pte;
uintptr_t dstva;
if((ret = envid2env(envid, &dstenv, 0)) < 0)
return ret;
if(dstenv->env_ipc_recving == 0)
return -E_IPC_NOT_RECV;
if((uintptr_t)srcva >= UTOP)
return -E_INVAL;
if(PGOFF((uintptr_t)srcva))
return -E_INVAL;
if((uintptr_t)srcva != USTACKTOP) {
if((perm & ~PTE_SYSCALL) || !(perm & PTE_P) || !(perm & PTE_U))
return -E_INVAL;
if((pte = pgdir_walk(curenv->env_pgdir, srcva, 0)) == NULL)
return -E_INVAL;
if((perm & PTE_W) && !(*pte & PTE_W))
return -E_INVAL;
dstva = (uintptr_t)dstenv->env_ipc_dstva;
if(dstva != USTACKTOP) {
/* if((ret = sys_page_map(0, srcva, envid, (void*)dstva, perm)) < 0)
return ret;*/
/* i don't use sys_page_map. because filesystem env is neither current env nor
* the child of current env. sys_page_map require envid is current env or the
* child of current env;
*/
struct Page *page;
if ((page = page_lookup(curenv->env_pgdir, srcva, NULL)) == NULL)
return -E_INVAL;
if (page_insert(dstenv->env_pgdir, page, (void*)dstva, perm) < 0)
return -E_NO_MEM;
dstenv->env_ipc_perm = perm;
} else {
dstenv->env_ipc_perm = 0;
}
} else {
dstenv->env_ipc_perm = 0;
}
dstenv->env_ipc_from = curenv->env_id;
dstenv->env_ipc_value = value;
dstenv->env_tf.tf_regs.reg_eax = 0;
dstenv->env_ipc_recving = 0;
dstenv->env_status = ENV_RUNNABLE;
return 0;
//panic("sys_ipc_try_send not implemented");
}
开发者ID:ldaochen,项目名称:JOS2011,代码行数:90,代码来源:syscall.c
示例15: sys_ipc_try_send
// Try to send 'value' to the target env 'envid'.
// If va != 0, then also send page currently mapped at 'va',
// 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 doesn't happen unless 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_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.
//cprintf("envid in try send:%08x\n",envid);
struct Env *env,dstenv;
int32_t ret;
struct Page *page;
pte_t *pte;
if(envid2env(envid,&env,0) != 0)
return -E_BAD_ENV;
if(env->env_ipc_recving == 0)
return -E_IPC_NOT_RECV;
else
{
//cprintf("try send set ipc:%8x not recv\n",envid);
env->env_ipc_recving = 0;
env->env_ipc_from = curenv->env_id;
env->env_ipc_value = value;
if(srcva == 0 ||env->env_ipc_dstva == 0)
{
env->env_ipc_perm = 0;
if(env->env_status != ENV_RUNNABLE)
{
env->tickets = INIT_TICKET;
global_tickets += env->tickets;
}
env->env_status = ENV_RUNNABLE;
return 0;
}
else if((uint32_t)srcva < UTOP)
{
env->env_ipc_perm = perm;
if((page = page_lookup(curenv->env_pgdir,srcva,&pte)) == NULL)
return -E_INVAL;
if((ret = page_insert(env->env_pgdir, page, env->env_ipc_dstva, perm)) < 0)
return ret;
if(ret == 0)
{
if(env->env_status != ENV_RUNNABLE)
{
env->tickets = INIT_TICKET;
global_tickets += env->tickets;
}
env->env_status = ENV_RUNNABLE;
return 1;
}
}
return 0;
}
}
开发者ID:gzs715,项目名称:JOS,代码行数:86,代码来源:syscall.c
示例16: tlb_invalidate
//
// Invalidate a TLB entry, but only if the page tables being
// edited are the ones currently in use by the processor.
//
void
tlb_invalidate(pde_t *pgdir, void *va)
{
// Flush the entry only if we're modifying the current address space.
// For now, there is only one address space, so always invalidate.
pte_t *tmppte;
struct PageInfo *tmp = page_lookup(pgdir, va, &tmppte);
if( tmp != NULL) {
page_decref(tmp);
*tmppte = 0;
}
invlpg(va);
}
开发者ID:liuxu1005,项目名称:Operating-System-Engineering,代码行数:17,代码来源:pmap.c
示例17: page_remove
//
// Unmaps the physical page at virtual address 'va'.
// If there is no physical page at that address, silently does nothing.
//
// Details:
// - The ref count on the physical page should decrement.
// - The physical page should be freed if the refcount reaches 0.
// - The pg table entry corresponding to 'va' should be set to 0.
// (if such a PTE exists)
// - The TLB must be invalidated if you remove an entry from
// the page table.
//
// Hint: The TA solution is implemented using page_lookup,
// tlb_invalidate, and page_decref.
//
void
page_remove(pde_t *pgdir, void *va)
{
// Fill this function in
//bluesea
struct PageInfo *page = NULL;
pte_t *ptep = NULL;
if ((page = page_lookup(pgdir, va, &ptep)) != NULL){
page_decref(page);
*ptep = *ptep & (0xfff & ~PTE_P);
tlb_invalidate(pgdir, va);
}
}
开发者ID:bluesea147,项目名称:6.828-lab,代码行数:28,代码来源:pmap.c
示例18: sys_clear_block_access_bit
static int sys_clear_block_access_bit(envid_t envid, void *va) {
struct Env *env;
pte_t *pte;
envid2env(envid,&env,1);
if(env == NULL)
return -E_BAD_ENV;
if((uintptr_t)va >= UTOP || PGOFF(va) != 0)
return -E_INVAL;
if(page_lookup(env->env_pgdir, va, &pte) == NULL)
return -E_INVAL;
*pte &= ~ PTE_A;
return 0;
}
开发者ID:Hisham-A,项目名称:JOS,代码行数:13,代码来源:syscall.c
示例19: page_remove
//
// Unmaps the physical page at virtual address 'va'.
// If there is no physical page at that address, silently does nothing.
//
// Details:
// - The ref count on the physical page should decrement.
// - The physical page should be freed if the refcount reaches 0.
// - The pg table entry corresponding to 'va' should be set to 0.
// (if such a PTE exists)
// - The TLB must be invalidated if you remove an entry from
// the page table.
//
// Hint: The TA solution is implemented using page_lookup,
// tlb_invalidate, and page_decref.
//
void
page_remove(pde_t *pgdir, void *va)
{
pte_t* pte;
struct Page* res;
res=page_lookup(pgdir,va,&pte);
if(res!=NULL)
{
page_decref(res);
*pte=0;
tlb_invalidate(pgdir,va);
}
}
开发者ID:yuki252111,项目名称:os,代码行数:28,代码来源:pmap.c
示例20: uva_is_kva
/* Returns true if uva and kva both resolve to the same phys addr. If uva is
* unmapped, it will return FALSE. This is probably what you want, since after
* all uva isn't kva. */
bool uva_is_kva(struct proc *p, void *uva, void *kva)
{
struct page *u_page;
assert(kva); /* catch bugs */
/* Check offsets first */
if (PGOFF(uva) != PGOFF(kva))
return FALSE;
/* Check to see if it is the same physical page */
u_page = page_lookup(p->env_pgdir, uva, 0);
if (!u_page)
return FALSE;
return (kva2page(kva) == u_page) ? TRUE : FALSE;
}
开发者ID:borisnorm,项目名称:akaros,代码行数:16,代码来源:umem.c
注:本文中的page_lookup函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论