Ignore:
Timestamp:
Jun 3, 2017, 4:46:59 PM (5 years ago)
Author:
max@…
Message:

cosmetic, and a few typos

File:
1 edited

Legend:

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

    r14 r19  
    11/*
    22 * core.c - core descriptor access function.
    3  * 
     3 *
    44 * Author  Ghassan Almaless (2008,2009,2010,2011,2012)
    55 *         Mohamed Lamine Karaoui (2015)
     
    4141
    4242/////////////////////////////////
    43 void core_init( core_t    * core, 
    44                 lid_t       lid, 
     43void core_init( core_t    * core,
     44                lid_t       lid,
    4545                gid_t       gid )
    4646{
     
    5353        core->usage             = 0;
    5454        core->spurious_irqs     = 0;
    55     core->rpc_threads       = 0;
     55        core->rpc_threads       = 0;
    5656
    5757        rpc_fifo_init( &core->rpc_fifo );
    5858
    59     list_root_init( &core->rpc_free_list );
    60 
    61     core->thread_rpc        = NULL;
    62     core->thread_idle       = NULL;
    63     core->fpu_owner         = NULL;
     59        list_root_init( &core->rpc_free_list );
     60
     61        core->thread_rpc        = NULL;
     62        core->thread_idle       = NULL;
     63        core->fpu_owner         = NULL;
    6464        core->rand_last         =  hal_time_stamp() & 0xFFF;
    6565
     
    7070inline uint32_t core_get_rand( core_t * core )
    7171{
    72     uint32_t value  = ((core->rand_last * CONFIG_RDNG_PARAM_A) +
    73                         CONFIG_RDNG_PARAM_C) ^ (hal_time_stamp() & 0xFFF);
    74     core->rand_last = value;
    75     return value;
     72        uint32_t value  = ((core->rand_last * CONFIG_RDNG_PARAM_A) +
     73                            CONFIG_RDNG_PARAM_C) ^ (hal_time_stamp() & 0xFFF);
     74        core->rand_last = value;
     75        return value;
    7676}
    7777
     
    7979inline uint64_t core_get_cycles( core_t * core )
    8080{
    81     uint32_t elapsed;
    82     uint64_t cycles;
     81        uint32_t elapsed;
     82        uint64_t cycles;
    8383        uint32_t time_stamp = core->time_stamp;
    8484        uint32_t time_now   = hal_time_stamp();
    85        
     85
    8686        // compute number of elapsed cycles, taking into account 32 bits register wrap
    8787        if(time_now < time_stamp) elapsed = (0xFFFFFFFF - time_stamp) + time_now;
    8888        else                      elapsed = (time_now - time_stamp);
    8989
    90     cycles = core->cycles + elapsed;
    91 
    92     // update core time
    93     core->time_stamp = time_now;
    94     core->cycles     = cycles;
     90        cycles = core->cycles + elapsed;
     91
     92        // update core time
     93        core->time_stamp = time_now;
     94        core->cycles     = cycles;
    9595        hal_wbflush();
    9696
     
    100100////////////////////////////////////
    101101void core_get_time( core_t   * core,
    102                     uint32_t * tm_ms, 
     102                    uint32_t * tm_ms,
    103103                    uint32_t * tm_us )
    104104{
    105105        // uint64_t cycles = core_get_cycles( core );
    106106
    107     // TODO ces deux ligne ne compilent pas : "undefined referenc to __udivdi3"
     107        // TODO ces deux ligne ne compilent pas : "undefined referenc to __udivdi3"
    108108
    109109        // *tm_ms = (cycles / CONFIG_CYCLES_PER_MS);
    110110        // *tm_us = (cycles % CONFIG_CYCLES_PER_MS) / (CONFIG_CYCLES_PER_MS / 1000000);
    111111
    112     printk("\n[PANIC] in %s : not implemented yet\n", __FUNCTION__ );
     112        printk("\n[PANIC] in %s : not implemented yet\n", __FUNCTION__ );
    113113}
    114114
     
    116116void core_time_update( core_t * core )
    117117{
    118     uint32_t elapsed;
     118        uint32_t elapsed;
    119119        uint32_t ticks_nr   = core->ticks_nr;
    120120        uint64_t cycles     = core->cycles;
     
    122122        uint32_t time_now   = hal_time_stamp();
    123123
    124     // compute number of elapsed cycles taking into account 32 bits register wrap
     124        // compute number of elapsed cycles taking into account 32 bits register wrap
    125125        if( time_now < time_stamp ) elapsed = (0xFFFFFFFF - time_stamp) + time_now;
    126126        else                        elapsed = time_now - time_stamp;
    127    
     127
    128128        cycles  += elapsed;
    129129        ticks_nr = elapsed / core->ticks_period;
     
    140140        uint32_t ticks;
    141141
    142     // update cycles and ticks counter
     142        // update cycles and ticks counter
    143143        core_time_update( core );
    144144
    145     // get current ticks number
     145        // get current ticks number
    146146        ticks = core->ticks_nr;
    147147
    148     // handle pending alarms TODO ??? [AG]
     148        // handle pending alarms TODO ??? [AG]
    149149        // alarm_clock( &core->alarm_mgr , ticks );
    150150
    151     // handle scheduler TODO  improve the scheduling condition ... AG
    152     if( (ticks % 10) == 0 ) sched_yield();
    153        
    154     // update DQDT TODO  This update should depend on the cluster identifier,
    155     // to avoid simultaneous updates from various clusters ... AG
     151        // handle scheduler TODO  improve the scheduling condition ... AG
     152        if( (ticks % 10) == 0 ) sched_yield();
     153
     154        // update DQDT TODO  This update should depend on the cluster identifier,
     155        // to avoid simultaneous updates from various clusters ... AG
    156156        if( ((ticks % CONFIG_DQDT_PERIOD) == 0) && (core->lid == 0) ) dqdt_global_update();
    157157}
    158158
    159159////////////////////////////////////////
    160 void core_compute_stats( core_t * core ) 
     160void core_compute_stats( core_t * core )
    161161{
    162162        thread_t * idle  = core->thread_idle;
     
    167167        uint32_t   usage;
    168168
    169     // compute cumulated usage       
     169        // compute cumulated usage
    170170        ticks         = (ticks) ? ticks : 1;
    171171        idle_percent  = (idle->ticks_nr * 100) / ticks;
     
    174174        usage         = (busy_percent + core->usage) / 2;
    175175
    176     // update core descriptor
     176        // update core descriptor
    177177        core->usage = usage;
    178178        hal_wbflush();
     
    204204                                chdev_t  * chdev )
    205205{
    206     if     ( irq_type == WTI_TYPE ) core->wti_vector[irq_id] = chdev;
    207     else if( irq_type == HWI_TYPE ) core->hwi_vector[irq_id] = chdev;
    208     else                            core->pti_vector[irq_id] = chdev;
    209 }
     206        if     ( irq_type == WTI_TYPE ) core->wti_vector[irq_id] = chdev;
     207        else if( irq_type == HWI_TYPE ) core->hwi_vector[irq_id] = chdev;
     208        else                            core->pti_vector[irq_id] = chdev;
     209}
Note: See TracChangeset for help on using the changeset viewer.