Beispiel #1
0
/**
 * Main loop of HD driver.
 *
 *****************************************************************************/
PUBLIC void task_hd()
{
    MESSAGE msg;
    init_hd();
    while (1) {
        send_recv(RECEIVE, ANY, &msg);
        int src = msg.source;

        switch (msg.type) {
        case DEV_OPEN:
            hd_open(msg.DEVICE);
            break;

        case DEV_CLOSE:
            hd_close(msg.DEVICE);
            break;

        case DEV_READ:
        case DEV_WRITE:
            hd_rdwt(&msg);
            break;

        case DEV_IOCTL:
            hd_ioctl(&msg);
            break;

        default:
            dump_msg("HD driver::unknown msg", &msg);
            spin("FS::main_loop (invalid msg.type)");
            break;
        }

        send_recv(SEND, src, &msg);
    }
}
Beispiel #2
0
PUBLIC void task_hd()
{
    MESSAGE msg;
    init_hd();

    while (true) {
        send_recv(RECEIVE, ANY, &msg);
        int src = msg.source;

        switch (msg.type) {
        case DEV_OPEN:
            hd_identify(0);
            //hd_open(msg.DEVICE);
            break;
        case DEV_CLOSE:
            hd_close(msg.DEVICE);
            break;
        case DEV_READ:
        case DEV_WRITE:
            hd_rdwt(&msg);
            break;
        case DEV_IOCTL:
            hd_ioctl(&msg);
            break;
        default:
            kprintf("[KERNEL ERROR]HD driveer::unknown msg");
            break;
        }

        send_recv(SEND, src, &msg);
    }
}
Beispiel #3
0
Datei: hd.c Projekt: Zach41/OS
PUBLIC void task_hd() {
    MESSAGE msg;

    init_hd();
    printl("Task HD begins.\n");
    while (TRUE) {
	send_recv(RECEIVE, ANY, &msg);

	int src = msg.source;

	switch(msg.type) {
	case DEV_OPEN:
	    /* 获得硬盘的信息 */
	    /* hd_identify(0); */
	    hd_open(msg.DEVICE);
	    break;
	case DEV_CLOSE:
	    hd_close(msg.DEVICE);
	    break;
	case DEV_READ:
	case DEV_WRITE:
	    hd_rdwt(&msg);
	    break;
	case DEV_IOCTL:
	    hd_ioctl(&msg);
	    break;
	default:
	    panic("HD driver::unknown msg");
	}

	send_recv(SEND, src, &msg);
    }
}
Beispiel #4
0
/**
 * <Ring 1> Main loop of task TTY.
 *****************************************************************************/
