DataMuseum.dk

Presents historical artifacts from the history of:

RC9000

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about RC9000

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: @ T v

⟦092f73d62⟧ TextFile

    Length: 6268 (0x187c)
    Types: TextFile
    Notes: @(#)vmmac.h 13.1  (RC Computer)        91/02/02     */
    Names: »vmmac.h«

Derivation

└─⟦50656ff4a⟧ Bits:30010538 TX 3.1 Coldstart
    └─⟦bbf173f5c⟧ »0004« 
        └─⟦this⟧ »./usr/include/sys/vmmac.h« 

TextFile

/*         @(#)vmmac.h	13.1  (RC Computer)        91/02/02     */

/*
 * Virtual memory related conversion macros
 */

/* Core clicks to number of pages of page tables needed to map that much */
#define	ctopt(x)	(((x)+NPTEPG-1)/NPTEPG)

/* Virtual page numbers to text|data|stack segment page numbers and back */
#define	vtotp(p, v)	((int)(v) - btop((p)->p_textstart))
#define vtodp(p, v)	((int)(v) - btop((p)->p_datastart))
#define	vtosp(p, v)	((int)(btop(USRSTACK) - 1 - (v)))
#define	tptov(p, i)	((unsigned)(i) + btop((p)->p_textstart))
#define	dptov(p, i)	((unsigned)(i) + btop((p)->p_datastart))
#define	sptov(p, i)	((unsigned)(btop(USRSTACK) - 1 - (i)))

/* virtual page number + shm att descriptor to segment page number and back */
#define vtoshmp(atp,v)   ((int)((v)-(atp)->shm_base))
#define shmptov(atp,i)   ((unsigned)((atp)->shm_base+(i)))

/* Tell whether virtual page numbers are in text|data|stack segment */
#define	isassv(p, v)	(((v) >= (btop(USRSTACK) - (p)->p_ssize)) && \
				((v) < btop(USRSTACK)))
#define	isatsv(p, v)	((((v) - btop((p)->p_textstart)) < (p)->p_tsize) && \
				(((v) >= btop((p)->p_textstart))))
#define	isadsv(p, v)	((((v) - btop((p)->p_datastart)) < (p)->p_dsize) && \
				(((v) >= btop((p)->p_datastart))))

/* Tell whether pte's are text|data|stack */
#define	isaspte(p, pte)		(((pte) > sptopte(p, (p)->p_ssize)) && \
					((pte) <= sptopte(p, 0)))
#define	isatpte(p, pte)		(((pte) < tptopte(p, (p)->p_tsize)) && \
					((pte) >= tptopte(p, 0)))
#define	isadpte(p, pte)		(((pte) < dptopte(p, (p)->p_dsize)) && \
					((pte) >= dptopte(p, 0)))

/* Text|data|stack pte's to segment page numbers and back */
#define	ptetotp(p, pte)		((pte) - (p)->p_textbr)
#define	ptetodp(p, pte)		((pte) - (p)->p_databr)
#define	ptetosp(p, pte)	\
	(((p)->p_stakbr + (p)->p_stakpt*NPTEPG - REDZONEPAGES - 1) - (pte))

#define	tptopte(p, i)		((p)->p_textbr + (i))
#define	dptopte(p, i)		((p)->p_databr + (i))
#define	sptopte(p, i)		\
	(((p)->p_stakbr + (p)->p_stakpt*NPTEPG - REDZONEPAGES - 1) - (i))

/* shm segment page number + shm att descriptor to pte address */
#define shmptopte(atp, i)	((atp)->shm_shmbr + (atp)->shm_ptoff + (i))

struct	pte *vtopte();

/* Bytes to pages without rounding, and back */
#define	btop(x)		(((unsigned)(x)) >> PGSHIFT)
#define	ptob(x)		((caddr_t)((x) << PGSHIFT))

/* Turn virtual addresses into kernel map indices */
#define	kmxtob(a)	(usrpt + (a) * NPTEPG)
#define	btokmx(b)	(((b) - usrpt) / NPTEPG)

/* Turn physical addresses into Sysmap indices and back: */
/* Sysmap[0] maps eighter base of kernel text or base of map'ed kernel data */
#define	smxtob(a)	(ctob(SYSBASE + (a)))
#define btosmx(b)	(btop((b) - SYSBASE))

/* User area address and pcb bases */
/* #define	uaddr(p)	((p)->p_addr) */
#define	pcbb(p)		(p)

/* Average new into old with aging factor time */
#define	ave(smooth, cnt, time) \
	smooth = ((time - 1) * (smooth) + (cnt)) / (time)

#define	outofmem()	wakeup((caddr_t)&proc[2]);

