Home | History | Annotate | Line # | Download | only in oea
pte.h revision 1.7
      1  1.7  ross /*	$NetBSD: pte.h,v 1.7 2005/12/27 02:19:27 ross Exp $	*/
      2  1.1  matt 
      3  1.1  matt /*-
      4  1.4  matt  * Copyright (C) 2003 Matt Thomas
      5  1.1  matt  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
      6  1.1  matt  * Copyright (C) 1995, 1996 TooLs GmbH.
      7  1.1  matt  * All rights reserved.
      8  1.1  matt  *
      9  1.1  matt  * Redistribution and use in source and binary forms, with or without
     10  1.1  matt  * modification, are permitted provided that the following conditions
     11  1.1  matt  * are met:
     12  1.1  matt  * 1. Redistributions of source code must retain the above copyright
     13  1.1  matt  *    notice, this list of conditions and the following disclaimer.
     14  1.1  matt  * 2. Redistributions in binary form must reproduce the above copyright
     15  1.1  matt  *    notice, this list of conditions and the following disclaimer in the
     16  1.1  matt  *    documentation and/or other materials provided with the distribution.
     17  1.1  matt  * 3. All advertising materials mentioning features or use of this software
     18  1.1  matt  *    must display the following acknowledgement:
     19  1.1  matt  *	This product includes software developed by TooLs GmbH.
     20  1.1  matt  * 4. The name of TooLs GmbH may not be used to endorse or promote products
     21  1.1  matt  *    derived from this software without specific prior written permission.
     22  1.1  matt  *
     23  1.1  matt  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
     24  1.1  matt  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     25  1.1  matt  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     26  1.1  matt  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     27  1.1  matt  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     28  1.1  matt  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     29  1.1  matt  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     30  1.1  matt  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     31  1.1  matt  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
     32  1.1  matt  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     33  1.1  matt  */
     34  1.1  matt 
     35  1.1  matt #ifndef	_POWERPC_OEA_PTE_H_
     36  1.1  matt #define	_POWERPC_OEA_PTE_H_
     37  1.1  matt 
     38  1.1  matt #include <sys/queue.h>
     39  1.1  matt 
     40  1.1  matt /*
     41  1.1  matt  * Page Table Entries
     42  1.1  matt  */
     43  1.1  matt #ifndef	_LOCORE
     44  1.1  matt struct pte {
     45  1.2  matt 	register_t pte_hi;
     46  1.2  matt 	register_t pte_lo;
     47  1.2  matt };
     48  1.2  matt 
     49  1.2  matt struct pteg {
     50  1.2  matt 	struct pte pt[8];
     51  1.1  matt };
     52  1.1  matt #endif	/* _LOCORE */
     53  1.2  matt 
     54  1.1  matt /* High word: */
     55  1.4  matt #ifdef PPC_OEA64
     56  1.4  matt #define	PTE_VALID	0x00000001
     57  1.4  matt #define	PTE_HID		0x00000002
     58  1.4  matt #define	PTE_API		0x00000f80
     59  1.4  matt #define	PTE_API_SHFT	7
     60  1.4  matt #define	PTE_VSID_SHFT	12
     61  1.4  matt #define	PTE_VSID	(~0xfffL)
     62  1.4  matt #else
     63  1.1  matt #define	PTE_VALID	0x80000000
     64  1.2  matt #define	PTE_VSID	0x7fffff80
     65  1.1  matt #define	PTE_VSID_SHFT	7
     66  1.2  matt #define	PTE_VSID_LEN	24
     67  1.1  matt #define	PTE_HID		0x00000040
     68  1.1  matt #define	PTE_API		0x0000003f
     69  1.2  matt #define	PTE_API_SHFT	0
     70  1.4  matt #endif	/* PPC_OEA64 */
     71  1.4  matt 
     72  1.4  matt 
     73  1.1  matt /* Low word: */
     74  1.4  matt #define	PTE_RPGN	(~0xfffL)
     75  1.1  matt #define	PTE_RPGN_SHFT	12
     76  1.1  matt #define	PTE_REF		0x00000100
     77  1.1  matt #define	PTE_CHG		0x00000080
     78  1.1  matt #define	PTE_W		0x00000040	/* 1 = write-through, 0 = write-back */
     79  1.1  matt #define	PTE_I		0x00000020	/* cache inhibit */
     80  1.1  matt #define	PTE_M		0x00000010	/* memory coherency enable */
     81  1.1  matt #define	PTE_G		0x00000008	/* guarded region (not on 601) */
     82  1.1  matt #define	PTE_WIMG	(PTE_W|PTE_I|PTE_M|PTE_G)
     83  1.1  matt #define	PTE_IG		(PTE_I|PTE_G)
     84  1.1  matt #define	PTE_PP		0x00000003
     85  1.1  matt #define	PTE_SO		0x00000000	/* Super. Only       (U: XX, S: RW) */
     86  1.1  matt #define	PTE_SW		0x00000001	/* Super. Write-Only (U: RO, S: RW) */
     87  1.1  matt #define	PTE_BW		0x00000002	/* Supervisor        (U: RW, S: RW) */
     88  1.1  matt #define	PTE_BR		0x00000003	/* Both Read Only    (U: RO, S: RO) */
     89  1.1  matt #define	PTE_RW		PTE_BW
     90  1.1  matt #define	PTE_RO		PTE_BR
     91  1.1  matt 
     92  1.3   chs #define	PTE_EXEC	0x00000200	/* pseudo bit; page is exec */
     93  1.1  matt 
     94  1.1  matt /*
     95  1.1  matt  * Extract bits from address
     96  1.1  matt  */
     97  1.4  matt #define	ADDR_SR	        (~0x0fffffffL)
     98  1.1  matt #define	ADDR_SR_SHFT	28
     99  1.1  matt #define	ADDR_PIDX	0x0ffff000
    100  1.1  matt #define	ADDR_PIDX_SHFT	12
    101  1.4  matt #ifdef PPC_OEA64
    102  1.4  matt #define	ADDR_API_SHFT	23	/* API is 5 bits */
    103  1.4  matt #else
    104  1.4  matt #define	ADDR_API_SHFT	22	/* API is 6 bits */
    105  1.4  matt #endif /* PPC_OEA64 */
    106  1.1  matt #define	ADDR_POFF	0x00000fff
    107  1.4  matt 
    108  1.4  matt #ifdef PPC_OEA64
    109  1.4  matt /*
    110  1.4  matt  * Segment Table Element
    111  1.4  matt  */
    112  1.4  matt #ifndef	_LOCORE
    113  1.4  matt struct ste {
    114  1.4  matt 	register_t ste_hi;
    115  1.4  matt 	register_t ste_lo;
    116  1.4  matt };
    117  1.4  matt 
    118  1.4  matt struct steg {
    119  1.4  matt 	struct ste st[8];
    120  1.4  matt };
    121  1.4  matt #endif	/* _LOCORE */
    122  1.4  matt 
    123  1.4  matt /* High Word */
    124  1.4  matt #define	STE_VALID	0x00000080
    125  1.4  matt #define	STE_TYPE	0x00000040
    126  1.4  matt #define	STE_SUKEY	0x00000020	/* Super-state protection */
    127  1.4  matt #define	STE_PRKEY	0x00000010	/* User-state protection */
    128  1.4  matt #define	STE_NOEXEC	0x00000008	/* No-execute protection bit */
    129  1.4  matt #define	STE_ESID	(~0x0fffffffL)	/* Effective Segment ID */
    130  1.4  matt #define	STE_ESID_SHFT	28
    131  1.4  matt #define	STE_ESID_MASK	0x0000001f	/* low 5 bits of the ESID */
    132  1.4  matt 
    133  1.4  matt /* Low Word */
    134  1.4  matt #define	STE_VSID	(~0xfffL)	/* Virtual Segment ID */
    135  1.4  matt #define	STE_VSID_SHFT	12
    136  1.7  ross #define	STE_VSID_WIDTH	52
    137  1.5  matt 
    138  1.5  matt #define	SR_VSID_SHFT	STE_VSID_SHFT	/* compatibility with PPC_OEA */
    139  1.5  matt #define	SR_VSID_WIDTH	STE_VSID_WIDTH	/* compatibility with PPC_OEA */
    140  1.4  matt 
    141  1.4  matt #define	SR_KEY_LEN	9		/* 64 groups of 8 segment entries */
    142  1.4  matt #else	/* !defined(PPC_OEA64) */
    143  1.2  matt 
    144  1.2  matt /*
    145  1.2  matt  * Segment registers
    146  1.2  matt  */
    147  1.4  matt #define	SR_KEY_LEN	4		/* 16 segment registers */
    148  1.2  matt #define	SR_TYPE		0x80000000	/* T=0 selects memory format */
    149  1.2  matt #define	SR_SUKEY	0x40000000	/* Supervisor protection key */
    150  1.2  matt #define	SR_PRKEY	0x20000000	/* User protection key */
    151  1.2  matt #define	SR_NOEXEC	0x10000000	/* No-execute protection bit */
    152  1.5  matt #define	SR_VSID_SHFT	0		/* Starts at LSB */
    153  1.5  matt #define	SR_VSID_WIDTH	24		/* Goes for 24 bits */
    154  1.4  matt 
    155  1.4  matt #endif	/* PPC_OEA64 */
    156  1.5  matt 
    157  1.5  matt 					/* Virtual segment ID */
    158  1.5  matt #define	SR_VSID		(((1L << SR_VSID_WIDTH) - 1) << SR_VSID_SHFT)
    159  1.1  matt 
    160  1.1  matt #endif	/* _POWERPC_OEA_PTE_H_ */
    161