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

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