本文整理汇总了C++中pte_offset函数的典型用法代码示例。如果您正苦于以下问题:C++ pte_offset函数的具体用法?C++ pte_offset怎么用?C++ pte_offset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pte_offset函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: copy_pte_range
static inline int copy_pte_range(pmd_t *dst_pmd, pmd_t *src_pmd, unsigned long address, unsigned long size, int cow)
{
pte_t * src_pte, * dst_pte;
unsigned long end;
if (pmd_none(*src_pmd))
return 0;
if (pmd_bad(*src_pmd)) {
printk("copy_pte_range: bad pmd (%08lx)\n", pmd_val(*src_pmd));
pmd_clear(src_pmd);
return 0;
}
src_pte = pte_offset(src_pmd, address);
if (pmd_none(*dst_pmd)) {
if (!pte_alloc(dst_pmd, 0))
return -ENOMEM;
}
dst_pte = pte_offset(dst_pmd, address);
address &= ~PMD_MASK;
end = address + size;
if (end >= PMD_SIZE)
end = PMD_SIZE;
do {
/* I would like to switch arguments here, to make it
* consistent with copy_xxx_range and memcpy syntax.
*/
copy_one_pte(src_pte++, dst_pte++, cow);
address += PAGE_SIZE;
} while (address < end);
return 0;
}
开发者ID:shattered,项目名称:linux-m68k,代码行数:31,代码来源:memory.c
示例2: zap_pte_range
static inline void zap_pte_range(pmd_t * pmd, unsigned long address, unsigned long size)
{
pte_t * pte;
if (pmd_none(*pmd))
return;
if (pmd_bad(*pmd)) {
printk("zap_pte_range: bad pmd (%08lx)\n", pmd_val(*pmd));
pmd_clear(pmd);
return;
}
pte = pte_offset(pmd, address);
address &= ~PMD_MASK;
if (address + size > PMD_SIZE)
size = PMD_SIZE - address;
size >>= PAGE_SHIFT;
for (;;) {
pte_t page;
if (!size)
break;
page = *pte;
pte++;
size--;
if (pte_none(page))
continue;
pte_clear(pte-1);
free_pte(page);
}
}
开发者ID:shattered,项目名称:linux-m68k,代码行数:29,代码来源:memory.c
示例3: partial_clear
/*
* This function zeroes out partial mmap'ed pages at truncation time..
*/
static void partial_clear(struct vm_area_struct *vma, unsigned long address)
{
pgd_t *page_dir;
pmd_t *page_middle;
pte_t *page_table, pte;
page_dir = pgd_offset(vma->vm_mm, address);
if (pgd_none(*page_dir))
return;
if (pgd_bad(*page_dir)) {
printk("bad page table directory entry %p:[%lx]\n", page_dir, pgd_val(*page_dir));
pgd_clear(page_dir);
return;
}
page_middle = pmd_offset(page_dir, address);
if (pmd_none(*page_middle))
return;
if (pmd_bad(*page_middle)) {
printk("bad page table directory entry %p:[%lx]\n", page_dir, pgd_val(*page_dir));
pmd_clear(page_middle);
return;
}
page_table = pte_offset(page_middle, address);
pte = *page_table;
if (!pte_present(pte))
return;
flush_cache_page(vma, address);
address &= ~PAGE_MASK;
address += pte_page(pte);
if (address >= high_memory)
return;
memset((void *) address, 0, PAGE_SIZE - (address & ~PAGE_MASK));
flush_page_to_ram(pte_page(pte));
}
开发者ID:shattered,项目名称:linux-m68k,代码行数:37,代码来源:memory.c
示例4: get_phys_addr
static unsigned long get_phys_addr(struct task_struct * p, unsigned long ptr)
{
pgd_t *page_dir;
pmd_t *page_middle;
pte_t pte;
if (!p || !p->mm || ptr >= TASK_SIZE)
return 0;
page_dir = pgd_offset(p->mm,ptr);
if (pgd_none(*page_dir))
return 0;
if (pgd_bad(*page_dir)) {
printk("bad page directory entry %08lx\n", pgd_val(*page_dir));
pgd_clear(page_dir);
return 0;
}
page_middle = pmd_offset(page_dir,ptr);
if (pmd_none(*page_middle))
return 0;
if (pmd_bad(*page_middle)) {
printk("bad page middle entry %08lx\n", pmd_val(*page_middle));
pmd_clear(page_middle);
return 0;
}
pte = *pte_offset(page_middle,ptr);
if (!pte_present(pte))
return 0;
return pte_page(pte) + (ptr & ~PAGE_MASK);
}
开发者ID:liexusong,项目名称:linux2.0-comment,代码行数:29,代码来源:array.c
示例5: remove_mapping_pte_range
static inline void
remove_mapping_pte_range (pmd_t *pmd, unsigned long address, unsigned long size)
{
pte_t *pte;
unsigned long end;
if (pmd_none (*pmd))
return;
if (pmd_bad (*pmd)){
printk ("remove_graphics_pte_range: bad pmd (%08lx)\n", pmd_val (*pmd));
pmd_clear (pmd);
return;
}
pte = pte_offset (pmd, address);
address &= ~PMD_MASK;
end = address + size;
if (end > PMD_SIZE)
end = PMD_SIZE;
do {
pte_t entry = *pte;
if (pte_present (entry))
set_pte (pte, pte_modify (entry, PAGE_NONE));
address += PAGE_SIZE;
pte++;
} while (address < end);
}
开发者ID:dmgerman,项目名称:linux-pre-history,代码行数:27,代码来源:umap.c
示例6: free_pgd_slow
void free_pgd_slow(pgd_t *pgd)
{
pmd_t *pmd;
pte_t *pte;
if (!pgd)
return;
/* pgd is always present and good */
pmd = (pmd_t *)pgd;
if (pmd_none(*pmd))
goto free;
if (pmd_bad(*pmd)) {
pmd_ERROR(*pmd);
pmd_clear(pmd);
goto free;
}
pte = pte_offset(pmd, 0);
pmd_clear(pmd);
pte_free(pte);
pmd_free(pmd);
free:
free_pages((unsigned long) pgd, 2);
}
开发者ID:hugh712,项目名称:Jollen,代码行数:25,代码来源:mm-armv.c
示例7: pgd_offset
/* The pgtable.h claims some functions generically exist, but I
* can't find them......
*/
pte_t *va_to_pte(unsigned long address)
{
pgd_t *dir;
pmd_t *pmd;
pte_t *pte;
struct mm_struct *mm;
if (address < TASK_SIZE)
mm = current->mm;
else
mm = &init_mm;
dir = pgd_offset(mm, address & PAGE_MASK);
if (dir) {
pmd = pmd_offset(dir, address & PAGE_MASK);
if (pmd && pmd_present(*pmd)) {
pte = pte_offset(pmd, address & PAGE_MASK);
if (pte && pte_present(*pte)) {
return(pte);
}
}
else {
return (0);
}
}
else {
return (0);
}
return (0);
}
开发者ID:dmgerman,项目名称:linux-pre-history,代码行数:33,代码来源:fault.c
示例8: pgd_offset_k
/* we parse the page tables in order to find the direct mapping of
the page. This works only without holding any locks for pages we
are sure that they do not move in memory.
*/
volatile void *virt_to_kseg(volatile void *address)
{
pgd_t *pgd; pmd_t *pmd; pte_t *ptep, pte;
unsigned long va, ret = 0UL;
va=VMALLOC_VMADDR((unsigned long)address);
/* get the page directory. Use the kernel memory map. */
pgd = pgd_offset_k(va);
/* check whether we found an entry */
if (!pgd_none(*pgd))
{
/* get the page middle directory */
pmd = pmd_offset(pgd, va);
/* check whether we found an entry */
if (!pmd_none(*pmd))
{
/* get a pointer to the page table entry */
ptep = pte_offset(pmd, va);
pte = *ptep;
/* check for a valid page */
if (pte_present(pte))
{
/* get the address the page is refering to */
ret = (unsigned long)page_address(pte_page(pte));
/* add the offset within the page to the page address */
ret |= (va & (PAGE_SIZE -1));
}
}
}
return((volatile void *)ret);
}
开发者ID:UWMRO,项目名称:ScienceCamera,代码行数:37,代码来源:vm_mmap.c
示例9: sunos_mincore
/* Places into character array, the status of all the pages in the passed
* range from 'addr' to 'addr + len'. -1 on failure, 0 on success...
* The encoding in each character is:
* low-bit is zero == Page is not in physical ram right now
* low-bit is one == Page is currently residing in core
* All other bits are undefined within the character so there...
* Also, if you try to get stats on an area outside of the user vm area
* *or* the passed base address is not aligned on a page boundary you
* get an error.
*/
asmlinkage int sunos_mincore(unsigned long addr, unsigned long len, char *array)
{
pgd_t *pgdp;
pmd_t *pmdp;
pte_t *ptep;
unsigned long limit;
int num_pages, pnum;
if(addr & (PAGE_SIZE - 1))
return -EINVAL;
num_pages = (len / PAGE_SIZE);
if(verify_area(VERIFY_WRITE, array, num_pages))
return -EFAULT; /* bum array, you lose... */
if((addr >= KERNBASE) || ((addr + len) > KERNBASE))
return -ENOMEM; /* I'm sure you're curious about kernel mappings.. */
/* Wheee, go through pte's */
pnum = 0;
for(limit = addr + len; addr < limit; addr += PAGE_SIZE, pnum++) {
pgdp = pgd_offset(current->mm, addr);
if(pgd_none(*pgdp))
return -ENOMEM; /* As per SunOS manpage */
pmdp = pmd_offset(pgdp, addr);
if(pmd_none(*pmdp))
return -ENOMEM; /* As per SunOS manpage */
ptep = pte_offset(pmdp, addr);
if(pte_none(*ptep))
return -ENOMEM; /* As per SunOS manpage */
/* Page in core or Swapped page? */
array[pnum] = pte_present(*ptep) ? 1 : 0;
}
return 0; /* Success... I think... */
}
开发者ID:andreiw,项目名称:mkunity,代码行数:44,代码来源:sys_sunos.c
示例10: unuse_pmd
static inline int unuse_pmd(struct vm_area_struct * vma, pmd_t *dir,
unsigned long address, unsigned long size, unsigned long offset,
unsigned int type, unsigned long page)
{
pte_t * pte;
unsigned long end;
if (pmd_none(*dir))
return 0;
if (pmd_bad(*dir)) {
printk("unuse_pmd: bad pmd (%08lx)\n", pmd_val(*dir));
pmd_clear(dir);
return 0;
}
pte = pte_offset(dir, address);
offset += address & PMD_MASK;
address &= ~PMD_MASK;
end = address + size;
if (end > PMD_SIZE)
end = PMD_SIZE;
do {
if (unuse_pte(vma, offset+address-vma->vm_start, pte, type, page))
return 1;
address += PAGE_SIZE;
pte++;
} while (address < end);
return 0;
}
开发者ID:shattered,项目名称:linux-m68k,代码行数:28,代码来源:swapfile.c
示例11: unswap_pmd
static inline void unswap_pmd(struct vm_area_struct * vma, pmd_t *dir,
unsigned long address, unsigned long size,
unsigned long offset, unsigned long entry,
unsigned long page /* , int isswap */)
{
pte_t * pte;
unsigned long end;
if (pmd_none(*dir))
return;
if (pmd_bad(*dir)) {
printk("unswap_pmd: bad pmd (%08lx)\n", pmd_val(*dir));
pmd_clear(dir);
return;
}
pte = pte_offset(dir, address);
offset += address & PMD_MASK;
address &= ~PMD_MASK;
end = address + size;
if (end > PMD_SIZE)
end = PMD_SIZE;
do {
unswap_pte(vma, offset+address-vma->vm_start, pte, entry,
page /* , isswap */);
address += PAGE_SIZE;
pte++;
} while (address < end);
}
开发者ID:chinnyannieb,项目名称:empeg-hijack,代码行数:28,代码来源:stram.c
示例12: print_8xx_pte
void
print_8xx_pte(struct mm_struct *mm, unsigned long addr)
{
pgd_t * pgd;
pmd_t * pmd;
pte_t * pte;
printk(" pte @ 0x%8lx: ", addr);
pgd = pgd_offset(mm, addr & PAGE_MASK);
if (pgd) {
pmd = pmd_offset(pgd, addr & PAGE_MASK);
if (pmd && pmd_present(*pmd)) {
pte = pte_offset(pmd, addr & PAGE_MASK);
if (pte) {
printk(" (0x%08lx)->(0x%08lx)->0x%08lx\n",
(long)pgd, (long)pte, (long)pte_val(*pte));
#define pp ((long)pte_val(*pte))
printk(" RPN: %05lx PP: %lx SPS: %lx SH: %lx "
"CI: %lx v: %lx\n",
pp>>12, /* rpn */
(pp>>10)&3, /* pp */
(pp>>3)&1, /* small */
(pp>>2)&1, /* shared */
(pp>>1)&1, /* cache inhibit */
pp&1 /* valid */
);
#undef pp
}
else {
printk("no pte\n");
}
}
开发者ID:dmgerman,项目名称:linux-pre-history,代码行数:32,代码来源:fault.c
示例13: swap_out_pmd
static inline int swap_out_pmd(struct mm_struct * mm, struct vm_area_struct * vma, pmd_t *dir, unsigned long address, unsigned long end, int gfp_mask)
{
pte_t * pte;
unsigned long pmd_end;
if (pmd_none(*dir))
return 0;
if (pmd_bad(*dir)) {
pmd_ERROR(*dir);
pmd_clear(dir);
return 0;
}
pte = pte_offset(dir, address);
pmd_end = (address + PMD_SIZE) & PMD_MASK;
if (end > pmd_end)
end = pmd_end;
do {
int result;
mm->swap_address = address + PAGE_SIZE;
result = try_to_swap_out(mm, vma, address, pte, gfp_mask);
if (result)
return result;
if (!mm->swap_cnt)
return 0;
address += PAGE_SIZE;
pte++;
} while (address && (address < end));
return 0;
}
开发者ID:davidbau,项目名称:davej,代码行数:32,代码来源:vmscan.c
示例14: iterate_pte
static inline void iterate_pte(pmd_t * pmd, unsigned long address,
unsigned long size, pte_iterator_t op,
unsigned long arg)
{
pte_t *pte;
unsigned long end;
if (pmd_none(*pmd))
return;
if (pmd_bad(*pmd)) {
pmd_ERROR(*pmd);
pmd_clear(pmd);
return;
}
pte = pte_offset(pmd, address);
address &= ~PMD_MASK;
end = address + size;
if (end > PMD_SIZE)
end = PMD_SIZE;
do {
op(pte, arg);
address += PAGE_SIZE;
pte++;
} while (address < end);
}
开发者ID:nhanh0,项目名称:hah,代码行数:25,代码来源:kmap.c
示例15: vmap_pte_range
/*
* maps a range of vmalloc()ed memory into the requested pages. the old
* mappings are removed.
*/
static inline void
vmap_pte_range (pte_t *pte, unsigned long address, unsigned long size, unsigned long vaddr)
{
unsigned long end;
pgd_t *vdir;
pmd_t *vpmd;
pte_t *vpte;
address &= ~PMD_MASK;
end = address + size;
if (end > PMD_SIZE)
end = PMD_SIZE;
do {
pte_t oldpage = *pte;
struct page * page;
pte_clear(pte);
vdir = pgd_offset_k (vaddr);
vpmd = pmd_offset (vdir, vaddr);
vpte = pte_offset (vpmd, vaddr);
page = pte_page (*vpte);
set_pte(pte, mk_pte(page, PAGE_USERIO));
forget_pte(oldpage);
address += PAGE_SIZE;
vaddr += PAGE_SIZE;
pte++;
} while (address < end);
}
开发者ID:dmgerman,项目名称:linux-pre-history,代码行数:33,代码来源:umap.c
示例16: zap_pte_range
static inline int zap_pte_range(struct mm_struct *mm, pmd_t * pmd, unsigned long address, unsigned long size)
{
pte_t * pte;
int freed;
if (pmd_none(*pmd))
return 0;
if (pmd_bad(*pmd)) {
pmd_ERROR(*pmd);
pmd_clear(pmd);
return 0;
}
pte = pte_offset(pmd, address);
address &= ~PMD_MASK;
if (address + size > PMD_SIZE)
size = PMD_SIZE - address;
size >>= PAGE_SHIFT;
freed = 0;
for (;;) {
pte_t page;
if (!size)
break;
page = ptep_get_and_clear(pte);
pte++;
size--;
if (pte_none(page))
continue;
freed += free_pte(page);
}
return freed;
}
开发者ID:davidbau,项目名称:davej,代码行数:31,代码来源:memory.c
示例17: alloc_pgd_table
pgd_t *get_pgd_slow(struct mm_struct *mm)
{
pgd_t *new_pgd, *init_pgd;
pmd_t *new_pmd, *init_pmd;
pte_t *new_pte, *init_pte;
new_pgd = alloc_pgd_table(GFP_KERNEL);
if (!new_pgd)
goto no_pgd;
/*
* This lock is here just to satisfy pmd_alloc and pte_lock
*/
spin_lock(&mm->page_table_lock);
/*
* On ARM, first page must always be allocated since it contains
* the machine vectors.
*/
new_pmd = pmd_alloc(mm, new_pgd, 0);
if (!new_pmd)
goto no_pmd;
new_pte = pte_alloc(mm, new_pmd, 0);
if (!new_pte)
goto no_pte;
init_pgd = pgd_offset_k(0);
init_pmd = pmd_offset(init_pgd, 0);
init_pte = pte_offset(init_pmd, 0);
set_pte(new_pte, *init_pte);
/*
* most of the page table entries are zeroed
* wne the table is created.
*/
memcpy(new_pgd + USER_PTRS_PER_PGD, init_pgd + USER_PTRS_PER_PGD,
(PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
spin_unlock(&mm->page_table_lock);
/* update MEMC tables */
cpu_memc_update_all(new_pgd);
return new_pgd;
no_pte:
spin_unlock(&mm->page_table_lock);
pmd_free(new_pmd);
free_pgd_slow(new_pgd);
return NULL;
no_pmd:
spin_unlock(&mm->page_table_lock);
free_pgd_slow(new_pgd);
return NULL;
no_pgd:
return NULL;
}
开发者ID:GunioRobot,项目名称:MI424WR_GEN2_Rev_E-F,代码行数:60,代码来源:mm-armo.c
示例18: pgd_offset
static struct page *lookup_page_table(const struct mm_struct *mm,unsigned int address,int clear) {
pgd_t *pgd;
pmd_t *pmd;
pte_t *pte;
struct page *page = NOPAGE_SIGBUS;//default no PAGE
pgd = pgd_offset(mm,address);
if(! pgd_none(*pgd) ) {
/*Go for a PMD lookup */
pmd = pmd_offset(pgd,address);
if( ! pmd_none(*pmd) ) {
pte = pte_offset(pmd,address); //get the Pte entry
if(pte_present(*pte) ) {
page = pte_page(*pte); //get the page from the entry
if(clear && VALID_PAGE(page) && (!PageReserved(page) ) ) {
pte_t x = ptep_get_and_clear(pte); //clear the pte
(void)x;
#ifdef DEBUG_NOT_NOW
printk(KERN_ALERT "Non Contiguous Pages getting cleared off the List(%lx):\n",PAGE_VIRTUAL(page));
#endif
__free_page(page); //free of the page
page = (struct page *) 1;
}
}
}
}
return page;
}
开发者ID:eerpini,项目名称:contig-alloc,代码行数:27,代码来源:contiguous.c
示例19: pgd_index
/**
* kvm_mips_walk_pgd() - Walk page table with optional allocation.
* @pgd: Page directory pointer.
* @addr: Address to index page table using.
* @cache: MMU page cache to allocate new page tables from, or NULL.
*
* Walk the page tables pointed to by @pgd to find the PTE corresponding to the
* address @addr. If page tables don't exist for @addr, they will be created
* from the MMU cache if @cache is not NULL.
*
* Returns: Pointer to pte_t corresponding to @addr.
* NULL if a page table doesn't exist for @addr and [email protected]
* NULL if a page table allocation failed.
*/
static pte_t *kvm_mips_walk_pgd(pgd_t *pgd, struct kvm_mmu_memory_cache *cache,
unsigned long addr)
{
pud_t *pud;
pmd_t *pmd;
pgd += pgd_index(addr);
if (pgd_none(*pgd)) {
/* Not used on MIPS yet */
BUG();
return NULL;
}
pud = pud_offset(pgd, addr);
if (pud_none(*pud)) {
pmd_t *new_pmd;
if (!cache)
return NULL;
new_pmd = mmu_memory_cache_alloc(cache);
pmd_init((unsigned long)new_pmd,
(unsigned long)invalid_pte_table);
pud_populate(NULL, pud, new_pmd);
}
pmd = pmd_offset(pud, addr);
if (pmd_none(*pmd)) {
pte_t *new_pte;
if (!cache)
return NULL;
new_pte = mmu_memory_cache_alloc(cache);
clear_page(new_pte);
pmd_populate_kernel(NULL, pmd, new_pte);
}
return pte_offset(pmd, addr);
}
开发者ID:0x7f454c46,项目名称:linux,代码行数:49,代码来源:mmu.c
示例20: kvm_mips_flush_gpa_pmd
static bool kvm_mips_flush_gpa_pmd(pmd_t *pmd, unsigned long start_gpa,
unsigned long end_gpa)
{
pte_t *pte;
unsigned long end = ~0ul;
int i_min = __pmd_offset(start_gpa);
int i_max = __pmd_offset(end_gpa);
bool safe_to_remove = (i_min == 0 && i_max == PTRS_PER_PMD - 1);
int i;
for (i = i_min; i <= i_max; ++i, start_gpa = 0) {
if (!pmd_present(pmd[i]))
continue;
pte = pte_offset(pmd + i, 0);
if (i == i_max)
end = end_gpa;
if (kvm_mips_flush_gpa_pte(pte, start_gpa, end)) {
pmd_clear(pmd + i);
pte_free_kernel(NULL, pte);
} else {
safe_to_remove = false;
}
}
return safe_to_remove;
}
开发者ID:0x7f454c46,项目名称:linux,代码行数:27,代码来源:mmu.c
注:本文中的pte_offset函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论