Home | History | Annotate | Line # | Download | only in include
pte.h revision 1.8.2.1
      1 /* $NetBSD: pte.h,v 1.8.2.1 1997/06/01 04:12:32 cgd Exp $ */
      2 
      3 /*
      4  * Copyright Notice:
      5  *
      6  * Copyright (c) 1997 Christopher G. Demetriou.  All rights reserved.
      7  *
      8  * License:
      9  *
     10  * This License applies to this software ("Software"), created
     11  * by Christopher G. Demetriou ("Author").
     12  *
     13  * You may use, copy, modify and redistribute this Software without
     14  * charge, in either source code form, binary form, or both, on the
     15  * following conditions:
     16  *
     17  * 1.  (a) Binary code: (i) a complete copy of the above copyright notice
     18  * must be included within each copy of the Software in binary code form,
     19  * and (ii) a complete copy of the above copyright notice and all terms
     20  * of this License as presented here must be included within each copy of
     21  * all documentation accompanying or associated with binary code, in any
     22  * medium, along with a list of the software modules to which the license
     23  * applies.
     24  *
     25  * (b) Source Code: A complete copy of the above copyright notice and all
     26  * terms of this License as presented here must be included within: (i)
     27  * each copy of the Software in source code form, and (ii) each copy of
     28  * all accompanying or associated documentation, in any medium.
     29  *
     30  * 2. The following Acknowledgment must be used in communications
     31  * involving the Software as described below:
     32  *
     33  *      This product includes software developed by
     34  *      Christopher G. Demetriou for the NetBSD Project.
     35  *
     36  * The Acknowledgment must be conspicuously and completely displayed
     37  * whenever the Software, or any software, products or systems containing
     38  * the Software, are mentioned in advertising, marketing, informational
     39  * or publicity materials of any kind, whether in print, electronic or
     40  * other media (except for information provided to support use of
     41  * products containing the Software by existing users or customers).
     42  *
     43  * 3. The name of the Author may not be used to endorse or promote
     44  * products derived from this Software without specific prior written
     45  * permission (conditions (1) and (2) above are not considered
     46  * endorsement or promotion).
     47  *
     48  * 4.  This license applies to: (a) all copies of the Software, whether
     49  * partial or whole, original or modified, and (b) your actions, and the
     50  * actions of all those who may act on your behalf.  All uses not
     51  * expressly permitted are reserved to the Author.
     52  *
     53  * 5.  Disclaimer.  THIS SOFTWARE IS MADE AVAILABLE BY THE AUTHOR TO THE
     54  * PUBLIC FOR FREE AND "AS IS.''  ALL USERS OF THIS FREE SOFTWARE ARE
     55  * SOLELY AND ENTIRELY RESPONSIBLE FOR THEIR OWN CHOICE AND USE OF THIS
     56  * SOFTWARE FOR THEIR OWN PURPOSES.  BY USING THIS SOFTWARE, EACH USER
     57  * AGREES THAT THE AUTHOR SHALL NOT BE LIABLE FOR DAMAGES OF ANY KIND IN
     58  * RELATION TO ITS USE OR PERFORMANCE.
     59  *
     60  * 6.  If you have a special need for a change in one or more of these
     61  * license conditions, please contact the Author via electronic mail to
     62  *
     63  *     cgd (at) NetBSD.ORG
     64  *
     65  * or via the contact information on
     66  *
     67  *     http://www.NetBSD.ORG/People/Pages/cgd.html
     68  */
     69 
     70 /*
     71  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
     72  * All rights reserved.
     73  *
     74  * Author: Chris G. Demetriou
     75  *
     76  * Permission to use, copy, modify and distribute this software and
     77  * its documentation is hereby granted, provided that both the copyright
     78  * notice and this permission notice appear in all copies of the
     79  * software, derivative works or modified versions, and any portions
     80  * thereof, and that both notices appear in supporting documentation.
     81  *
     82  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     83  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     84  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     85  *
     86  * Carnegie Mellon requests users of this software to return to
     87  *
     88  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     89  *  School of Computer Science
     90  *  Carnegie Mellon University
     91  *  Pittsburgh PA 15213-3890
     92  *
     93  * any improvements or extensions that they make and grant Carnegie the
     94  * rights to redistribute these changes.
     95  */
     96 
     97 /*
     98  * Alpha page table entry.
     99  * Things which are in the VMS PALcode but not in the OSF PALcode
    100  * are marked with "(VMS)".
    101  *
    102  * This information derived from pp. (II) 3-3 - (II) 3-6 and
    103  * (III) 3-3 - (III) 3-5 of the "Alpha Architecture Reference Manual" by
    104  * Richard L. Sites.
    105  */
    106 
    107 /*
    108  * Alpha Page Table Entry
    109  */
    110 
    111 #include <machine/alpha_cpu.h>
    112 
    113 typedef	alpha_pt_entry_t	pt_entry_t;
    114 
    115 #define	PT_ENTRY_NULL	((pt_entry_t *) 0)
    116 #define	PTESHIFT	3			/* pte size == 1 << PTESHIFT */
    117 
    118 #define	PG_V		ALPHA_PTE_VALID
    119 #define	PG_NV		0
    120 #define	PG_FOR		ALPHA_PTE_FAULT_ON_READ
    121 #define	PG_FOW		ALPHA_PTE_FAULT_ON_WRITE
    122 #define	PG_FOE		ALPHA_PTE_FAULT_ON_EXECUTE
    123 #define	PG_ASM		ALPHA_PTE_ASM
    124 #define	PG_GH		ALPHA_PTE_GRANULARITY
    125 #define	PG_KRE		ALPHA_PTE_KR
    126 #define	PG_URE		ALPHA_PTE_UR
    127 #define	PG_KWE		ALPHA_PTE_KW
    128 #define	PG_UWE		ALPHA_PTE_UW
    129 #define	PG_PROT		ALPHA_PTE_PROT
    130 #define	PG_RSVD		0x000000000000cc80	/* Reserved fpr hardware */
    131 #define	PG_WIRED	0x0000000000010000	/* Wired. [SOFTWARE] */
    132 #define	PG_FRAME	ALPHA_PTE_RAME
    133 #define	PG_SHIFT	32
    134 #define	PG_PFNUM(x)	ALPHA_PTE_TO_PFN(x)
    135 
    136 #if 0 /* XXX NOT HERE */
    137 #define	K0SEG_BEGIN	0xfffffc0000000000	/* unmapped, cached */
    138 #define	K0SEG_END	0xfffffe0000000000
    139 #define PHYS_UNCACHED	0x0000000040000000
    140 #endif
    141 
    142 #ifndef _LOCORE
    143 #if 0 /* XXX NOT HERE */
    144 #define	k0segtophys(x)	((vm_offset_t)(x) & 0x00000003ffffffff)
    145 #define	phystok0seg(x)	((vm_offset_t)(x) | K0SEG_BEGIN)
    146 
    147 #define phystouncached(x) ((vm_offset_t)(x) | PHYS_UNCACHED)
    148 #define uncachedtophys(x) ((vm_offset_t)(x) & ~PHYS_UNCACHED)
    149 #endif
    150 
    151 #define	PTEMASK		(NPTEPG - 1)
    152 #define	vatopte(va)	(((va) >> PGSHIFT) & PTEMASK)
    153 #define	vatoste(va)	(((va) >> SEGSHIFT) & PTEMASK)
    154 #define kvtol1pte(va) \
    155 	(((vm_offset_t)(va) >> (PGSHIFT + 2*(PGSHIFT-PTESHIFT))) & PTEMASK)
    156 
    157 #define	vatopa(va) \
    158 	((PG_PFNUM(*kvtopte(va)) << PGSHIFT) | ((vm_offset_t)(va) & PGOFSET))
    159 
    160 #define	ALPHA_STSIZE		((u_long)NBPG)			/* 8k */
    161 #define	ALPHA_MAX_PTSIZE	((u_long)(NPTEPG * NBPG))	/* 8M */
    162 
    163 #ifdef _KERNEL
    164 /*
    165  * Kernel virtual address to Sysmap entry and visa versa.
    166  */
    167 #define	kvtopte(va) \
    168 	(Sysmap + (((vm_offset_t)(va) - VM_MIN_KERNEL_ADDRESS) >> PGSHIFT))
    169 #define	ptetokv(pte) \
    170 	((((pt_entry_t *)(pte) - Sysmap) << PGSHIFT) + VM_MIN_KERNEL_ADDRESS)
    171 
    172 #define loadustp(stpte) {					\
    173 	Lev1map[kvtol1pte(VM_MIN_ADDRESS)] = stpte;		\
    174 	ALPHA_TBIAP();						\
    175 	alpha_pal_imb();					\
    176 }
    177 
    178 extern	pt_entry_t *Lev1map;		/* Alpha Level One page table */
    179 extern	pt_entry_t *Sysmap;		/* kernel pte table */
    180 extern	vm_size_t Sysmapsize;		/* number of pte's in Sysmap */
    181 #endif
    182 #endif
    183