Kernel messages infrastructure
[akaros.git] / kern / src / frontend.c
index e3fccb2..7781399 100644 (file)
@@ -20,18 +20,22 @@ volatile int magic_mem[10];
 void
 frontend_proc_init(struct proc *SAFE p)
 {
+#ifdef __CONFIG_APPSERVER__
        pid_t parent_id = p->ppid, id = p->pid;
        int32_t errno;
        if(frontend_syscall(parent_id,APPSERVER_SYSCALL_proc_init,id,0,0,0,&errno))
                panic("Front-end server couldn't initialize new process!");
+#endif
 }
 
 void
 frontend_proc_free(struct proc *SAFE p)
 {
+#ifdef __CONFIG_APPSERVER__
        int32_t errno;
        if(frontend_syscall(0,APPSERVER_SYSCALL_proc_free,p->pid,0,0,0,&errno))
                panic("Front-end server couldn't free process!");
+#endif
 }
 
 void* user_memdup(struct proc* p, const void* va, int len)
@@ -229,13 +233,21 @@ int32_t frontend_syscall(pid_t pid, int32_t syscall_num,
                          uint32_t arg0, uint32_t arg1, 
                          uint32_t arg2, uint32_t arg3, int32_t* errno)
 {
+#ifndef __CONFIG_APPSERVER__
+       warn("No appserver support: either "
+            "don't make this syscall or enable the appserver!\n");
+       if(errno)
+               *errno = ENOSYS;
+       return -1;
+#endif
+
        static spinlock_t lock = SPINLOCK_INITIALIZER;
        int32_t ret;
 
        // only one frontend request at a time.
        // interrupts could try to do frontend requests,
        // which would deadlock, so disable them
-       spin_lock_irqsave(&lock);
+       spin_lock(&lock);
 
        // write syscall into magic memory
        magic_mem[7] = 0;
@@ -255,7 +267,7 @@ int32_t frontend_syscall(pid_t pid, int32_t syscall_num,
        if(errno)
                *errno = magic_mem[2];
 
-       spin_unlock_irqsave(&lock);
+       spin_unlock(&lock);
 
        return ret;
 }
@@ -272,7 +284,8 @@ void appserver_die(int code)
        int i;
        for(i = 0; i < num_cpus; i++)
                if(i != core_id())
-                       while(send_active_message(i,(amr_t)&__diediedie,(void*)code,0,0));
+                       while(send_kernel_message(i,(amr_t)&__diediedie,(void*)code,0,0,
+                                                 AMSG_IMMEDIATE));
 
        // just in case.
        __diediedie(0,0,code,0,0);