Home | History | Annotate | Line # | Download | only in include
pmap.h revision 1.10
      1 /*	$NetBSD: pmap.h,v 1.10 1994/10/26 09:10:59 cgd Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1993 Adam Glass
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *	This product includes software developed by Adam Glass.
     18  * 4. The name of the Author may not be used to endorse or promote products
     19  *    derived from this software without specific prior written permission.
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY Adam Glass ``AS IS'' AND
     22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     31  * SUCH DAMAGE.
     32  */
     33 
     34 #ifndef	_PMAP_MACHINE_
     35 #define	_PMAP_MACHINE_
     36 
     37 #include <sys/queue.h>
     38 
     39 /*
     40  * Pmap stuff
     41  * [some ideas borrowed from torek, but no code]
     42  */
     43 
     44 struct context_state {
     45 	TAILQ_ENTRY(context_state) context_link;
     46 	int            context_num;
     47 	struct pmap   *context_upmap;
     48 };
     49 
     50 typedef struct context_state *context_t;
     51 
     52 struct pmap {
     53 	int	                pm_refcount;	/* pmap reference count */
     54 	simple_lock_data_t      pm_lock;	/* lock on pmap */
     55 	struct pmap_statistics	pm_stats;	/* pmap statistics */
     56 	context_t               pm_context;     /* context if any */
     57 	int                     pm_version;
     58 	unsigned char           *pm_segmap;
     59 };
     60 
     61 typedef struct pmap *pmap_t;
     62 
     63 extern pmap_t kernel_pmap;
     64 
     65 #define PMEGQ_FREE     0
     66 #define PMEGQ_INACTIVE 1
     67 #define PMEGQ_ACTIVE   2
     68 #define PMEGQ_KERNEL   3
     69 #define PMEGQ_NONE     4
     70 
     71 struct pmeg_state {
     72 	TAILQ_ENTRY(pmeg_state) pmeg_link;
     73 	int            pmeg_index;
     74 	pmap_t         pmeg_owner;
     75 	int            pmeg_owner_version;
     76 	vm_offset_t    pmeg_va;
     77 	int            pmeg_wired_count;
     78 	int            pmeg_reserved;
     79 	int            pmeg_vpages;
     80 	int            pmeg_qstate;
     81 };
     82 
     83 typedef struct pmeg_state *pmeg_t;
     84 
     85 #define PMAP_ACTIVATE(pmap, pcbp, iscurproc) \
     86       pmap_activate(pmap, pcbp)
     87 #define PMAP_DEACTIVATE(pmap, pcbp) \
     88       pmap_deactivate(pmap, pcbp)
     89 
     90 #define	pmap_kernel()			(kernel_pmap)
     91 
     92 /* like the sparc port, use the lower bits of a pa which must be page
     93  *  aligned anyway to pass memtype, caching information.
     94  */
     95 #define PMAP_MMEM      0x0
     96 #define PMAP_OBIO      0x1
     97 #define PMAP_VME16D    0x2
     98 #define PMAP_VME32D    0x3
     99 #define PMAP_MEMMASK   0x3
    100 #define PMAP_NC        0x4
    101 #define PMAP_SPECMASK  0x7
    102 
    103 extern vm_offset_t virtual_avail, virtual_end;
    104 extern vm_offset_t avail_start, avail_end;
    105 
    106 #endif	_PMAP_MACHINE_
    107