mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-31 22:48:21 +00:00
system calls
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
||||
objects := $(patsubst %.c,%.o,$(wildcard *.c))
|
||||
subdirs := mm sched
|
||||
subdirs := mm sched syscalls
|
||||
OBJPATH=$(OBJDIR)
|
||||
export
|
||||
|
||||
|
||||
@@ -162,9 +162,9 @@ void sched_timerhook(arch_regs* regs){
|
||||
|
||||
spinlock_release(&running.lock);
|
||||
|
||||
|
||||
|
||||
memcpy(current->regs, regs, sizeof(arch_regs));
|
||||
|
||||
arch_regs_saveextra(¤t->extraregs);
|
||||
|
||||
spinlock_acquire(¤tqueue->lock);
|
||||
|
||||
@@ -198,6 +198,8 @@ static void switch_thread(thread_t* thread){
|
||||
|
||||
arch_setkernelstack(thread->kernelstack);
|
||||
|
||||
arch_regs_setupextra(&thread->extraregs);
|
||||
|
||||
arch_switchcontext(thread->regs);
|
||||
|
||||
__builtin_unreachable();
|
||||
@@ -291,6 +293,8 @@ void sched_runinit(){
|
||||
printf("ELF load error: %s\n", strerror(ret));
|
||||
_panic("Could not load init", 0);
|
||||
}
|
||||
|
||||
thread->extraregs.gsbase = 0xFFFFFFFFDEADBEEF;
|
||||
|
||||
switch_thread(thread);
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
objects := $(patsubst %.c,%.o,$(wildcard *.c))
|
||||
subdirs :=
|
||||
OBJPATH=$(OBJDIR)
|
||||
export
|
||||
|
||||
all: $(subdirs) $(objects)
|
||||
for subdir in $(subdirs) ; do $(MAKE) -C $${subdir} ; done
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
mkdir -p $(OBJPATH)
|
||||
cp $@ $(OBJPATH)/$@
|
||||
@@ -0,0 +1,29 @@
|
||||
#include <kernel/syscalls.h>
|
||||
#include <kernel/alloc.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
syscallret syscall_libc_log(char* str){
|
||||
|
||||
syscallret ret;
|
||||
|
||||
char* buf = alloc(strlen(str) + 1);
|
||||
if(!buf){
|
||||
ret.errno = ENOMEM;
|
||||
ret.ret = -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
strcpy(buf, str);
|
||||
|
||||
printf("%s", str);
|
||||
|
||||
ret.errno = 0;
|
||||
ret.ret = 0;
|
||||
|
||||
free(buf);
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user