PUBLIC void task_tty()
{
	TTY *	tty;
	MESSAGE msg;

	init_keyboard();

	for (tty = TTY_FIRST; tty < TTY_END; tty++)
		init_tty(tty);

	select_console(0);

	while (1) {
		for (tty = TTY_FIRST; tty < TTY_END; tty++) {
			do {
				tty_dev_read(tty);
				tty_dev_write(tty);
			} while (tty->ibuf_cnt);
		}

		send_recv(RECEIVE, ANY, &msg);

		int src = msg.source;
		assert(src != TASK_TTY);

		TTY* ptty = &tty_table[msg.DEVICE];

		switch (msg.type) {
		case DEV_OPEN:
			reset_msg(&msg);
			msg.type = SYSCALL_RET;
			send_recv(SEND, src, &msg);
			break;
		case DEV_READ:
			tty_do_read(ptty, &msg);
			break;
		case DEV_WRITE:
			tty_do_write(ptty, &msg);
			break;
		case HARD_INT:
			/**
			 * waked up by clock_handler -- a key was just pressed
			 * @see clock_handler() inform_int()
			 */
			key_pressed = 0;
			continue;
		default:
			dump_msg("TTY::unknown msg", &msg);
			break;
		}
	}
}
Beispiel #5
0
Datei: fs.c Projekt: qpig/sfs
void task_fs()
{
	printk("Task FS begins.\n");

	init_buffer( 0x300000 );
	init_fs();

	MESSAGE msg;

	while(1)
	{
		send_recv( RECEIVE, ANY, &msg );
		int src = msg.source;
		switch(msg.type)
		{
			case OPEN:
				msg.FD = do_open( &msg );
				break;
			case CLOSE:
				msg.RETVAL = do_close( &msg );
				break;
			case READ:
			case WRITE:
				msg.CNT = do_rdwr( &msg );
				break;
			case RESUME_PROC:
				src = msg.PROC_NR;
				break;
			case FORK:
				msg.RETVAL = fs_fork( &msg );
				break;
			case EXIT:
				msg.RETVAL = fs_exit( &msg );
				break;
			default:
				dump_msg("FS:unknow message:", &msg );
				assert(0);
				break;
		}

		if( msg.type != SUSPEND_PROC )
		{
			msg.type = SYSCALL_RET;
			send_recv( SEND, src, &msg );
		}
	}
	spin("FS");
}
Beispiel #6
0
PUBLIC int execv(const char *path, char *argv[])
{
	char **p = argv;
	char arg_stack[PROC_ORIGIN_STACK];
	int stack_len = 0;

	while(*p++) {
		stack_len += sizeof(char*);
	}

	*((int*)(&arg_stack[stack_len])) = 0;
	stack_len += sizeof(char*);

	char ** q = (char**)arg_stack;
	for (p = argv; *p != 0; p++) {
		*q++ = &arg_stack[stack_len];

		strcpy(&arg_stack[stack_len], *p);
		stack_len += strlen(*p);
		arg_stack[stack_len] = 0;
		stack_len++;
	}

	MESSAGE msg;
	msg.type = EXEC;
	msg.PATHNAME = (void*)path;
	msg.NAME_LEN = strlen(path);
	msg.BUF	= (void*)arg_stack;
	msg.BUF_LEN	= stack_len;

	send_recv(BOTH, TASK_MM, &msg);

	return msg.RETVAL;
}
Beispiel #7
0
int main()
{
        fd_set master;
        fd_set read_fds;
        int fdmax, i;
        int sockfd= 0;
        struct sockaddr_in my_addr, client_addr;
        
        FD_ZERO(&master);
        FD_ZERO(&read_fds);
        connect_request(&sockfd, &my_addr);
        printf("debug: %i", sockfd);
        FD_SET(sockfd, &master);
        
        fdmax = sockfd;
        while(1){
                read_fds = master;
                if(select(fdmax+1, &read_fds, NULL, NULL, NULL) == -1){
                        perror("select");
                        exit(4);
                }
                for (i = 0; i <= fdmax; i++){
                        if (FD_ISSET(i, &read_fds)){
                                if (i == sockfd){
                                        connection_accept(&master, &fdmax, sockfd, &client_addr);
                                }else{
                                        send_recv(i, &master, sockfd, fdmax);
                                }
                        }
                }
        }
        return 0;
}
Beispiel #8
0
/**
 * <Ring 1> Read super block from the given device then write it into a free
 *          super_block[] slot.
 * 
 * @param dev  From which device the super block comes.
 *****************************************************************************/
PRIVATE void read_super_block(int dev)
{
	int i;
	MESSAGE driver_msg;

	driver_msg.type		= DEV_READ;
	driver_msg.DEVICE	= MINOR(dev);
	driver_msg.POSITION	= SECTOR_SIZE * 1;
	driver_msg.BUF		= fsbuf;
	driver_msg.CNT		= SECTOR_SIZE;
	driver_msg.PROC_NR	= TASK_FS;
	assert(dd_map[MAJOR(dev)].driver_nr != INVALID_DRIVER);
	send_recv(BOTH, dd_map[MAJOR(dev)].driver_nr, &driver_msg);

	/* find a free slot in super_block[] */
	for (i = 0; i < NR_SUPER_BLOCK; i++)
		if (super_block[i].sb_dev == NO_DEV)
			break;
	if (i == NR_SUPER_BLOCK)
		panic("super_block slots used up");

	assert(i == 0); /* currently we use only the 1st slot */

	struct super_block * psb = (struct super_block *)fsbuf;

	super_block[i] = *psb;
	super_block[i].sb_dev = dev;
}
Beispiel #9
0
/**
 * Write chars to console.
 * 
 * @param tty The TTY struct.
 *****************************************************************************/
