syscall.c
ubixos/syscall.h
ubixos/syscalls.h
ubixos/sched.h
ubixos/types.h
ubixos/exec.h
ubixos/elf.h
ubixos/endtask.h
ubixos/time.h
sys/video.h
sys/trap.h
vfs/file.h
ubixfs/ubixfs.h
lib/string.h
lib/kprintf.h
lib/kmalloc.h
ubixos/vitals.h
mpi/mpi.h
vmm/vmm.h
sys/thread.h
ubixos/sched.h
ubixos/endtask.h
ubixos/syscall.h
ubixos/vitals.h
ubixos/types.h
sys/_types.h
sys/video.h
lib/string.h
vmm/paging.h
ubixos/time.h
vfs/file.h
sys/tss.h
lib/kmalloc.h
vmm/vmm.h
mpi/mpi.h
vfs/vfs.h
vfs/mount.h
lib/kprintf.h
ubixfs/ubixfs.h
ubixos/ubthread.h
src/sys/kernel/syscall.c
ubixfs/dirCache.h
ubixos/exec.h
ubixos/syscalls.h
sys/sysproto.h
ubixos/elf.h
sys/signal.h
ubixos/tty.h
sys/io.h
sys/device.h
sys/trap.h
_UbixUser
_UbixUser typedef struct _UbixUser UbixUser UbixUser
asm
(".globl _sysCallNew \n""_sysCallNew: \n"" pusha \n"" push %ss \n"" push %ds \n"" push %es \n"" push %fs \n"" push %gs \n"" cmpl totalCalls,%eax \n"" jae invalidSysCallNew \n"" mov %esp,%ebx \n"" add $12,%ebx \n"" push (%ebx) \n"" call *systemCalls(,%eax,4) \n"" add $4,%esp \n"" jmp doneNew \n""invalidSysCallNew: \n"" call InvalidSystemCall \n""doneNew: \n"" pop %gs \n"" pop %fs \n"" pop %es \n"" pop %ds \n"" pop %ss \n"" popa \n"" iret \n")
asm
".globl _sysCallNew \n""_sysCallNew: \n"" pusha \n"" push %ss \n"" push %ds \n"" push %es \n"" push %fs \n"" push %gs \n"" cmpl totalCalls
%eax\n""jae invalidSysCallNew\n""mov% esp
%ebx\n""add $ 12
%ebx\n""push(%ebx)\n""call *systemCalls(,%eax, 4)\n""add $ 4
%esp\n""jmp doneNew\n""invalidSysCallNew:\n""call InvalidSystemCall\n""doneNew:\n""pop%gs\n""pop%fs\n""pop%es\n""pop%ds\n""pop%ss\n""popa\n""iret\n"
long long fuword (const void *base) fuword const void * base
void void invalidCall (int sys_call) invalidCall int sys_call kprintf
void void InvalidSystemCall () InvalidSystemCall kprintf
void void sdeTestThread () sdeTestThread
void void sysAddModule () sysAddModule
void void sysAuth (UbixUser *uu) sysAuth UbixUser * uu _UbixUser::gid kprintf _UbixUser::password _UbixUser::uid _UbixUser::username
void void sysCheckPid (int pid, int *ptr) sysCheckPid int pid int * ptr schedFindTask taskStruct::state
void void sysExit (int status) sysExit int status _current endTask taskStruct::id
void void sysGetCwd (char *data, int len) sysGetCwd char * data int len _current osInfo::cwd taskStruct::oInfo sprintf
void void sysGetDrives (uInt32 *ptr) sysGetDrives uInt32 * ptr
void void sysGetFreePage (long *ptr, int count, int type) sysGetFreePage long * ptr int count int type _current taskStruct::id VM_TASK VM_THRD vmmGetFreeVirtualPage
void void sysGetGid (int *gid) sysGetGid int * gid _current taskStruct::gid
void void sysGetpid (int *pid) sysGetpid int * pid _current taskStruct::id
void void sysGetTime (uInt32 *ptr) sysGetTime uInt32 * ptr systemVitals vitalsStruct::sysUptime vitalsStruct::timeStart
void void sysGetUid (int *uid) sysGetUid int * uid _current taskStruct::uid
void void sysGetUptime (uInt32 *ptr) sysGetUptime uInt32 * ptr systemVitals vitalsStruct::sysTicks
void void sysPasswd (char *passwd) sysPasswd char * passwd _current kprintf taskStruct::uid
void void sysRmModule () sysRmModule
void void sysSchedYield () sysSchedYield sched_yield
void void sysSetGid (int gid, int *status) sysSetGid int gid int * status _current taskStruct::gid
void void sysSetUid (int uid, int *status) sysSetUid int uid int * status _current taskStruct::uid
void void sysStartSDE () sysStartSDE

    /*****************************************************************************************
    Copyright(c)2002-2004TheUbixOSProject
    Allrightsreserved.

    Redistributionanduseinsourceandbinaryforms,withorwithoutmodification,are
    permittedprovidedthatthefollowingconditionsaremet:

    Redistributionsofsourcecodemustretaintheabovecopyrightnotice,thislistof
    conditions,thefollowingdisclaimerandthelistofauthors.Redistributionsinbinary
    formmustreproducetheabovecopyrightnotice,thislistofconditions,thefollowing
    disclaimerandthelistofauthorsinthedocumentationand/orothermaterialsprovided
    withthedistribution.NeitherthenameoftheUbixOSProjectnorthenamesofits
    contributorsmaybeusedtoendorseorpromoteproductsderivedfromthissoftware
    withoutspecificpriorwrittenpermission.

    THISSOFTWAREISPROVIDEDBYTHECOPYRIGHTHOLDERSANDCONTRIBUTORS"ASIS"ANDANY
    EXPRESSORIMPLIEDWARRANTIES,INCLUDING,BUTNOTLIMITEDTO,THEIMPLIEDWARRANTIESOF
    MERCHANTABILITYANDFITNESSFORAPARTICULARPURPOSEAREDISCLAIMED.INNOEVENTSHALL
    THECOPYRIGHTOWNERORCONTRIBUTORSBELIABLEFORANYDIRECT,INDIRECT,INCIDENTAL,
    SPECIAL,EXEMPLARY,ORCONSEQUENTIALDAMAGES(INCLUDING,BUTNOTLIMITEDTO,PROCUREMENT
    OFSUBSTITUTEGOODSORSERVICES;LOSSOFUSE,DATA,ORPROFITS;ORBUSINESSINTERRUPTION)
    HOWEVERCAUSEDANDONANYTHEORYOFLIABILITY,WHETHERINCONTRACT,STRICTLIABILITY,OR
    TORT(INCLUDINGNEGLIGENCEOROTHERWISE)ARISINGINANYWAYOUTOFTHEUSEOFTHIS
    SOFTWARE,EVENIFADVISEDOFTHEPOSSIBILITYOFSUCHDAMAGE.

    $Id: syscall_8c.xml 88 2016-01-12 00:11:29Z reddawg $

    *****************************************************************************************/

    #include<ubixos/syscall.h>
    #include<ubixos/syscalls.h>
    #include<ubixos/sched.h>
    #include<ubixos/types.h>
    #include<ubixos/exec.h>
    #include<ubixos/elf.h>
    #include<ubixos/endtask.h>
    #include<ubixos/time.h>
    #include<sys/video.h>
    #include<sys/trap.h>
    #include<vfs/file.h>
    #include<ubixfs/ubixfs.h>
    #include<lib/string.h>
    #include<lib/kprintf.h>
    #include<lib/kmalloc.h>
    #include<ubixos/vitals.h>
    /*#include<sde/sde.h>*/
    #include<mpi/mpi.h>
    #include<vmm/vmm.h>

    longfuword(constvoid*base);

    voidsdeTestThread();

    asm(
    ".globl_sysCallNew\n"
    "_sysCallNew:\n"
    "pusha\n"
    "push%ss\n"
    "push%ds\n"
    "push%es\n"
    "push%fs\n"
    "push%gs\n"
    "cmpltotalCalls,%eax\n"
    "jaeinvalidSysCallNew\n"
    "mov%esp,%ebx\n"
    "add$12,%ebx\n"
    "push(%ebx)\n"
    "call*systemCalls(,%eax,4)\n"
    "add$4,%esp\n"
    "jmpdoneNew\n"
    "invalidSysCallNew:\n"
    "callInvalidSystemCall\n"
    "doneNew:\n"
    "pop%gs\n"
    "pop%fs\n"
    "pop%es\n"
    "pop%ds\n"
    "pop%ss\n"
    "popa\n"
    "iret\n"
    );

    voidInvalidSystemCall()
    {
    kprintf("attemptwasmadetoaninvalidsystemcall\n");
    return;
    }

    typedefstruct_UbixUserUbixUser;
    struct_UbixUser
    {
    char*username;
    char*password;
    intuid;
    intgid;
    char*home;
    char*shell;
    };

    voidsysAuth(UbixUser*uu)
    {
    kprintf("authenticatinguser%s\n",uu->username);
    if(uu->username=="root"&&uu->password=="user")
    {
    uu->uid=0;
    uu->gid=0;
    }
    uu->uid=-1;
    uu->gid=-1;
    return;
    }

    voidsysPasswd(char*passwd)
    {
    kprintf("changinguserpasswordforuser%d\n",_current->uid);
    return;
    }

    voidsysAddModule()
    {
    return;
    }

    voidsysRmModule()
    {
    return;
    }

    voidsysGetpid(int*pid)
    {
    if(pid)
    *pid=_current->id;
    return;
    }

    voidsysGetUid(int*uid){
    if(uid)
    *uid=_current->uid;
    return;
    }

    voidsysGetGid(int*gid){
    if(gid)
    *gid=_current->gid;
    return;
    }

    voidsysSetUid(intuid,int*status){
    if(_current->uid==0x0){
    _current->uid=uid;
    if(status)
    *status=0x0;
    }
    else{
    if(status)
    *status=1;
    }
    return;
    }

    voidsysSetGid(intgid,int*status){
    if(_current->gid==0x0){
    _current->gid=gid;
    if(status)
    *status=0x0;
    }
    else{
    if(status)
    *status=1;
    }
    return;
    }

    voidsysExit(intstatus)
    {
    endTask(_current->id);
    }

    voidsysCheckPid(intpid,int*ptr)
    {
    kTask_t*tmpTask=schedFindTask(pid);
    if((tmpTask!=0x0)&&(ptr!=0x0))
    *ptr=tmpTask->state;
    else
    *ptr=0x0;
    return;
    }

    /************************************************************************

    Function:voidsysGetFreePage();
    Description:AllocsAPageToTheUsersVMSpace
    Notes:

    ************************************************************************/
    voidsysGetFreePage(long*ptr,intcount,inttype){
    if(ptr){
    if(type==2)
    *ptr=(long)vmmGetFreeVirtualPage(_current->id,count,VM_THRD);
    else
    *ptr=(long)vmmGetFreeVirtualPage(_current->id,count,VM_TASK);
    }
    return;
    }

    voidsysGetDrives(uInt32*ptr)
    {
    if(ptr)
    *ptr=0x0;//(uInt32)devices;
    return;
    }

    voidsysGetUptime(uInt32*ptr)
    {
    if(ptr)
    *ptr=systemVitals->sysTicks;
    return;
    }

    voidsysGetTime(uInt32*ptr)
    {
    if(ptr)
    *ptr=systemVitals->sysUptime+systemVitals->timeStart;
    return;
    }

    voidsysGetCwd(char*data,intlen)
    {
    if(data)
    sprintf(data,"%s",_current->oInfo.cwd);
    return;
    }

    voidsysSchedYield(){
    sched_yield();
    }

    voidsysStartSDE(){
    inti=0x0;
    for(i=0;i<1400;i++){
    asm("hlt");
    }
    //execThread(sdeThread,(uInt32)(kmalloc(0x2000)+0x2000),0x0);
    for(i=0;i<1400;i++){
    asm("hlt");
    }
    return;
    }

    voidinvalidCall(intsys_call){
    kprintf("InvalidSystemCall#[%i]\n",sys_call);
    return;
    }

    /***
    END
    ***/