root/include/asm-sparc/pgtable.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. remove_from_ctx_list
  2. add_to_ctx_list

   1 /* $Id: pgtable.h,v 1.25 1995/11/25 02:32:22 davem Exp $ */
   2 #ifndef _SPARC_PGTABLE_H
   3 #define _SPARC_PGTABLE_H
   4 
   5 /*  asm-sparc/pgtable.h:  Defines and functions used to work
   6  *                        with Sparc page tables.
   7  *
   8  *  Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
   9  */
  10 
  11 #include <linux/mm.h>
  12 #include <asm/asi.h>
  13 #include <asm/pgtsun4c.h>
  14 #include <asm/pgtsrmmu.h>
  15 #include <asm/vac-ops.h>
  16 #include <asm/oplib.h>
  17 
  18 extern void load_mmu(void);
  19 
  20 /* mmu-specific process creation/cloning/etc hooks. */
  21 extern void (*mmu_exit_hook)(void *);
  22 extern void (*mmu_fork_hook)(void *, unsigned long);
  23 extern void (*mmu_release_hook)(void *);
  24 extern void (*mmu_flush_hook)(void *);
  25 extern void (*mmu_task_cacheflush)(void *);
  26 
  27 /* Routines for data transfer buffers. */
  28 extern char *(*mmu_lockarea)(char *, unsigned long);
  29 extern void  (*mmu_unlockarea)(char *, unsigned long);
  30 
  31 /* Routines for getting a dvma scsi buffer. */
  32 extern char *(*mmu_get_scsi_buffer)(char *, unsigned long);
  33 extern void  (*mmu_release_scsi_buffer)(char *, unsigned long);
  34 
  35 extern unsigned int pmd_shift;
  36 extern unsigned int pmd_size;
  37 extern unsigned int pmd_mask;
  38 extern unsigned int (*pmd_align)(unsigned int);
  39 
  40 extern unsigned int pgdir_shift;
  41 extern unsigned int pgdir_size;
  42 extern unsigned int pgdir_mask;
  43 extern unsigned int (*pgdir_align)(unsigned int);
  44 
  45 extern unsigned int ptrs_per_pte;
  46 extern unsigned int ptrs_per_pmd;
  47 extern unsigned int ptrs_per_pgd;
  48 
  49 extern unsigned int ptrs_per_page;
  50 
  51 extern unsigned long (*(vmalloc_start))(void);
  52 
  53 #define VMALLOC_VMADDR(x) ((unsigned long)(x))
  54 #define VMALLOC_START vmalloc_start()
  55 
  56 extern pgprot_t page_none;
  57 extern pgprot_t page_shared;
  58 extern pgprot_t page_copy;
  59 extern pgprot_t page_readonly;
  60 extern pgprot_t page_kernel;
  61 extern pgprot_t page_invalid;
  62 
  63 #define PMD_SHIFT      (pmd_shift)
  64 #define PMD_SIZE       (pmd_size)
  65 #define PMD_MASK       (pmd_mask)
  66 #define PMD_ALIGN      (pmd_align)
  67 #define PGDIR_SHIFT    (pgdir_shift)
  68 #define PGDIR_SIZE     (pgdir_size)
  69 #define PGDIR_MASK     (pgdir_mask)
  70 #define PGDIR_ALIGN    (pgdir_align)
  71 #define PTRS_PER_PTE   (ptrs_per_pte)
  72 #define PTRS_PER_PMD   (ptrs_per_pmd)
  73 #define PTRS_PER_PGD   (ptrs_per_pgd)
  74 
  75 #define PAGE_NONE      (page_none)
  76 #define PAGE_SHARED    (page_shared)
  77 #define PAGE_COPY      (page_copy)
  78 #define PAGE_READONLY  (page_readonly)
  79 #define PAGE_KERNEL    (page_kernel)
  80 #define PAGE_INVALID   (page_invalid)
  81 
  82 /* Top-level page directory */
  83 extern pgd_t swapper_pg_dir[1024];
  84 
  85 /* Page table for 0-4MB for everybody, on the Sparc this
  86  * holds the same as on the i386.
  87  */
  88 extern pte_t pg0[1024];
  89 
  90 extern unsigned long ptr_in_current_pgd;
  91 
  92 /* the no. of pointers that fit on a page: this will go away */
  93 #define PTRS_PER_PAGE   (PAGE_SIZE/sizeof(void*))
  94 
  95 /* Here is a trick, since mmap.c need the initializer elements for
  96  * protection_map[] to be constant at compile time, I set the following
  97  * to all zeros.  I set it to the real values after I link in the
  98  * appropriate MMU page table routines at boot time.
  99  */
 100 #define __P000  __pgprot(0)
 101 #define __P001  __pgprot(0)
 102 #define __P010  __pgprot(0)
 103 #define __P011  __pgprot(0)
 104 #define __P100  __pgprot(0)
 105 #define __P101  __pgprot(0)
 106 #define __P110  __pgprot(0)
 107 #define __P111  __pgprot(0)
 108 
 109 #define __S000  __pgprot(0)
 110 #define __S001  __pgprot(0)
 111 #define __S010  __pgprot(0)
 112 #define __S011  __pgprot(0)
 113 #define __S100  __pgprot(0)
 114 #define __S101  __pgprot(0)
 115 #define __S110  __pgprot(0)
 116 #define __S111  __pgprot(0)
 117 
 118 extern int num_contexts;
 119 
 120 /*
 121  * BAD_PAGETABLE is used when we need a bogus page-table, while
 122  * BAD_PAGE is used for a bogus page.
 123  *
 124  * ZERO_PAGE is a global shared page that is always zero: used
 125  * for zero-mapped memory areas etc..
 126  */
 127 extern pte_t __bad_page(void);
 128 extern pte_t * __bad_pagetable(void);
 129 
 130 extern unsigned long __zero_page(void);
 131 
 132 #define BAD_PAGETABLE __bad_pagetable()
 133 #define BAD_PAGE __bad_page()
 134 #define ZERO_PAGE __zero_page()
 135 
 136 /* number of bits that fit into a memory pointer */
 137 #define BITS_PER_PTR      (8*sizeof(unsigned long))
 138 
 139 /* to align the pointer to a pointer address */
 140 #define PTR_MASK          (~(sizeof(void*)-1))
 141 
 142 #define SIZEOF_PTR_LOG2   2
 143 
 144 extern unsigned long (*pte_page)(pte_t);
 145 extern unsigned long (*pmd_page)(pmd_t);
 146 extern unsigned long (*pgd_page)(pgd_t);
 147 
 148 /* to set the page-dir
 149  *
 150  * On the Sparc the page segments hold 64 pte's which means 256k/segment.
 151  * Therefore there is no global idea of 'the' page directory, although we
 152  * make a virtual one in kernel memory so that we can keep the stats on
 153  * all the pages since not all can be loaded at once in the mmu.
 154  *
 155  * Actually on the SRMMU things do work exactly like the i386, the
 156  * page tables live in real physical ram, no funky TLB buisness.
 157  */
 158 
 159 extern void (*sparc_update_rootmmu_dir)(struct task_struct *, pgd_t *pgdir);
 160 
 161 #define SET_PAGE_DIR(tsk,pgdir) sparc_update_rootmmu_dir(tsk, pgdir)
 162        
 163 /* to find an entry in a page-table */
 164 #define PAGE_PTR(address) \
 165 ((unsigned long)(address)>>(PAGE_SHIFT-SIZEOF_PTR_LOG2)&PTR_MASK&~PAGE_MASK)
 166 
 167 extern unsigned long high_memory;
 168 
 169 extern int (*pte_none)(pte_t);
 170 extern int (*pte_present)(pte_t);
 171 extern int (*pte_inuse)(pte_t *);
 172 extern void (*pte_clear)(pte_t *);
 173 extern void (*pte_reuse)(pte_t *);
 174 
 175 extern int (*pmd_none)(pmd_t);
 176 extern int (*pmd_bad)(pmd_t);
 177 extern int (*pmd_present)(pmd_t);
 178 extern int (*pmd_inuse)(pmd_t *);
 179 extern void (*pmd_clear)(pmd_t *);
 180 extern void (*pmd_reuse)(pmd_t *);
 181 
 182 extern int (*pgd_none)(pgd_t);
 183 extern int (*pgd_bad)(pgd_t);
 184 extern int (*pgd_present)(pgd_t);
 185 extern int (*pgd_inuse)(pgd_t *);
 186 extern void (*pgd_clear)(pgd_t *);
 187 extern void (*pgd_reuse)(pgd_t *);
 188 
 189 /*
 190  * The following only work if pte_present() is true.
 191  * Undefined behaviour if not..
 192  */
 193 extern int (*pte_read)(pte_t);
 194 extern int (*pte_write)(pte_t);
 195 extern int (*pte_exec)(pte_t);
 196 extern int (*pte_dirty)(pte_t);
 197 extern int (*pte_young)(pte_t);
 198 extern int (*pte_cow)(pte_t);
 199 
 200 extern pte_t (*pte_wrprotect)(pte_t);
 201 extern pte_t (*pte_rdprotect)(pte_t);
 202 extern pte_t (*pte_exprotect)(pte_t);
 203 extern pte_t (*pte_mkclean)(pte_t);
 204 extern pte_t (*pte_mkold)(pte_t);
 205 extern pte_t (*pte_uncow)(pte_t);
 206 extern pte_t (*pte_mkwrite)(pte_t);
 207 extern pte_t (*pte_mkread)(pte_t);
 208 extern pte_t (*pte_mkexec)(pte_t);
 209 extern pte_t (*pte_mkdirty)(pte_t);
 210 extern pte_t (*pte_mkyoung)(pte_t);
 211 extern pte_t (*pte_mkcow)(pte_t);
 212 
 213 /*
 214  * Conversion functions: convert a page and protection to a page entry,
 215  * and a page entry and page directory to the page they refer to.
 216  */
 217 extern pte_t (*mk_pte)(unsigned long, pgprot_t);
 218 
 219 extern void (*pgd_set)(pgd_t *, pmd_t *);
 220 
 221 extern pte_t (*pte_modify)(pte_t, pgprot_t);
 222 
 223 /* to find an entry in a page-table-directory */
 224 extern pgd_t * (*pgd_offset)(struct mm_struct *, unsigned long);
 225 
 226 /* Find an entry in the second-level page table.. */
 227 extern pmd_t * (*pmd_offset)(pgd_t *, unsigned long);
 228 
 229 /* Find an entry in the third-level page table.. */ 
 230 extern pte_t * (*pte_offset)(pmd_t *, unsigned long);
 231 
 232 /*
 233  * Allocate and free page tables. The xxx_kernel() versions are
 234  * used to allocate a kernel page table - this turns on ASN bits
 235  * if any, and marks the page tables reserved.
 236  */
 237 extern void (*pte_free_kernel)(pte_t *);
 238 
 239 extern pte_t * (*pte_alloc_kernel)(pmd_t *, unsigned long);
 240 
 241 /*
 242  * allocating and freeing a pmd is trivial: the 1-entry pmd is
 243  * inside the pgd, so has no extra memory associated with it.
 244  */
 245 extern void (*pmd_free_kernel)(pmd_t *);
 246 
 247 extern pmd_t * (*pmd_alloc_kernel)(pgd_t *, unsigned long);
 248 
 249 extern void (*pte_free)(pte_t *);
 250 
 251 extern pte_t * (*pte_alloc)(pmd_t *, unsigned long);
 252 
 253 /*
 254  * allocating and freeing a pmd is trivial: the 1-entry pmd is
 255  * inside the pgd, so has no extra memory associated with it.
 256  */
 257 extern void (*pmd_free)(pmd_t *);
 258 
 259 extern pmd_t * (*pmd_alloc)(pgd_t *, unsigned long);
 260 
 261 extern void (*pgd_free)(pgd_t *);
 262 
 263 extern pgd_t * (*pgd_alloc)(void);
 264 
 265 /* Fault handler stuff... */
 266 #define FAULT_CODE_PROT     0x1
 267 #define FAULT_CODE_WRITE    0x2
 268 #define FAULT_CODE_USER     0x4
 269 extern int (*get_fault_info)(unsigned long *, unsigned long *, unsigned long);
 270 extern void (*update_mmu_cache)(struct vm_area_struct *vma, unsigned long address, pte_t pte);
 271 
 272 extern int invalid_segment;
 273 
 274 #define SWP_TYPE(entry) (((entry) >> 1) & 0x7f)
 275 #define SWP_OFFSET(entry) ((entry) >> 8)
 276 #define SWP_ENTRY(type,offset) (((type) << 1) | ((offset) << 8))
 277 
 278 struct ctx_list {
 279         struct ctx_list *next;
 280         struct ctx_list *prev;
 281         unsigned char ctx_number;
 282         struct task_struct *ctx_task; /* Who has it now, if not free */
 283 };
 284 
 285 extern struct ctx_list *ctx_list_pool;  /* Dynamically allocated */
 286 extern struct ctx_list ctx_free;        /* Head of free list */
 287 extern struct ctx_list ctx_used;        /* Head of used contexts list */
 288 
 289 extern inline void remove_from_ctx_list(struct ctx_list *entry)
     /* [previous][next][first][last][top][bottom][index][help] */
 290 {
 291         entry->next->prev = entry->prev;
 292         entry->prev->next = entry->next;
 293 }
 294 
 295 extern inline void add_to_ctx_list(struct ctx_list *head, struct ctx_list *entry)
     /* [previous][next][first][last][top][bottom][index][help] */
 296 {
 297         entry->next = head;
 298         (entry->prev = head->prev)->next = entry;
 299         head->prev = entry;
 300 }
 301 #define add_to_free_ctxlist(entry) add_to_ctx_list(&ctx_free, entry)
 302 #define add_to_used_ctxlist(entry) add_to_ctx_list(&ctx_used, entry)
 303 
 304 #endif /* !(_SPARC_PGTABLE_H) */

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