PRIVATE void cons_write(TTY * tty)
{
	char buf[TTY_OUT_BUF_LEN];
	char * p = tty->tty_outbuf;
	int i = tty->tty_outleft;
	int j;

	/* Nothing to write */
	if (i == 0) return;
	while (i) {
		int bytes = min(TTY_OUT_BUF_LEN, i);
		data_copy(TASK_TTY, D, buf, tty->tty_outprocnr, D, p, bytes);
		for (j = 0; j < bytes; j++)
		{
			tty->tty_outcnt++;
			out_char(tty, buf[j]);
		}
		tty->tty_outleft -= bytes;
		i -= bytes;
		p += bytes;
	}

	flush((CONSOLE *)tty->tty_dev);

	if (tty->tty_outleft == 0) {	/* done, reply to caller */
		MESSAGE msg;
		msg.type = tty->tty_outreply;
		msg.PROC_NR = tty->tty_outprocnr;
		msg.CNT = tty->tty_outcnt;
		send_recv(SEND, tty->tty_outcaller, &msg); 
	}
}
Beispiel #10
0
int main()
{
        int sockfd, fdmax, i;
        struct sockaddr_in server_addr;
        fd_set master;
        fd_set read_fds;
        char name[20];
        printf("Enter your name: ");
        gets(name);

        connect_request(&sockfd, &server_addr);
        send(sockfd, name, strlen(name), 0);

        FD_ZERO(&master);
        FD_ZERO(&read_fds);
        FD_SET(0, &master);
        FD_SET(sockfd, &master);
        fdmax = sockfd;
        
        while(1){
                read_fds = master;
                if(select(fdmax+1, &read_fds, NULL, NULL, NULL) == -1){
                        perror("select");
                        exit(4);
                }
                
                for(i=0; i <= fdmax; i++ )
                        if(FD_ISSET(i, &read_fds))
                                send_recv(i, sockfd);
        }
        printf("client-quited\n");
        close(sockfd);
        return 0;
}
Beispiel #11
0
/**
 * <Ring 1> Send read/write request.
 * @param  fs_ep      Endpoint of FS driver.
 * @param  dev        On which device this file resides.
 * @param  num        Inode nr.
 * @param  pos        Where to read/write.
 * @param  rw_flag    Read or write.
 * @param  src        Who wanna read/write.
 * @param  buf        Buffer.
 * @param  nbytes     How many bytes to read/write.
 * @param  newpos     [OUT] New position.
 * @param  bytes_rdwt [OUT] How many bytes read/written. 
 * @return            Zero on success. Otherwise an error code.
 */
PUBLIC int request_readwrite(endpoint_t fs_ep, dev_t dev, ino_t num, u64 pos, int rw_flag, endpoint_t src,
    void * buf, int nbytes, u64 * newpos, int * bytes_rdwt)
{
    MESSAGE m;
    m.type = FS_RDWT;
    m.RWDEV = dev;
    m.RWINO = num;
    m.RWPOS = pos;
    m.RWFLAG = rw_flag;
    m.RWSRC = src;
    m.RWBUF = buf;
    m.RWCNT = nbytes;

    send_recv(BOTH, fs_ep, &m);

    if (m.type != FSREQ_RET) {
        printl("VFS: request_readwrite: received invalid message.");
        return EINVAL;
    }

    *newpos = m.RWPOS;
    *bytes_rdwt = m.RWCNT;

    return m.RWRET;
}
Beispiel #12
0
PUBLIC int do_ioctl(MESSAGE * p)
{
    int fd = p->FD;
    struct file_desc * filp = pcaller->filp[fd];

    struct inode * pin = filp->fd_inode;

    int file_type = pin->i_mode & I_TYPE;
    if (file_type != I_CHAR_SPECIAL && file_type != I_BLOCK_SPECIAL) return ENOTTY;

    dev_t dev = pin->i_specdev;

    if (file_type == I_BLOCK_SPECIAL) {

    } else {
        MESSAGE msg_to_driver;

        msg_to_driver.type = DEV_IOCTL;
        msg_to_driver.DEVICE = MINOR(dev);
        msg_to_driver.REQUEST = p->REQUEST;
        msg_to_driver.BUF = p->BUF;
        msg_to_driver.PROC_NR = p->source;

        assert(dd_map[MAJOR(dev)].driver_nr != INVALID_DRIVER);
        send_recv(BOTH, dd_map[MAJOR(dev)].driver_nr, &msg_to_driver);
    }

    return 0;
}
Beispiel #13
0
/**
 * <Ring 1> Do some preparation.
 * 
 *****************************************************************************/
PRIVATE void init_fs()
{
	int i;

	/* f_desc_table[] */
	for (i = 0; i < NR_FILE_DESC; i++)
		memset(&f_desc_table[i], 0, sizeof(struct file_desc));

	/* inode_table[] */
	for (i = 0; i < NR_INODE; i++)
		memset(&inode_table[i], 0, sizeof(struct inode));

	/* super_block[] */
	struct super_block * sb = super_block;
	for (; sb < &super_block[NR_SUPER_BLOCK]; sb++)
		sb->sb_dev = NO_DEV;

	/* open the device: hard disk */
	MESSAGE driver_msg;
	driver_msg.type = DEV_OPEN;
	driver_msg.DEVICE = MINOR(ROOT_DEV);
	assert(dd_map[MAJOR(ROOT_DEV)].driver_nr != INVALID_DRIVER);
	send_recv(BOTH, dd_map[MAJOR(ROOT_DEV)].driver_nr, &driver_msg);

	/* make FS */
	mkfs();

	/* load super block of ROOT */
	read_super_block(ROOT_DEV);

	sb = get_super_block(ROOT_DEV);
	assert(sb->magic == MAGIC_V1);

	root_inode = get_inode(ROOT_DEV, ROOT_INODE);
}
Beispiel #14
0
void _stlink_usb_read_all_regs(stlink_t *sl, reg *regp) {
    struct stlink_libusb * const slu = sl->backend_data;
    unsigned char* const cmd = sl->c_buf;
    unsigned char* const data = sl->q_buf;
    ssize_t size;
    uint32_t rep_len = 84;
    int i = fill_command(sl, SG_DXFER_FROM_DEV, rep_len);

    cmd[i++] = STLINK_DEBUG_COMMAND;
    cmd[i++] = STLINK_DEBUG_READALLREGS;
    size = send_recv(slu, 1, cmd, slu->cmd_len, data, rep_len);
    if (size == -1) {
        printf("[!] send_recv\n");
        return;
    }
    sl->q_len = (size_t) size;
    stlink_print_data(sl);
    for(i=0; i<16; i++)
        regp->r[i]= read_uint32(sl->q_buf, i*4);
    regp->xpsr       = read_uint32(sl->q_buf, 64);
    regp->main_sp    = read_uint32(sl->q_buf, 68);
    regp->process_sp = read_uint32(sl->q_buf, 72);
    regp->rw         = read_uint32(sl->q_buf, 76);
    regp->rw2        = read_uint32(sl->q_buf, 80);
    if (sl->verbose < 2)
        return;

    DLOG("xpsr       = 0x%08x\n", read_uint32(sl->q_buf, 64));
    DLOG("main_sp    = 0x%08x\n", read_uint32(sl->q_buf, 68));
    DLOG("process_sp = 0x%08x\n", read_uint32(sl->q_buf, 72));
    DLOG("rw         = 0x%08x\n", read_uint32(sl->q_buf, 76));
    DLOG("rw2        = 0x%08x\n", read_uint32(sl->q_buf, 80));
}
Beispiel #15
0
static void open_stream(int sd, const char *str) {
	int n;
	send_recv(sd, str);
	n=read(sd, buf, BUFSIZE);
	buf[n] = '\0';
	printf("%s\n",buf);
}
Beispiel #16
0
int node1(const char *url)
{
        int sock = nn_socket(AF_SP, NN_PAIR);
        assert(sock >= 0);
        assert(nn_connect(sock, url) >= 0);
        send_recv(sock, NODE1);
        return nn_shutdown (sock, 0);
}
Beispiel #17
0
/*****************************************************************************
 *                                get_ticks
 *****************************************************************************/
