]> git.corax.cc Git - corax/commitdiff
Add process_get_sighandler() function
authorMatthias Kruk <m@m10k.eu>
Sun, 5 Jan 2020 07:50:48 +0000 (16:50 +0900)
committerMatthias Kruk <m@m10k.eu>
Sun, 5 Jan 2020 07:50:48 +0000 (16:50 +0900)
kernel/core/process.c
kernel/include/process.h

index 23335e2ce0fc6a785153489a4a45b1fd698f2d7f..3102317a8ee4fd21e3ab1d6793e61ea870f59443 100644 (file)
@@ -497,7 +497,6 @@ int process_memcpy_ktop(process_t *proc, void *dst, void *src, u32_t bytes)
 {
        int ret_val;
 
-       dbg_printf("pg_dir_memcpy(%p, %p, NULL, %p, 0x%08x)\n", proc, dst, src, bytes);
        ret_val = pg_dir_memcpy(proc->p_pgdir, dst, NULL, src, bytes);
 
        return(ret_val);
@@ -761,6 +760,7 @@ int process_signal_deliver(process_t *proc, int signal)
                                }
                        }
                } else {
+                       dbg_printf("Signal to current task\n");
                        /* handle the signal in the current task */
                        task = task_get_current();
                }
@@ -779,16 +779,28 @@ int process_signal_deliver(process_t *proc, int signal)
                 * we can use it without having to perform any translations. The usermode
                 * stack will have to be translated though.
                 */
-               vesp3 = (u32_t*)kstk->prevesp;
-               ret_val = _pg_dir_vpxlate((struct pagedir*)task->t_pgdir,
-                                                                 (u32_t)vesp3, (u32_t*)&pesp3);
 
-               if(!ret_val) {
-                       u32_t *parg0;
-                       u32_t *peip;
+//             vesp3 = (u32_t*)kstk->prevesp;
+//             ret_val = _pg_dir_vpxlate((struct pagedir*)task->t_pgdir,
+//                                                               (u32_t)vesp3, (u32_t*)&pesp3);
 
-                       /* push the signal number and the return address on the userspace stack */
+               if(!ret_val) {
+                       /*
+                        * The stack frame for the signal handler should look something like this:
+                        *
+                        * | ... |
+                        * |-----|
+                        * | EIP |
+                        * | EBP |
+                        *
+                        *
+                        * We need space for two registers and the stack frame of the signal
+                        * handler. We will make use of process_memcpy_ktop() for simplicity's
+                        * sake.
+                        */
 
+                       /* ...and just return from the interrupt. Done. */
+#if 0
                        /*
                         * pesp3, pesp3 - 1, and pesp3 - 2 may not be on the same page, which would
                         * be an atrociously hard-to-find bug.
@@ -837,6 +849,7 @@ int process_signal_deliver(process_t *proc, int signal)
                         */
                        kstk->eip = (u32_t)proc->p_sighandler[signal];
                        kstk->prevesp -= (sizeof(kstk->prevesp) * 2);
+#endif /* 0 */
                }
 
                /* let the process continue execution */
@@ -857,24 +870,32 @@ cleanup:
  */
 static void _sig_term(int sig)
 {
+       debug(__func__, strlen(__func__));
+
        _exit(sig);
        return;
 }
 
 static void _sig_ign(int sig)
 {
+       debug(__func__, strlen(__func__));
+
        /* do nothing */
        return;
 }
 
 static void _sig_core(int sig)
 {
+       debug(__func__, strlen(__func__));
+
        _exit(sig);
        return;
 }
 
 static void _sig_stop(int sig)
 {
+       debug(__func__, strlen(__func__));
+
        /*
         * FIXME: Stop the process
         *  - Change the process state
@@ -889,6 +910,8 @@ static void _sig_stop(int sig)
 
 static void _sig_cont(int sig)
 {
+       debug(__func__, strlen(__func__));
+
        /*
         * FIXME: Continue the process
         *  - Change its state back to a runnable state
@@ -1012,3 +1035,12 @@ int process_task_foreach(process_t *proc, int (*func)(process_t*, task_t*, void*
 
        return(ret_val);
 }
+
+void* process_get_sighandler(process_t *proc, int signal)
+{
+       if(signal < 0 || signal > SIGMAX) {
+               return(NULL);
+       }
+
+       return((void*)proc->p_sighandler[signal]);
+}
index c24970964bc026b592502546ab8003a103a55948..ce2a108f4cea352c7a163675a242e35a41878d21 100644 (file)
@@ -48,6 +48,8 @@ int           process_wait(pid_t);
 int           process_signal(pid_t);
 int           process_signal_deliver(process_t*, int);
 
+void*         process_get_sighandler(process_t*, int);
+
 void*         process_get_tasks(process_t*);
 pid_t         process_get_id(process_t*);
 int           process_exit(process_t*, int);