linux/arch/sparc/include/asm/page_32.h
<<
>>
Prefs
   1/*
   2 * page.h:  Various defines and such for MMU operations on the Sparc for
   3 *          the Linux kernel.
   4 *
   5 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
   6 */
   7
   8#ifndef _SPARC_PAGE_H
   9#define _SPARC_PAGE_H
  10
  11#include <linux/const.h>
  12
  13#define PAGE_SHIFT   12
  14#define PAGE_SIZE    (_AC(1, UL) << PAGE_SHIFT)
  15#define PAGE_MASK    (~(PAGE_SIZE-1))
  16
  17#ifndef __ASSEMBLY__
  18
  19#define clear_page(page)         memset((void *)(page), 0, PAGE_SIZE)
  20#define copy_page(to,from)      memcpy((void *)(to), (void *)(from), PAGE_SIZE)
  21#define clear_user_page(addr, vaddr, page)      \
  22        do {    clear_page(addr);               \
  23                sparc_flush_page_to_ram(page);  \
  24        } while (0)
  25#define copy_user_page(to, from, vaddr, page)   \
  26        do {    copy_page(to, from);            \
  27                sparc_flush_page_to_ram(page);  \
  28        } while (0)
  29
  30/* The following structure is used to hold the physical
  31 * memory configuration of the machine.  This is filled in
  32 * prom_meminit() and is later used by mem_init() to set up
  33 * mem_map[].  We statically allocate SPARC_PHYS_BANKS+1 of
  34 * these structs, this is arbitrary.  The entry after the
  35 * last valid one has num_bytes==0.
  36 */
  37struct sparc_phys_banks {
  38  unsigned long base_addr;
  39  unsigned long num_bytes;
  40};
  41
  42#define SPARC_PHYS_BANKS 32
  43
  44extern struct sparc_phys_banks sp_banks[SPARC_PHYS_BANKS+1];
  45
  46/* passing structs on the Sparc slow us down tremendously... */
  47
  48/* #define STRICT_MM_TYPECHECKS */
  49
  50#ifdef STRICT_MM_TYPECHECKS
  51/*
  52 * These are used to make use of C type-checking..
  53 */
  54typedef struct { unsigned long pte; } pte_t;
  55typedef struct { unsigned long iopte; } iopte_t;
  56typedef struct { unsigned long pmdv[16]; } pmd_t;
  57typedef struct { unsigned long pgd; } pgd_t;
  58typedef struct { unsigned long ctxd; } ctxd_t;
  59typedef struct { unsigned long pgprot; } pgprot_t;
  60typedef struct { unsigned long iopgprot; } iopgprot_t;
  61
  62#define pte_val(x)      ((x).pte)
  63#define iopte_val(x)    ((x).iopte)
  64#define pmd_val(x)      ((x).pmdv[0])
  65#define pgd_val(x)      ((x).pgd)
  66#define ctxd_val(x)     ((x).ctxd)
  67#define pgprot_val(x)   ((x).pgprot)
  68#define iopgprot_val(x) ((x).iopgprot)
  69
  70#define __pte(x)        ((pte_t) { (x) } )
  71#define __iopte(x)      ((iopte_t) { (x) } )
  72#define __pgd(x)        ((pgd_t) { (x) } )
  73#define __ctxd(x)       ((ctxd_t) { (x) } )
  74#define __pgprot(x)     ((pgprot_t) { (x) } )
  75#define __iopgprot(x)   ((iopgprot_t) { (x) } )
  76
  77#else
  78/*
  79 * .. while these make it easier on the compiler
  80 */
  81typedef unsigned long pte_t;
  82typedef unsigned long iopte_t;
  83typedef struct { unsigned long pmdv[16]; } pmd_t;
  84typedef unsigned long pgd_t;
  85typedef unsigned long ctxd_t;
  86typedef unsigned long pgprot_t;
  87typedef unsigned long iopgprot_t;
  88
  89#define pte_val(x)      (x)
  90#define iopte_val(x)    (x)
  91#define pmd_val(x)      ((x).pmdv[0])
  92#define pgd_val(x)      (x)
  93#define ctxd_val(x)     (x)
  94#define pgprot_val(x)   (x)
  95#define iopgprot_val(x) (x)
  96
  97#define __pte(x)        (x)
  98#define __iopte(x)      (x)
  99#define __pgd(x)        (x)
 100#define __ctxd(x)       (x)
 101#define __pgprot(x)     (x)
 102#define __iopgprot(x)   (x)
 103
 104#endif
 105
 106typedef struct page *pgtable_t;
 107
 108#define TASK_UNMAPPED_BASE      0x50000000
 109
 110#else /* !(__ASSEMBLY__) */
 111
 112#define __pgprot(x)     (x)
 113
 114#endif /* !(__ASSEMBLY__) */
 115
 116#define PAGE_OFFSET     0xf0000000
 117#ifndef __ASSEMBLY__
 118extern unsigned long phys_base;
 119extern unsigned long pfn_base;
 120#endif
 121#define __pa(x)                 ((unsigned long)(x) - PAGE_OFFSET + phys_base)
 122#define __va(x)                 ((void *)((unsigned long) (x) - phys_base + PAGE_OFFSET))
 123
 124#define virt_to_phys            __pa
 125#define phys_to_virt            __va
 126
 127#define ARCH_PFN_OFFSET         (pfn_base)
 128#define virt_to_page(kaddr)     pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
 129
 130#define pfn_valid(pfn)          (((pfn) >= (pfn_base)) && (((pfn)-(pfn_base)) < max_mapnr))
 131#define virt_addr_valid(kaddr)  ((((unsigned long)(kaddr)-PAGE_OFFSET)>>PAGE_SHIFT) < max_mapnr)
 132
 133#define VM_DATA_DEFAULT_FLAGS   (VM_READ | VM_WRITE | VM_EXEC | \
 134                                 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 135
 136#include <asm-generic/memory_model.h>
 137#include <asm-generic/getorder.h>
 138
 139#endif /* _SPARC_PAGE_H */
 140