Пример #1
1
static void
openter(Cpu *cpu, Inst *i)
{
	print_func_entry();
	Iarg *sp, *bp;
	unsigned long oframe, nframe;
	int j, n;

	sp = areg(cpu, cpu->slen, RSP);
	bp = areg(cpu, cpu->slen, RBP);
	push(sp, bp);
	oframe = ar(bp);
	nframe = ar(sp);
	n = ar(i->a2) % 32;
	if(n > 0){
		for(j=1; j<n; j++){
			aw(bp, oframe - i->olen*j);
			push(sp, bp);
		}
		push(sp, acon(cpu, i->olen, nframe));
	}
	aw(bp, nframe);
	aw(sp, nframe - ar(i->a1));
	print_func_exit();
}
Пример #2
0
int32_t
devdirread(Chan *c, char *d, int32_t n, Dirtab *tab, int ntab,
	   Devgen *gen)
{
	if (0) print_func_entry();
	int32_t m, dsz;
	Dir dir;

	for(m=0; m<n; c->dri++) {
		switch((*gen)(c, nil, tab, ntab, c->dri, &dir)){
		case -1:
			if (0) print_func_exit();
			return m;

		case 0:
			break;

		case 1:
			dsz = convD2M(&dir, (uint8_t*)d, n-m);
			if(dsz <= BIT16SZ){	/* <= not < because this isn't stat; read is stuck */
				if(m == 0)
					error(Eshort);
				if (0) print_func_exit();
				return m;
			}
			m += dsz;
			d += dsz;
			break;
		}
	}

	if (0) print_func_exit();
	return m;
}
Пример #3
0
void
wclosewin(Window *w)
{
	print_func_entry();
	int i;

	w->deleted = TRUE;
	if(w == input){
		input = nil;
	}
	if(w == wkeyboard)
		wkeyboard = nil;
	for(i=0; i<nhidden; i++)
		if(hidden[i] == w){
			--nhidden;
			memmove(hidden+i, hidden+i+1, (nhidden-i)*sizeof(hidden[0]));
			hidden[nhidden] = nil;
			break;
		}
	for(i=0; i<nwindow; i++)
		if(window[i] == w){
			--nwindow;
			memmove(window+i, window+i+1, (nwindow-i)*sizeof(Window*));
			w->deleted = TRUE;
			print_func_exit();
			return;
		}
	error("unknown window in closewin");
	print_func_exit();
}
Пример #4
0
void
wcurrent(Window *w)
{
	print_func_entry();
	if (0) {
	Window *oi;

	if(wkeyboard!=nil && w==wkeyboard) {
		print_func_exit();
		return;
	}
	oi = input;
	input = w;
	if(w != oi){
		if(oi){
			oi->wctlready = 1;
			wsendctlmesg(oi, Wakeup, nil);
		}
		if(w){
			w->wctlready = 1;
			wsendctlmesg(w, Wakeup, nil);
		}
	}
	}
	input = w;
	print_func_exit();
}
Пример #5
0
/*
 * the zeroth element of the table MUST be the directory itself for ..
*/
int
devgen(Chan *c, char *name, Dirtab *tab, int ntab, int i, Dir *dp)
{
	if (0) print_func_entry();
	if(tab == 0) {
	if (0) print_func_exit();
	return -1;
	}
	if(i == DEVDOTDOT){
		/* nothing */
	}else if(name){
		for(i=1; i<ntab; i++)
			if(strcmp(tab[i].name, name) == 0)
				break;
		if(i==ntab) {
			if (0) print_func_exit();
			return -1;
		}
		tab += i;
	}else{
		/* skip over the first element, that for . itself */
		i++;
		if(i >= ntab) {
		if (0) print_func_exit();
		return -1;
		}
		tab += i;
	}
	devdir(c, tab->qid, tab->name, tab->length, eve, tab->perm, dp);
	if (0) print_func_exit();
	return 1;
}
Пример #6
0
void
devdir(Chan *c, Qid qid, char *n, int64_t length, char *user,
       int32_t perm,
       Dir *db)
{
	if (0) print_func_entry();
	db->name = n;
	if(c->flag&CMSG)
		qid.type |= QTMOUNT;
	db->qid = qid;
	/*
	 * When called via devwalk c->dev is nil
	 * until the walk succeeds.
	 */
	if(c->dev != nil)
		db->type = c->dev->dc;
	else
		db->type = -1;
	db->dev = c->devno;
	db->mode = perm;
	db->mode |= qid.type << 24;
	db->atime = seconds();
	db->mtime = kerndate;
	db->length = length;
	db->uid = user;
	db->gid = eve;
	db->muid = user;
	if (0) print_func_exit();
}
Пример #7
0
Chan*
devclone(Chan *c)
{
	if (0) print_func_entry();
	Chan *nc;

	if(c->flag & COPEN){
		panic("devclone: file of type %C already open\n",
			c->dev != nil? c->dev->dc: -1);
	}

	nc = newchan();

	/*
	 * The caller fills dev in if and when necessary.
	nc->dev = nil;					//XDYNXX
	 */
	nc->devno = c->devno;
	nc->mode = c->mode;
	nc->qid = c->qid;
	nc->offset = c->offset;
	nc->umh = nil;
	nc->aux = c->aux;
	nc->mqid = c->mqid;
	nc->mc = c->mc;
	if (0) print_func_exit();
	return nc;
}
Пример #8
0
Chan*
devattach(int dc, char *spec)
{
	if (0) print_func_entry();
	Chan *c;
	char *buf;

	/*
	 * There are no error checks here because
	 * this can only be called from the driver of dc
	 * which pretty much guarantees devtabget will
	 * succeed.
	 */
	c = newchan();
	mkqid(&c->qid, 0, 0, QTDIR);
	c->dev = devtabget(dc, 0);
	if(spec == nil)
		spec = "";
	buf = smalloc(1+UTFmax+strlen(spec)+1);
	sprint(buf, "#%C%s", dc, spec);
	c->path = newpath(buf);
	free(buf);
	if (0) print_func_exit();
	return c;
}
Пример #9
0
static void
opcmc(Cpu *cpu, Inst *inst)
{
	print_func_entry();
	cpu->reg[RFL] ^= CF;
	print_func_exit();
}
Пример #10
0
static void
opstd(Cpu *cpu, Inst *inst)
{
	print_func_entry();
	cpu->reg[RFL] |= DF;
	print_func_exit();
}
Пример #11
0
static void
opcli(Cpu *cpu, Inst *inst)
{
	print_func_entry();
	cpu->reg[RFL] &= ~IF;
	print_func_exit();
}
Пример #12
0
static void
oplahf(Cpu *cpu, Inst *i)
{
	print_func_entry();
	aw(i->a1, cpu->reg[RFL]);
	print_func_exit();
}
Пример #13
0
static void
oppushf(Cpu *cpu, Inst *i)
{
	print_func_entry();
	push(areg(cpu, cpu->slen, RSP), areg(cpu, i->olen, RFL));
	print_func_exit();
}
Пример #14
0
Chan*
devopen(Chan *c, int omode, Dirtab *tab, int ntab, Devgen *gen)
{
	if (0) print_func_entry();
	int i;
	Dir dir;

	for(i=0;; i++) {
		switch((*gen)(c, nil, tab, ntab, i, &dir)){
		case -1:
			goto Return;
		case 0:
			break;
		case 1:
			if(c->qid.path == dir.qid.path) {
				devpermcheck(dir.uid, dir.mode, omode);
				goto Return;
			}
			break;
		}
	}
Return:
	c->offset = 0;
	if((c->qid.type & QTDIR) && omode!=OREAD)
		error(Eperm);
	c->mode = openmode(omode);
	c->flag |= COPEN;
	if (0) print_func_exit();
	return c;
}
Пример #15
0
static void
oppop(Cpu *cpu, Inst *i)
{
	print_func_entry();
	pop(areg(cpu, cpu->slen, RSP), i->a1);
	print_func_exit();
}
Пример #16
0
void
devpower(int i)
{
	if (0) print_func_entry();
	error(Eperm);
	if (0) print_func_exit();
}
Пример #17
0
void
devremove(Chan* c)
{
	if (0) print_func_entry();
	error(Eperm);
	if (0) print_func_exit();
}
Пример #18
0
void
devcreate(Chan* c, char* d, int i, int n)
{
	if (0) print_func_entry();
	error(Eperm);
	if (0) print_func_exit();
}
Пример #19
0
int32_t
devstat(Chan *c, uint8_t *db, int32_t n, Dirtab *tab, int ntab,
	Devgen *gen)
{
	if (0) print_func_entry();
	int i;
	Dir dir;
	char *p, *elem;

	for(i=0;; i++){
		switch((*gen)(c, nil, tab, ntab, i, &dir)){
		case -1:
			if(c->qid.type & QTDIR){
				if(c->path == nil)
					elem = "???";
				else if(strcmp(c->path->s, "/") == 0)
					elem = "/";
				else
					for(elem=p=c->path->s; *p; p++)
						if(*p == '/')
							elem = p+1;
				devdir(c, c->qid, elem, 0, eve, DMDIR|0555, &dir);
				n = convD2M(&dir, db, n);
				if(n == 0)
					error(Ebadarg);
				if (0) print_func_exit();
				return n;
			}

			error(Enonexist);
		case 0:
			break;
		case 1:
			if(c->qid.path == dir.qid.path) {
				if(c->flag&CMSG)
					dir.mode |= DMMOUNT;
				n = convD2M(&dir, db, n);
				if(n == 0)
					error(Ebadarg);
				if (0) print_func_exit();
				return n;
			}
			break;
		}
	}
	if (0) print_func_exit();
}
Пример #20
0
static void
opint(Cpu *cpu, Inst *i)
{
	print_func_entry();
	cpu->trap = ar(i->a1);
	longjmp(cpu->jmp, 1);
	print_func_exit();
}
Пример #21
0
Window*
wlookid(int id)
{
	print_func_entry();
	int i;

	fprint(2, "%d:", id);
	for(i=0; i<nwindow; i++)
		if(window[i]->id == id) {
			fprint(2, "FOUND @%p", window[i]);
			print_func_exit();
			return window[i];
		}
	fprint(2, "NOT FOUND;");
	print_func_exit();
	return nil;
}
Пример #22
0
int
devconfig(int i, char *c, DevConf *d)
{
	if (0) print_func_entry();
	error(Eperm);
	if (0) print_func_exit();
	return 0;
}
Пример #23
0
int32_t
devwstat(Chan* c, uint8_t* i, int32_t n)
{
	if (0) print_func_entry();
	error(Eperm);
	if (0) print_func_exit();
	return 0;
}
Пример #24
0
void
mkqid(Qid *q, int64_t path, uint32_t vers, int type)
{
	if (0) print_func_entry();
	q->type = type;
	q->vers = vers;
	q->path = path;
	if (0) print_func_exit();
}
Пример #25
0
void
waddraw(Window *w, Rune *r, int nr)
{
	print_func_entry();
	w->raw = runerealloc(w->raw, w->nraw+nr);
	runemove(w->raw+w->nraw, r, nr);
	w->nraw += nr;
	print_func_exit();
}
Пример #26
0
int
wclose(Window *w)
{
	print_func_entry();
	int i;

	i = decref(w);
	if(i > 0) {
		print_func_exit();
		return 0;
	}
	if(i < 0)
		error("negative ref count");
	if(!w->deleted)
		wclosewin(w);
	wsendctlmesg(w, Exited, nil);
	print_func_exit();
	return 1;
}
Пример #27
0
void
wsendctlmesg(Window *w, int type, Console *image)
{
	print_func_entry();
	Wctlmesg wcm;

	wcm.type = type;
	send(w->cctl, &wcm);
	print_func_exit();
}
Пример #28
0
/*
 * Need to do this in a separate proc because if process we're interrupting
 * is dying and trying to print tombstone, kernel is blocked holding p->debug lock.
 */
void
interruptproc(void *v)
{
	print_func_entry();
	int *notefd;

	notefd = v;
	write(*notefd, "interrupt", 9);
	free(notefd);
	print_func_exit();
}
Пример #29
0
static void
pop(Iarg *sp, Iarg *a)
{
	print_func_entry();
	Iarg *p;

	p = amem(sp->cpu, a->len, RSS, ar(sp));
	aw(a, ar(p));
	aw(sp, p->off + a->len);
	print_func_exit();
}
Пример #30
0
static void
opleave(Cpu *cpu, Inst *i)
{
	print_func_entry();
	Iarg *sp;

	sp = areg(cpu, cpu->slen, RSP);
	aw(sp, ar(areg(cpu, cpu->slen, RBP)));
	pop(sp, areg(cpu, i->olen, RBP));
	print_func_exit();
}