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

Annotation of sys/arch/hppa/include/pmap.h, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: pmap.h,v 1.33 2004/08/06 22:39:12 deraadt Exp $       */
                      2:
                      3: /*
                      4:  * Copyright (c) 2002-2004 Michael Shalayeff
                      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:  *
                     16:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     17:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     18:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     19:  * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
                     20:  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
                     21:  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
                     22:  * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     23:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
                     24:  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
                     25:  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
                     26:  * THE POSSIBILITY OF SUCH DAMAGE.
                     27:  */
                     28:
                     29: #ifndef _MACHINE_PMAP_H_
                     30: #define _MACHINE_PMAP_H_
                     31:
                     32: #include <machine/pte.h>
                     33: #include <uvm/uvm_pglist.h>
                     34: #include <uvm/uvm_object.h>
                     35:
                     36: struct pmap {
                     37:        struct uvm_object pm_obj;       /* object (lck by object lock) */
                     38: #define        pm_lock pm_obj.vmobjlock
                     39:        struct vm_page  *pm_ptphint;
                     40:        struct vm_page  *pm_pdir_pg;    /* vm_page for pdir */
                     41:        volatile u_int32_t *pm_pdir;    /* page dir (read-only after create) */
                     42:        pa_space_t      pm_space;       /* space id (read-only after create) */
                     43:        u_int           pm_pid;         /* prot id (read-only after create) */
                     44:
                     45:        struct pmap_statistics  pm_stats;
                     46: };
                     47: typedef struct pmap *pmap_t;
                     48:
                     49: #define HPPA_MAX_PID    0xfffa
                     50: #define        HPPA_SID_MAX    0x7ffd
                     51: #define HPPA_SID_KERNEL 0
                     52: #define HPPA_PID_KERNEL 2
                     53:
                     54: #define KERNEL_ACCESS_ID 1
                     55: #define KERNEL_TEXT_PROT (TLB_AR_KRX | (KERNEL_ACCESS_ID << 1))
                     56: #define KERNEL_DATA_PROT (TLB_AR_KRW | (KERNEL_ACCESS_ID << 1))
                     57:
                     58: struct pv_entry {                      /* locked by its list's pvh_lock */
                     59:        struct pv_entry *pv_next;
                     60:        struct pmap     *pv_pmap;       /* the pmap */
                     61:        vaddr_t         pv_va;          /* the virtual address */
                     62:        struct vm_page  *pv_ptp;        /* the vm_page of the PTP */
                     63: };
                     64:
                     65: /* also match the hardware tlb walker definition */
                     66: struct vp_entry {
                     67:        u_int   vp_tag;
                     68:        u_int   vp_tlbprot;
                     69:        u_int   vp_tlbpage;
                     70:        u_int   vp_ptr;
                     71: };
                     72:
                     73: #ifdef _KERNEL
                     74:
                     75: extern void gateway_page(void);
                     76: extern struct pmap kernel_pmap_store;
                     77:
                     78: #if defined(HP7100LC_CPU) || defined(HP7300LC_CPU)
                     79: extern int pmap_hptsize;
                     80: extern struct pdc_hwtlb pdc_hwtlb;
                     81: #endif
                     82:
                     83: /*
                     84:  * pool quickmaps
                     85:  */
                     86: #define        pmap_map_direct(pg)     ((vaddr_t)VM_PAGE_TO_PHYS(pg))
                     87: #define        pmap_unmap_direct(va) PHYS_TO_VM_PAGE((paddr_t)(va))
                     88: #define        __HAVE_PMAP_DIRECT
                     89:
                     90: /*
                     91:  * according to the parisc manual aliased va's should be
                     92:  * different by high 12 bits only.
                     93:  */
                     94: #define        PMAP_PREFER(o,h)        do {                                    \
                     95:        vaddr_t pmap_prefer_hint;                                       \
                     96:        pmap_prefer_hint = (*(h) & HPPA_PGAMASK) | ((o) & HPPA_PGAOFF); \
                     97:        if (pmap_prefer_hint < *(h))                                    \
                     98:                pmap_prefer_hint += HPPA_PGALIAS;                       \
                     99:        *(h) = pmap_prefer_hint;                                        \
                    100: } while(0)
                    101:
                    102: #define        pmap_sid2pid(s)                 (((s) + 1) << 1)
                    103: #define pmap_kernel()                  (&kernel_pmap_store)
                    104: #define        pmap_resident_count(pmap)       ((pmap)->pm_stats.resident_count)
                    105: #define        pmap_update(pm)                 (void)(pm)
                    106: #define pmap_copy(dpmap,spmap,da,len,sa)
                    107:
                    108: #define pmap_clear_modify(pg)  pmap_changebit(pg, 0, PTE_PROT(TLB_DIRTY))
                    109: #define pmap_clear_reference(pg) pmap_changebit(pg, PTE_PROT(TLB_REFTRAP), 0)
                    110: #define pmap_is_modified(pg)   pmap_testbit(pg, PTE_PROT(TLB_DIRTY))
                    111: #define pmap_is_referenced(pg) pmap_testbit(pg, PTE_PROT(TLB_REFTRAP))
                    112: #define pmap_phys_address(ppn) ((ppn) << PAGE_SHIFT)
                    113:
                    114: #define pmap_proc_iflush(p,va,len)     /* nothing */
                    115: #define pmap_unuse_final(p)            /* nothing */
                    116:
                    117: void pmap_bootstrap(vaddr_t);
                    118: boolean_t pmap_changebit(struct vm_page *, u_int, u_int);
                    119: boolean_t pmap_testbit(struct vm_page *, u_int);
                    120: void pmap_write_protect(struct pmap *, vaddr_t, vaddr_t, vm_prot_t);
                    121: void pmap_remove(struct pmap *pmap, vaddr_t sva, vaddr_t eva);
                    122: void pmap_page_remove(struct vm_page *pg);
                    123:
                    124: static __inline int
                    125: pmap_prot(struct pmap *pmap, int prot)
                    126: {
                    127:        extern u_int hppa_prot[];
                    128:        return (hppa_prot[prot] | (pmap == pmap_kernel()? 0 : TLB_USER));
                    129: }
                    130:
                    131: static __inline void
                    132: pmap_page_protect(struct vm_page *pg, vm_prot_t prot)
                    133: {
                    134:        if ((prot & UVM_PROT_WRITE) == 0) {
                    135:                if (prot & (UVM_PROT_RX))
                    136:                        pmap_changebit(pg, 0, PTE_PROT(TLB_WRITE));
                    137:                else
                    138:                        pmap_page_remove(pg);
                    139:        }
                    140: }
                    141:
                    142: static __inline void
                    143: pmap_protect(struct pmap *pmap, vaddr_t sva, vaddr_t eva, vm_prot_t prot)
                    144: {
                    145:        if ((prot & UVM_PROT_WRITE) == 0) {
                    146:                if (prot & (UVM_PROT_RX))
                    147:                        pmap_write_protect(pmap, sva, eva, prot);
                    148:                else
                    149:                        pmap_remove(pmap, sva, eva);
                    150:        }
                    151: }
                    152:
                    153: #endif /* _KERNEL */
                    154: #endif /* _MACHINE_PMAP_H_ */

CVSweb