From 6a3646bd288f26db323e5205e3e7d417c865933a Mon Sep 17 00:00:00 2001 From: Julian Barathieu Date: Tue, 9 Mar 2021 13:33:43 +0100 Subject: [PATCH] Syscall --- Makefile | 6 +++++- docs/kaleid/kernel/ke/syscalls.md | 9 ++++---- include/sys.h | 34 +++++++++++++++++++++++++++++++ kaleid/libc/syscall.asm | 31 ++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 include/sys.h create mode 100644 kaleid/libc/syscall.asm diff --git a/Makefile b/Makefile index 43190e0..533b311 100644 --- a/Makefile +++ b/Makefile @@ -102,7 +102,7 @@ NC='\033[1;37m' LibCSources = libc/mem.c libc/ctype.c \ libc/rand.c libc/sprintf.c \ libc/errno.c libc/string.c \ - libc/strtol.c \ + libc/strtol.c libc/syscall.c \ libbuf/bopen.c libbuf/bputc.c libbuf/bscroll.c \ libbuf/bprint.c libbuf/bgetc.c libbuf/bscan.c \ libbuf/bflush.c libbuf/bwrite.c libbuf/bread.c \ @@ -219,6 +219,10 @@ $(KOBJDIR)/libc/mem.o: $(KALEIDDIR)/libc/mem.c | $(KOBJDIR) @$(KCC) -fno-strict-aliasing $< -o $@ @echo ${CL2}[$@] ${CL}Compiled.${CL3} +$(KOBJDIR)/libc/syscall.o: $(KALEIDDIR)/libc/syscall.asm | $(KOBJDIR) + @mkdir -p $(shell dirname $@) + @$(ASM) $(ASMFLAGS) $(KALEIDDIR)/libc/syscall.asm -o $@ + @echo ${CL2}[$@] ${CL}Compiled.${CL3} ## KERNEL SPECIAL RECIPES MAKEFILE ------------------------------------------- # diff --git a/docs/kaleid/kernel/ke/syscalls.md b/docs/kaleid/kernel/ke/syscalls.md index 1b84587..fab04ee 100644 --- a/docs/kaleid/kernel/ke/syscalls.md +++ b/docs/kaleid/kernel/ke/syscalls.md @@ -13,10 +13,11 @@ registers #### Arguments -rdi : system call code -rsi : first argument -rdx : second argument -r10 : third argument +rax : system call code +rdi : first argument +rsi : second argument +rdx : third argument +rcx : fourth argument #### Return value diff --git a/include/sys.h b/include/sys.h new file mode 100644 index 0000000..377ddf9 --- /dev/null +++ b/include/sys.h @@ -0,0 +1,34 @@ +//----------------------------------------------------------------------------// +// OS on Kaleid // +// // +// Desc: System calls // +// // +// // +// Copyright © 2018-2021 The OS/K Team // +// // +// This file is part of OS/K. // +// // +// OS/K is free software: you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation, either version 3 of the License, or // +// any later version. // +// // +// OS/K is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY//without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with OS/K. If not, see . // +//----------------------------------------------------------------------------// + +#ifndef _SYS_H +#define _SYS_H + +#ifndef _LIBC_H +#include +#endif + +error_t SysStartKernelShell(void); + +#endif diff --git a/kaleid/libc/syscall.asm b/kaleid/libc/syscall.asm new file mode 100644 index 0000000..5dcf797 --- /dev/null +++ b/kaleid/libc/syscall.asm @@ -0,0 +1,31 @@ +;=----------------------------------------------------------------------------=; +; OS on Kaleid ; +; ; +; Desc: System calls ; +; ; +; ; +; Copyright © 2018-2021 The OS/K Team ; +; ; +; This file is part of OS/K. ; +; ; +; OS/K is free software: you can redistribute it and/or modify ; +; it under the terms of the GNU General Public License as published by ; +; the Free Software Foundation, either version 3 of the License, or ; +; (at your option) any later version. ; +; ; +; OS/K is distributed in the hope that it will be useful, ; +; but WITHOUT ANY WARRANTY; without even the implied warranty of ; +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; +; GNU General Public License for more details. ; +; ; +; You should have received a copy of the GNU General Public License ; +; along with OS/K. If not, see . ; +;=----------------------------------------------------------------------------=; + +global SysStartKernelShell + +SysStartKernelShell: + mov eax, 4 + int $0x80 + ret +