PUBLIC int get_ticks()
{
	MESSAGE msg;
	reset_msg(&msg);
	msg.type = GET_TICKS;
	send_recv(BOTH, TASK_SYS, &msg);
	return msg.RETVAL;
}
Beispiel #18
0
int
main(int argc, char *argv[])
{
	int sockfd, fdmax, i, ret;
	struct sockaddr_in server_addr;
	fd_set master, read_fds;
	struct User user;
	strncpy(user.room, "Default", 8);

	if (argc < 2) {
		getlogin_r(user.name, sizeof(user.name));
		if (strcmp(user.name,"") == 0 )
			printf
			    ("\nNO user informed: Using system's username: %s\n",
			    user.name);
	} else if (argc == 3 || argc > 3) {
		strncpy(user.room, argv[2], sizeof(argv[2])+1);
		strncpy(user.name, argv[1], sizeof(argv[1])+1);
	} else
		strncpy(user.name, argv[1], sizeof(argv[1])+1);

	

	ret = connect_request(&sockfd, &server_addr);
	if (ret)
		exit (1);


	FD_ZERO(&master);
	FD_ZERO(&read_fds);
	FD_SET(0, &master);
	FD_SET(sockfd, &master);
	fdmax = sockfd + 1;

	ret = auth(user, sockfd);
	if (ret) {
		printf("\nERROR: authentication error\n");
		return (401);
	}

	printf("\n\nWellcome to Room #(%s) \n\n", user.room);
	fflush(stdout);

	while (1) {
		read_fds = master;
		if (select(fdmax, &read_fds, NULL, NULL, NULL) == -1) {
			perror("select");
			exit (4);
		}

		for (i = 0; i <= fdmax; i++)
			if (FD_ISSET(i, &read_fds))
				send_recv(i, sockfd, user);
	}

	close (sockfd);
	return 0;
}
Beispiel #19
0
static void send_data(int sd, const char *to, const char *data, int len) {
	int n;
	//int i, seq;
	char *sid = new_sid();

	send_recv(sd, get_send_init(buf, to, new_id(), sid, "log.xml", 619));
	send_recv(sd, get_send_disco(buf, to, new_id()));
	n = read(sd, buf, BUFSIZE);
	buf[n] = '\0';
	printf("<===\n%s\n", buf);
	send_recv(sd, get_send_block_size(buf, to, new_id(), sid));

	sprintf(buf, "<iq id=\"%s\" to=\"%s@%s/Spark 2.6.3\" type=\"set\"><data xmlns=\"http://jabber.org/protocol/ibb\" seq=\"0\" sid=\"%s\">PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0nVVRGLTgnPz48c3RyZWFtOnN0cmVhbSB4bWxuczpzdHJlYW09Imh0dHA6Ly9ldGhlcnguamFiYmVyLm9yZy9zdHJlYW1zIiB4bWxucz0iamFiYmVyOmNsaWVudCIgZnJvbT0iMTkyLjE2OC4xLjEyNyIgaWQ9IjE1ZDc0NTAzIiB4bWw6bGFuZz0iZW4iIHZlcnNpb249IjEuMCI+PHN0cmVhbTpmZWF0dXJlcz48bWVjaGFuaXNtcyB4bWxucz0idXJuOmlldGY6cGFyYW1zOnhtbDpuczp4bXBwLXNhc2wiPjxtZWNoYW5pc20+RElHRVNULU1ENTwvbWVjaGFuaXNtPjxtZWNoYW5pc20+SklWRS1TSEFSRURTRUNSRVQ8L21lY2hhbmlzbT48bWVjaGFuaXNtPlBMQUlOPC9tZWNoYW5pc20+PG1lY2hhbmlzbT5DUkFNLU1ENTwvbWVjaGFuaXNtPjwvbWVjaGFuaXNtcz48Y29tcHJlc3Npb24geG1sbnM9Imh0dHA6Ly9qYWJiZXIub3JnL2ZlYXR1cmVzL2NvbXByZXNzIj48bWV0aG9kPnpsaWI8L21ldGhvZD48L2NvbXByZXNzaW9uPjxhdXRoIHhtbG5zPSJodHRwOi8vamFiYmVyLm9yZy9mZWF0dXJlcy9pcS1hdXRoIi8+PHJlZ2lzdGVyIHhtbG5zPSJodHRwOi8vamFiYmVyLm9yZy9mZWF0dXJlcy9pcS1yZWdpc3RlciIvPjwvc3RyZWFtOmZlYXR1cmVzPg==</data></iq>", new_id(), to, SERVER_IP, sid);
	send_recv(sd, buf);

	send_recv(sd, get_send_close(buf, new_id(), to, sid));

	return;
#if 0
	for (i = 0, seq = 0; i < len; i += 400, seq++) {
		n = sprintf(sock_buf, "<iq id=\"%s\" to=\"%s@%s/Spark 2.6.3\" type=\"set\"><data xmlns=\"http://jabber.org/protocol/ibb\" seq=\"%d\" sid=\"%s\">", new_id(), to, SERVER_IP, seq, sid);
		base64_encode(sock_buf + n, data+i, (len - i) > 400 ? 400 : (len -i));
		strcat(sock_buf, "</data></iq>");
		
		send_recv(sd, sock_buf);
	}

	send_recv(sd, get_send_close(buf, to, id, sid));
#endif
}
Beispiel #20
0
/**
 * Write to a file descriptor.
 *
 *****************************************************************************/
