root/include/asm-sparc/page.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. get_segmap
  2. put_segmap
  3. get_pte
  4. put_pte
  5. switch_to_context
  6. get_context

   1 /* page.h:  Various defines and such for MMU operations on the Sparc for
   2             the Linux kernel.
   3 
   4    Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu)
   5 */
   6 
   7 #ifndef _SPARC_PAGE_H
   8 #define _SPARC_PAGE_H
   9 
  10 #include <asm/asi.h>        /* for get/set segmap/pte routines */
  11 #include <asm/contregs.h>   /* for switch_to_context */
  12 
  13 #define PAGE_SHIFT   12             /* This is the virtual page... */
  14 
  15 #ifndef __ASSEMBLY__
  16 #define PAGE_SIZE    (1UL << PAGE_SHIFT)
  17 
  18 /* to mask away the intra-page address bits */
  19 #define PAGE_MASK         (~(PAGE_SIZE-1))
  20 
  21 #ifdef __KERNEL__
  22 
  23 #define CONFIG_STRICT_MM_TYPECHECKS
  24 
  25 #ifdef CONFIG_STRICT_MM_TYPECHECKS
  26 /*
  27  * These are used to make use of C type-checking..
  28  */
  29 typedef struct { unsigned long pte; } pte_t;
  30 typedef struct { unsigned long pmd; } pmd_t;
  31 typedef struct { unsigned long pgd; } pgd_t;
  32 typedef struct { unsigned long pgprot; } pgprot_t;
  33 
  34 #define pte_val(x)      ((x).pte)
  35 #define pmd_val(x)      ((x).pmd)
  36 #define pgd_val(x)      ((x).pgd)
  37 #define pgprot_val(x)   ((x).pgprot)
  38 
  39 #define __pte(x)        ((pte_t) { (x) } )
  40 #define __pmd(x)        ((pmd_t) { (x) } )
  41 #define __pgd(x)        ((pgd_t) { (x) } )
  42 #define __pgprot(x)     ((pgprot_t) { (x) } )
  43 
  44 #else
  45 /*
  46  * .. while these make it easier on the compiler
  47  */
  48 typedef unsigned long pte_t;
  49 typedef unsigned long pmd_t;
  50 typedef unsigned long pgd_t;
  51 typedef unsigned long pgprot_t;
  52 
  53 #define pte_val(x)      (x)
  54 #define pmd_val(x)      (x)
  55 #define pgd_val(x)      (x)
  56 #define pgprot_val(x)   (x)
  57 
  58 #define __pte(x)        (x)
  59 #define __pmd(x)        (x)
  60 #define __pgd(x)        (x)
  61 #define __pgprot(x)     (x)
  62 
  63 #endif
  64 
  65 /* The current va context is global and known, so all that is needed to
  66  * do an invalidate is flush the VAC.
  67  */
  68 
  69 #define invalidate() flush_vac_context()  /* how conveeeiiiiinnnient :> */
  70 
  71 /* to align the pointer to the (next) page boundary */
  72 #define PAGE_ALIGN(addr)  (((addr)+PAGE_SIZE-1)&PAGE_MASK)
  73 
  74 #define PAGE_OFFSET    0
  75 #define MAP_NR(addr) (((unsigned long)(addr)) >> PAGE_SHIFT)
  76 #define MAP_PAGE_RESERVED (1<<15)
  77 
  78 
  79 #endif /* !(__ASSEMBLY__) */
  80 
  81 /* The rest is kind of funky because on the sparc, the offsets into the mmu 
  82  * entries are encoded in magic alternate address space tables. I will 
  83  * probably find some nifty inline assembly routines to do the equivalent. 
  84  * Much thought must go into this code.   (davem@caip.rutgers.edu)
  85  */
  86 
  87 /* Bitfields within a Sparc sun4c PTE (page table entry). */
  88 
  89 #define PTE_V     0x80000000   /* valid bit */
  90 #define PTE_ACC   0x60000000   /* access bits */
  91 #define PTE_W     0x40000000   /* writable bit */
  92 #define PTE_P     0x20000000   /* privileged page */
  93 #define PTE_NC    0x10000000   /* page is non-cacheable */
  94 #define PTE_TYP   0x0c000000   /* page type field */
  95 #define PTE_RMEM  0x00000000   /* type == on board real memory */
  96 #define PTE_IO    0x04000000   /* type == i/o area */
  97 #define PTE_VME16 0x08000000   /* type == 16-bit VME area */
  98 #define PTE_VME32 0x0c000000   /* type == 32-bit VME area */
  99 #define PTE_R     0x02000000   /* page has been referenced */
 100 #define PTE_M     0x01000000   /* page has been modified */
 101 #define PTE_RESV  0x00f80000   /* reserved bits */
 102 #define PTE_PHYPG 0x0007ffff   /* phys pg number, sun4c only uses 16bits */
 103 
 104 extern __inline__ unsigned long get_segmap(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 105 {
 106   register unsigned long entry;
 107 
 108   __asm__ __volatile__("lduha [%1] 0x3, %0" : 
 109                        "=r" (entry) :
 110                        "r" (addr));
 111 
 112   return entry;
 113 }
 114 
 115 extern __inline__ void put_segmap(unsigned long* addr, unsigned long entry)
     /* [previous][next][first][last][top][bottom][index][help] */
 116 {
 117 
 118   __asm__ __volatile__("stha %1, [%0] 0x3" : : "r" (addr), "r" (entry));
 119 
 120   return;
 121 }
 122 
 123 extern __inline__ unsigned long get_pte(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 124 {
 125   register unsigned long entry;
 126 
 127   __asm__ __volatile__("lda [%1] 0x4, %0" : 
 128                        "=r" (entry) :
 129                        "r" (addr));
 130   return entry;
 131 }
 132 
 133 extern __inline__ void put_pte(unsigned long addr, unsigned long entry)
     /* [previous][next][first][last][top][bottom][index][help] */
 134 {
 135   __asm__ __volatile__("sta %1, [%0] 0x4" : :
 136                        "r" (addr), 
 137                        "r" (entry));
 138 
 139   return;
 140 }
 141 
 142 extern __inline__ void switch_to_context(int context)
     /* [previous][next][first][last][top][bottom][index][help] */
 143 {
 144   __asm__ __volatile__("stba %0, [%1] 0x2" : :
 145                        "r" (context),
 146                        "r" (0x30000000));                      
 147 
 148   return;
 149 }
 150 
 151 extern __inline__ int get_context(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 152 {
 153   register int ctx;
 154 
 155   __asm__ __volatile__("lduba [%1] 0x2, %0" :
 156                        "=r" (ctx) :
 157                        "r" (0x30000000));
 158 
 159   return ctx;
 160 }
 161 
 162 typedef unsigned short mem_map_t;
 163 
 164 #endif /* __KERNEL__ */
 165 
 166 #endif /* _SPARC_PAGE_H */

/* [previous][next][first][last][top][bottom][index][help] */