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 #ifdef __KERNEL__
  26 
  27 #define BITS_PER_PTR      (8*sizeof(unsigned long))   /* better check this stuff */
  28 #define PAGE_MASK         (~(PAGE_SIZE-1))
  29 #define PGDIR_MASK        (~(PGDIR_SIZE-1))
  30 #define PAGE_ALIGN(addr)  (((addr)+PAGE_SIZE-1)&PAGE_MASK)
  31 #define PGDIR_ALIGN(addr) (((addr)+PGDIR_SIZE-1)&PGDIR_MASK)
  32 #define PTR_MASK          (~(sizeof(void*)-1))
  33 
  34 
  35 #define SIZEOF_PTR_LOG2   2
  36 
  37 /* The rest is kind of funky because on the sparc, the offsets into the mmu 
  38  * entries are encoded in magic alternate address space tables. I will 
  39  * probably find some nifty inline assembly routines to do the equivalent. 
  40  * Much thought must go into this code.   (davem@caip.rutgers.edu)
  41  */
  42 
  43 #define PAGE_DIR_OFFSET(base, address)   ((unsigned long *) 0)
  44 #define PAGE_PTR(address)                ((unsigned long) 0)
  45 #define PTRS_PER_PAGE                    (64)  /* 64 pte's per phys_seg */
  46 
  47 /* Bitfields within a Sparc sun4c PTE (page table entry). */
  48 
  49 #define PTE_V     0x80000000   /* valid bit */
  50 #define PTE_ACC   0x60000000   /* access bits */
  51 #define PTE_W     0x40000000   /* writable bit */
  52 #define PTE_P     0x20000000   /* privileged page */
  53 #define PTE_NC    0x10000000   /* page is non-cacheable */
  54 #define PTE_TYP   0x0c000000   /* page type field */
  55 #define PTE_RMEM  0x00000000   /* type == on board real memory */
  56 #define PTE_IO    0x04000000   /* type == i/o area */
  57 #define PTE_VME16 0x08000000   /* type == 16-bit VME area */
  58 #define PTE_VME32 0x0c000000   /* type == 32-bit VME area */
  59 #define PTE_R     0x02000000   /* page has been referenced */
  60 #define PTE_M     0x01000000   /* page has been modified */
  61 #define PTE_RESV  0x00f80000   /* reserved bits */
  62 #define PTE_PHYPG 0x0007ffff   /* phys pg number, sun4c only uses 16bits */
  63 
  64 /* termed a 'page table' in the linux kernel, a segmap entry is obtained
  65  * with the following macro
  66  */
  67 
  68 #ifndef __ASSEMBLY__ /* for head.S */
  69 extern __inline__ unsigned long get_segmap(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  70 {
  71   register unsigned long entry;
  72 
  73   __asm__ __volatile__("lduha [%1] 0x3, %0" : 
  74                        "=r" (entry) :
  75                        "r" (addr)); 
  76 
  77   return entry;
  78 }
  79 
  80 extern __inline__ void put_segmap(unsigned long* addr, unsigned long entry)
     /* [previous][next][first][last][top][bottom][index][help] */
  81 {
  82 
  83   __asm__ __volatile__("stha %1, [%0] 0x3" : : "r" (addr), "r" (entry));
  84 
  85   return;
  86 }
  87 
  88 extern __inline__ unsigned long get_pte(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  89 {
  90   register unsigned long entry;
  91 
  92   __asm__ __volatile__("lda [%1] 0x4, %0" : 
  93                        "=r" (entry) :
  94                        "r" (addr));
  95   return entry;
  96 }
  97 
  98 extern __inline__ void put_pte(unsigned long addr, unsigned long entry)
     /* [previous][next][first][last][top][bottom][index][help] */
  99 {
 100   __asm__ __volatile__("sta %1, [%0] 0x4" : :
 101                        "r" (addr), 
 102                        "r" (entry));
 103 
 104   return;
 105 }
 106 
 107 extern __inline__ void switch_to_context(int context)
     /* [previous][next][first][last][top][bottom][index][help] */
 108 {
 109   __asm__ __volatile__("stba %0, [%1] 0x2" : :
 110                        "r" (context),
 111                        "r" (0x30000000));                      
 112 
 113   return;
 114 }
 115 
 116 extern __inline__ int get_context(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 117 {
 118   register int ctx;
 119 
 120   __asm__ __volatile__("lduba [%1] 0x2, %0" :
 121                        "=r" (ctx) :
 122                        "r" (0x30000000));
 123 
 124   return ctx;
 125 }
 126 
 127 /* to set the page-dir
 128  *
 129  * On the Sparc this is a nop for now. It will set the proper segmap
 130  * in the real implementation.
 131  */
 132 
 133 #define SET_PAGE_DIR(tsk,pgdir)
 134 
 135 
 136 #endif /* !(__ASSEMBLY__) */
 137 
 138 #endif /* __KERNEL__ */
 139 
 140 #endif /* _SPARC_PAGE_H */

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