[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-merge] [PATCH 11/23] page subarch headers



--- linux-2.6.12-xen0-arch.orig/include/asm-i386/page.h
+++ linux-2.6.12-xen0-arch/include/asm-i386/page.h
@@ -49,16 +49,22 @@ typedef struct { unsigned long pte_low, 
 typedef struct { unsigned long long pmd; } pmd_t;
 typedef struct { unsigned long long pgd; } pgd_t;
 typedef struct { unsigned long long pgprot; } pgprot_t;
-#define pmd_val(x)     ((x).pmd)
-#define pte_val(x)     ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
-#define __pmd(x) ((pmd_t) { (x) } )
+/* accessors are machine dependent */
+#if 0
+#define pmd_val(x)     mach_pmd_val(x)
+#define pte_val(x)     mach_pte_val(x)
+#define __pmd(x)       mach__pmd(x)
+#endif
 #define HPAGE_SHIFT    21
 #else
 typedef struct { unsigned long pte_low; } pte_t;
 typedef struct { unsigned long pgd; } pgd_t;
 typedef struct { unsigned long pgprot; } pgprot_t;
 #define boot_pte_t pte_t /* or would you rather have a typedef */
+/* accessors are machine dependent */
+#if 0
 #define pte_val(x)     ((x).pte_low)
+#endif
 #define HPAGE_SHIFT    22
 #endif
 #define PTE_MASK       PAGE_MASK
@@ -70,11 +76,13 @@ typedef struct { unsigned long pgprot; }
 #define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
 #endif
 
-#define pgd_val(x)     ((x).pgd)
+#include <mach_page.h>
+
+#define pgd_val(x)     mach_pgd_val(x)
 #define pgprot_val(x)  ((x).pgprot)
 
-#define __pte(x) ((pte_t) { (x) } )
-#define __pgd(x) ((pgd_t) { (x) } )
+#define __pte(x)       mach__pte(x)
+#define __pgd(x)       mach__pgd(x)
 #define __pgprot(x)    ((pgprot_t) { (x) } )
 
 #endif /* !__ASSEMBLY__ */
@@ -130,7 +138,7 @@ extern int sysctl_legacy_va_layout;
 
 #define PAGE_OFFSET            ((unsigned long)__PAGE_OFFSET)
 #define VMALLOC_RESERVE                ((unsigned long)__VMALLOC_RESERVE)
-#define MAXMEM                 (-__PAGE_OFFSET-__VMALLOC_RESERVE)
+#define MAXMEM                 
(MACH_VIRT_START-__PAGE_OFFSET-__VMALLOC_RESERVE)
 #define __pa(x)                        ((unsigned long)(x)-PAGE_OFFSET)
 #define __va(x)                        ((void *)((unsigned 
long)(x)+PAGE_OFFSET))
 #define pfn_to_kaddr(pfn)      __va((pfn) << PAGE_SHIFT)
