Home | History | Annotate | Line # | Download | only in include
pmap.h revision 1.2.2.2
      1  1.2.2.2  eeh /*	$NetBSD: pmap.h,v 1.2.2.2 1998/08/02 00:06:49 eeh Exp $	*/
      2      1.1  eeh 
      3      1.1  eeh /*-
      4      1.1  eeh  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
      5      1.1  eeh  * Copyright (C) 1995, 1996 TooLs GmbH.
      6      1.1  eeh  * All rights reserved.
      7      1.1  eeh  *
      8      1.1  eeh  * Redistribution and use in source and binary forms, with or without
      9      1.1  eeh  * modification, are permitted provided that the following conditions
     10      1.1  eeh  * are met:
     11      1.1  eeh  * 1. Redistributions of source code must retain the above copyright
     12      1.1  eeh  *    notice, this list of conditions and the following disclaimer.
     13      1.1  eeh  * 2. Redistributions in binary form must reproduce the above copyright
     14      1.1  eeh  *    notice, this list of conditions and the following disclaimer in the
     15      1.1  eeh  *    documentation and/or other materials provided with the distribution.
     16      1.1  eeh  * 3. All advertising materials mentioning features or use of this software
     17      1.1  eeh  *    must display the following acknowledgement:
     18      1.1  eeh  *	This product includes software developed by TooLs GmbH.
     19      1.1  eeh  * 4. The name of TooLs GmbH may not be used to endorse or promote products
     20      1.1  eeh  *    derived from this software without specific prior written permission.
     21      1.1  eeh  *
     22      1.1  eeh  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
     23      1.1  eeh  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24      1.1  eeh  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25      1.1  eeh  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     26      1.1  eeh  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     27      1.1  eeh  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     28      1.1  eeh  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     29      1.1  eeh  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     30      1.1  eeh  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
     31      1.1  eeh  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32      1.1  eeh  */
     33      1.1  eeh 
     34      1.1  eeh #ifndef	_MACHINE_PMAP_H_
     35      1.1  eeh #define	_MACHINE_PMAP_H_
     36      1.1  eeh 
     37      1.1  eeh #ifndef _LOCORE
     38      1.1  eeh #include <machine/pte.h>
     39      1.1  eeh #include <sys/queue.h>
     40      1.1  eeh #endif
     41      1.1  eeh 
     42      1.1  eeh /*
     43      1.1  eeh  * This scheme uses 2-level page tables.
     44      1.1  eeh  *
     45      1.1  eeh  * While we're still in 32-bit mode we do the following:
     46      1.1  eeh  *
     47      1.1  eeh  *   offset:						13 bits
     48      1.1  eeh  * 1st level: 1024 64-bit TTEs in an 8K page for	10 bits
     49      1.1  eeh  * 2nd level: 512 32-bit pointers in the pmap for 	 9 bits
     50      1.1  eeh  *							-------
     51      1.1  eeh  * total:						32 bits
     52      1.1  eeh  *
     53      1.1  eeh  * In 64-bit mode this should be changed as follows
     54      1.1  eeh  *
     55      1.1  eeh  *   offset:						13 bits
     56      1.1  eeh  * 1st level: 1024 64-bit TTEs in an 8K page for	10 bits
     57      1.1  eeh  * 2nd level: 1024 64-bit pointers in an 8K page for 	10 bits
     58      1.1  eeh  * 3rd level: 128 64-bit pointers in the pmap for 	 7 bits
     59      1.1  eeh  *							-------
     60      1.1  eeh  * total:						40 bits
     61      1.1  eeh  */
     62      1.1  eeh 
     63      1.1  eeh #define PTSZ	(NBPG/8)
     64      1.1  eeh #define STSZ	(1<<9)
     65      1.1  eeh 
     66      1.1  eeh #define PTSHIFT		(13)
     67      1.1  eeh #define STSHIFT		(10+PTSHIFT)
     68      1.1  eeh 
     69      1.1  eeh #define PTMASK		(PTSZ-1)
     70      1.1  eeh #define STMASK		(STSZ-1)
     71      1.1  eeh 
     72      1.1  eeh #ifndef _LOCORE
     73      1.1  eeh 
     74      1.1  eeh /*
     75      1.1  eeh  * Support for big page sizes.  This maps the page size to the
     76      1.1  eeh  * page bits.
     77      1.1  eeh  */
     78      1.1  eeh struct page_size_map {
     79      1.1  eeh 	u_int64_t mask;
     80      1.1  eeh 	u_int64_t code;
     81      1.1  eeh #ifdef DEBUG
     82      1.1  eeh 	u_int64_t use;
     83      1.1  eeh #endif
     84      1.1  eeh };
     85      1.1  eeh extern struct page_size_map page_size_map[];
     86      1.1  eeh 
     87      1.1  eeh /*
     88      1.1  eeh  * Pmap stuff
     89      1.1  eeh  */
     90      1.1  eeh 
     91      1.1  eeh #define va_to_seg(v)	(((v)>>STSHIFT)&STMASK)
     92      1.1  eeh #define va_to_pte(v)	(((v)>>PTSHIFT)&PTMASK)
     93      1.1  eeh 
     94      1.1  eeh /* typedef union sun4u_data ptab[PTSZ]; */
     95      1.1  eeh 
     96      1.1  eeh struct pmap {
     97      1.1  eeh 	int pm_ctx;		/* Current context */
     98      1.1  eeh 	int pm_refs;		/* ref count */
     99  1.2.2.1  eeh 	paddr_t pm_physaddr;	/* physical address of pm_segs */
    100      1.1  eeh 	union sun4u_data* pm_segs[STSZ];
    101      1.1  eeh };
    102      1.1  eeh 
    103      1.1  eeh /*
    104      1.1  eeh  * This comes from the PROM and is used to map prom entries.
    105      1.1  eeh  */
    106      1.1  eeh struct prom_map {
    107      1.1  eeh 	u_int64_t	vstart;
    108      1.1  eeh 	u_int64_t	vsize;
    109      1.1  eeh /*	struct sun4u_data	tte;*/
    110      1.1  eeh 	u_int64_t	tte;
    111      1.1  eeh };
    112      1.1  eeh 
    113      1.1  eeh #define PMAP_NC		1	/* Set the E bit in the page */
    114      1.2  eeh #define PMAP_NVC	2	/* Don't enable the virtual cache */
    115  1.2.2.2  eeh #define PMAP_LITTLE	3	/* Map in little endian mode */
    116      1.1  eeh /* If these bits are different in va's to the same PA then there is an aliasing in the d$ */
    117      1.1  eeh #define VA_ALIAS_MASK   (1<<14)
    118      1.1  eeh 
    119      1.1  eeh typedef	struct pmap *pmap_t;
    120      1.1  eeh 
    121      1.1  eeh /*
    122      1.1  eeh  * Encode IO space for pmap_enter()
    123      1.1  eeh  *
    124      1.1  eeh  * Since sun4u machines don't have separate IO spaces, this is a noop.
    125      1.1  eeh  */
    126      1.1  eeh #define PMAP_IOENC(io)	0
    127      1.1  eeh 
    128      1.1  eeh #ifdef	_KERNEL
    129      1.1  eeh extern struct pmap kernel_pmap_;
    130      1.1  eeh #define	pmap_kernel()	(&kernel_pmap_)
    131      1.1  eeh 
    132  1.2.2.1  eeh void pmap_clear_modify __P((paddr_t pa));
    133  1.2.2.1  eeh void pmap_clear_reference __P((paddr_t pa));
    134  1.2.2.1  eeh int pmap_is_modified __P((paddr_t pa));
    135  1.2.2.1  eeh int pmap_is_referenced __P((paddr_t pa));
    136      1.1  eeh int pmap_count_res __P((pmap_t pmap));
    137  1.2.2.1  eeh /* int pmap_change_wiring __P((pmap_t pm, vaddr_t va, boolean_t wired)); */
    138      1.1  eeh #define pmap_resident_count(pm)		pmap_count_res((pm))
    139  1.2.2.2  eeh #define	pmap_phys_address(x)		(((x)))
    140      1.1  eeh 
    141      1.1  eeh void pmap_bootstrap __P((u_int kernelstart, u_int kernelend, u_int numctx));
    142      1.1  eeh 
    143      1.1  eeh /* This needs to be implemented when we get a kernel map */
    144  1.2.2.1  eeh void pmap_changeprot __P((pmap_t pmap, vaddr_t start, vm_prot_t prot, int size));
    145      1.1  eeh 
    146      1.1  eeh /* SPARC specific? */
    147      1.1  eeh void		pmap_redzone __P((void));
    148      1.1  eeh int             pmap_dumpsize __P((void));
    149      1.1  eeh int             pmap_dumpmmu __P((int (*)__P((dev_t, daddr_t, caddr_t, size_t)),
    150      1.1  eeh                                  daddr_t));
    151  1.2.2.1  eeh int		pmap_pa_exists __P((paddr_t));
    152      1.1  eeh struct user;
    153      1.1  eeh void		switchexit __P((vm_map_t, struct user *, int));
    154      1.1  eeh 
    155      1.1  eeh /* SPARC64 specific */
    156      1.1  eeh int	ctx_alloc __P((struct pmap*));
    157      1.1  eeh void	ctx_free __P((struct pmap*));
    158  1.2.2.1  eeh void	pmap_enter_phys __P((pmap_t, vaddr_t, u_int64_t, u_int64_t, vm_prot_t, boolean_t));
    159      1.1  eeh 
    160      1.1  eeh 
    161      1.1  eeh #endif	/* _KERNEL */
    162      1.1  eeh #endif	/* _LOCORE */
    163      1.1  eeh #endif	/* _MACHINE_PMAP_H_ */
    164