diff --git a/sortix/dispmsg.cpp b/sortix/dispmsg.cpp index a50bf76a..ecc17f83 100644 --- a/sortix/dispmsg.cpp +++ b/sortix/dispmsg.cpp @@ -34,8 +34,8 @@ #include #include #include +#include -#include "syscall.h" #include "dispmsg.h" namespace Sortix { diff --git a/sortix/fs/user.cpp b/sortix/fs/user.cpp index 18822222..86f04759 100644 --- a/sortix/fs/user.cpp +++ b/sortix/fs/user.cpp @@ -48,8 +48,8 @@ #include #include #include +#include -#include "../syscall.h" #include "../process.h" namespace Sortix { diff --git a/sortix/syscall.h b/sortix/include/sortix/kernel/syscall.h similarity index 72% rename from sortix/syscall.h rename to sortix/include/sortix/kernel/syscall.h index ebb4852f..1ae3ef04 100644 --- a/sortix/syscall.h +++ b/sortix/include/sortix/kernel/syscall.h @@ -1,6 +1,6 @@ /******************************************************************************* - Copyright(C) Jonas 'Sortie' Termansen 2011, 2012. + Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013. This file is part of Sortix. @@ -17,27 +17,24 @@ You should have received a copy of the GNU General Public License along with Sortix. If not, see . - syscall.h - Handles system calls from userspace. + sortix/kernel/syscall.h + Handles system calls from user-space. *******************************************************************************/ -#ifndef SORTIX_SYSCALL_H -#define SORTIX_SYSCALL_H +#ifndef INCLUDE_SORTIX_KERNEL_SYSCALL_H +#define INCLUDE_SORTIX_KERNEL_SYSCALL_H #include -#include "cpu.h" -namespace Sortix -{ - class Thread; +namespace Sortix { +namespace Syscall { - namespace Syscall - { - void Init(); - void Register(size_t index, void* funcptr); - } -} +void Init(); +void Register(size_t index, void* funcptr); + +} // namespace Syscall +} // namespace Sortix extern "C" void syscall_handler(); diff --git a/sortix/initrd.cpp b/sortix/initrd.cpp index 7bfeaaaf..3c368cdb 100644 --- a/sortix/initrd.cpp +++ b/sortix/initrd.cpp @@ -30,15 +30,18 @@ #include #include #include +#include + #include #include #include #include + #include #include #include + #include "initrd.h" -#include "syscall.h" namespace Sortix { namespace InitRD { diff --git a/sortix/interrupt.cpp b/sortix/interrupt.cpp index 370521c3..c6bc8903 100644 --- a/sortix/interrupt.cpp +++ b/sortix/interrupt.cpp @@ -23,13 +23,15 @@ *******************************************************************************/ #include +#include + #include #include #include + #include "x86-family/idt.h" #include "interrupt.h" #include "scheduler.h" -#include "syscall.h" #include "signal.h" #include "process.h" diff --git a/sortix/io.cpp b/sortix/io.cpp index 66e4b790..6499994b 100644 --- a/sortix/io.cpp +++ b/sortix/io.cpp @@ -30,16 +30,18 @@ #include #include #include +#include #include #include #include #include + #include #include + #include "thread.h" #include "process.h" -#include "syscall.h" #include "io.h" namespace Sortix { diff --git a/sortix/kernel.cpp b/sortix/kernel.cpp index c5d27229..cdee85de 100644 --- a/sortix/kernel.cpp +++ b/sortix/kernel.cpp @@ -41,13 +41,17 @@ #include #include #include +#include + #include #include #include #include + #include #include #include + #include "kernelinfo.h" #include "x86-family/gdt.h" #include "x86-family/float.h" @@ -57,7 +61,6 @@ #include "process.h" #include "scheduler.h" #include "signal.h" -#include "syscall.h" #include "ata.h" #include "com.h" #include "uart.h" diff --git a/sortix/kernelinfo.cpp b/sortix/kernelinfo.cpp index 49a5b809..679f619f 100644 --- a/sortix/kernelinfo.cpp +++ b/sortix/kernelinfo.cpp @@ -23,8 +23,10 @@ *******************************************************************************/ #include +#include + #include -#include "syscall.h" + #include "kernelinfo.h" #ifndef VERSIONSTR diff --git a/sortix/log.cpp b/sortix/log.cpp index aa230579..d6a92ba9 100644 --- a/sortix/log.cpp +++ b/sortix/log.cpp @@ -23,9 +23,10 @@ *******************************************************************************/ #include -#include +#include #include -#include "syscall.h" + +#include namespace Sortix { diff --git a/sortix/memorymanagement.cpp b/sortix/memorymanagement.cpp index 9dc49a82..54a46ad0 100644 --- a/sortix/memorymanagement.cpp +++ b/sortix/memorymanagement.cpp @@ -24,7 +24,7 @@ #include #include -#include "syscall.h" +#include namespace Sortix { namespace Memory { diff --git a/sortix/pipe.cpp b/sortix/pipe.cpp index 4f1271d8..1bec9dfb 100644 --- a/sortix/pipe.cpp +++ b/sortix/pipe.cpp @@ -41,16 +41,18 @@ #include #include #include +#include #include #include + #include #include #include + #include "signal.h" #include "thread.h" #include "process.h" -#include "syscall.h" #include "pipe.h" namespace Sortix { diff --git a/sortix/poll.cpp b/sortix/poll.cpp index 56000198..9cb4244d 100644 --- a/sortix/poll.cpp +++ b/sortix/poll.cpp @@ -40,8 +40,8 @@ #include #include #include +#include -#include "syscall.h" #include "process.h" #include "poll.h" diff --git a/sortix/process.cpp b/sortix/process.cpp index 3672139f..f1e9497b 100644 --- a/sortix/process.cpp +++ b/sortix/process.cpp @@ -33,6 +33,9 @@ #include #include #include +#include +#include + #include #include #include @@ -40,16 +43,16 @@ #include #include #include -#include + #include #include #include + #include "thread.h" #include "process.h" #include "scheduler.h" #include "initrd.h" #include "elf.h" -#include "syscall.h" namespace Sortix { diff --git a/sortix/scheduler.cpp b/sortix/scheduler.cpp index 81b9f0a2..1b9287b8 100644 --- a/sortix/scheduler.cpp +++ b/sortix/scheduler.cpp @@ -24,11 +24,13 @@ #include #include +#include + #include #include + #include "x86-family/gdt.h" #include "x86-family/float.h" -#include "syscall.h" #include "interrupt.h" #include "time.h" #include "thread.h" diff --git a/sortix/sound.cpp b/sortix/sound.cpp index fb944d7e..a7cee97a 100644 --- a/sortix/sound.cpp +++ b/sortix/sound.cpp @@ -24,8 +24,10 @@ #include #include +#include + +#include "cpu.h" #include "sound.h" -#include "syscall.h" namespace Sortix { diff --git a/sortix/syscall.cpp b/sortix/syscall.cpp index fa800027..7878227a 100644 --- a/sortix/syscall.cpp +++ b/sortix/syscall.cpp @@ -1,6 +1,6 @@ /******************************************************************************* - Copyright(C) Jonas 'Sortie' Termansen 2011, 2012. + Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013. This file is part of Sortix. @@ -22,49 +22,46 @@ *******************************************************************************/ -#include -#include "syscall.h" #include -#include + +#include +#include + #include "process.h" #include "thread.h" #include "scheduler.h" -namespace Sortix +namespace Sortix { +namespace Syscall { + +extern "C" { - namespace Syscall - { - extern "C" - { - size_t SYSCALL_MAX; - volatile void* syscall_list[SYSCALL_MAX_NUM]; - } - - int BadSyscall() - { - Log::PrintF("I am the bad system call!\n"); - // TODO: Send signal, set errnx o, or crash/abort process? - return -1; - } - - void Init() - { - SYSCALL_MAX = SYSCALL_MAX_NUM; - for ( size_t i = 0; i < SYSCALL_MAX_NUM; i++ ) - { - syscall_list[i] = (void*) BadSyscall; - } - } - - void Register(size_t index, void* funcptr) - { - if ( SYSCALL_MAX_NUM <= index ) - { - PanicF("attempted to register syscall 0x%p to index %zu, but " - "SYSCALL_MAX_NUM = %zu", funcptr, index, SYSCALL_MAX_NUM); - } - - syscall_list[index] = funcptr; - } - } + size_t SYSCALL_MAX; + volatile void* syscall_list[SYSCALL_MAX_NUM]; } + +int BadSyscall() +{ + Log::PrintF("I am the bad system call!\n"); + // TODO: Send signal, set errno, or crash/abort process? + return -1; +} + +void Init() +{ + SYSCALL_MAX = SYSCALL_MAX_NUM; + for ( size_t i = 0; i < SYSCALL_MAX_NUM; i++ ) + syscall_list[i] = (void*) BadSyscall; +} + +void Register(size_t index, void* funcptr) +{ + + if ( SYSCALL_MAX_NUM <= index ) + PanicF("attempted to register syscall 0x%p to index %zu, but " + "SYSCALL_MAX_NUM = %zu", funcptr, index, SYSCALL_MAX_NUM); + syscall_list[index] = funcptr; +} + +} // namespace Syscall +} // namespace Sortix diff --git a/sortix/thread.cpp b/sortix/thread.cpp index fe81562f..a95b27ff 100644 --- a/sortix/thread.cpp +++ b/sortix/thread.cpp @@ -25,17 +25,20 @@ #include #include #include +#include + #include #include + #include #include #include + #include "process.h" #include "thread.h" #include "scheduler.h" #include "interrupt.h" #include "time.h" -#include "syscall.h" namespace Sortix { diff --git a/sortix/time.cpp b/sortix/time.cpp index 99cefcb4..00ae4d22 100644 --- a/sortix/time.cpp +++ b/sortix/time.cpp @@ -24,13 +24,13 @@ *******************************************************************************/ #include +#include + #include "time.h" #include "interrupt.h" #include "process.h" #include "scheduler.h" -#include #include "sound.h" -#include "syscall.h" #ifdef PLATFORM_SERIAL #include "serialterminal.h" diff --git a/sortix/vga.cpp b/sortix/vga.cpp index 2b1acc9a..bf03d84e 100644 --- a/sortix/vga.cpp +++ b/sortix/vga.cpp @@ -29,12 +29,14 @@ #include #include #include +#include + #include #include + #include "fs/util.h" #include "vga.h" #include "scheduler.h" -#include "syscall.h" #include "process.h" #define TEST_VGAFONT 0 diff --git a/sortix/x86-family/memorymanagement.cpp b/sortix/x86-family/memorymanagement.cpp index 050be003..11bff8bb 100644 --- a/sortix/x86-family/memorymanagement.cpp +++ b/sortix/x86-family/memorymanagement.cpp @@ -26,13 +26,16 @@ #include #include #include +#include + #include + #include #include #include + #include "multiboot.h" #include "memorymanagement.h" -#include "syscall.h" #include "msr.h" namespace Sortix