Signals kinda work!

This commit is contained in:
Mark
2019-12-29 16:29:16 +02:00
parent ccc13ef0d5
commit 2cbd3e65c4
15 changed files with 320 additions and 4 deletions
+9 -1
View File
@@ -5,10 +5,16 @@
struct thread;
struct amd64_thread {
uintptr_t rsp0;
uintptr_t rsp0, rsp0s;
// Normal context
uintptr_t stack0_base;
uintptr_t stack0_size;
// Signal handling context
uintptr_t stack0s_base;
uintptr_t stack0s_size;
// User stack
uintptr_t stack3_base;
uintptr_t stack3_size;
@@ -16,3 +22,5 @@ struct amd64_thread {
};
void amd64_thread_set_ip(struct thread *t, uintptr_t ip);
void amd64_thread_sigenter(struct thread *t, int signum);
void amd64_thread_sigret(struct thread *t);
+1
View File
@@ -1,6 +1,7 @@
#pragma once
#include "sys/thread.h"
struct thread *sched_find(int pid);
void sched_set_cpu_count(size_t ncpus);
void sched_add(struct thread *t);
void sched_init(void);
+13
View File
@@ -0,0 +1,13 @@
#pragma once
#define SIGINT 2
#define SIGQUIT 3
#define SIGILL 4
#define SIGABRT 6
#define SIGFPE 8
#define SIGKILL 9
#define SIGSEGV 11
#define SIGUSR1 16
#define SIGUSR2 17
+3
View File
@@ -8,6 +8,9 @@
#define SYSCALL_NR_READDIR 89
#define SYSCALL_NR_BRK 12
#define SYSCALL_NRX_SIGNAL 48
#define SYSCALL_NR_FORK 57
#define SYSCALL_NR_EXECVE 59
#define SYSCALL_NR_EXIT 60
#define SYSCALL_NR_KILL 62
#define SYSCALL_NRX_SIGRET 119
+10
View File
@@ -5,6 +5,7 @@
#define THREAD_KERNEL (1 << 31)
#define THREAD_CTX_ONLY (1 << 30)
#define THREAD_STOPPED (1 << 2)
#define THREAD_SIGRET (1 << 29)
#if defined(ARCH_AMD64)
typedef uint64_t *mm_space_t;
@@ -28,6 +29,13 @@ struct thread {
struct vfs_ioctx ioctx;
struct ofile fds[4];
// Signal processing queue
int sigqueue[8];
size_t sigqsz;
// Signal handler stack and entry
uintptr_t sigentry;
uintptr_t sigstack;
mm_space_t space;
// TODO: maybe __sched_thread
@@ -46,3 +54,5 @@ int thread_init(struct thread *t,
uint32_t flags,
void *arg);
void thread_cleanup(struct thread *t);
void thread_signal(struct thread *t, int signum);