summaryrefslogtreecommitdiff
path: root/src/libc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libc')
-rw-r--r--src/libc/_start2.c2
-rw-r--r--src/libc/include/camellia/intr.h5
-rw-r--r--src/libc/intr.c9
-rw-r--r--src/libc/intr.s13
4 files changed, 12 insertions, 17 deletions
diff --git a/src/libc/_start2.c b/src/libc/_start2.c
index 2c6b64d..e6809b9 100644
--- a/src/libc/_start2.c
+++ b/src/libc/_start2.c
@@ -35,8 +35,8 @@ _Noreturn void _start2(struct execdata *ed) {
_klogf("_start2 %s %p", progname, __executable_start);
- _sys_intr_set(intr_trampoline);
intr_set(intr_default);
+ _sys_intr_set(intr_trampoline); /* can cause queued interrupts to arrive */
__initialcwd = ed->cwd;
exit(main(ed->argc, ed->argv, ed->envp));
diff --git a/src/libc/include/camellia/intr.h b/src/libc/include/camellia/intr.h
index b9390fd..c6d0310 100644
--- a/src/libc/include/camellia/intr.h
+++ b/src/libc/include/camellia/intr.h
@@ -1,4 +1,5 @@
#pragma once
+#include <camellia/types.h>
-void intr_set(void (*fn)(void));
-void intr_default(void);
+void intr_set(void (*fn)(struct intr_data *));
+void intr_default(struct intr_data *);
diff --git a/src/libc/intr.c b/src/libc/intr.c
index cdefc2f..c44a90e 100644
--- a/src/libc/intr.c
+++ b/src/libc/intr.c
@@ -1,13 +1,14 @@
#include <camellia/intr.h>
+#include <stdio.h>
#include <stdlib.h>
-static void intr_null(void) { }
+static void intr_null(struct intr_data *) { }
-extern void (*volatile _intr)(void);
-void intr_set(void (*fn)(void)) {
+extern void (*volatile _intr)(struct intr_data *);
+void intr_set(void (*fn)(struct intr_data *)) {
_intr = fn ? fn : intr_null;
}
-void intr_default(void) {
+void intr_default(struct intr_data *intr) {
exit(-1);
}
diff --git a/src/libc/intr.s b/src/libc/intr.s
index 008387d..dcc61fe 100644
--- a/src/libc/intr.s
+++ b/src/libc/intr.s
@@ -2,19 +2,12 @@
.global intr_trampoline
.type intr_trampoline, @function
intr_trampoline:
- push %rax
- push %rdx
+ mov %rsp, %rdi /* pass intr_data as the argument */
+ and $~0xF, %rsp
call *_intr(%rip)
- pop %rdx
- pop %rax
- pop tmprip(%rip)
- pop %rsp
- jmp *tmprip(%rip)
+ int3 /* you weren't supposed to return */
.section .bss
-tmprip:
- .skip 8
-
.global _intr
_intr:
.skip 8