⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ureg.c

📁 unix v7是最后一个广泛发布的研究型UNIX版本
💻 C
字号:
#include "../h/param.h"#include "../h/systm.h"#include "../h/dir.h"#include "../h/user.h"#include "../h/proc.h"#include "../h/text.h"#include "../h/seg.h"/* * Load the user hardware segmentation * registers from the software prototype. * The software registers must have * been setup prior by estabur. */sureg(){	register *udp, *uap, *rdp;	int *rap, *limudp;	int taddr, daddr;	struct text *tp;	taddr = daddr = u.u_procp->p_addr;	if ((tp=u.u_procp->p_textp) != NULL)		taddr = tp->x_caddr;	limudp = &u.u_uisd[16];	if (cputype==40)		limudp = &u.u_uisd[8];	rap = (int *)UISA;	rdp = (int *)UISD;	uap = &u.u_uisa[0];	for (udp = &u.u_uisd[0]; udp < limudp;) {		*rap++ = *uap++ + (*udp&TX? taddr: (*udp&ABS? 0: daddr));		*rdp++ = *udp++;	}}/* * Set up software prototype segmentation * registers to implement the 3 pseudo * text,data,stack segment sizes passed * as arguments. * The argument sep specifies if the * text and data+stack segments are to * be separated. * The last argument determines whether the text * segment is read-write or read-only. */estabur(nt, nd, ns, sep, xrw)unsigned nt, nd, ns;{	register a, *ap, *dp;	if(sep) {		if(cputype == 40)			goto err;		if(ctos(nt) > 8 || ctos(nd)+ctos(ns) > 8)			goto err;	} else		if(ctos(nt)+ctos(nd)+ctos(ns) > 8)			goto err;	if(nt+nd+ns+USIZE > maxmem)		goto err;	a = 0;	ap = &u.u_uisa[0];	dp = &u.u_uisd[0];	while(nt >= 128) {		*dp++ = (127<<8) | xrw|TX;		*ap++ = a;		a += 128;		nt -= 128;	}	if(nt) {		*dp++ = ((nt-1)<<8) | xrw|TX;		*ap++ = a;	}	if(sep)	while(ap < &u.u_uisa[8]) {		*ap++ = 0;		*dp++ = 0;	}	a = USIZE;	while(nd >= 128) {		*dp++ = (127<<8) | RW;		*ap++ = a;		a += 128;		nd -= 128;	}	if(nd) {		*dp++ = ((nd-1)<<8) | RW;		*ap++ = a;		a += nd;	}	while(ap < &u.u_uisa[8]) {		if(*dp &ABS) {			dp++;			ap++;			continue;		}		*dp++ = 0;		*ap++ = 0;	}	if(sep)	while(ap < &u.u_uisa[16]) {		if(*dp & ABS) {			dp++;			ap++;			continue;		}		*dp++ = 0;		*ap++ = 0;	}	a += ns;	while(ns >= 128) {		a -= 128;		ns -= 128;		*--dp = (127<<8) | RW;		*--ap = a;	}	if(ns) {		*--dp = ((128-ns)<<8) | RW | ED;		*--ap = a-128;	}	if(!sep) {		ap = &u.u_uisa[0];		dp = &u.u_uisa[8];		while(ap < &u.u_uisa[8])			*dp++ = *ap++;		ap = &u.u_uisd[0];		dp = &u.u_uisd[8];		while(ap < &u.u_uisd[8])			*dp++ = *ap++;	}	sureg();	return(0);err:	u.u_error = ENOMEM;	return(-1);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -