fork.c
ubixos/fork.h
ubixos/types.h
ubixos/sched.h
ubixos/tty.h
ubixos/vitals.h
vmm/vmm.h
string.h
assert.h
sys/thread.h
ubixos/sched.h
ubixos/vitals.h
ubixos/types.h
sys/_types.h
vmm/paging.h
string.h
ubixos/time.h
vfs/file.h
src/sys/kernel/fork.c
sys/tss.h
vmm/vmm.h
ubixos/fork.h
vfs/vfs.h
vfs/mount.h
assert.h
ubixos/ubthread.h
ubixfs/dirCache.h
sys/sysproto.h
sys/signal.h
ubixos/tty.h
sys/io.h
asm
(".globl sysFork \n""sysFork: \n"" xor %eax,%eax \n"" call schedNewTask \n"" testl %eax,%eax \n"" je fork_ret \n"" pushl %esi \n"" pushl %edi \n"" pushl %ebp \n"" pushl %eax \n"" call fork_copyProcess \n"" movl %eax,(%ebx) \n"" addl $16,%esp \n""fork_ret: \n"" ret \n")
asm
".globl sysFork \n""sysFork: \n"" xor % eax
%eax\n""call schedNewTask\n""testl% eax
%eax\n""je fork_ret\n""pushl%esi\n""pushl%edi\n""pushl%ebp\n""pushl%eax\n""call fork_copyProcess\n""movl% eax
(%ebx)\n""addl $ 16
%esp\n""fork_ret:\n""ret\n"
int int fork_copyProcess (struct taskStruct *newProcess, long ebp, long edi, long esi, long none, long ebx, long ecx, long edx, long eip, long cs, long eflags, long esp, long ss) fork_copyProcess struct taskStruct * newProcess long ebp long edi long esi long none long ebx long ecx long edx long eip long cs long eflags long esp long ss _current assert tssStruct::back_link tssStruct::cr3 tssStruct::cs osInfo::cwd tssStruct::ds tssStruct::eax tssStruct::ebp tssStruct::ebx tssStruct::ecx tssStruct::edi tssStruct::edx tssStruct::eflags tssStruct::eip tssStruct::es tssStruct::esi tssStruct::esp tssStruct::esp0 tssStruct::esp1 tssStruct::esp2 FORK tssStruct::fs taskStruct::gid tssStruct::gs taskStruct::id tssStruct::io_map tssStruct::ldt memcpy taskStruct::oInfo tty_termNode::owner sched_yield tssStruct::ss tssStruct::ss0 tssStruct::ss1 tssStruct::ss2 taskStruct::state taskStruct::term tssStruct::trace_bitmap taskStruct::tss taskStruct::uid vmmCopyVirtualSpace osInfo::vmStart

    /*****************************************************************************************
    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: fork_8c.xml 88 2016-01-12 00:11:29Z reddawg $

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

    #include<ubixos/fork.h>
    #include<ubixos/types.h>
    #include<ubixos/sched.h>
    #include<ubixos/tty.h>
    #include<ubixos/vitals.h>
    #include<vmm/vmm.h>
    #include<string.h>
    #include<assert.h>

    /*****************************************************************************************
    Functoin:staticintfork_copyProcess(structtaskStruct*newProcess,longebp,longedi,
    longesi,longnone,longebx,longecx,longedx,longeip,longcs,longeflags,
    longesp,longss)

    Desc:Thisfunctionwillcopyaprocess

    Notes:

    *****************************************************************************************/
    /*Hadtoremovestaticthoughtihsfunctionisonlyusedinthisfile*/
    intfork_copyProcess(structtaskStruct*newProcess,longebp,longedi,longesi,longnone,longebx,longecx,longedx,longeip,longcs,longeflags,longesp,longss){
    volatilestructtaskStruct*tmpProcPtr=newProcess;
    assert(newProcess);
    assert(_current);

    /*SetUpNewTasksInformation*/
    memcpy(newProcess->oInfo.cwd,_current->oInfo.cwd,1024);

    newProcess->tss.eip=eip;
    newProcess->oInfo.vmStart=_current->oInfo.vmStart;
    newProcess->term=_current->term;
    newProcess->term->owner=newProcess->id;
    newProcess->uid=_current->uid;
    newProcess->gid=_current->gid;
    newProcess->tss.back_link=0x0;
    newProcess->tss.esp0=_current->tss.esp0;
    newProcess->tss.ss0=0x10;
    newProcess->tss.esp1=0x0;
    newProcess->tss.ss1=0x0;
    newProcess->tss.esp2=0x0;
    newProcess->tss.ss2=0x0;
    newProcess->tss.eflags=eflags;
    newProcess->tss.eax=0x0;
    newProcess->tss.ebx=ebx;
    newProcess->tss.ecx=ecx;
    newProcess->tss.edx=edx;
    newProcess->tss.esi=esi;
    newProcess->tss.edi=edi;
    newProcess->tss.ebp=ebp;
    newProcess->tss.esp=esp;
    newProcess->tss.cs=cs&0xFF;
    newProcess->tss.ss=ss&0xFF;
    newProcess->tss.ds=_current->tss.ds&0xFF;
    newProcess->tss.fs=_current->tss.fs&0xFF;
    newProcess->tss.gs=_current->tss.gs&0xFF;
    newProcess->tss.es=_current->tss.es&0xFF;
    newProcess->tss.ldt=0x18;
    newProcess->tss.trace_bitmap=0x0000;
    newProcess->tss.io_map=0x8000;
    /*CreateACopyOfTheVMSpaceForNewTask*/
    newProcess->tss.cr3=(uInt32)vmmCopyVirtualSpace(newProcess->id);
    newProcess->state=FORK;

    /*Fixgccoptimizationproblems*/
    while(tmpProcPtr->state==FORK)sched_yield();

    /*ReturnIdofProccess*/
    return(newProcess->id);
    }

    /*****************************************************************************************
    Functoin:voidsysFork();

    Desc:Thisfunctionwillforkanewtask

    Notes:

    08/01/02-ThisSeemsToBeWorkingFineHoweverI'mNotSureIfI
    ChoseTheBestPathToImplimentItIGuessWeWillSee
    WhatTheFutureMayBring

    *****************************************************************************************/
    asm(
    ".globlsysFork\n"
    "sysFork:\n"
    "xor%eax,%eax\n"
    "callschedNewTask\n"
    "testl%eax,%eax\n"
    "jefork_ret\n"
    "pushl%esi\n"
    "pushl%edi\n"
    "pushl%ebp\n"
    "pushl%eax\n"
    "callfork_copyProcess\n"
    "movl%eax,(%ebx)\n"
    "addl$16,%esp\n"
    "fork_ret:\n"
    "ret\n"
    );

    /***
    END
    ***/