--- /dev/null
+++ linux-2.6.12-xen0-arch/include/asm-i386/mach-default/mach_page.h
@@ -0,0 +1,22 @@
+#ifndef __ASM_MACH_PAGE_H
+#define __ASM_MACH_PAGE_H
+
+#ifdef CONFIG_X86_PAE
+#define pmd_val(x)     ((x).pmd)
+#define pte_val(x)     ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
+#define __pmd(x)       ((pmd_t) { (x) } )
+#else
+#define pte_val(x)     ((x).pte_low)
+#endif
+
+#define mach_pgd_val(x)                ((x).pgd)
+
+#define mach__pte(x)           ((pte_t) { (x) } )
+#define mach__pgd(x)           ((pgd_t) { (x) } )
+
+#define MACH_VIRT_START                0UL
+
+#define phys_to_machine(x) (x)
+#define machine_to_phys(x) (x)
+
+#endif
--- linux-2.6.12-xen0/include/asm-i386/mach-xen/mach_page.h     1969-12-31 
16:00:00.000000000 -0800
+++ linux-2.6.12-xen0-arch/include/asm-i386/mach-xen/mach_page.h        
2005-07-30 07:07:34.000000000 -0700
@@ -0,0 +1,104 @@
+#ifndef __ASM_MACH_PAGE_H
+#define __ASM_MACH_PAGE_H
+
+/*
+#include <linux/string.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <asm/bug.h>
+*/
+#include <xen-public/xen.h>
+#include <xen_foreign_page.h>
+
+#define arch_free_page(_page,_order)                   \
+({     int foreign = PageForeign(_page);               \
+       if (foreign)                                    \
+               (PageForeignDestructor(_page))(_page);  \
+       foreign;                                        \
+})
+#define HAVE_ARCH_FREE_PAGE
+
+#ifdef CONFIG_XEN_SCRUB_PAGES
+#define scrub_pages(_p,_n) memset((void *)(_p), 0, (_n) << PAGE_SHIFT)
+#else
+#define scrub_pages(_p,_n) ((void)0)
+#endif
+ 
+/**** MACHINE <-> PHYSICAL CONVERSION MACROS ****/
+extern unsigned int *phys_to_machine_mapping;
+#define pfn_to_mfn(_pfn) ((unsigned long)(phys_to_machine_mapping[(_pfn)]))
+#define mfn_to_pfn(_mfn) ((unsigned long)(machine_to_phys_mapping[(_mfn)]))
+static inline unsigned long phys_to_machine(unsigned long phys)
+{
+       unsigned long machine = pfn_to_mfn(phys >> PAGE_SHIFT);
+       machine = (machine << PAGE_SHIFT) | (phys & ~PAGE_MASK);
+       return machine;
+}
+static inline unsigned long machine_to_phys(unsigned long machine)
+{
+       unsigned long phys = mfn_to_pfn(machine >> PAGE_SHIFT);
+       phys = (phys << PAGE_SHIFT) | (machine & ~PAGE_MASK);
+       return phys;
+}
+ 
+#ifdef CONFIG_X86_PAE
+#define mach__pte(x) ({ unsigned long long _x = (x); \
+       (((_x)&1) ? ((pte_t) {phys_to_machine(_x)}) : ((pte_t) {(_x)})); })
+#define mach__pgd(x) ({ unsigned long long _x = (x); \
+       (((_x)&1) ? ((pgd_t) {phys_to_machine(_x)}) : ((pgd_t) {(_x)})); })
+#define mach__pmd(x) ({ unsigned long long _x = (x); \
+       (((_x)&1) ? ((pmd_t) {phys_to_machine(_x)}) : ((pmd_t) {(_x)})); })
+static inline unsigned long long pte_val(pte_t x)
+{
+       unsigned long long ret;
+
+       if (x.pte_low) {
+               ret = x.pte_low | (unsigned long long)x.pte_high << 32;
+               ret = machine_to_phys(ret) | 1;
+       } else {
+               ret = 0;
+       }
+       return ret;
+}
+static inline unsigned long long pmd_val(pmd_t x)
+{
+       unsigned long long ret = x.pmd;
+       if (ret) ret = machine_to_phys(ret) | 1;
+       return ret;
+}
+static inline unsigned long long mach_pgd_val(pgd_t x)
+{
+       unsigned long long ret = x.pgd;
+       if (ret) ret = machine_to_phys(ret) | 1;
+       return ret;
+}
+static inline unsigned long long pte_val_ma(pte_t x)
+{
+       return (unsigned long long)x.pte_high << 32 | x.pte_low;
+}
+#else
+#define pte_val(x)     (((x).pte_low & 1) ? machine_to_phys((x).pte_low) : \
+                        (x).pte_low)
+#define pte_val_ma(x)  ((x).pte_low)
+#define mach__pte(x) ({ unsigned long _x = (x); \
+       (((_x)&1) ? ((pte_t) {phys_to_machine(_x)}) : ((pte_t) {(_x)})); })
+#define mach__pgd(x) ({ unsigned long _x = (x); \
+       (((_x)&1) ? ((pgd_t) {phys_to_machine(_x)}) : ((pgd_t) {(_x)})); })
+static inline unsigned long mach_pgd_val(pgd_t x)
+{
+       unsigned long ret = x.pgd;
+       if (ret) ret = machine_to_phys(ret) | 1;
+       return ret;
+}
+#endif
+#define _HAVE_MACH_PAGE
+
+#define __pte_ma(x)    ((pte_t) { (x) } )
+ 
+#define MACH_VIRT_START                HYPERVISOR_VIRT_START
+
+/* VIRT <-> MACHINE conversion */
+#define virt_to_machine(_a)    (phys_to_machine(__pa(_a)))
+#define machine_to_virt(_m)    (__va(machine_to_phys(_m)))
+ 
+#endif

--


_______________________________________________
Xen-merge mailing list
Xen-merge@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-merge


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.