Home | History | Annotate | Line # | Download | only in include
pte3x.h revision 1.2
      1 /*	$NetBSD: pte3x.h,v 1.2 1997/01/16 21:48:32 gwr Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1997 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Jeremy Cooper.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *        This product includes software developed by the NetBSD
     21  *        Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 /*
     40  * This file should contain the machine-dependent details about
     41  * Page Table Entries (PTEs) and related things.  For example,
     42  * things that depend on the MMU configuration (number of levels
     43  * in the translation structure) should go here.
     44  */
     45 
     46 #ifndef _MACHINE_PTE_H
     47 #define _MACHINE_PTE_H
     48 
     49 #include <machine/mc68851.h>
     50 
     51 #define OBMEM	0
     52 #define OBIO 	1
     53 #define VME_D16	2
     54 #define VME_D32	3
     55 #define PG_TYPE_SHIFT 26
     56 
     57 #define MAKE_PGTYPE(x) ((x) << PG_TYPE_SHIFT)
     58 #define PG_PGNUM(pte) (pte & PG_FRAME)
     59 #define PG_PA(pte) ((pte & PG_FRAME) <<PGSHIFT)
     60 
     61 #define	PGT_MASK	MAKE_PGTYPE(3)
     62 #define	PGT_OBMEM	MAKE_PGTYPE(OBMEM)		/* onboard memory */
     63 #define	PGT_OBIO	MAKE_PGTYPE(OBIO)		/* onboard I/O */
     64 #define	PGT_VME_D16	MAKE_PGTYPE(VME_D16)	/* VMEbus 16-bit data */
     65 #define	PGT_VME_D32	MAKE_PGTYPE(VME_D32)	/* VMEbus 32-bit data */
     66 
     67 #define VA_SEGNUM(x)	((u_int)(x) >> SEGSHIFT)
     68 
     69 #define VA_PTE_NUM_SHIFT  13
     70 #define VA_PTE_NUM_MASK (0xF << VA_PTE_NUM_SHIFT)
     71 #define VA_PTE_NUM(va) ((va & VA_PTE_NUM_MASK) >> VA_PTE_NUM_SHIFT)
     72 
     73 #define PA_PGNUM(pa) ((unsigned)pa >> PGSHIFT)
     74 
     75 /*
     76  * Mach derived conversion macros
     77  */
     78 #define sun3x_round_seg(x)	((((unsigned)(x)) + SEGOFSET) & ~SEGOFSET)
     79 #define sun3x_trunc_seg(x)	((unsigned)(x) & ~SEGOFSET)
     80 #define sun3x_btos(x)		((unsigned)(x) >> SEGSHIFT)
     81 #define sun3x_stob(x)		((unsigned)(x) << SEGSHIFT)
     82 
     83 #define sun3x_round_page(x)	((((unsigned)(x)) + PGOFSET) & ~PGOFSET)
     84 #define sun3x_trunc_page(x)	((unsigned)(x) & ~PGOFSET)
     85 #define sun3x_btop(x)		((unsigned)(x) >> PGSHIFT)
     86 #define sun3x_ptob(x)		((unsigned)(x) << PGSHIFT)
     87 
     88 #define	sun3x_round_up_page(x)\
     89 	((unsigned long) ((x) + MMU_PAGE_SIZE - 1) & MMU_PAGE_MASK)
     90 
     91 /* XXX - Not sure about these.  Use pmap_enter_kernel() instead? */
     92 #if 1 /* XXX */
     93 /* defined in pmap.c */
     94 vm_offset_t get_pte __P((vm_offset_t va));
     95 void set_pte __P((vm_offset_t, vm_offset_t));
     96 #endif /* XXX */
     97 
     98 #endif /* !_MACHINE_PTE_H*/
     99