Refactor system call API.

This commit is contained in:
Jonas 'Sortie' Termansen 2013-01-09 00:41:35 +01:00
parent 76fe8602f3
commit 2ce76e3876
20 changed files with 100 additions and 76 deletions

View File

@ -34,8 +34,8 @@
#include <sortix/kernel/platform.h>
#include <sortix/kernel/video.h>
#include <sortix/kernel/string.h>
#include <sortix/kernel/syscall.h>
#include "syscall.h"
#include "dispmsg.h"
namespace Sortix {

View File

@ -48,8 +48,8 @@
#include <sortix/kernel/descriptor.h>
#include <sortix/kernel/vnode.h>
#include <sortix/kernel/mtable.h>
#include <sortix/kernel/syscall.h>
#include "../syscall.h"
#include "../process.h"
namespace Sortix {

View File

@ -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 <http://www.gnu.org/licenses/>.
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 <sortix/syscallnum.h>
#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();

View File

@ -30,15 +30,18 @@
#include <sortix/kernel/string.h>
#include <sortix/kernel/ioctx.h>
#include <sortix/kernel/fsfunc.h>
#include <sortix/kernel/syscall.h>
#include <sortix/fcntl.h>
#include <sortix/initrd.h>
#include <sortix/stat.h>
#include <sortix/mman.h>
#include <assert.h>
#include <errno.h>
#include <string.h>
#include "initrd.h"
#include "syscall.h"
namespace Sortix {
namespace InitRD {

View File

@ -23,13 +23,15 @@
*******************************************************************************/
#include <sortix/kernel/platform.h>
#include <sortix/kernel/syscall.h>
#include <assert.h>
#include <errno.h>
#include <string.h>
#include "x86-family/idt.h"
#include "interrupt.h"
#include "scheduler.h"
#include "syscall.h"
#include "signal.h"
#include "process.h"

View File

@ -30,16 +30,18 @@
#include <sortix/kernel/dtable.h>
#include <sortix/kernel/string.h>
#include <sortix/kernel/kthread.h>
#include <sortix/kernel/syscall.h>
#include <sortix/seek.h>
#include <sortix/dirent.h>
#include <sortix/fcntl.h>
#include <sortix/stat.h>
#include <assert.h>
#include <errno.h>
#include "thread.h"
#include "process.h"
#include "syscall.h"
#include "io.h"
namespace Sortix {

View File

@ -41,13 +41,17 @@
#include <sortix/kernel/dtable.h>
#include <sortix/kernel/mtable.h>
#include <sortix/kernel/keyboard.h>
#include <sortix/kernel/syscall.h>
#include <sortix/fcntl.h>
#include <sortix/stat.h>
#include <sortix/mman.h>
#include <sortix/wait.h>
#include <assert.h>
#include <errno.h>
#include <malloc.h>
#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"

View File

@ -23,8 +23,10 @@
*******************************************************************************/
#include <sortix/kernel/platform.h>
#include <sortix/kernel/syscall.h>
#include <errno.h>
#include "syscall.h"
#include "kernelinfo.h"
#ifndef VERSIONSTR

View File

@ -23,9 +23,10 @@
*******************************************************************************/
#include <sortix/kernel/platform.h>
#include <string.h>
#include <sortix/kernel/syscall.h>
#include <sortix/kernel/log.h>
#include "syscall.h"
#include <string.h>
namespace Sortix
{

View File

@ -24,7 +24,7 @@
#include <sortix/kernel/platform.h>
#include <sortix/kernel/memorymanagement.h>
#include "syscall.h"
#include <sortix/kernel/syscall.h>
namespace Sortix {
namespace Memory {

View File

@ -41,16 +41,18 @@
#include <sortix/kernel/descriptor.h>
#include <sortix/kernel/dtable.h>
#include <sortix/kernel/poll.h>
#include <sortix/kernel/syscall.h>
#include <sortix/signal.h>
#include <sortix/stat.h>
#include <assert.h>
#include <errno.h>
#include <string.h>
#include "signal.h"
#include "thread.h"
#include "process.h"
#include "syscall.h"
#include "pipe.h"
namespace Sortix {

View File

@ -40,8 +40,8 @@
#include <sortix/kernel/descriptor.h>
#include <sortix/kernel/ioctx.h>
#include <sortix/kernel/poll.h>
#include <sortix/kernel/syscall.h>
#include "syscall.h"
#include "process.h"
#include "poll.h"

View File

@ -33,6 +33,9 @@
#include <sortix/kernel/worker.h>
#include <sortix/kernel/memorymanagement.h>
#include <sortix/kernel/string.h>
#include <sortix/kernel/syscall.h>
#include <sortix/kernel/sortedlist.h>
#include <sortix/signal.h>
#include <sortix/unistd.h>
#include <sortix/fcntl.h>
@ -40,16 +43,16 @@
#include <sortix/fork.h>
#include <sortix/mman.h>
#include <sortix/wait.h>
#include <sortix/kernel/sortedlist.h>
#include <assert.h>
#include <errno.h>
#include <string.h>
#include "thread.h"
#include "process.h"
#include "scheduler.h"
#include "initrd.h"
#include "elf.h"
#include "syscall.h"
namespace Sortix
{

View File

@ -24,11 +24,13 @@
#include <sortix/kernel/platform.h>
#include <sortix/kernel/memorymanagement.h>
#include <sortix/kernel/syscall.h>
#include <assert.h>
#include <string.h>
#include "x86-family/gdt.h"
#include "x86-family/float.h"
#include "syscall.h"
#include "interrupt.h"
#include "time.h"
#include "thread.h"

View File

@ -24,8 +24,10 @@
#include <sortix/kernel/platform.h>
#include <sortix/kernel/kthread.h>
#include <sortix/kernel/syscall.h>
#include "cpu.h"
#include "sound.h"
#include "syscall.h"
namespace Sortix
{

View File

@ -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 <sortix/kernel/platform.h>
#include "syscall.h"
#include <sortix/syscallnum.h>
#include <sortix/kernel/panic.h>
#include <sortix/kernel/platform.h>
#include <sortix/kernel/syscall.h>
#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

View File

@ -25,17 +25,20 @@
#include <sortix/kernel/platform.h>
#include <sortix/kernel/kthread.h>
#include <sortix/kernel/memorymanagement.h>
#include <sortix/kernel/syscall.h>
#include <sortix/mman.h>
#include <sortix/signal.h>
#include <assert.h>
#include <errno.h>
#include <string.h>
#include "process.h"
#include "thread.h"
#include "scheduler.h"
#include "interrupt.h"
#include "time.h"
#include "syscall.h"
namespace Sortix
{

View File

@ -24,13 +24,13 @@
*******************************************************************************/
#include <sortix/kernel/platform.h>
#include <sortix/kernel/syscall.h>
#include "time.h"
#include "interrupt.h"
#include "process.h"
#include "scheduler.h"
#include <sortix/kernel/log.h>
#include "sound.h"
#include "syscall.h"
#ifdef PLATFORM_SERIAL
#include "serialterminal.h"

View File

@ -29,12 +29,14 @@
#include <sortix/kernel/inode.h>
#include <sortix/kernel/descriptor.h>
#include <sortix/kernel/interlock.h>
#include <sortix/kernel/syscall.h>
#include <errno.h>
#include <string.h>
#include "fs/util.h"
#include "vga.h"
#include "scheduler.h"
#include "syscall.h"
#include "process.h"
#define TEST_VGAFONT 0

View File

@ -26,13 +26,16 @@
#include <sortix/kernel/panic.h>
#include <sortix/kernel/kthread.h>
#include <sortix/kernel/memorymanagement.h>
#include <sortix/kernel/syscall.h>
#include <sortix/mman.h>
#include <assert.h>
#include <errno.h>
#include <string.h>
#include "multiboot.h"
#include "memorymanagement.h"
#include "syscall.h"
#include "msr.h"
namespace Sortix