Annotation of cci/sys/h/vmmac.h, revision 1.1

1.1     ! root        1: /*     vmmac.h 6.1     83/07/29        */
        !             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)-LOWPAGES)
        !            12: #define        vtodp(p, v)     ((int)((v) - stoc(ctos((p)->p_tsize)) - LOWPAGES))
        !            13: #define        vtosp(p, v)     ((int)(btop(USRSTACK) - 1 - (v)))
        !            14: #define        tptov(p, i)     ((unsigned)(i) + LOWPAGES)
        !            15: #define        dptov(p, i)     ((unsigned)(stoc(ctos((p)->p_tsize)) + (i) + LOWPAGES))
        !            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) & 0x200000)
        !            20: #define        isatsv(p, v)    (((v) - LOWPAGES) < (p)->p_tsize)
        !            21: #define        isadsv(p, v)    (((v) - LOWPAGES) >= stoc(ctos((p)->p_tsize)) && \
        !            22:                                !isassv(p, v))
        !            23: 
        !            24: /* Tell whether pte's are text|data|stack */
        !            25: #define        isaspte(p, pte)         ((pte) > sptopte(p, (p)->p_ssize))
        !            26: #define        isatpte(p, pte)         ((pte) < dptopte(p, 0))
        !            27: #define        isadpte(p, pte)         (!isaspte(p, pte) && !isatpte(p, pte))
        !            28: 
        !            29: /* Text|data|stack pte's to segment page numbers and back */
        !            30: #define        ptetotp(p, pte)         ((pte) - (p)->p_p0br)
        !            31: #define        ptetodp(p, pte)         ((pte) - ((p)->p_p0br + (p)->p_tsize))
        !            32: #define        ptetosp(p, pte) \
        !            33:        (((p)->p_p0br + (p)->p_szpt*NPTEPG - UPAGES - 1) - (pte))
        !            34: 
        !            35: #define        tptopte(p, i)           ((p)->p_p0br + (i))
        !            36: #define        dptopte(p, i)           ((p)->p_p0br + (p)->p_tsize + (i))
        !            37: #define        sptopte(p, i) \
        !            38:        (((p)->p_p0br + (p)->p_szpt*NPTEPG - UPAGES - 1) - (i))
        !            39: 
        !            40: /* Virtual page numbers to shared memory segment numbers and back */
        !            41: #define vtoshmp(p, v)          vtodp(p, v)
        !            42: #define shmptov(p, i)          dptov(p, i)
        !            43: 
        !            44: /* Tell if a virtual data page is in a shared-memory memory segment or not */
        !            45: #define        isashmsv(p, v)          ((isadsv(p, v)) && \
        !            46:        (((v) - LOWPAGES) >= stoc(ctos((p)->p_tsize + (p)->p_dsize))))
        !            47: #define        isansdsv(p, v)          ((isadsv(p, v)) && \
        !            48:        (((v) - LOWPAGES) < stoc(ctos((p)->p_tsize + (p)->p_dsize))))
        !            49: 
        !            50: /* Tell if a data pte is a shared or non-shared data pte */
        !            51: #define isashmpte(p, pte)      ((isadpte(p, pte)) && \
        !            52:                                        ((pte) >= dptopte(p, (p)->p_dsize)))
        !            53: #define isansdpte(p, pte)      ((isadpte(p, pte)) && \
        !            54:                                        ((pte) < dptopte(p, (p)->p_dsize)))
        !            55: 
        !            56: /* Shared memory ptes to segment page numbers and back */
        !            57: #define        ptetoshmp(p, pte)       ptetodp(p, pte)
        !            58: #define        shmptopte(p, i)         dptopte(p, i)
        !            59: 
        !            60: /* Bytes to pages without rounding, and back */
        !            61: #define        btop(x)         (((unsigned)(x)) >> PGSHIFT)
        !            62: #define        ptob(x)         ((caddr_t)((x) << PGSHIFT))
        !            63: 
        !            64: /* Turn virtual addresses into kernel map indices */
        !            65: #define        kmxtob(a)       (usrpt + (a) * NPTEPG)
        !            66: #define        btokmx(b)       (((b) - usrpt) / NPTEPG)
        !            67: 
        !            68: /* User area address and pcb bases */
        !            69: #define        uaddr(p)        (&((p)->p_p0br[(p)->p_szpt * NPTEPG - UPAGES]))
        !            70: #define        pcbb(p)         ((p)->p_addr[0].pg_pfnum)
        !            71: 
        !            72: /* Average new into old with aging factor time */
        !            73: #define        ave(smooth, cnt, time) \
        !            74:        smooth = ((time - 1) * (smooth) + (cnt)) / (time)
        !            75: 
        !            76: /* Abstract machine dependent operations */
        !            77: 
        !            78: #define        setp0br(x)      (u.u_pcb.pcb_p0br = (x), mtpr(x, P0BR))
        !            79: #define        setp0lr(x)      (u.u_pcb.pcb_p0lr = (x), mtpr(x, P0LR))
        !            80: #define        setp1br(x)      (u.u_pcb.pcb_p1br = (x), mtpr(x, P1BR))
        !            81: #define        setp1lr(x)      (u.u_pcb.pcb_p1lr = (x), mtpr(x, P1LR))
        !            82: #define        setp2br(x)      (u.u_pcb.pcb_p2br = (x), mtpr(x, P2BR))
        !            83: #define        setp2lr(x)      (u.u_pcb.pcb_p2lr = (x), mtpr(x, P2LR))
        !            84: #define        initp2br(x)     ((x) - P2PAGES)
        !            85: 
        !            86: 
        !            87: #define        outofmem()      wakeup((caddr_t)&proc[2]);
        !            88: 
        !            89: /*
        !            90:  * Page clustering macros.
        !            91:  * 
        !            92:  * dirtycl(pte)                        is the page cluster dirty?
        !            93:  * anycl(pte,fld)              does any pte in the cluster has fld set?
        !            94:  * zapcl(pte,fld) = val                set all fields fld in the cluster to val
        !            95:  * distcl(pte)                 distribute high bits to cluster; note that
        !            96:  *                             distcl copies everything but pg_pfnum,
        !            97:  *                             INCLUDING pg_m!!!
        !            98:  *
        !            99:  * In all cases, pte must be the low pte in the cluster, even if
        !           100:  * the segment grows backwards (e.g. the stack).
        !           101:  */
        !           102: #define        H(pte)  ((struct hpte *)(pte))
        !           103: 
        !           104: #if CLSIZE==1
        !           105: #define        dirtycl(pte)    dirty(pte)
        !           106: #define        anycl(pte,fld)  ((pte)->fld)
        !           107: #define        zapcl(pte,fld)  (pte)->fld
        !           108: #define        distcl(pte)
        !           109: #endif
        !           110: 
        !           111: #if CLSIZE==2
        !           112: #define        dirtycl(pte)    (dirty(pte) || dirty((pte)+1))
        !           113: #define        anycl(pte,fld)  ((pte)->fld || (((pte)+1)->fld))
        !           114: #define        zapcl(pte,fld)  (pte)[1].fld = (pte)[0].fld
        !           115: #endif
        !           116: 
        !           117: #if CLSIZE==4
        !           118: #define        dirtycl(pte) \
        !           119:     (dirty(pte) || dirty((pte)+1) || dirty((pte)+2) || dirty((pte)+3))
        !           120: #define        anycl(pte,fld) \
        !           121:     ((pte)->fld || (((pte)+1)->fld) || (((pte)+2)->fld) || (((pte)+3)->fld))
        !           122: #define        zapcl(pte,fld) \
        !           123:     (pte)[3].fld = (pte)[2].fld = (pte)[1].fld = (pte)[0].fld
        !           124: #endif
        !           125: 
        !           126: #ifndef distcl
        !           127: #define        distcl(pte)     zapcl(H(pte),pg_high)
        !           128: #endif

unix.superglobalmegacorp.com

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