PUBLIC int ls()
{
    MESSAGE msg;
    msg.type = LS;

    send_recv(BOTH, TASK_FS, &msg);

    return msg.RETVAL;
}
Beispiel #21
0
Datei: exit.c Projekt: qpig/sfs
void exit(int status)
{
    MESSAGE msg;
    msg.type    = EXIT;
    msg.STATUS  = status;

    send_recv(BOTH, TASK_MM, &msg);
    assert(msg.type == SYSCALL_RET);
}
Beispiel #22
0
/**
 * Get the PID.
 * 
 * @return The PID.
 *****************************************************************************/
PUBLIC int getpid()
{
	MESSAGE msg;
	msg.type	= GET_PID;

	send_recv(BOTH, TASK_SYS, &msg);
	assert(msg.type == SYSCALL_RET);

	return msg.PID;
}
Beispiel #23
0
/*****************************************************************************
 *                                getgid
 *************************************************************************//**
 * Get the gid of given process
 * 
 * @return The gid
 *****************************************************************************/
PUBLIC int getgid(void)
{
	MESSAGE msg;
	msg.type	= GETGID;

	send_recv(BOTH, TASK_MM, &msg);
	assert(msg.type == SYSCALL_RET);

	return msg.RETVAL;
}
Beispiel #24
0
PUBLIC int unlink(const char* pathname) {
    MESSAGE msg;
    msg.PATHNAME = (void*)pathname;
    msg.NAME_LEN = strlen(pathname);
    msg.type     = UNLINK;

    send_recv(BOTH, TASK_FS, &msg);

    return msg.RETVAL;
}
Beispiel #25
0
/**
 * Close a file descriptor.
 * 
 * @param fd  File descriptor.
 * 
 * @return Zero if successful, otherwise -1.
 *****************************************************************************/
