time.c
ubixos/types.h
ubixos/time.h
ubixos/vitals.h
lib/kprintf.h
assert.h
sys/thread.h
ubixos/sched.h
ubixos/vitals.h
ubixos/types.h
sys/_types.h
ubixos/time.h
vfs/file.h
sys/tss.h
vfs/vfs.h
vfs/mount.h
lib/kprintf.h
assert.h
ubixos/ubthread.h
ubixfs/dirCache.h
sys/sysproto.h
src/sys/kernel/time.c
sys/signal.h
ubixos/tty.h
sys/io.h
int int gettimeofday (struct timeval *tp, struct timezone *tzp) gettimeofday struct timeval * tp struct timezone * tzp timeval::tv_sec timeval::tv_usec
int int time_init () time_init BCD_TO_BIN timeStruct::day timeStruct::hour kprintf timeStruct::min timeStruct::mon timeStruct::sec systemVitals timeCmosRead timeMake vitalsStruct::timeStart timeStruct::year
int static int timeCmosRead (int addr) timeCmosRead int addr inportByte outportByteP time_init
uInt32 uInt32 timeMake (struct timeStruct *time) timeMake struct timeStruct * time timeStruct::day DAY timeStruct::hour HOUR timeStruct::min MINUTE timeStruct::mon month timeStruct::sec YEAR timeStruct::year time_init
int int month[12] [12] month { 0, DAY*(31), DAY*(31+29), DAY*(31+29+31), DAY*(31+29+31+30), DAY*(31+29+31+30+31), DAY*(31+29+31+30+31+30), DAY*(31+29+31+30+31+30+31), DAY*(31+29+31+30+31+30+31+31), DAY*(31+29+31+30+31+30+31+31+30), DAY*(31+29+31+30+31+30+31+31+30+31), DAY*(31+29+31+30+31+30+31+31+30+31+30) } timeMake

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

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

    #include<ubixos/types.h>
    #include<ubixos/time.h>
    #include<ubixos/vitals.h>
    #include<lib/kprintf.h>
    #include<assert.h>

    staticintmonth[12]={
    0,
    DAY*(31),
    DAY*(31+29),
    DAY*(31+29+31),
    DAY*(31+29+31+30),
    DAY*(31+29+31+30+31),
    DAY*(31+29+31+30+31+30),
    DAY*(31+29+31+30+31+30+31),
    DAY*(31+29+31+30+31+30+31+31),
    DAY*(31+29+31+30+31+30+31+31+30),
    DAY*(31+29+31+30+31+30+31+31+30+31),
    DAY*(31+29+31+30+31+30+31+31+30+31+30)
    };

    staticinttimeCmosRead(intaddr){
    outportByteP(0x70,addr);
    return((int)inportByte(0x71));
    }

    inttime_init(){
    inti;
    structtimeStructtime;

    for(i=0;i<1000000;i++){
    if(!(timeCmosRead(10)&0x80)){
    break;
    }
    }

    do{
    time.sec=timeCmosRead(0);
    time.min=timeCmosRead(2);
    time.hour=timeCmosRead(4);
    time.day=timeCmosRead(7);
    time.mon=timeCmosRead(8);
    time.year=timeCmosRead(9);
    }while(time.sec!=timeCmosRead(0));

    BCD_TO_BIN(time.sec);
    BCD_TO_BIN(time.min);
    BCD_TO_BIN(time.hour);
    BCD_TO_BIN(time.day);
    BCD_TO_BIN(time.mon);
    BCD_TO_BIN(time.year);

    /*Setupourstarttimeinseconds*/
    systemVitals->timeStart=timeMake(&time);

    kprintf("%i/%i/%i%i:%i.%i\n",time.mon,time.day,time.year,time.hour,time.min,time.sec);

    /*Returnsoweknowallwentwell*/
    return(0x0);
    }

    uInt32timeMake(structtimeStruct*time){
    uInt32res;
    intyear;

    year=(time->year+100)-70;
    /*magicoffsets(y+1)neededtogetleapyearsright.*/
    res=YEAR*year+DAY*((year+1)/4);
    res+=month[time->mon];
    /*and(y+2)here.Ifitwasn'taleap-year,wehavetoadjust*/
    if(time->mon>1&&((year+2)%4))
    res-=DAY;
    res+=DAY*(time->day-1);
    res+=HOUR*time->hour;
    res+=MINUTE*time->min;
    res+=time->sec;
    return(res);
    }

    intgettimeofday(structtimeval*tp,structtimezone*tzp){
    //tp->tv_sec=systemVitals->timeStart+systemVitals->sysUptime;
    tp->tv_sec=0x0;//systemVitals->sysUptime;
    tp->tv_usec=0x0;
    return(0x0);
    }

    /***
    END
    ***/