Go to the FreeLists Home Page Home Signup Help Login
 



[openbeosstorage] || [Date Prev] [02-2002 Date Index] [Date Next] || [Thread Prev] [02-2002 Thread Index] [Thread Next]

[openbeosstorage] System calls

  • From: Keith Poole <keef@xxxxxxxxxxxxxxx>
  • To: tyler@xxxxxxxxxxxxx
  • Date: Sat, 02 Feb 2002 10:09:27 +0000
Tyler,
    I've just been looking throught the NewOS kernel code again & I came 
across this file (syscalls.c), which contains a list of the system calls 
supported by NewOS - and they're different from the ones in the Dominic 
Giampolo book.  Should we be using these instead?

Mind you, it doesn't seem to cover all the apis we require (no attribute 
api for example).  Is it worth asking the kernel team whether they will 
e added?

                Keith

PS, the file kernel/vfs.h contains the vnode file system defintions.

/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#include <kernel/kernel.h>
#include <kernel/syscalls.h>
#include <kernel/int.h>
#include <kernel/debug.h>
#include <kernel/vfs.h>
#include <kernel/thread.h>
#include <kernel/sem.h>
#include <kernel/arch/cpu.h>

#define INT32TOINT64(x, y) ((int64)(x) | ((int64)(y) << 32))

#define arg0  (((uint32 *)arg_buffer)[0])
#define arg1  (((uint32 *)arg_buffer)[1])
#define arg2  (((uint32 *)arg_buffer)[2])
#define arg3  (((uint32 *)arg_buffer)[3])
#define arg4  (((uint32 *)arg_buffer)[4])
#define arg5  (((uint32 *)arg_buffer)[5])
#define arg6  (((uint32 *)arg_buffer)[6])
#define arg7  (((uint32 *)arg_buffer)[7])
#define arg8  (((uint32 *)arg_buffer)[8])
#define arg9  (((uint32 *)arg_buffer)[9])
#define arg10 (((uint32 *)arg_buffer)[10])
#define arg11 (((uint32 *)arg_buffer)[11])
#define arg12 (((uint32 *)arg_buffer)[12])
#define arg13 (((uint32 *)arg_buffer)[13])
#define arg14 (((uint32 *)arg_buffer)[14])
#define arg15 (((uint32 *)arg_buffer)[15])

