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 /* The current va context is global and known, so all that is needed to
  14  * do an invalidate is flush the VAC.
  15  */
  16 
  17 #define invalidate() flush_vac_context()  /* how conveeeiiiiinnnient :> */
  18 
  19 
  20 #define PAGE_SHIFT   12             /* This is the virtual page... */
  21 #define PGDIR_SHIFT  18             /* This is the virtual segment */
  22 #define PAGE_SIZE    4096
  23 #define PGDIR_SIZE   (1UL << PGDIR_SHIFT)
  24 
  25 #define PAGE_OFFSET    0
  26 #define MAP_NR(addr) (((addr)) >> PAGE_SHIFT)
  27 #define MAP_PAGE_RESERVED (1<<31)
  28 
  29 
  30 
  31 #define PAGE_PRESENT    0x001
  32 #define PAGE_RW         0x002
  33 #define PAGE_USER       0x004
  34 #define PAGE_ACCESSED   0x020
  35 #define PAGE_DIRTY      0x040
  36 #define PAGE_COW        0x200   /* implemented in software (one of the AVL bits) */
  37 
  38 #define PAGE_PRIVATE    (PAGE_PRESENT | PAGE_RW | PAGE_USER | PAGE_ACCESSED | PAGE_COW)
  39 #define PAGE_SHARED     (PAGE_PRESENT | PAGE_RW | PAGE_USER | PAGE_ACCESSED)
  40 #define PAGE_COPY       (PAGE_PRESENT | PAGE_USER | PAGE_ACCESSED | PAGE_COW)
  41 #define PAGE_READONLY   (PAGE_PRESENT | PAGE_USER | PAGE_ACCESSED)
  42 #define PAGE_EXECONLY   (PAGE_PRESENT | PAGE_USER | PAGE_ACCESSED)
  43 #define PAGE_TABLE      (PAGE_PRESENT | PAGE_RW | PAGE_USER | PAGE_ACCESSED)
  44 
  45 #define PAGE_CHG_MASK (PAGE_MASK | PAGE_ACCESSED | PAGE_DIRTY)
  46 
  47 #ifdef __KERNEL__
  48 
  49 /* number of bits that fit into a memory pointer */
  50 #define BITS_PER_PTR      (8*sizeof(unsigned long))   /* better check this stuff */
  51 
  52 /* to mask away the intra-page address bits */
  53 #define PAGE_MASK         (~(PAGE_SIZE-1))
  54 
  55 /* to mask away the intra-page address bits */
  56 #define PGDIR_MASK        (~(PGDIR_SIZE-1))
  57 
  58 /* to align the pointer to the (next) page boundary */
  59 #define PAGE_ALIGN(addr)  (((addr)+PAGE_SIZE-1)&PAGE_MASK)
  60 #define PGDIR_ALIGN(addr) (((addr)+PGDIR_SIZE-1)&PGDIR_MASK)
  61 
  62 /* to align the pointer to a pointer address */
  63 #define PTR_MASK          (~(sizeof(void*)-1))
  64 
  65 
  66 #define SIZEOF_PTR_LOG2   2
  67 
  68 /* The rest is kind of funky because on the sparc, the offsets into the mmu 
  69  * entries are encoded in magic alternate address space tables. I will 
  70  * probably find some nifty inline assembly routines to do the equivalent. 
  71  * Much thought must go into this code.   (davem@caip.rutgers.edu)
  72  */
  73 
  74 #define PAGE_DIR_OFFSET(base, address)   ((unsigned long *) 0)
  75 #define PAGE_PTR(address)                ((unsigned long) 0)
  76 #define PTRS_PER_PAGE                    (64)  /* 64 pte's per phys_seg */
  77 
  78 /* Bitfields within a Sparc sun4c PTE (page table entry). */
  79 
  80 #define PTE_V     0x80000000   /* valid bit */
  81 #define PTE_ACC   0x60000000   /* access bits */
  82 #define PTE_W     0x40000000   /* writable bit */
  83 #define PTE_P     0x20000000   /* privileged page */
  84 #define PTE_NC    0x10000000   /* page is non-cacheable */
  85 #define PTE_TYP   0x0c000000   /* page type field */
  86 #define PTE_RMEM  0x00000000   /* type == on board real memory */
  87 #define PTE_IO    0x04000000   /* type == i/o area */
  88 #define PTE_VME16 0x08000000   /* type == 16-bit VME area */
  89 #define PTE_VME32 0x0c000000   /* type == 32-bit VME area */
  90 #define PTE_R     0x02000000   /* page has been referenced */
  91 #define PTE_M     0x01000000   /* page has been modified */
  92 #define PTE_RESV  0x00f80000   /* reserved bits */
  93 #define PTE_PHYPG 0x0007ffff   /* phys pg number, sun4c only uses 16bits */
  94 
  95 /* termed a 'page table' in the linux kernel, a segmap entry is obtained
  96  * with the following macro
  97  */
  98 
  99 #ifndef __ASSEMBLY__ /* for head.S */
 100 /*
 101  * BAD_PAGETABLE is used when we need a bogus page-table, while
 102  * BAD_PAGE is used for a bogus page.
 103  *
 104  * ZERO_PAGE is a global shared page that is always zero: used
 105  * for zero-mapped memory areas etc..
 106  */
 107 extern unsigned long __bad_page(void);
 108 extern unsigned long __bad_pagetable(void);
 109 extern unsigned long __zero_page(void);
 110 
 111 typedef unsigned int mem_map_t;
 112 
 113 #define BAD_PAGETABLE __bad_pagetable()
 114 #define BAD_PAGE __bad_page()
 115 #define ZERO_PAGE __zero_page()
 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__("lduha [%1] 0x3, %0" : 
 122                        "=r" (entry) :
 123                        "r" (addr));
 124 
 125   return entry;
 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__("stha %1, [%0] 0x3" : : "r" (addr), "r" (entry));
 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 /* to set the page-dir
 176  *
 177  * On the Sparc this is a nop for now. It will set the proper segmap
 178  * in the real implementation.
 179  */
 180 
 181 #define SET_PAGE_DIR(tsk,pgdir)
 182 
 183 
 184 #endif /* !(__ASSEMBLY__) */
 185 
 186 #endif /* __KERNEL__ */
 187 
 188 #endif /* _SPARC_PAGE_H */

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