Esempio n. 1
0
File: pjw.c Progetto: aiju/hdl
void
main()
{
	int c;
	int i, j;
	u16int *p;
	
	reg = segattach(0, "axi", nil, 4096);
	if(reg == (int*)-1)
		sysfatal("segattach: %r");
	*reg = 0;
	cmd("CL");
	cmd("DIM");
	*reg = 80-24;
	*reg = 60-24;
	*reg = 48;
	*reg = 48;
	p = face;
	for(i = 0; i < 48; i++){
		for(j = 0; j < 3; j++){
			*reg = ~*p >> 8;
			*reg = ~*p;
			p++;
		}
	}
}
Esempio n. 2
0
uintptr
syssegattach(va_list list)
{
	ulong attr;
	char *name;
	uintptr va;
	ulong len;

	attr = va_arg(list, ulong);
	name = va_arg(list, char*);
	va = va_arg(list, uintptr);
	len = va_arg(list, ulong);
	return segattach(up, attr, name, va, len);
}
Esempio n. 3
0
/*
 *  create a shared segment.  Make is start 2 meg higher than the current
 *  end of process memory.
 */
void*
share(ulong len)
{
	uchar *vastart;

	vastart = sbrk(0);
	if(vastart == (void*)-1)
		return 0;
	vastart += 2*1024*1024;

	if(segattach(0, "shared", vastart, len) == (void*)-1)
		return 0;

	return vastart;
}
Esempio n. 4
0
uintptr
syssegattach(va_list list)
{
	ulong attr;
	char *name;
	uintptr va;
	ulong len;

	attr = va_arg(list, ulong);
	name = va_arg(list, char*);
	va = va_arg(list, uintptr);
	len = va_arg(list, ulong);
	validaddr((uintptr)name, 1, 0);
	name = validnamedup(name, 1);
	if(waserror()){
		free(name);
		nexterror();
	}
	va = segattach(up, attr, name, va, len);
	free(name);
	poperror();
	return va;
}
Esempio n. 5
0
long
syssegattach(ulong *arg)
{
	return segattach(up, arg[0], (char*)arg[1], arg[2], arg[3]);
}
Esempio n. 6
0
/*
 *  bind a pipe onto consctl and keep reading it to
 *  get changes to console state.
 */
Consstate*
consctl(void)
{
	int i, n, fd, tries;
	char buf[128];
	Consstate *x;
	char *field[10];

	x = segattach(0, "shared", 0, sizeof *x);
	if(x == (void*)-1)
		sysfatal("segattach: %r");

	/* a pipe to simulate consctl */
	if(bind("#|", "/mnt/cons/consctl", MBEFORE) < 0
	|| bind("/mnt/cons/consctl/data1", "/dev/consctl", MREPL) < 0)
		sysfatal("bind consctl: %r");

	/* a pipe to simulate the /dev/cons */
	if(bind("#|", "/mnt/cons/cons", MREPL) < 0
	|| bind("/mnt/cons/cons/data1", "/dev/cons", MREPL) < 0)
		sysfatal("bind cons: %r");

	switch(fork()){
	case -1:
		sysfatal("fork: %r");
	case 0:
		break;
	default:
		return x;
	}

	notify(0);

	for(tries = 0; tries < 100; tries++){
		x->raw = 0;
		x->hold = 0;
		fd = open("/mnt/cons/consctl/data", OREAD);
		if(fd < 0)
			break;
		tries = 0;
		for(;;){
			n = read(fd, buf, sizeof(buf)-1);
			if(n <= 0)
				break;
			buf[n] = 0;
			n = getfields(buf, field, 10, 1, " ");
			for(i = 0; i < n; i++){
				if(strcmp(field[i], "rawon") == 0)
					x->raw = 1;
				else if(strcmp(field[i], "rawoff") == 0)
					x->raw = 0;
				else if(strcmp(field[i], "holdon") == 0)
					x->hold = 1;
				else if(strcmp(field[i], "holdoff") == 0)
					x->hold = 0;
			}
		}
		close(fd);
	}
	exits(0);
	return 0;		/* dummy to keep compiler quiet*/
}