Home | History | Annotate | Line # | Download | only in oea
      1  1.10      rin /*	$NetBSD: pte.h,v 1.10 2020/07/06 08:17:01 rin 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.9  garbled #if defined(PMAP_OEA64) || defined(PMAP_OEA64_BRIDGE)
     45   1.8  sanjayl struct pte {
     46   1.8  sanjayl 	register64_t pte_hi;
     47   1.8  sanjayl 	register64_t pte_lo;
     48   1.8  sanjayl };
     49  1.10      rin #else	/* PMAP_OEA */
     50   1.1     matt struct pte {
     51   1.2     matt 	register_t pte_hi;
     52   1.2     matt 	register_t pte_lo;
     53   1.2     matt };
     54   1.8  sanjayl #endif
     55   1.2     matt 
     56   1.2     matt struct pteg {
     57   1.2     matt 	struct pte pt[8];
     58   1.1     matt };
     59   1.1     matt #endif	/* _LOCORE */
     60   1.2     matt 
     61   1.1     matt /* High word: */
     62   1.9  garbled #if defined (PMAP_OEA64)
     63   1.4     matt #define	PTE_VALID	0x00000001
     64   1.4     matt #define	PTE_HID		0x00000002
     65   1.4     matt #define	PTE_API		0x00000f80
     66   1.4     matt #define	PTE_API_SHFT	7
     67   1.4     matt #define	PTE_VSID_SHFT	12
     68   1.4     matt #define	PTE_VSID	(~0xfffL)
     69   1.9  garbled #elif defined (PMAP_OEA64_BRIDGE)
     70   1.8  sanjayl #define	PTE_VALID	0x00000001
     71   1.8  sanjayl #define	PTE_HID		0x00000002
     72   1.8  sanjayl #define	PTE_API		0x00000f80
     73   1.8  sanjayl #define	PTE_API_SHFT	7
     74   1.8  sanjayl #define	PTE_VSID_SHFT	12
     75   1.8  sanjayl #define	PTE_VSID	(~0xfffULL)
     76   1.4     matt #else
     77   1.1     matt #define	PTE_VALID	0x80000000
     78   1.2     matt #define	PTE_VSID	0x7fffff80
     79   1.1     matt #define	PTE_VSID_SHFT	7
     80   1.2     matt #define	PTE_VSID_LEN	24
     81   1.1     matt #define	PTE_HID		0x00000040
     82   1.1     matt #define	PTE_API		0x0000003f
     83   1.2     matt #define	PTE_API_SHFT	0
     84   1.9  garbled #endif	/* PMAP_OEA64 */
     85   1.4     matt 
     86   1.4     matt 
     87   1.1     matt /* Low word: */
     88   1.9  garbled #if defined (PMAP_OEA64_BRIDGE)
     89   1.9  garbled #define	PTE_RPGN	(~0xfffULL)
     90   1.9  garbled #else
     91   1.8  sanjayl #define	PTE_RPGN	(~0xfffUL)
     92   1.8  sanjayl #endif
     93   1.1     matt #define	PTE_RPGN_SHFT	12
     94   1.1     matt #define	PTE_REF		0x00000100
     95   1.1     matt #define	PTE_CHG		0x00000080
     96   1.1     matt #define	PTE_W		0x00000040	/* 1 = write-through, 0 = write-back */
     97   1.1     matt #define	PTE_I		0x00000020	/* cache inhibit */
     98   1.1     matt #define	PTE_M		0x00000010	/* memory coherency enable */
     99   1.1     matt #define	PTE_G		0x00000008	/* guarded region (not on 601) */
    100   1.1     matt #define	PTE_WIMG	(PTE_W|PTE_I|PTE_M|PTE_G)
    101   1.1     matt #define	PTE_IG		(PTE_I|PTE_G)
    102   1.1     matt #define	PTE_PP		0x00000003
    103   1.1     matt #define	PTE_SO		0x00000000	/* Super. Only       (U: XX, S: RW) */
    104   1.1     matt #define	PTE_SW		0x00000001	/* Super. Write-Only (U: RO, S: RW) */
    105   1.1     matt #define	PTE_BW		0x00000002	/* Supervisor        (U: RW, S: RW) */
    106   1.1     matt #define	PTE_BR		0x00000003	/* Both Read Only    (U: RO, S: RO) */
    107   1.1     matt #define	PTE_RW		PTE_BW
    108   1.1     matt #define	PTE_RO		PTE_BR
    109   1.1     matt 
    110   1.3      chs #define	PTE_EXEC	0x00000200	/* pseudo bit; page is exec */
    111   1.1     matt 
    112   1.1     matt /*
    113   1.1     matt  * Extract bits from address
    114   1.1     matt  */
    115   1.4     matt #define	ADDR_SR	        (~0x0fffffffL)
    116   1.1     matt #define	ADDR_SR_SHFT	28
    117   1.1     matt #define	ADDR_PIDX	0x0ffff000
    118   1.1     matt #define	ADDR_PIDX_SHFT	12
    119   1.9  garbled #if defined (PMAP_OEA64) || defined (PMAP_OEA64_BRIDGE)
    120   1.4     matt #define	ADDR_API_SHFT	23	/* API is 5 bits */
    121   1.4     matt #else
    122   1.4     matt #define	ADDR_API_SHFT	22	/* API is 6 bits */
    123   1.9  garbled #endif /* PMAP_OEA64 */
    124   1.1     matt #define	ADDR_POFF	0x00000fff
    125   1.4     matt 
    126   1.9  garbled #ifdef PMAP_OEA64
    127   1.4     matt /*
    128   1.4     matt  * Segment Table Element
    129   1.4     matt  */
    130   1.4     matt #ifndef	_LOCORE
    131   1.4     matt struct ste {
    132   1.4     matt 	register_t ste_hi;
    133   1.4     matt 	register_t ste_lo;
    134   1.4     matt };
    135   1.4     matt 
    136   1.4     matt struct steg {
    137   1.4     matt 	struct ste st[8];
    138   1.4     matt };
    139   1.4     matt #endif	/* _LOCORE */
    140   1.4     matt 
    141   1.4     matt /* High Word */
    142   1.4     matt #define	STE_VALID	0x00000080
    143   1.4     matt #define	STE_TYPE	0x00000040
    144   1.4     matt #define	STE_SUKEY	0x00000020	/* Super-state protection */
    145   1.4     matt #define	STE_PRKEY	0x00000010	/* User-state protection */
    146   1.4     matt #define	STE_NOEXEC	0x00000008	/* No-execute protection bit */
    147   1.4     matt #define	STE_ESID	(~0x0fffffffL)	/* Effective Segment ID */
    148   1.4     matt #define	STE_ESID_SHFT	28
    149   1.4     matt #define	STE_ESID_MASK	0x0000001f	/* low 5 bits of the ESID */
    150   1.4     matt 
    151   1.4     matt /* Low Word */
    152   1.4     matt #define	STE_VSID	(~0xfffL)	/* Virtual Segment ID */
    153   1.4     matt #define	STE_VSID_SHFT	12
    154   1.7     ross #define	STE_VSID_WIDTH	52
    155   1.5     matt 
    156   1.5     matt #define	SR_VSID_SHFT	STE_VSID_SHFT	/* compatibility with PPC_OEA */
    157   1.5     matt #define	SR_VSID_WIDTH	STE_VSID_WIDTH	/* compatibility with PPC_OEA */
    158   1.4     matt 
    159   1.4     matt #define	SR_KEY_LEN	9		/* 64 groups of 8 segment entries */
    160   1.9  garbled #else	/* !defined(PMAP_OEA64) */
    161   1.2     matt 
    162   1.2     matt /*
    163   1.2     matt  * Segment registers
    164   1.2     matt  */
    165   1.4     matt #define	SR_KEY_LEN	4		/* 16 segment registers */
    166   1.2     matt #define	SR_TYPE		0x80000000	/* T=0 selects memory format */
    167   1.2     matt #define	SR_SUKEY	0x40000000	/* Supervisor protection key */
    168   1.2     matt #define	SR_PRKEY	0x20000000	/* User protection key */
    169   1.2     matt #define	SR_NOEXEC	0x10000000	/* No-execute protection bit */
    170   1.5     matt #define	SR_VSID_SHFT	0		/* Starts at LSB */
    171   1.5     matt #define	SR_VSID_WIDTH	24		/* Goes for 24 bits */
    172   1.4     matt 
    173   1.9  garbled #endif	/* PMAP_OEA64 */
    174   1.5     matt 
    175   1.5     matt 					/* Virtual segment ID */
    176   1.5     matt #define	SR_VSID		(((1L << SR_VSID_WIDTH) - 1) << SR_VSID_SHFT)
    177   1.1     matt 
    178   1.1     matt #endif	/* _POWERPC_OEA_PTE_H_ */
    179