PUBLIC int close(int fd)
{
	MESSAGE msg;
	msg.type   = CLOSE;
	msg.FD     = fd;

	send_recv(BOTH, TASK_FS, &msg);

	return msg.RETVAL;
}
Beispiel #26
0
int main(int argc, char **argv)
{
	int op, ret;

	opts = INIT_OPTS;
	hints = fi_allocinfo();
	if (!hints)
		return EXIT_FAILURE;

	while ((op = getopt(argc, argv, "h" ADDR_OPTS INFO_OPTS)) != -1) {
		switch (op) {
		default:
			ft_parse_addr_opts(op, optarg, &opts);
			ft_parseinfo(op, optarg, hints);
			break;
		case '?':
		case 'h':
			ft_usage(argv[0], "A simple MSG client-sever example that "
				"demonstrates one possible usage of the underlying "
				"cq wait objects.");
			return EXIT_FAILURE;
		}
	}

	if (optind < argc)
		opts.dst_addr = argv[optind];

	hints->ep_attr->type	= FI_EP_MSG;
	hints->caps		= FI_MSG;
	hints->mode		= FI_LOCAL_MR;
	hints->addr_format	= FI_SOCKADDR;

	/* Fabric and connection setup */
	if (!opts.dst_addr) {
		ret = server_listen();
		if (ret)
			return -ret;
	}

	ret = opts.dst_addr ? client_connect() : server_connect();
	if (ret) {
		return -ret;
	}

	/* Exchange data */
	ret = send_recv();

	fi_shutdown(ep, 0);
	free_ep_res();
	fi_close(&cmeq->fid);
	fi_close(&dom->fid);
	fi_close(&fab->fid);

	return ret;
}
Beispiel #27
0
/**
 * <Ring 1> Do some preparation.
 * 
 *****************************************************************************/
PRIVATE void init_fs()
{
	/* open the device: hard disk */
	MESSAGE driver_msg;
	driver_msg.type = DEV_OPEN;
	driver_msg.DEVICE = MINOR(ROOT_DEV);
	assert(dd_map[MAJOR(ROOT_DEV)].driver_nr != INVALID_DRIVER);
	send_recv(BOTH, dd_map[MAJOR(ROOT_DEV)].driver_nr, &driver_msg);

	mkfs();
}
Beispiel #28
0
/**
 * Create a child process, which is actually a copy of the caller.
 * 
 * @return   On success, the PID of the child process is returned in the
 *         parent's thread of execution, and a 0 is returned in the child's
 *         thread of execution.
 *           On failure, a -1 will be returned in the parent's context, no
 *         child process will be created.
 *****************************************************************************/
PUBLIC int fork()
{
	MESSAGE msg;
	msg.type = FORK;

	send_recv(BOTH, TASK_MM, &msg);
	assert(msg.type == SYSCALL_RET);
	assert(msg.RETVAL == 0);

	return msg.PID;
}
Beispiel #29
0
/*****************************************************************************
 *                                setgid
 *************************************************************************//**
 * Set the gid of given process
 * 
 * @param gid
 * 
 * @return 
 *****************************************************************************/
PUBLIC int setgid(gid_t gid)
{
	MESSAGE msg;
	msg.type	= SETUID;
	msg.REQUEST = gid;

	send_recv(BOTH, TASK_MM, &msg);
	assert(msg.type == SYSCALL_RET);

	return msg.RETVAL;
}
Beispiel #30
0
Datei: systask.c Projekt: qq53/os
PUBLIC void task_sys()
{
	MESSAGE msg;
	
	while(1)
	{
		send_recv(RECEIVE, ANY, &msg);
		int src = msg.source;
		switch(msg.type)
		{
		case GET_TICKS:
			msg.u.mess1 = ticks;
			send_recv(SEND, src, &msg);
			break;
		default:
			panic("unknown msg type");
			break;
		}
	}
}