/* macroes to deal with tx compatibility */
#define PFNUM_VAL(p)    ((p)->pg_pfnum)
#define VAL_PFNUM(p,v)  ((p)->pg_pfnum=(v))
#define PFNUM_ADR(p)    (*(int *)(p) & PG_PFNUM)
#define PBLKNO_VAL(p)   ((p)->pg_blkno)
#define VAL_PBLKNO(p,b) ((p)->pg_blkno=(b))
#define PBLKNO_TZ(p)    (*(int *)(p) & 0xfffff000)
 
/*
 * Page clustering macros.
 * 
 * dirtycl(pte)			is the page cluster dirty?
 * anycl(pte,fld)		does any pte in the cluster has fld set?
 * zapcl(pte,fld) = val		set all fields fld in the cluster to val
 * distcl(pte)			distribute high bits to cluster; note that
 *				distcl copies everything but pg_pfnum,
 *				INCLUDING pg_m!!!
 * distpfcl(pf)			distribute all bits to cluster including
 *				pg_fnum, which is assumed non-zero
 * distzpfcl(pf)		distribute all bits to cluster including
 *				pg_fnum, which is assumed == zero
 * copypcl(dpte, spte)		copy pte cluster
 *
 * In all cases, pte must be the low pte in the cluster, even if
 * the segment grows backwards (e.g. the stack).
 */
#define	H(pte)	((struct hpte *)(pte))

#if CLSIZE==1
#define	dirtycl(pte)	dirty(pte)
#define	anycl(pte,fld)	((pte)->fld)
#define	zapcl(pte,fld)	(pte)->fld
#define	distcl(pte)
#endif

#if CLSIZE==2
#define	dirtycl(pte)	(dirty(pte) || dirty((pte)+1))
#define	anycl(pte,fld)	((pte)->fld || (((pte)+1)->fld))
#define	zapcl(pte,fld)	(pte)[1].fld = (pte)[0].fld
#endif

#if CLSIZE==4
#define	dirtycl(pte) \
    (dirty(pte) || dirty((pte)+1) || dirty((pte)+2) || dirty((pte)+3))
#define	anycl(pte,fld) \
    ((pte)->fld || (((pte)+1)->fld) || (((pte)+2)->fld) || (((pte)+3)->fld))
#define	zapcl(pte,fld) \
    (pte)[3].fld = (pte)[2].fld = (pte)[1].fld = (pte)[0].fld
#endif

#ifndef distcl
#define	distcl(pte)	zapcl(H(pte),pg_high)
#endif

/* 
 * Macroes kept for kompatibility with Tolerant/tx
 */

#if CLSIZE == 1
#define zapcl_zpfnum(pte)	((pte)->pg_pfnum = 0)
#endif

#if CLSIZE == 2
#define	zapcl_zpfnum(pte)	((pte)->pg_pfnum = ((pte)+1)->pg_pfnum = 0);
#endif

#if CLSIZE > 2
#define zapcl_zpfnum(pte)	(panic("zapcl_zpfnum: CLSIZE"))
#endif

#if CLSIZE == 1
#define distpfcl(pte)
#endif

#if CLSIZE == 2
#define	distpfcl(pte)		(*(int *) ((pte) + 1) = \
					*(int *) (pte) + (1 << PGSHIFT))
#endif

#if CLSIZE == 4
#define	distpfcl(pte)		(*(int *) ((pte) + 1) = \
					*(int *) (pte) + (1 << PGSHIFT))
#define	distpfcl(pte)		(*(int *) ((pte) + 2) = \
					*(int *) (pte) + (2 << PGSHIFT))
#define	distpfcl(pte)		(*(int *) ((pte) + 3) = \
					*(int *) (pte) + (3 << PGSHIFT))
#endif

#if CLSIZE > 4
#define distpfcl(pte)		(panic("distpfcl: CLSIZE"))
#endif

#if CLSIZE == 1
#define distzpfcl(pte)
#endif

#if CLSIZE == 2
#define	distzpfcl(pte)		((pte)[1] = (pte)[0])
#endif

#if CLSIZE == 4
#define	distzpfcl(pte)		((pte)[3] = (pte)[2] = (pte)[1] = (pte)[0])
#endif

#if CLSIZE > 4
#define distzpfcl(pte)		(panic("distzpfcl: CLSIZE"))
#endif

#if CLSIZE == 1
#define	copypcl(dpte, spte)	((dpte)[0] = (spte)[0])
#endif CLSIZE == 1

#if CLSIZE == 2
#define	copypcl(dpte, spte)	((dpte)[0] = (spte)[0], (dpte)[1] = (spte)[1])
#endif CLSIZE == 2

#if CLSIZE == 4
#define	copypcl(dpte, spte)	((dpte)[0] = (spte)[0],		\
					(dpte)[1] = (spte)[1],	\
					(dpte)[2] = (spte)[3],	\
					(dpte)[3] = (spte)[3])
#endif CLSIZE == 4

#if CLSIZE > 4
#define copypcl(dpte, spte)	(panic("copycl: CLSIZE"))
#endif