[BACK]Return to pmap.h CVS log [TXT][DIR] Up to [local] / sys / arch / vax / include

Annotation of sys/arch/vax/include/pmap.h, Revision 1.1

1.1     ! nbrk        1: /*      $OpenBSD: pmap.h,v 1.28 2007/04/22 10:05:51 miod Exp $     */
        !             2: /*     $NetBSD: pmap.h,v 1.37 1999/08/01 13:48:07 ragge Exp $     */
        !             3:
        !             4: /*
        !             5:  * Copyright (c) 1987 Carnegie-Mellon University
        !             6:  * Copyright (c) 1991 Regents of the University of California.
        !             7:  * All rights reserved.
        !             8:  *
        !             9:  * Changed for the VAX port. /IC
        !            10:  *
        !            11:  * This code is derived from software contributed to Berkeley by
        !            12:  * the Systems Programming Group of the University of Utah Computer
        !            13:  * Science Department.
        !            14:  *
        !            15:  * Redistribution and use in source and binary forms, with or without
        !            16:  * modification, are permitted provided that the following conditions
        !            17:  * are met:
        !            18:  * 1. Redistributions of source code must retain the above copyright
        !            19:  *    notice, this list of conditions and the following disclaimer.
        !            20:  * 2. Redistributions in binary form must reproduce the above copyright
        !            21:  *    notice, this list of conditions and the following disclaimer in the
        !            22:  *    documentation and/or other materials provided with the distribution.
        !            23:  * 3. Neither the name of the University nor the names of its contributors
        !            24:  *    may be used to endorse or promote products derived from this software
        !            25:  *    without specific prior written permission.
        !            26:  *
        !            27:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
        !            28:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            29:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            30:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
        !            31:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            32:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            33:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            34:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            35:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            36:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            37:  * SUCH DAMAGE.
        !            38:  *
        !            39:  *     @(#)pmap.h      7.6 (Berkeley) 5/10/91
        !            40:  */
        !            41:
        !            42:
        !            43: #ifndef PMAP_H
        !            44: #define PMAP_H
        !            45:
        !            46: #include <machine/pte.h>
        !            47: #include <machine/mtpr.h>
        !            48: #include <machine/pcb.h>
        !            49:
        !            50: /*
        !            51:  * Some constants to make life easier.
        !            52:  */
        !            53: #define LTOHPS         (PGSHIFT - VAX_PGSHIFT)
        !            54: #define LTOHPN         (1 << LTOHPS)
        !            55: #define USRPTSIZE ((MAXTSIZ + 40*1024*1024 + MAXSSIZ) / VAX_NBPG)
        !            56: #define        NPTEPGS (USRPTSIZE / (sizeof(pt_entry_t) * LTOHPN))
        !            57:
        !            58: /*
        !            59:  * Pmap structure
        !            60:  *  pm_stack holds lowest allocated memory for the process stack.
        !            61:  */
        !            62:
        !            63: typedef struct pmap {
        !            64:        vaddr_t pm_stack;       /* Base of alloced p1 pte space */
        !            65:        int              ref_count;     /* reference count        */
        !            66:        pt_entry_t      *pm_p0br;       /* page 0 base register */
        !            67:        long             pm_p0lr;       /* page 0 length register */
        !            68:        pt_entry_t      *pm_p1br;       /* page 1 base register */
        !            69:        long             pm_p1lr;       /* page 1 length register */
        !            70:        int              pm_lock;       /* Lock entry in MP environment */
        !            71:        struct pmap_statistics   pm_stats;      /* Some statistics */
        !            72:        u_char           pm_refcnt[NPTEPGS];    /* Refcount per pte page */
        !            73: } *pmap_t;
        !            74:
        !            75: /*
        !            76:  * For each vm_page_t, there is a list of all currently valid virtual
        !            77:  * mappings of that page.  An entry is a pv_entry_t.
        !            78:  */
        !            79:
        !            80: struct pv_entry {
        !            81:        struct pv_entry *pv_next;       /* next pv_entry */
        !            82:        pt_entry_t      *pv_pte;        /* pte for this physical page */
        !            83:        struct pmap     *pv_pmap;       /* pmap this entry belongs to */
        !            84: };
        !            85:
        !            86: /* ROUND_PAGE used before vm system is initialized */
        !            87: #define ROUND_PAGE(x)  (((uint)(x) + PGOFSET) & ~PGOFSET)
        !            88: #define TRUNC_PAGE(x)  ((uint)(x) & ~PGOFSET)
        !            89:
        !            90: /* Mapping macros used when allocating SPT */
        !            91: #define MAPVIRT(ptr, count)                                    \
        !            92:        (vaddr_t)ptr = virtual_avail;                           \
        !            93:        virtual_avail += (count) * VAX_NBPG;
        !            94:
        !            95: #define MAPPHYS(ptr, count, perm)                              \
        !            96:        (paddr_t)ptr = avail_start + KERNBASE;                  \
        !            97:        avail_start += (count) * VAX_NBPG;
        !            98:
        !            99: #ifdef _KERNEL
        !           100:
        !           101: extern struct pmap kernel_pmap_store;
        !           102:
        !           103: #define pmap_kernel()                  (&kernel_pmap_store)
        !           104:
        !           105: /*
        !           106:  * Real nice (fast) routines to get the virtual address of a physical page
        !           107:  * (and vice versa).
        !           108:  */
        !           109: #define pmap_map_direct(pg)    (VM_PAGE_TO_PHYS(pg) | KERNBASE)
        !           110: #define pmap_unmap_direct(va) PHYS_TO_VM_PAGE((va) & ~KERNBASE)
        !           111: #define        __HAVE_PMAP_DIRECT
        !           112:
        !           113: #define PMAP_STEAL_MEMORY
        !           114:
        !           115: /*
        !           116:  * This is the by far most used pmap routine. Make it inline.
        !           117:  */
        !           118:
        !           119: /* Routines that are best to define as macros */
        !           120: #define pmap_phys_address(phys)                ((u_int)(phys) << PGSHIFT)
        !           121: #define pmap_copy(a,b,c,d,e)           /* Dont do anything */
        !           122: #define pmap_update(pm)                        /* nothing */
        !           123: #define pmap_collect(pmap)             /* No need so far */
        !           124: #define pmap_remove(pmap, start, slut) pmap_protect(pmap, start, slut, 0)
        !           125: #define pmap_resident_count(pmap)      ((pmap)->pm_stats.resident_count)
        !           126: #define pmap_deactivate(p)             /* Dont do anything */
        !           127: #define pmap_reference(pmap)           (pmap)->ref_count++
        !           128:
        !           129: /* These can be done as efficient inline macros */
        !           130: #define pmap_copy_page(srcpg, dstpg) do {                              \
        !           131:        paddr_t __src = VM_PAGE_TO_PHYS(srcpg);                         \
        !           132:        paddr_t __dst = VM_PAGE_TO_PHYS(dstpg);                         \
        !           133:        __asm__("addl3 $0x80000000,%0,r0;addl3 $0x80000000,%1,r1;       \
        !           134:            movc3 $4096,(r0),(r1)"                                      \
        !           135:            :: "r"(__src),"r"(__dst):"r0","r1","r2","r3","r4","r5");    \
        !           136: } while (0)
        !           137:
        !           138: #define pmap_zero_page(pg) do {                                                \
        !           139:        paddr_t __pa = VM_PAGE_TO_PHYS(pg);                             \
        !           140:        __asm__("addl3 $0x80000000,%0,r0;movc5 $0,(r0),$0,$4096,(r0)"   \
        !           141:            :: "r"(__pa): "r0","r1","r2","r3","r4","r5");               \
        !           142: } while (0)
        !           143:
        !           144: #define pmap_proc_iflush(p,va,len)     /* nothing */
        !           145: #define pmap_unuse_final(p)            /* nothing */
        !           146:
        !           147: /* Prototypes */
        !           148: void   pmap_bootstrap(void);
        !           149: vaddr_t pmap_map(vaddr_t, paddr_t, paddr_t, int);
        !           150: void   pmap_pinit(pmap_t);
        !           151:
        !           152: #endif /* _KERNEL */
        !           153:
        !           154: #endif /* PMAP_H */

CVSweb