diff options
author | Jon Santmyer <jon@jonsantmyer.com> | 2025-09-15 15:51:13 -0400 |
---|---|---|
committer | Jon Santmyer <jon@jonsantmyer.com> | 2025-09-15 15:51:13 -0400 |
commit | 5d73ba1059771f3226c1f45d41a9e3f52d68ee3d (patch) | |
tree | d1a93562ddff3810162d5180c3fe3cda58e24dad /apps/init/stage1 | |
parent | 76ee61642d9d5c7d2abb8b92adec7ec59bd8791a (diff) | |
download | jove-os-main.tar.gz jove-os-main.tar.bz2 jove-os-main.zip |
begin init staging refactormain
Diffstat (limited to 'apps/init/stage1')
-rw-r--r-- | apps/init/stage1/initrd.h | 5 | ||||
-rw-r--r-- | apps/init/stage1/kprint.c | 15 | ||||
-rw-r--r-- | apps/init/stage1/kprint.h | 7 | ||||
-rw-r--r-- | apps/init/stage1/main.c | 24 | ||||
-rw-r--r-- | apps/init/stage1/memory.h | 6 | ||||
-rw-r--r-- | apps/init/stage1/stage1.h | 12 | ||||
-rw-r--r-- | apps/init/stage1/x86_64/syscall.c | 19 |
7 files changed, 88 insertions, 0 deletions
diff --git a/apps/init/stage1/initrd.h b/apps/init/stage1/initrd.h new file mode 100644 index 0000000..b4bec79 --- /dev/null +++ b/apps/init/stage1/initrd.h @@ -0,0 +1,5 @@ +#ifndef INIT_STAGE1_INITRD_H +#define INIT_STAGE1_INITRD_H 1 + + +#endif diff --git a/apps/init/stage1/kprint.c b/apps/init/stage1/kprint.c new file mode 100644 index 0000000..57e10f5 --- /dev/null +++ b/apps/init/stage1/kprint.c @@ -0,0 +1,15 @@ +#include "stage1.h" +#include <kernel/syscall.h> + +void +kputc(char c) +{ + _syscall_payload[0] = c; + syscall_invoke_noret(SYSCALL_DEBUG_PUTC); +} + +void +kputs(const char *s) +{ + for(; *s; s++) kputc(*s); +} diff --git a/apps/init/stage1/kprint.h b/apps/init/stage1/kprint.h new file mode 100644 index 0000000..ea71012 --- /dev/null +++ b/apps/init/stage1/kprint.h @@ -0,0 +1,7 @@ +#ifndef INIT_STAGE1_KPRINT_H +#define INIT_STAGE1_KPRINT_H 1 + +void kputc(char c); +void kputs(const char *s); + +#endif diff --git a/apps/init/stage1/main.c b/apps/init/stage1/main.c new file mode 100644 index 0000000..90e663d --- /dev/null +++ b/apps/init/stage1/main.c @@ -0,0 +1,24 @@ +#include "stage1.h" +#include "kprint.h" +#include <kernel/init.h> + +uint8_t *_syscall_payload; +uint8_t _syscall_message; + +void main(void *init_message_ptr) +{ + _syscall_payload = init_message_ptr; + _syscall_message = INIT_OBJECT_MESSAGE; + + kputs("Hello, Userland!\n"); + for(;;); +} + +__attribute__((naked)) +void +_start(void) +{ + __asm__ volatile("\ + popq %rdi; \ + jmp main"); +} diff --git a/apps/init/stage1/memory.h b/apps/init/stage1/memory.h new file mode 100644 index 0000000..72db624 --- /dev/null +++ b/apps/init/stage1/memory.h @@ -0,0 +1,6 @@ +#ifndef INIT_STAGE1_MEMORY_H +#define INIT_STAGE1_MEMORY_H 1 + + + +#endif diff --git a/apps/init/stage1/stage1.h b/apps/init/stage1/stage1.h new file mode 100644 index 0000000..d6c3e90 --- /dev/null +++ b/apps/init/stage1/stage1.h @@ -0,0 +1,12 @@ +#ifndef INIT_STAGE1_H +#define INIT_STAGE1_H 1 + +#include <stdint.h> + +extern uint8_t *_syscall_payload; +extern uint8_t _syscall_message; + +void syscall_invoke_noret(uint64_t calltype); +intmax_t syscall_invoke_ret(uint64_t calltype); + +#endif diff --git a/apps/init/stage1/x86_64/syscall.c b/apps/init/stage1/x86_64/syscall.c new file mode 100644 index 0000000..d63be52 --- /dev/null +++ b/apps/init/stage1/x86_64/syscall.c @@ -0,0 +1,19 @@ +#include "stage1/stage1.h" + +void +syscall_invoke_noret(uint64_t calltype) +{ + __asm__ volatile("syscall":: "S"(calltype), "D"(_syscall_message): "memory"); +} + +int64_t +syscall_invoke_ret(uint64_t calltype) +{ + int rax = 0; \ + __asm__ volatile("syscall": "=a"(rax) \ + : "S"(calltype), "D"(_syscall_message) \ + : "memory"); + return rax; + +} + |