Ignore:
Timestamp:
Jun 29, 2017, 4:44:52 PM (7 years ago)
Author:
alain
Message:

euh...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/core.c

    r68 r101  
    5757        core->thread_idle       = NULL;
    5858        core->fpu_owner         = NULL;
    59         core->rand_last         =  hal_time_stamp() & 0xFFF;
     59        core->rand_last         =  hal_get_cycles() & 0xFFF;
    6060
    6161        sched_init( core );
     
    6666{
    6767        uint32_t value  = ((core->rand_last * CONFIG_RDNG_PARAM_A) +
    68                             CONFIG_RDNG_PARAM_C) ^ (hal_time_stamp() & 0xFFF);
     68                            CONFIG_RDNG_PARAM_C) ^ (hal_get_cycles() & 0xFFF);
    6969        core->rand_last = value;
    7070        return value;
    71 }
    72 
    73 ////////////////////////////////////////////////
    74 inline uint64_t core_get_cycles( core_t * core )
    75 {
    76         uint32_t elapsed;
    77         uint64_t cycles;
    78         uint32_t time_stamp = core->time_stamp;
    79         uint32_t time_now   = hal_time_stamp();
    80 
    81         // compute number of elapsed cycles, taking into account 32 bits register wrap
    82         if(time_now < time_stamp) elapsed = (0xFFFFFFFF - time_stamp) + time_now;
    83         else                      elapsed = (time_now - time_stamp);
    84 
    85         cycles = core->cycles + elapsed;
    86 
    87         // update core time
    88         core->time_stamp = time_now;
    89         core->cycles     = cycles;
    90         hal_wbflush();
    91 
    92         return cycles;
    9371}
    9472
     
    9876                    uint32_t * tm_us )
    9977{
    100         // uint64_t cycles = core_get_cycles( core );
     78        uint64_t cycles = hal_get_cycles();
    10179
    102         // TODO ces deux ligne ne compilent pas : "undefined referenc to __udivdi3"
    103 
    104         // *tm_ms = (cycles / CONFIG_CYCLES_PER_MS);
    105         // *tm_us = (cycles % CONFIG_CYCLES_PER_MS) / (CONFIG_CYCLES_PER_MS / 1000000);
    106 
    107         printk("\n[PANIC] in %s : not implemented yet\n", __FUNCTION__ );
     80        *tm_s  = (cycles / CONFIG_CYCLES_PER_MS);
     81        *tm_us = (cycles % CONFIG_CYCLES_PER_MS) / (CONFIG_CYCLES_PER_MS / 1000000);
    10882}
    10983
     
    11589        uint64_t cycles     = core->cycles;
    11690        uint32_t time_stamp = core->time_stamp;
    117         uint32_t time_now   = hal_time_stamp();
     91        uint32_t time_now   = hal_get_cycles();
    11892
    11993        // compute number of elapsed cycles taking into account 32 bits register wrap
Note: See TracChangeset for help on using the changeset viewer.