Home | History | Annotate | Line # | Download | only in include
pte.h revision 1.3.4.1
      1      1.1      cgd /*-
      2      1.1      cgd  * Copyright (c) 1990 The Regents of the University of California.
      3      1.1      cgd  * All rights reserved.
      4      1.1      cgd  *
      5      1.1      cgd  * This code is derived from software contributed to Berkeley by
      6      1.1      cgd  * William Jolitz.
      7      1.1      cgd  *
      8      1.1      cgd  * Redistribution and use in source and binary forms, with or without
      9      1.1      cgd  * modification, are permitted provided that the following conditions
     10      1.1      cgd  * are met:
     11      1.1      cgd  * 1. Redistributions of source code must retain the above copyright
     12      1.1      cgd  *    notice, this list of conditions and the following disclaimer.
     13      1.1      cgd  * 2. Redistributions in binary form must reproduce the above copyright
     14      1.1      cgd  *    notice, this list of conditions and the following disclaimer in the
     15      1.1      cgd  *    documentation and/or other materials provided with the distribution.
     16      1.1      cgd  * 3. All advertising materials mentioning features or use of this software
     17      1.1      cgd  *    must display the following acknowledgement:
     18      1.1      cgd  *	This product includes software developed by the University of
     19      1.1      cgd  *	California, Berkeley and its contributors.
     20      1.1      cgd  * 4. Neither the name of the University nor the names of its contributors
     21      1.1      cgd  *    may be used to endorse or promote products derived from this software
     22      1.1      cgd  *    without specific prior written permission.
     23      1.1      cgd  *
     24      1.1      cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     25      1.1      cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     26      1.1      cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     27      1.1      cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     28      1.1      cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     29      1.1      cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     30      1.1      cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     31      1.1      cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     32      1.1      cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     33      1.1      cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     34      1.1      cgd  * SUCH DAMAGE.
     35      1.1      cgd  *
     36      1.2      cgd  *	from: @(#)pte.h	5.5 (Berkeley) 5/9/91
     37  1.3.4.1  mycroft  *	$Id: pte.h,v 1.3.4.1 1993/10/15 13:12:49 mycroft Exp $
     38      1.1      cgd  */
     39      1.1      cgd 
     40      1.1      cgd /*
     41      1.1      cgd  * 386 page table entry and page table directory
     42      1.1      cgd  * W.Jolitz, 8/89
     43      1.1      cgd  *
     44      1.1      cgd  * There are two major kinds of pte's: those which have ever existed (and are
     45      1.1      cgd  * thus either now in core or on the swap device), and those which have
     46      1.1      cgd  * never existed, but which will be filled on demand at first reference.
     47      1.1      cgd  * There is a structure describing each.  There is also an ancillary
     48      1.1      cgd  * structure used in page clustering.
     49      1.1      cgd  */
     50      1.1      cgd 
     51      1.3   andrew #ifndef _I386_PTE_H_
     52      1.3   andrew #define _I386_PTE_H_
     53      1.3   andrew 
     54  1.3.4.1  mycroft #define	PDSHIFT		22		/* LOG2(NBPDR) */
     55  1.3.4.1  mycroft #define	NBPD		(1 << PDSHIFT)	/* bytes/page dir */
     56  1.3.4.1  mycroft #define	PDOFSET		(NBPD-1)	/* byte offset into page dir */
     57  1.3.4.1  mycroft #define	NPTEPD		(NBPD / NBPG)
     58  1.3.4.1  mycroft 
     59      1.1      cgd #ifndef LOCORE
     60  1.3.4.1  mycroft 
     61      1.1      cgd struct pde
     62      1.1      cgd {
     63      1.1      cgd unsigned int
     64      1.1      cgd 		pd_v:1,			/* valid bit */
     65      1.1      cgd 		pd_prot:2,		/* access control */
     66      1.1      cgd 		pd_mbz1:2,		/* reserved, must be zero */
     67      1.1      cgd 		pd_u:1,			/* hardware maintained 'used' bit */
     68      1.1      cgd 		:1,			/* not used */
     69      1.1      cgd 		pd_mbz2:2,		/* reserved, must be zero */
     70      1.1      cgd 		:3,			/* reserved for software */
     71      1.1      cgd 		pd_pfnum:20;		/* physical page frame number of pte's*/
     72      1.1      cgd };
     73  1.3.4.1  mycroft 
     74      1.1      cgd struct pte
     75      1.1      cgd {
     76      1.1      cgd unsigned int
     77      1.1      cgd 		pg_v:1,			/* valid bit */
     78      1.1      cgd 		pg_prot:2,		/* access control */
     79      1.1      cgd 		pg_mbz1:2,		/* reserved, must be zero */
     80      1.1      cgd 		pg_u:1,			/* hardware maintained 'used' bit */
     81      1.1      cgd 		pg_m:1,			/* hardware maintained modified bit */
     82      1.1      cgd 		pg_mbz2:2,		/* reserved, must be zero */
     83  1.3.4.1  mycroft 		pg_w:1,			/* is wired */
     84      1.1      cgd 		:1,			/* must write back to swap (unused) */
     85      1.1      cgd 		pg_nc:1,		/* 'uncacheable page' bit */
     86      1.1      cgd 		pg_pfnum:20;		/* physical page frame number */
     87      1.1      cgd };
     88  1.3.4.1  mycroft 
     89      1.1      cgd struct hpte
     90      1.1      cgd {
     91      1.1      cgd unsigned int
     92      1.1      cgd 		pg_high:12,		/* special for clustering */
     93      1.1      cgd 		pg_pfnum:20;
     94      1.1      cgd };
     95  1.3.4.1  mycroft 
     96      1.1      cgd struct fpte
     97      1.1      cgd {
     98      1.1      cgd unsigned int
     99      1.1      cgd 		pg_v:1,			/* valid bit */
    100      1.1      cgd 		pg_prot:2,		/* access control */
    101      1.1      cgd 		:5,
    102      1.1      cgd 		pg_fileno:1,		/* file mapped from or TEXT or ZERO */
    103      1.1      cgd 		pg_fod:1,		/* is fill on demand (=1) */
    104      1.1      cgd 		pg_blkno:22;		/* file system block number */
    105      1.1      cgd };
    106  1.3.4.1  mycroft 
    107  1.3.4.1  mycroft typedef struct pde	pd_entry_t;	/* page directory entry */
    108  1.3.4.1  mycroft typedef struct pte	pt_entry_t;	/* Mach page table entry */
    109  1.3.4.1  mycroft 
    110      1.1      cgd #endif
    111      1.1      cgd 
    112      1.1      cgd #define	PD_MASK		0xffc00000	/* page directory address bits */
    113  1.3.4.1  mycroft #define	PT_MASK		0x003ff000	/* page table address bits */
    114      1.1      cgd 
    115      1.1      cgd #define	PG_V		0x00000001
    116  1.3.4.1  mycroft #define	PG_RO		0x00000000
    117  1.3.4.1  mycroft #define	PG_RW		0x00000002
    118  1.3.4.1  mycroft #define	PG_u		0x00000004
    119      1.1      cgd #define	PG_PROT		0x00000006 /* all protection bits . */
    120      1.1      cgd #define	PG_FOD		0x00000200
    121      1.1      cgd #define	PG_SWAPM	0x00000400
    122  1.3.4.1  mycroft #define PG_W            0x00000200
    123      1.1      cgd #define PG_N		0x00000800 /* Non-cacheable */
    124      1.1      cgd #define	PG_M		0x00000040
    125      1.1      cgd #define PG_U		0x00000020 /* not currently used */
    126      1.1      cgd #define	PG_FRAME	0xfffff000
    127      1.1      cgd 
    128      1.1      cgd #define	PG_FZERO	0
    129      1.1      cgd #define	PG_FTEXT	1
    130      1.1      cgd #define	PG_FMAX		(PG_FTEXT)
    131      1.1      cgd 
    132      1.1      cgd #define	PG_NOACC	0
    133      1.1      cgd #define	PG_KR		0x00000000
    134      1.1      cgd #define	PG_KW		0x00000002
    135      1.1      cgd #define	PG_URKR		0x00000004
    136      1.1      cgd #define	PG_URKW		0x00000004
    137      1.1      cgd #define	PG_UW		0x00000006
    138      1.1      cgd 
    139      1.1      cgd /*
    140      1.1      cgd  * Page Protection Exception bits
    141      1.1      cgd  */
    142      1.1      cgd 
    143      1.1      cgd #define PGEX_P		0x01	/* Protection violation vs. not present */
    144      1.1      cgd #define PGEX_W		0x02	/* during a Write cycle */
    145      1.1      cgd #define PGEX_U		0x04	/* access from User mode (UPL) */
    146      1.1      cgd 
    147      1.1      cgd /*
    148      1.1      cgd  * Pte related macros
    149      1.1      cgd  */
    150      1.1      cgd #define	dirty(pte)	((pte)->pg_m)
    151      1.1      cgd 
    152      1.1      cgd #ifndef LOCORE
    153      1.1      cgd #ifdef KERNEL
    154      1.1      cgd /* utilities defined in pmap.c */
    155      1.1      cgd extern	struct pte *Sysmap;
    156      1.1      cgd #endif
    157      1.1      cgd #endif
    158      1.3   andrew 
    159      1.3   andrew #endif /* _I386_PTE_H_ */
    160