diff options
author | dzwdz | 2023-01-19 23:36:11 +0100 |
---|---|---|
committer | dzwdz | 2023-01-19 23:36:11 +0100 |
commit | a2f9ae9d4ab678fa66a2ec5d1072ea22a36a18a1 (patch) | |
tree | c048e9165b27d27075d2c17ab943ac52b46a6a40 /src/user/app | |
parent | da546a0822b1995efe1832c9cc57aab62ccdcf65 (diff) |
kernel: user interrupts
Diffstat (limited to 'src/user/app')
-rw-r--r-- | src/user/app/ext2fs/main.c | 3 | ||||
-rw-r--r-- | src/user/app/init/driver/initctl.c | 4 | ||||
-rw-r--r-- | src/user/app/init/init.c | 22 | ||||
-rw-r--r-- | src/user/app/shell/shell.c | 1 |
4 files changed, 25 insertions, 5 deletions
diff --git a/src/user/app/ext2fs/main.c b/src/user/app/ext2fs/main.c index f6d65cc..65e7460 100644 --- a/src/user/app/ext2fs/main.c +++ b/src/user/app/ext2fs/main.c @@ -12,6 +12,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> struct handle { uint32_t n; @@ -191,6 +192,8 @@ err: int main(int argc, char **argv) { + intr_set(NULL); + if (argc < 2) errx(1, "bad usage"); // TODO pread/pwrite for normal handles FILE *disk = fopen(argv[1], "r+"); diff --git a/src/user/app/init/driver/initctl.c b/src/user/app/init/driver/initctl.c index 76d1b1b..67c8ade 100644 --- a/src/user/app/init/driver/initctl.c +++ b/src/user/app/init/driver/initctl.c @@ -29,7 +29,9 @@ void initctl_drv(handle_t killswitch) { } if (!strcmp(buf, "halt")) { _syscall_write(killswitch, "halt", 4, 0, 0); - exit(1); + } + if (!strcmp(buf, "intr")) { + _syscall_write(killswitch, "intr", 4, 0, 0); } c0_fs_respond(NULL, res.len, 0); break; diff --git a/src/user/app/init/init.c b/src/user/app/init/init.c index 350d9a0..0114ac5 100644 --- a/src/user/app/init/init.c +++ b/src/user/app/init/init.c @@ -3,6 +3,7 @@ #include <camellia/syscalls.h> #include <stdint.h> #include <stdio.h> +#include <string.h> #include <unistd.h> #include <camellia/fs/misc.h> @@ -29,7 +30,7 @@ void redirect(const char *exe, const char *out, const char *in) { exit(1); } _syscall_await(); - _syscall_filicide(); + _syscall_intr(); } } } @@ -39,7 +40,7 @@ int main(void) { freopen("/kdev/com1", "a+", stdout); freopen("/kdev/com1", "a+", stderr); - printf("in init (stage 2), main at %p\n", &main); + printf("[init] stage 2, main at %p\n", &main); MOUNT_AT("/keyboard") { MOUNT_AT("/") { fs_whitelist((const char*[]){"/kdev/ps2/kb", NULL}); } @@ -104,7 +105,22 @@ int main(void) { exit(1); } - _syscall_read(killswitch_pipe[0], NULL, 0, 0); + char buf[128]; + for (;;) { + if (_syscall_read(killswitch_pipe[0], buf, 128, 0) != 4) { + break; + } + if (memcmp(buf, "intr", 4) == 0) { + _syscall_intr(); + } else if (memcmp(buf, "halt", 4) == 0) { + break; + } + } + printf("[init] intr\n"); + _syscall_intr(); + _syscall_sleep(1000); + printf("[init] filicide\n"); _syscall_filicide(); + printf("[init] goodbye\n"); return 0; } diff --git a/src/user/app/shell/shell.c b/src/user/app/shell/shell.c index 3dad1bd..564daa8 100644 --- a/src/user/app/shell/shell.c +++ b/src/user/app/shell/shell.c @@ -144,7 +144,6 @@ static void run(char *cmd) { } } - int main(int argc, char **argv) { static char buf[256]; FILE *f = stdin; |