ia64/xen-unstable

changeset 9499:aab421b5ad45

[IA64] dom0 vp model linux part: import page.h from linux-2.6.16-rc3

[note: verified same as linux-2.6.16]

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author awilliam@xenbuild.aw
date Fri Apr 07 14:01:13 2006 -0600 (2006-04-07)
parents c160c05da8d4
children e311941eb7be
files linux-2.6-xen-sparse/include/asm-ia64/page.h
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/linux-2.6-xen-sparse/include/asm-ia64/page.h	Fri Apr 07 14:01:13 2006 -0600
     1.3 @@ -0,0 +1,222 @@
     1.4 +#ifndef _ASM_IA64_PAGE_H
     1.5 +#define _ASM_IA64_PAGE_H
     1.6 +/*
     1.7 + * Pagetable related stuff.
     1.8 + *
     1.9 + * Copyright (C) 1998, 1999, 2002 Hewlett-Packard Co
    1.10 + *	David Mosberger-Tang <davidm@hpl.hp.com>
    1.11 + */
    1.12 +
    1.13 +#include <linux/config.h>
    1.14 +
    1.15 +#include <asm/intrinsics.h>
    1.16 +#include <asm/types.h>
    1.17 +
    1.18 +/*
    1.19 + * The top three bits of an IA64 address are its Region Number.
    1.20 + * Different regions are assigned to different purposes.
    1.21 + */
    1.22 +#define RGN_SHIFT	(61)
    1.23 +#define RGN_BASE(r)	(__IA64_UL_CONST(r)<<RGN_SHIFT)
    1.24 +#define RGN_BITS	(RGN_BASE(-1))
    1.25 +
    1.26 +#define RGN_KERNEL	7	/* Identity mapped region */
    1.27 +#define RGN_UNCACHED    6	/* Identity mapped I/O region */
    1.28 +#define RGN_GATE	5	/* Gate page, Kernel text, etc */
    1.29 +#define RGN_HPAGE	4	/* For Huge TLB pages */
    1.30 +
    1.31 +/*
    1.32 + * PAGE_SHIFT determines the actual kernel page size.
    1.33 + */
    1.34 +#if defined(CONFIG_IA64_PAGE_SIZE_4KB)
    1.35 +# define PAGE_SHIFT	12
    1.36 +#elif defined(CONFIG_IA64_PAGE_SIZE_8KB)
    1.37 +# define PAGE_SHIFT	13
    1.38 +#elif defined(CONFIG_IA64_PAGE_SIZE_16KB)
    1.39 +# define PAGE_SHIFT	14
    1.40 +#elif defined(CONFIG_IA64_PAGE_SIZE_64KB)
    1.41 +# define PAGE_SHIFT	16
    1.42 +#else
    1.43 +# error Unsupported page size!
    1.44 +#endif
    1.45 +
    1.46 +#define PAGE_SIZE		(__IA64_UL_CONST(1) << PAGE_SHIFT)
    1.47 +#define PAGE_MASK		(~(PAGE_SIZE - 1))
    1.48 +#define PAGE_ALIGN(addr)	(((addr) + PAGE_SIZE - 1) & PAGE_MASK)
    1.49 +
    1.50 +#define PERCPU_PAGE_SHIFT	16	/* log2() of max. size of per-CPU area */
    1.51 +#define PERCPU_PAGE_SIZE	(__IA64_UL_CONST(1) << PERCPU_PAGE_SHIFT)
    1.52 +
    1.53 +
    1.54 +#ifdef CONFIG_HUGETLB_PAGE
    1.55 +# define HPAGE_REGION_BASE	RGN_BASE(RGN_HPAGE)
    1.56 +# define HPAGE_SHIFT		hpage_shift
    1.57 +# define HPAGE_SHIFT_DEFAULT	28	/* check ia64 SDM for architecture supported size */
    1.58 +# define HPAGE_SIZE		(__IA64_UL_CONST(1) << HPAGE_SHIFT)
    1.59 +# define HPAGE_MASK		(~(HPAGE_SIZE - 1))
    1.60 +
    1.61 +# define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
    1.62 +# define ARCH_HAS_HUGEPAGE_ONLY_RANGE
    1.63 +#endif /* CONFIG_HUGETLB_PAGE */
    1.64 +
    1.65 +#ifdef __ASSEMBLY__
    1.66 +# define __pa(x)		((x) - PAGE_OFFSET)
    1.67 +# define __va(x)		((x) + PAGE_OFFSET)
    1.68 +#else /* !__ASSEMBLY */
    1.69 +# ifdef __KERNEL__
    1.70 +#  define STRICT_MM_TYPECHECKS
    1.71 +
    1.72 +extern void clear_page (void *page);
    1.73 +extern void copy_page (void *to, void *from);
    1.74 +
    1.75 +/*
    1.76 + * clear_user_page() and copy_user_page() can't be inline functions because
    1.77 + * flush_dcache_page() can't be defined until later...
    1.78 + */
    1.79 +#define clear_user_page(addr, vaddr, page)	\
    1.80 +do {						\
    1.81 +	clear_page(addr);			\
    1.82 +	flush_dcache_page(page);		\
    1.83 +} while (0)
    1.84 +
    1.85 +#define copy_user_page(to, from, vaddr, page)	\
    1.86 +do {						\
    1.87 +	copy_page((to), (from));		\
    1.88 +	flush_dcache_page(page);		\
    1.89 +} while (0)
    1.90 +
    1.91 +
    1.92 +#define alloc_zeroed_user_highpage(vma, vaddr) \
    1.93 +({						\
    1.94 +	struct page *page = alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO, vma, vaddr); \
    1.95 +	if (page)				\
    1.96 + 		flush_dcache_page(page);	\
    1.97 +	page;					\
    1.98 +})
    1.99 +
   1.100 +#define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
   1.101 +
   1.102 +#define virt_addr_valid(kaddr)	pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
   1.103 +
   1.104 +#ifdef CONFIG_VIRTUAL_MEM_MAP
   1.105 +extern int ia64_pfn_valid (unsigned long pfn);
   1.106 +#elif defined(CONFIG_FLATMEM)
   1.107 +# define ia64_pfn_valid(pfn) 1
   1.108 +#endif
   1.109 +
   1.110 +#ifdef CONFIG_FLATMEM
   1.111 +# define pfn_valid(pfn)		(((pfn) < max_mapnr) && ia64_pfn_valid(pfn))
   1.112 +# define page_to_pfn(page)	((unsigned long) (page - mem_map))
   1.113 +# define pfn_to_page(pfn)	(mem_map + (pfn))
   1.114 +#elif defined(CONFIG_DISCONTIGMEM)
   1.115 +extern struct page *vmem_map;
   1.116 +extern unsigned long min_low_pfn;
   1.117 +extern unsigned long max_low_pfn;
   1.118 +# define pfn_valid(pfn)		(((pfn) >= min_low_pfn) && ((pfn) < max_low_pfn) && ia64_pfn_valid(pfn))
   1.119 +# define page_to_pfn(page)	((unsigned long) (page - vmem_map))
   1.120 +# define pfn_to_page(pfn)	(vmem_map + (pfn))
   1.121 +#endif
   1.122 +
   1.123 +#define page_to_phys(page)	(page_to_pfn(page) << PAGE_SHIFT)
   1.124 +#define virt_to_page(kaddr)	pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
   1.125 +#define pfn_to_kaddr(pfn)	__va((pfn) << PAGE_SHIFT)
   1.126 +
   1.127 +typedef union ia64_va {
   1.128 +	struct {
   1.129 +		unsigned long off : 61;		/* intra-region offset */
   1.130 +		unsigned long reg :  3;		/* region number */
   1.131 +	} f;
   1.132 +	unsigned long l;
   1.133 +	void *p;
   1.134 +} ia64_va;
   1.135 +
   1.136 +/*
   1.137 + * Note: These macros depend on the fact that PAGE_OFFSET has all
   1.138 + * region bits set to 1 and all other bits set to zero.  They are
   1.139 + * expressed in this way to ensure they result in a single "dep"
   1.140 + * instruction.
   1.141 + */
   1.142 +#define __pa(x)		({ia64_va _v; _v.l = (long) (x); _v.f.reg = 0; _v.l;})
   1.143 +#define __va(x)		({ia64_va _v; _v.l = (long) (x); _v.f.reg = -1; _v.p;})
   1.144 +
   1.145 +#define REGION_NUMBER(x)	({ia64_va _v; _v.l = (long) (x); _v.f.reg;})
   1.146 +#define REGION_OFFSET(x)	({ia64_va _v; _v.l = (long) (x); _v.f.off;})
   1.147 +
   1.148 +#ifdef CONFIG_HUGETLB_PAGE
   1.149 +# define htlbpage_to_page(x)	(((unsigned long) REGION_NUMBER(x) << 61)			\
   1.150 +				 | (REGION_OFFSET(x) >> (HPAGE_SHIFT-PAGE_SHIFT)))
   1.151 +# define HUGETLB_PAGE_ORDER	(HPAGE_SHIFT - PAGE_SHIFT)
   1.152 +# define is_hugepage_only_range(mm, addr, len)		\
   1.153 +	 (REGION_NUMBER(addr) == RGN_HPAGE &&	\
   1.154 +	  REGION_NUMBER((addr)+(len)-1) == RGN_HPAGE)
   1.155 +extern unsigned int hpage_shift;
   1.156 +#endif
   1.157 +
   1.158 +static __inline__ int
   1.159 +get_order (unsigned long size)
   1.160 +{
   1.161 +	long double d = size - 1;
   1.162 +	long order;
   1.163 +
   1.164 +	order = ia64_getf_exp(d);
   1.165 +	order = order - PAGE_SHIFT - 0xffff + 1;
   1.166 +	if (order < 0)
   1.167 +		order = 0;
   1.168 +	return order;
   1.169 +}
   1.170 +
   1.171 +# endif /* __KERNEL__ */
   1.172 +#endif /* !__ASSEMBLY__ */
   1.173 +
   1.174 +#ifdef STRICT_MM_TYPECHECKS
   1.175 +  /*
   1.176 +   * These are used to make use of C type-checking..
   1.177 +   */
   1.178 +  typedef struct { unsigned long pte; } pte_t;
   1.179 +  typedef struct { unsigned long pmd; } pmd_t;
   1.180 +#ifdef CONFIG_PGTABLE_4
   1.181 +  typedef struct { unsigned long pud; } pud_t;
   1.182 +#endif
   1.183 +  typedef struct { unsigned long pgd; } pgd_t;
   1.184 +  typedef struct { unsigned long pgprot; } pgprot_t;
   1.185 +
   1.186 +# define pte_val(x)	((x).pte)
   1.187 +# define pmd_val(x)	((x).pmd)
   1.188 +#ifdef CONFIG_PGTABLE_4
   1.189 +# define pud_val(x)	((x).pud)
   1.190 +#endif
   1.191 +# define pgd_val(x)	((x).pgd)
   1.192 +# define pgprot_val(x)	((x).pgprot)
   1.193 +
   1.194 +# define __pte(x)	((pte_t) { (x) } )
   1.195 +# define __pgprot(x)	((pgprot_t) { (x) } )
   1.196 +
   1.197 +#else /* !STRICT_MM_TYPECHECKS */
   1.198 +  /*
   1.199 +   * .. while these make it easier on the compiler
   1.200 +   */
   1.201 +# ifndef __ASSEMBLY__
   1.202 +    typedef unsigned long pte_t;
   1.203 +    typedef unsigned long pmd_t;
   1.204 +    typedef unsigned long pgd_t;
   1.205 +    typedef unsigned long pgprot_t;
   1.206 +# endif
   1.207 +
   1.208 +# define pte_val(x)	(x)
   1.209 +# define pmd_val(x)	(x)
   1.210 +# define pgd_val(x)	(x)
   1.211 +# define pgprot_val(x)	(x)
   1.212 +
   1.213 +# define __pte(x)	(x)
   1.214 +# define __pgd(x)	(x)
   1.215 +# define __pgprot(x)	(x)
   1.216 +#endif /* !STRICT_MM_TYPECHECKS */
   1.217 +
   1.218 +#define PAGE_OFFSET			RGN_BASE(RGN_KERNEL)
   1.219 +
   1.220 +#define VM_DATA_DEFAULT_FLAGS		(VM_READ | VM_WRITE |					\
   1.221 +					 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC |		\
   1.222 +					 (((current->personality & READ_IMPLIES_EXEC) != 0)	\
   1.223 +					  ? VM_EXEC : 0))
   1.224 +
   1.225 +#endif /* _ASM_IA64_PAGE_H */