Annotation of 42BSD/sys/h/vmmac.h, revision 1.1.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) >= btop(USRSTACK) - (p)->p_ssize)
                     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: /* Bytes to pages without rounding, and back */
                     41: #define        btop(x)         (((unsigned)(x)) >> PGSHIFT)
                     42: #define        ptob(x)         ((caddr_t)((x) << PGSHIFT))
                     43: 
                     44: /* Turn virtual addresses into kernel map indices */
                     45: #define        kmxtob(a)       (usrpt + (a) * NPTEPG)
                     46: #define        btokmx(b)       (((b) - usrpt) / NPTEPG)
                     47: 
                     48: /* User area address and pcb bases */
                     49: #define        uaddr(p)        (&((p)->p_p0br[(p)->p_szpt * NPTEPG - UPAGES]))
                     50: #ifdef vax
                     51: #define        pcbb(p)         ((p)->p_addr[0].pg_pfnum)
                     52: #endif
                     53: 
                     54: /* Average new into old with aging factor time */
                     55: #define        ave(smooth, cnt, time) \
                     56:        smooth = ((time - 1) * (smooth) + (cnt)) / (time)
                     57: 
                     58: /* Abstract machine dependent operations */
                     59: #ifdef vax
                     60: #define        setp0br(x)      (u.u_pcb.pcb_p0br = (x), mtpr(P0BR, x))
                     61: #define        setp0lr(x)      (u.u_pcb.pcb_p0lr = \
                     62:                            (x) | (u.u_pcb.pcb_p0lr & AST_CLR), \
                     63:                         mtpr(P0LR, x))
                     64: #define        setp1br(x)      (u.u_pcb.pcb_p1br = (x), mtpr(P1BR, x))
                     65: #define        setp1lr(x)      (u.u_pcb.pcb_p1lr = (x), mtpr(P1LR, x))
                     66: #define        initp1br(x)     ((x) - P1PAGES)
                     67: #endif
                     68: 
                     69: #define        outofmem()      wakeup((caddr_t)&proc[2]);
                     70: 
                     71: /*
                     72:  * Page clustering macros.
                     73:  * 
                     74:  * dirtycl(pte)                        is the page cluster dirty?
                     75:  * anycl(pte,fld)              does any pte in the cluster has fld set?
                     76:  * zapcl(pte,fld) = val                set all fields fld in the cluster to val
                     77:  * distcl(pte)                 distribute high bits to cluster; note that
                     78:  *                             distcl copies everything but pg_pfnum,
                     79:  *                             INCLUDING pg_m!!!
                     80:  *
                     81:  * In all cases, pte must be the low pte in the cluster, even if
                     82:  * the segment grows backwards (e.g. the stack).
                     83:  */
                     84: #define        H(pte)  ((struct hpte *)(pte))
                     85: 
                     86: #if CLSIZE==1
                     87: #define        dirtycl(pte)    dirty(pte)
                     88: #define        anycl(pte,fld)  ((pte)->fld)
                     89: #define        zapcl(pte,fld)  (pte)->fld
                     90: #define        distcl(pte)
                     91: #endif
                     92: 
                     93: #if CLSIZE==2
                     94: #define        dirtycl(pte)    (dirty(pte) || dirty((pte)+1))
                     95: #define        anycl(pte,fld)  ((pte)->fld || (((pte)+1)->fld))
                     96: #define        zapcl(pte,fld)  (pte)[1].fld = (pte)[0].fld
                     97: #endif
                     98: 
                     99: #if CLSIZE==4
                    100: #define        dirtycl(pte) \
                    101:     (dirty(pte) || dirty((pte)+1) || dirty((pte)+2) || dirty((pte)+3))
                    102: #define        anycl(pte,fld) \
                    103:     ((pte)->fld || (((pte)+1)->fld) || (((pte)+2)->fld) || (((pte)+3)->fld))
                    104: #define        zapcl(pte,fld) \
                    105:     (pte)[3].fld = (pte)[2].fld = (pte)[1].fld = (pte)[0].fld
                    106: #endif
                    107: 
                    108: #ifndef distcl
                    109: #define        distcl(pte)     zapcl(H(pte),pg_high)
                    110: #endif

unix.superglobalmegacorp.com

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