void etharp_init(void)
{
	u8_t i;

	sys_lock_init( &arp_table_lock );
	arp_table = mem_calloc ( ARP_TABLE_SIZE, sizeof(struct etharp_entry) );
}
Exemplo n.º 2
0
void trap_kernel_handler(struct user_context *user_ctx)
{
	_debug("...... in %s, code = %p\n",
			__func__, user_ctx->code & ~YALNIX_PREFIX);

	switch (user_ctx->code) {
	case YALNIX_FORK:
		SET_RET(user_ctx, sys_fork(user_ctx));
		break;
	case YALNIX_EXEC:
		sys_exec((char *)user_ctx->regs[0], (char **)user_ctx->regs[1],
				user_ctx);
		break;
	case YALNIX_EXIT:
		sys_exit(user_ctx->regs[0], user_ctx);
		break;
	case YALNIX_WAIT:
		if (!FROM_USER_SPACE(user_ctx->regs[0])) {
			_error("Bad man! Please pass user space pointer!\n");
			sys_exit(ERROR, user_ctx);
		}
		SET_RET(user_ctx, sys_wait((int *)user_ctx->regs[0], user_ctx));
		break;
	case YALNIX_GETPID:
		SET_RET(user_ctx, sys_getpid());
		break;
	case YALNIX_BRK:
		SET_RET(user_ctx, sys_brk(user_ctx->regs[0]));
		break;
	case YALNIX_DELAY:
		SET_RET(user_ctx, sys_delay(user_ctx->regs[0], user_ctx));
		break;
	case YALNIX_TTY_READ:
		if (!FROM_USER_SPACE(user_ctx->regs[1])) {
			_error("Bad man! Please pass user space pointer!\n");
			sys_exit(ERROR, user_ctx);
		}
		SET_RET(user_ctx, sys_tty_read(user_ctx->regs[0],
				(char *)user_ctx->regs[1],
				user_ctx->regs[2],
				user_ctx));
		break;
	case YALNIX_TTY_WRITE:
		if (!FROM_USER_SPACE(user_ctx->regs[1])) {
			_error("Bad man! Please pass user space pointer!\n");
			sys_exit(ERROR, user_ctx);
		}
		SET_RET(user_ctx, sys_tty_write(user_ctx->regs[0],
				(char *)user_ctx->regs[1],
				user_ctx->regs[2],
				user_ctx));
		break;
	case YALNIX_PIPE_INIT:
		if (!FROM_USER_SPACE(user_ctx->regs[0])) {
			_error("Bad man! Please pass user space pointer!\n");
			sys_exit(ERROR, user_ctx);
		}
		SET_RET(user_ctx, sys_pipe_init((unsigned int *)
					user_ctx->regs[0]));
		break;
	case YALNIX_PIPE_READ:
		if (!FROM_USER_SPACE(user_ctx->regs[1])) {
			_error("Bad man! Please pass user space pointer!\n");
			sys_exit(ERROR, user_ctx);
		}
		SET_RET(user_ctx, sys_pipe_read(user_ctx->regs[0],
					(char *)user_ctx->regs[1],
					user_ctx->regs[2],
					user_ctx));
		break;
	case YALNIX_PIPE_WRITE:
		if (!FROM_USER_SPACE(user_ctx->regs[1])) {
			_error("Bad man! Please pass user space pointer!\n");
			sys_exit(ERROR, user_ctx);
		}
		SET_RET(user_ctx, sys_pipe_write(user_ctx->regs[0],
					(char *)user_ctx->regs[1],
					user_ctx->regs[2],
					user_ctx));
		break;
	case YALNIX_LOCK_INIT:
		if (!FROM_USER_SPACE(user_ctx->regs[0])) {
			_error("Bad man! Please pass user space pointer!\n");
			sys_exit(ERROR, user_ctx);
		}
		SET_RET(user_ctx, sys_lock_init((unsigned int *)
					user_ctx->regs[0]));
		break;
	case YALNIX_LOCK_ACQUIRE:
		SET_RET(user_ctx, sys_lock_acquire(user_ctx->regs[0],
						user_ctx));
		break;
	case YALNIX_LOCK_RELEASE:
		SET_RET(user_ctx, sys_lock_release(user_ctx->regs[0]));
		break;
	case YALNIX_CVAR_INIT:
		if (!FROM_USER_SPACE(user_ctx->regs[0])) {
			_error("Bad man! Please pass user space pointer!\n");
			sys_exit(ERROR, user_ctx);
		}
		SET_RET(user_ctx, sys_cvar_init((unsigned int *)
					user_ctx->regs[0]));
		break;
	case YALNIX_CVAR_WAIT:
		SET_RET(user_ctx, sys_cvar_wait(user_ctx->regs[0],
					user_ctx->regs[1],
					user_ctx));
		break;
	case YALNIX_CVAR_SIGNAL:
		SET_RET(user_ctx, sys_cvar_signal(user_ctx->regs[0]));
		break;
	case YALNIX_CVAR_BROADCAST:
		SET_RET(user_ctx, sys_cvar_broadcast(user_ctx->regs[0]));
		break;
	case YALNIX_RECLAIM:
		SET_RET(user_ctx, sys_reclaim(user_ctx->regs[0]));
		break;
	case YALNIX_CUSTOM_0:
		SET_RET(user_ctx, sys_fork_share(user_ctx));
		break;
	}

	return;
}
Exemplo n.º 3
0
void udp_init()
{
	sys_lock_init( &udp_lock );
}