int syscall_dispatcher(unsigned long call_num, void *arg_buffer, uint64 
*call_ret)
{
//    dprintf("syscall_dispatcher: thread 0x%x call 0x%x, arg0 0x%x, 
arg1 0x%x arg2 0x%x arg3 0x%x arg4 0x%x\n",
//        thread_get_current_thread_id(), call_num, arg0, arg1, arg2, 
arg3, arg4);

    switch(call_num) {
        case SYSCALL_NULL:
            *call_ret = 0;
            break;
        case SYSCALL_MOUNT:
            *call_ret = user_mount((const char *)arg0, (const char 
*)arg1, (const char *)arg2, (void *)arg3);
            break;
        case SYSCALL_UNMOUNT:
            *call_ret = user_unmount((const char *)arg0);
            break;
        case SYSCALL_SYNC:
            *call_ret = user_sync();
            break;
        case SYSCALL_OPEN:
            *call_ret = user_open((const char *)arg0, (stream_type)arg1, 
(int)arg2);
            break;
        case SYSCALL_CLOSE:
            *call_ret = user_close((int)arg0);
            break;
        case SYSCALL_FSYNC:
            *call_ret = user_fsync((int)arg0);
            break;
        case SYSCALL_READ:
            *call_ret = user_read((int)arg0, (void *)arg1, 
(off_t)INT32TOINT64(arg2, arg3), (ssize_t)arg4);
            break;
        case SYSCALL_WRITE:
            *call_ret = user_write((int)arg0, (const void *)arg1, 
(off_t)INT32TOINT64(arg2, arg3), (ssize_t)arg4);
            break;
        case SYSCALL_SEEK:
            *call_ret = user_seek((int)arg0, (off_t)INT32TOINT64(arg1, 
arg2), (seek_type)arg3);
            break;
        case SYSCALL_IOCTL:
            *call_ret = user_ioctl((int)arg0, (int)arg1, (void *)arg2, 
(size_t)arg3);
            break;
        case SYSCALL_CREATE:
            *call_ret = user_create((const char *)arg0, (stream_type)arg1);
            break;
        case SYSCALL_UNLINK:
            *call_ret = user_unlink((const char *)arg0);
            break;
        case SYSCALL_RENAME:
            *call_ret = user_rename((const char *)arg0, (const char *)arg1);
            break;
        case SYSCALL_RSTAT:
            *call_ret = user_rstat((const char *)arg0, (struct file_stat 
*)arg1);
            break;
        case SYSCALL_WSTAT:
            *call_ret = user_wstat((const char *)arg0, (struct file_stat 
*)arg1, (int)arg2);
            break;
        case SYSCALL_SYSTEM_TIME:
            *call_ret = system_time();
            break;
        case SYSCALL_SNOOZE:
            thread_snooze((time_t)INT32TOINT64(arg0, arg1));
            *call_ret = 0;
            break;
        case SYSCALL_SEM_CREATE:
            *call_ret = user_sem_create((int)arg0, (const char *)arg1);
            break;
        case SYSCALL_SEM_DELETE:
            *call_ret = user_sem_delete((sem_id)arg0);
            break;
        case SYSCALL_SEM_ACQUIRE:
            *call_ret = user_sem_acquire_etc((sem_id)arg0, (int)arg1, 
SEM_FLAG_INTERRUPTABLE, 0, NULL);
            break;
        case SYSCALL_SEM_ACQUIRE_ETC:
            *call_ret = user_sem_acquire_etc((sem_id)arg0, (int)arg1, 
(int)arg2 | SEM_FLAG_INTERRUPTABLE, (time_t)INT32TOINT64(arg3, arg4), 
(int *)arg5);
            break;
        case SYSCALL_SEM_RELEASE:
            *call_ret = user_sem_release((sem_id)arg0, (int)arg1);
            break;
        case SYSCALL_SEM_RELEASE_ETC:
            *call_ret = user_sem_release_etc((sem_id)arg0, (int)arg1, 
(int)arg2);
            break;
        case SYSCALL_GET_CURRENT_THREAD_ID:
            *call_ret = thread_get_current_thread_id();
            break;
        case SYSCALL_EXIT_THREAD:
            thread_exit((int)arg0);
            *call_ret = 0;
            break;
        case SYSCALL_PROC_CREATE_PROC:
            *call_ret = user_proc_create_proc((const char *)arg0, (const 
char *)arg1, (int)arg2);
            break;
        case SYSCALL_THREAD_WAIT_ON_THREAD:
            *call_ret = user_thread_wait_on_thread((thread_id)arg0, (int 
*)arg1);
            break;
        case SYSCALL_PROC_WAIT_ON_PROC:
            *call_ret = user_proc_wait_on_proc((proc_id)arg0, (int *)arg1);
            break;
        case SYSCALL_VM_CREATE_ANONYMOUS_REGION:
            *call_ret = user_vm_create_anonymous_region(
                (char *)arg0, (void **)arg1, (int)arg2,
                (addr)arg3, (int)arg4, (int)arg5);
            break;
        case SYSCALL_VM_CLONE_REGION:
            *call_ret = user_vm_clone_region(
                (char *)arg0, (void **)arg1, (int)arg2,
                (region_id)arg3, (int)arg4, (int)arg5);
            break;
        case SYSCALL_VM_MAP_FILE:
            *call_ret = user_vm_map_file(
                (char *)arg0, (void **)arg1, (int)arg2,
                (addr)arg3, (int)arg4, (int)arg5, (const char *)arg6,
                (off_t)INT32TOINT64(arg7, arg8));
            break;
            break;
        case SYSCALL_VM_DELETE_REGION:
            *call_ret = 
vm_delete_region(vm_get_current_user_aspace_id(), (region_id)arg0);
            break;
        case SYSCALL_VM_GET_REGION_INFO:
            *call_ret = user_vm_get_region_info((region_id)arg0, 
(vm_region_info *)arg1);
            break;
        case SYSCALL_THREAD_CREATE_THREAD:
            *call_ret = user_thread_create_user_thread((char *)arg0, 
thread_get_current_thread()->proc->id, (addr)arg1, (void *)arg2);
            break;
        case SYSCALL_THREAD_KILL_THREAD:
            *call_ret = thread_kill_thread((thread_id)arg0);
            break;
        case SYSCALL_THREAD_SUSPEND_THREAD:
            *call_ret = thread_suspend_thread((thread_id)arg0);
            break;
        case SYSCALL_THREAD_RESUME_THREAD:
            *call_ret = thread_resume_thread((thread_id)arg0);
            break;
        case SYSCALL_PROC_KILL_PROC:
            *call_ret = proc_kill_proc((proc_id)arg0);
            break;
        case SYSCALL_GET_CURRENT_PROC_ID:
            *call_ret = proc_get_current_proc_id();
            break;
        case SYSCALL_GETCWD:
            *call_ret = user_getcwd((char*)arg0, (size_t)arg1);
            break;
        case SYSCALL_SETCWD:
            *call_ret = user_setcwd((const char*)arg0);
            break;
        default:
            *call_ret = -1;
    }

//    dprintf("syscall_dispatcher: done with syscall 0x%x\n", call_num);

    return INT_RESCHEDULE;
}







[ Home | Signup | Help | Login | Archives | Lists ]

All trademarks and copyrights within the FreeLists archives are owned by their respective owners.
Everything else ©2007 Avenir Technologies, LLC.