summaryrefslogtreecommitdiff
path: root/sys/include
diff options
context:
space:
mode:
Diffstat (limited to 'sys/include')
-rw-r--r--sys/include/sys/proc.h5
-rw-r--r--sys/include/sys/signal.h84
2 files changed, 89 insertions, 0 deletions
diff --git a/sys/include/sys/proc.h b/sys/include/sys/proc.h
index b9db603..b10ee41 100644
--- a/sys/include/sys/proc.h
+++ b/sys/include/sys/proc.h
@@ -38,6 +38,7 @@
#include <sys/syscall.h>
#include <sys/exec.h>
#include <sys/filedesc.h>
+#include <sys/signal.h>
#if defined(_KERNEL)
#include <machine/frame.h>
#include <machine/pcb.h>
@@ -48,10 +49,12 @@
#define PROC_STACK_PAGES 8
#define PROC_STACK_SIZE (PROC_STACK_PAGES * DEFAULT_PAGESIZE)
#define PROC_MAX_FILEDES 256
+#define PROC_SIGMAX 64
struct proc {
pid_t pid;
struct exec_prog exec;
+ struct ksiginfo *ksig_list[PROC_SIGMAX];
struct filedesc *fds[PROC_MAX_FILEDES];
struct trapframe tf;
struct pcb pcb;
@@ -59,6 +62,8 @@ struct proc {
bool rested;
uint32_t flags;
uintptr_t stack_base;
+ struct spinlock ksigq_lock;
+ TAILQ_HEAD(, ksiginfo) ksigq;
TAILQ_ENTRY(proc) link;
};
diff --git a/sys/include/sys/signal.h b/sys/include/sys/signal.h
new file mode 100644
index 0000000..f35ff82
--- /dev/null
+++ b/sys/include/sys/signal.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_SIGNAL_H_
+#define _SYS_SIGNAL_H_
+
+#include <sys/types.h>
+#include <sys/queue.h>
+#include <sys/proc.h>
+
+#define SIGFPE 8 /* Floating point exception */
+#define SIGKILL 9 /* Kill */
+#define SIGSEGV 11 /* Segmentation violation */
+
+typedef uint32_t sigset_t;
+
+typedef struct {
+ int si_signo;
+ int si_code;
+} siginfo_t;
+
+struct sigaction {
+ void(*sa_handler)(int signo);
+ sigset_t sa_mask;
+ int sa_flags;
+ void(*sa_sigaction)(int signo, siginfo_t *si, void *p);
+};
+
+#if defined(_KERNEL)
+struct proc;
+
+struct ksiginfo {
+ int signo;
+ int sigcode;
+ struct sigaction *si;
+ TAILQ_ENTRY(ksiginfo) link;
+};
+
+/* Signal management */
+int newsig(struct proc *td, int signo, struct ksiginfo **ksig);
+int delsig(struct proc *td, int signo);
+int sendsig(struct proc *td, const sigset_t *set);
+void dispatch_signals(struct proc *td);
+int signals_init(struct proc *td);
+
+/* Sigset functions */
+int sigemptyset(sigset_t *set);
+int sigfillset(sigset_t *set);
+int sigaddset(sigset_t *set, int signo);
+int sigdelset(sigset_t *set, int signo);
+int sigismember(const sigset_t *set, int signo);
+
+/* Default handlers */
+void sigfpe_default(int signo);
+void sigkill_default(int signo);
+void sigsegv_default(int signo);
+#endif /* _KERNEL */
+#endif /* !_SYS_SIGNAL_H_ */