Пример #1
0
// Gioco snake :P
void main_snake()
{
	// Prima cosa, sposto la pagina 0 sulla pagina 1
	// In sostanza copio da 0xB8000 a 0xB8FFF, su 0xB9000
	memcpyb(0xB9000, 0xB8000, 0x1000);


	unsigned char *Sbuffer = get_page(1);
	tmpfs_read("pixmap.sk", Sbuffer);
	//video_scrivi_stringa(Sbuffer);
	// Ora posso scrivere tranquillamente sullo schermo:
	memcpyb(0xB8000, Sbuffer, 0x1000);
	free_page(Sbuffer); 
}
Пример #2
0
/*
 * tmpfs_main()
 *	Endless loop to receive and serve requests
 */
static void
tmpfs_main()
{
	struct msg msg;
	int x;
	struct file *f;
	extern int valid_fname(char *, int);

loop:
	/*
	 * Receive a message, log an error and then keep going
	 */
	x = msg_receive(rootport, &msg);
	if (x < 0) {
		syslog(LOG_ERR, "msg_receive");
		goto loop;
	}

	/*
	 * Categorize by basic message operation
	 */
	f = hash_lookup(filehash, msg.m_sender);
	switch (msg.m_op & MSG_MASK) {
	case M_CONNECT:		/* New client */
		new_client(&msg);
		break;
	case M_DISCONNECT:	/* Client done */
		dead_client(&msg, f);
		break;
	case M_DUP:		/* File handle dup during exec() */
		dup_client(&msg, f);
		break;
	case M_ABORT:		/* Aborted operation */
		/*
		 * We're synchronous, so presumably the operation
		 * is all done and this abort is old news.
		 */
		msg_reply(msg.m_sender, &msg);
		break;
	case FS_OPEN:		/* Look up file from directory */
		if ((msg.m_nseg != 1) || !valid_fname(msg.m_buf,
				msg.m_buflen)) {
			msg_err(msg.m_sender, EINVAL);
			break;
		}
		tmpfs_open(&msg, f);
		break;

	case FS_ABSREAD:	/* Set position, then read */
		if (msg.m_arg1 < 0) {
			msg_err(msg.m_sender, EINVAL);
			break;
		}
		f->f_pos = msg.m_arg1;
		/* VVV fall into VVV */
	case FS_READ:		/* Read file */
		tmpfs_read(&msg, f);
		break;

	case FS_ABSWRITE:	/* Set position, then write */
		if (msg.m_arg1 < 0) {
			msg_err(msg.m_sender, EINVAL);
			break;
		}
		f->f_pos = msg.m_arg1;
		/* VVV fall into VVV */
	case FS_WRITE:		/* Write file */
		tmpfs_write(&msg, f);
		break;

	case FS_SEEK:		/* Set new file position */
		tmpfs_seek(&msg, f);
		break;
	case FS_REMOVE:		/* Get rid of a file */
		if ((msg.m_nseg != 1) || !valid_fname(msg.m_buf,
				msg.m_buflen)) {
			msg_err(msg.m_sender, EINVAL);
			break;
		}
		tmpfs_remove(&msg, f);
		break;
	case FS_STAT:		/* Tell about file */
		tmpfs_stat(&msg, f);
		break;
	case FS_WSTAT:		/* Set stuff on file */
		tmpfs_wstat(&msg, f);
		break;

	case FS_FID:		/* Return file ID for caching */
		tmpfs_fid(&msg, f);
		break;

	default:		/* Unknown */
		msg_err(msg.m_sender, EINVAL);
		break;
	}
	goto loop;
}