Annotation of 41BSD/4.0.upgrade/sys/h/vmmac.h, revision 1.1

1.1     ! root        1: /*     vmmac.h 4.3     81/04/23        */
        !             2: 
        !             3: /*
        !             4:  * Virtual memory related conversion macros
        !             5:  */
        !             6: 
        !             7: /* Core clicks to number of pages of page tables needed to map that much */
        !             8: #define        ctopt(x)        (((x)+NPTEPG-1)/NPTEPG)
        !             9: 
        !            10: /* Virtual page numbers to text|data|stack segment page numbers and back */
        !            11: #define        vtotp(p, v)     ((int)(v))
        !            12: #define        vtodp(p, v)     ((int)((v) - (p)->p_tsize))
        !            13: #define        vtosp(p, v)     ((int)(btop(USRSTACK) - 1 - (v)))
        !            14: #define        tptov(p, i)     ((unsigned)(i))
        !            15: #define        dptov(p, i)     ((unsigned)((p)->p_tsize + (i)))
        !            16: #define        sptov(p, i)     ((unsigned)(btop(USRSTACK) - 1 - (i)))
        !            17: 
        !            18: /* Tell whether virtual page numbers are in text|data|stack segment */
        !            19: #define        isassv(p, v)    ((v) & P1TOP)
        !            20: #define        isatsv(p, v)    ((v) < (p)->p_tsize)
        !            21: #define        isadsv(p, v)    ((v) >= (p)->p_tsize && !isassv(p, v))
        !            22: 
        !            23: /* Tell whether pte's are text|data|stack */
        !            24: #define        isaspte(p, pte)         ((pte) > sptopte(p, (p)->p_ssize))
        !            25: #define        isatpte(p, pte)         ((pte) < dptopte(p, 0))
        !            26: #define        isadpte(p, pte)         (!isaspte(p, pte) && !isatpte(p, pte))
        !            27: 
        !            28: /* Text|data|stack pte's to segment page numbers and back */
        !            29: #define        ptetotp(p, pte)         ((pte) - (p)->p_p0br)
        !            30: #define        ptetodp(p, pte)         ((pte) - ((p)->p_p0br + (p)->p_tsize))
        !            31: #define        ptetosp(p, pte) \
        !            32:        (((p)->p_p0br + (p)->p_szpt*NPTEPG - UPAGES - 1) - (pte))
        !            33: 
        !            34: #define        tptopte(p, i)           ((p)->p_p0br + (i))
        !            35: #define        dptopte(p, i)           ((p)->p_p0br + (p)->p_tsize + (i))
        !            36: #define        sptopte(p, i) \
        !            37:        (((p)->p_p0br + (p)->p_szpt*NPTEPG - UPAGES - 1) - (i))
        !            38: 
        !            39: /* Bytes to pages without rounding, and back */
        !            40: #define        btop(x)         (((unsigned)(x)) >> PGSHIFT)
        !            41: #define        ptob(x)         ((caddr_t)((x) << PGSHIFT))
        !            42: 
        !            43: /* Turn virtual addresses into kernel map indices */
        !            44: #define        kmxtob(a)       (usrpt + (a) * NPTEPG)
        !            45: #define        btokmx(b)       (((b) - usrpt) / NPTEPG)
        !            46: 
        !            47: /* User area address and pcb bases */
        !            48: #define        uaddr(p)        (&((p)->p_p0br[(p)->p_szpt * NPTEPG - UPAGES]))
        !            49: #define        pcbb(p)         ((p)->p_addr[0].pg_pfnum)
        !            50: 
        !            51: /* Average new into old with aging factor time */
        !            52: #define        ave(smooth, cnt, time) \
        !            53:        smooth = ((time - 1) * (smooth) + (cnt)) / (time)
        !            54: 
        !            55: /*
        !            56:  * Page clustering macros.
        !            57:  * 
        !            58:  * dirtycl(pte)                        is the page cluster dirty?
        !            59:  * anycl(pte,fld)              does any pte in the cluster has fld set?
        !            60:  * zapcl(pte,fld) = val                set all fields fld in the cluster to val
        !            61:  * distcl(pte)                 distribute high bits to cluster; note that
        !            62:  *                             distcl copies everything but pg_pfnum,
        !            63:  *                             INCLUDING pg_m!!!
        !            64:  *
        !            65:  * In all cases, pte must be the low pte in the cluster, even if
        !            66:  * the segment grows backwards (e.g. the stack).
        !            67:  */
        !            68: #define        H(pte)  ((struct hpte *)(pte))
        !            69: 
        !            70: #if CLSIZE==1
        !            71: #define        dirtycl(pte)    dirty(pte)
        !            72: #define        anycl(pte,fld)  ((pte)->fld)
        !            73: #define        zapcl(pte,fld)  (pte)->fld
        !            74: #define        distcl(pte)
        !            75: #endif
        !            76: 
        !            77: #if CLSIZE==2
        !            78: #define        dirtycl(pte)    (dirty(pte) || dirty((pte)+1))
        !            79: #define        anycl(pte,fld)  ((pte)->fld || (((pte)+1)->fld))
        !            80: #define        zapcl(pte,fld)  (pte)[1].fld = (pte)[0].fld
        !            81: #endif
        !            82: 
        !            83: #if CLSIZE==4
        !            84: #define        dirtycl(pte) \
        !            85:     (dirty(pte) || dirty((pte)+1) || dirty((pte)+2) || dirty((pte)+3))
        !            86: #define        anycl(pte,fld) \
        !            87:     ((pte)->fld || (((pte)+1)->fld) || (((pte)+2)->fld) || (((pte)+3)->fld))
        !            88: #define        zapcl(pte,fld) \
        !            89:     (pte)[3].fld = (pte)[2].fld = (pte)[1].fld = (pte)[0].fld
        !            90: #endif
        !            91: 
        !            92: #ifndef distcl
        !            93: #define        distcl(pte)     zapcl(H(pte),pg_high)
        !            94: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.