Beispiel #1
0
/*
 * Clean up
 */
void
__exception_exit(void)
{

#ifdef _REENTRANT
	mutex_destroy(&__sig_lock);
#endif
	exception_setup(NULL);
}
Beispiel #2
0
/*
 * Initialize exception
 */
void
__exception_init(void)
{
	int i;

#ifdef _REENTRANT
	mutex_init(&__sig_lock);
#endif
	exception_setup(NULL);

	__sig_mask = 0;
	__sig_pending = 0;

	for (i = 0; i < NSIG; i++) {
		__sig_act[i].sa_flags = 0;
		__sig_act[i].sa_handler = SIG_DFL;
	}

	/* Install exception handler */
	exception_setup(__exception_handler);
}
Beispiel #3
0
/*
 * Initialize TTY.
 *
 * Since we manage the process group only in the process
 * server, the TTY driver can not know anything about the
 * process group.  However, POSIX specification requires TTY
 * driver to send a signal to the specific process group.
 * So, we will catch all TTY related signals by this server
 * and forward them to the actual process or process group.
 */
void
tty_init(void)
{
	task_t self;

	/*
	 * Setup exception to receive signals from tty.
	 */
	exception_setup(exception_handler);

	if (device_open("tty", 0, &ttydev) != 0)
		ttydev = DEVICE_NULL;
	else {
		/*
		 * Notify the TTY driver to send all tty related
		 * signals in system to this task.
		 */
		self = task_self();
		device_ioctl(ttydev, TIOCSETSIGT, &self);
	}
}
Beispiel #4
0
/*
 * Initialize TTY.
 *
 * Since we manage the process group only in the process
 * server, the TTY driver can not know anything about the
 * process group.  However, POSIX specification requires TTY
 * driver to send a signal to the specific process group.
 * So, we will catch all TTY related signals by this server
 * and forward them to the actual process or process group.
 */
void
tty_init(void)
{
	task_t self;

	/*
	 * Setup exception to receive signals from tty.
	 */
	exception_setup(exception_handler);

	if (device_open("tty", 0, &ttydev) != 0) {
		DPRINTF(("proc: no tty found\n"));
		ttydev = NODEV;
	} else {
		/*
		 * Notify the TTY driver to send all tty related
		 * signals in system to this task.
		 */
		self = task_self();
		device_ioctl(ttydev, TIOCSETSIGT, &self);
	}
}
Beispiel #5
0
static void
pow_init(void)
{
    task_t self;

    /*
     * Set default power actions
     */
    pmact.pwrbtn = PWR_OFF;
    pmact.slpbtn = PWR_SUSPEND;
    pmact.lcdclose = PWR_SUSPEND;
    pmact.lowbatt = PWR_OFF;

    /*
     * Connect to the pm driver to get all power events.
     */
    if (device_open("pm", 0, &pmdev) != 0) {
        /*
         * Bad config...
         */
        sys_panic("pow: no pm driver");
    }
    self = task_self();
    device_ioctl(pmdev, PMIOC_CONNECT, &self);

    /*
     * Setup exception to receive signals from pm driver.
     */
    exception_setup(exception_handler);

    /*
     * Start power thread.
     */
    if (run_thread(power_thread))
        sys_panic("pow_init");
}
Beispiel #6
0
/*
 * Main routine for exec service.
 */
int
main(int argc, char *argv[])
{
    const struct msg_map *map;
    struct msg *msg;
    object_t obj;
    int error;

    sys_log("Starting exec server\n");

    /* Boost thread priority. */
    thread_setpri(thread_self(), PRI_EXEC);

    /*
     * Set capability for us
     */
    bind_cap("/boot/exec", task_self());

    /*
     * Setup exception handler.
     */
    exception_setup(exception_handler);

    /*
     * Initialize exec loaders.
     */
    exec_init();

    /*
     * Create an object to expose our service.
     */
    error = object_create("!exec", &obj);
    if (error)
        sys_panic("fail to create object");

    msg = malloc(MAX_EXECMSG);
    ASSERT(msg);

    /*
     * Message loop
     */
    for (;;) {
        /*
         * Wait for an incoming request.
         */
        error = msg_receive(obj, msg, MAX_EXECMSG);
        if (error)
            continue;

        error = EINVAL;
        map = &execmsg_map[0];
        while (map->code != 0) {
            if (map->code == msg->hdr.code) {
                error = (*map->func)(msg);
                break;
            }
            map++;
        }
#ifdef DEBUG_EXEC
        if (error)
            DPRINTF(("exec: msg error=%d code=%x\n",
                     error, msg->hdr.code));
#endif
        /*
         * Reply to the client.
         *
         * Note: If EXEC_EXECVE request is handled successfully,
         * the receiver task has been terminated here. But, we
         * have to call msg_reply() even in such case to reset
         * our IPC state.
         */
        msg->hdr.status = error;
        error = msg_reply(obj, msg, MAX_EXECMSG);
    }
}