Example #1
0
void *timer_thread(void *arg)
{
	int fd = open("#cons/vmctl", O_RDWR), ret;
	int initcount;

	fprintf(stderr, "TIMER THREAD START 0x%llx\n", vmctl.timer_msr);

	// We only begin injection when linux writes a non zero initial count
	initcount = vmctl.initial_count;
	while (!initcount) {
		uthread_usleep(10000);
		initcount = vmctl.initial_count;
	}
	fprintf(stderr, "INJECTING TIMER 0x%llx\n", vmctl.timer_msr);

	fflush(stderr);
	while (1) {
		if (initcount) {
			set_posted_interrupt(vmctl.timer_msr & 0xff);
			//set_posted_interrupt(0xff);
			pwrite(fd, &vmctl, sizeof(vmctl), 1<<12);
		}
		uthread_usleep(10000);
		// check initcount again to make sure linux still wants it
		initcount = vmctl.initial_count;
	}
	close(fd);
}
Example #2
0
void *timer_thread(void *arg)
{
	while (1) {
		set_posted_interrupt(0xef);
		ros_syscall(SYS_vmm_poke_guest, 0, 0, 0, 0, 0, 0);
		uthread_usleep(100000);
	}
	fprintf(stderr, "SENDING TIMER\n");
}
Example #3
0
void *consin(void *arg)
{
	struct virtio_threadarg *a = arg;
	char *line, *outline;
	static char consline[128];
	static struct scatterlist iov[32];
	static struct scatterlist out[] = { {NULL, sizeof(outline)}, };
	static struct scatterlist in[] = { {NULL, sizeof(line)}, };

	static unsigned int inlen, outlen, conslen;
	struct virtqueue *v = a->arg->virtio;
	fprintf(stderr, "consin thread ..\n");
	uint16_t head, gaveit = 0, gotitback = 0;
	uint32_t vv;
	int i;
	int num;
	//char c[1];

	if (debug) fprintf(stderr, "Spin on console being read, print num queues, halt\n");

	for(num = 0;! quit;num++) {
		//int debug = 1;
		/* host: use any buffers we should have been sent. */
		head = wait_for_vq_desc(v, iov, &outlen, &inlen);
		if (debug)
			fprintf(stderr, "vq desc head %d, gaveit %d gotitback %d\n", head, gaveit, gotitback);
		for(i = 0; debug && i < outlen + inlen; i++)
			fprintf(stderr, "v[%d/%d] v %p len %d\n", i, outlen + inlen, iov[i].v, iov[i].length);
		if (debug)
			fprintf(stderr, "outlen is %d; inlen is %d\n", outlen, inlen);
		/* host: fill in the writeable buffers. */
		for (i = outlen; i < outlen + inlen; i++) {
			/* host: read a line. */
			memset(consline, 0, 128);
			if (read(0, consline, 1) < 0) {
				exit(0);
			}
			if (debug) fprintf(stderr, "CONSIN: GOT A LINE:%s:\n", consline);
			if (debug) fprintf(stderr, "CONSIN: OUTLEN:%d:\n", outlen);
			if (strlen(consline) < 3 && consline[0] == 'q' ) {
				quit = 1;
				break;
			}

			memmove(iov[i].v, consline, strlen(consline)+ 1);
			iov[i].length = strlen(consline) + 1;
		}
		if (debug) fprintf(stderr, "call add_used\n");
		/* host: now ack that we used them all. */
		add_used(v, head, outlen+inlen);
		/* turn off consdata - the IRQ injection isn't right */
		//consdata = 1;
		if (debug) fprintf(stderr, "DONE call add_used\n");

		// Send spurious for testing (Gan)
		set_posted_interrupt(0xE5);
		virtio_mmio_set_vring_irq();

		ros_syscall(SYS_vmm_poke_guest, 0, 0, 0, 0, 0, 0);
	}
	fprintf(stderr, "All done\n");
	return NULL;
}