Changeset 228 for soft/giet_vm/boot


Ignore:
Timestamp:
Feb 12, 2013, 6:33:31 PM (11 years ago)
Author:
meunier
Message:

Added support for memspaces and const.
Added an interrupt masking to the "giet_context_switch" syscall
Corrected two bugs in boot/boot_init.c (one minor and one regarding barriers initialization)
Reformatted the code in all files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/boot/boot_init.c

    r218 r228  
    5656#include <mwmr_channel.h>
    5757#include <barrier.h>
     58#include <memspace.h>
    5859#include <irq_handler.h>
    5960#include <ctx_handler.h>
     
    6364#include <stdarg.h>
    6465
    65 #if !defined(NB_CLUSTERS)
     66
     67#if !defined(NB_CLUSTERS)
    6668# error The NB_CLUSTERS value must be defined in the 'giet_config.h' file !
    6769#endif
    6870
    69 #if !defined(NB_PROCS_MAX) 
     71#if !defined(NB_PROCS_MAX)
    7072# error The NB_PROCS_MAX value must be defined in the 'giet_config.h' file !
    7173#endif
    7274
    73 #if !defined(GIET_NB_VSPACE_MAX) 
     75#if !defined(GIET_NB_VSPACE_MAX)
    7476# error The GIET_NB_VSPACE_MAX value must be defined in the 'giet_config.h' file !
    7577#endif
     
    8284
    8385// Page table pointers array
    84 page_table_t*          boot_ptabs_vaddr[GIET_NB_VSPACE_MAX];
    85 page_table_t*          boot_ptabs_paddr[GIET_NB_VSPACE_MAX];
     86page_table_t * boot_ptabs_vaddr[GIET_NB_VSPACE_MAX];
     87page_table_t * boot_ptabs_paddr[GIET_NB_VSPACE_MAX];
    8688
    8789// Scheduler pointers array
    88 static_scheduler_t*    boot_schedulers_paddr[NB_CLUSTERS * NB_PROCS_MAX];
     90static_scheduler_t * boot_schedulers_paddr[NB_CLUSTERS * NB_PROCS_MAX];
    8991
    9092// Next free PT2 index array
    91 unsigned int            boot_next_free_pt2[GIET_NB_VSPACE_MAX] =
    92                              { [0 ... GIET_NB_VSPACE_MAX-1] = 0 };
     93unsigned int boot_next_free_pt2[GIET_NB_VSPACE_MAX] =
     94{ [0 ... GIET_NB_VSPACE_MAX - 1] = 0 };
    9395
    9496// Max PT2 index
    95 unsigned int            boot_max_pt2[GIET_NB_VSPACE_MAX] =
    96                             { [0 ... GIET_NB_VSPACE_MAX-1] = 0 };
     97unsigned int boot_max_pt2[GIET_NB_VSPACE_MAX] =
     98{ [0 ... GIET_NB_VSPACE_MAX - 1] = 0 };
    9799
    98100
     
    100102// boot_procid()
    101103//////////////////////////////////////////////////////////////////////////////
    102 inline unsigned int boot_procid()
    103 {
     104inline unsigned int boot_procid() {
    104105    unsigned int ret;
    105     asm volatile("mfc0 %0, $15, 1" : "=r"(ret));
     106    asm volatile ("mfc0 %0, $15, 1":"=r" (ret));
    106107    return (ret & 0x3FF);
    107108}
     109
     110
    108111//////////////////////////////////////////////////////////////////////////////
    109112// boot_proctime()
    110113//////////////////////////////////////////////////////////////////////////////
    111 inline unsigned int boot_proctime()
    112 {
     114inline unsigned int boot_proctime() {
    113115    unsigned int ret;
    114     asm volatile("mfc0 %0, $9" : "=r"(ret));
     116    asm volatile ("mfc0 %0, $9":"=r" (ret));
    115117    return ret;
    116118}
     119
     120
    117121//////////////////////////////////////////////////////////////////////////////
    118122// boot_exit()
    119123//////////////////////////////////////////////////////////////////////////////
    120 void boot_exit()
    121 {
    122     while(1) asm volatile("nop");
    123 }
     124void boot_exit() {
     125    while (1) {
     126        asm volatile ("nop");
     127    }
     128}
     129
     130
    124131//////////////////////////////////////////////////////////////////////////////
    125132// boot_eret()
     
    127134// in all task contexts (when the task has never been executed.
    128135/////////////////////////////////"/////////////////////////////////////////////
    129 void boot_eret()
    130 {
    131     asm volatile("eret");
    132 }
     136void boot_eret() {
     137    asm volatile ("eret");
     138}
     139
     140
    133141//////////////////////////////////////////////////////////////////////////////
    134142// boot_scheduler_set_context()
     
    140148// - value  : value to be written
    141149//////////////////////////////////////////////////////////////////////////////
    142 inline void boot_scheduler_set_context( unsigned int gpid,
    143                                         unsigned int ltid,
    144                                         unsigned int slotid,
    145                                         unsigned int value )
    146 {
     150inline void boot_scheduler_set_context(unsigned int gpid,
     151        unsigned int ltid,
     152        unsigned int slotid,
     153        unsigned int value) {
    147154    // get scheduler physical address
    148     static_scheduler_t*    psched = boot_schedulers_paddr[gpid];
    149    
     155    static_scheduler_t * psched = boot_schedulers_paddr[gpid];
     156
    150157    // get slot physical address
    151     unsigned int*           pslot  = &(psched->context[ltid][slotid]);
    152 
    153     asm volatile ( "li      $26,    0xB     \n"
    154                    "mtc2    $26,    $1      \n"     /* desactivate DTLB */
    155                    "sw      %1,     0(%0)   \n"     /* *pslot <= value  */
    156                    "li      $26,    0xF     \n"
    157                    "mtc2    $26,    $1      \n"     /* activate DTLB    */
    158                    :
    159                    : "r"(pslot), "r"(value)
    160                    : "$26" );
    161 }
     158    unsigned int * pslot = &(psched->context[ltid][slotid]);
     159
     160    asm volatile ("li      $26,    0xB     \n"
     161            "mtc2    $26,    $1      \n"    /* desactivate DTLB */
     162            "sw      %1,     0(%0)   \n"    /* *pslot <= value  */
     163            "li      $26,    0xF     \n"
     164            "mtc2    $26,    $1      \n"    /* activate DTLB    */
     165            :
     166            :"r" (pslot), "r"(value)
     167            :"$26");
     168}
     169
     170
    162171//////////////////////////////////////////////////////////////////////////////
    163172// boot_scheduler_set_itvector()
     
    168177// - value  : value to be written
    169178//////////////////////////////////////////////////////////////////////////////
    170 inline void boot_scheduler_set_itvector( unsigned int gpid,
    171                                          unsigned int slotid,
    172                                          unsigned int value )
    173 {
     179inline void boot_scheduler_set_itvector(unsigned int gpid,
     180        unsigned int slotid,
     181        unsigned int value) {
    174182    // get scheduler physical address
    175     static_scheduler_t*    psched = boot_schedulers_paddr[gpid];
    176    
     183    static_scheduler_t * psched = boot_schedulers_paddr[gpid];
     184
    177185    // get slot physical address
    178     unsigned int*           pslot  = &(psched->interrupt_vector[slotid]);
    179 
    180     asm volatile ( "li      $26,    0xB     \n"
    181                    "mtc2    $26,    $1      \n"     /* desactivate DTLB */
    182                    "sw      %1,     0(%0)   \n"     /* *pslot <= value  */
    183                    "li      $26,    0xF     \n"
    184                    "mtc2    $26,    $1      \n"     /* activate DTLB    */
    185                    :
    186                    : "r"(pslot), "r"(value)
    187                    : "$26" );
    188 }
     186    unsigned int * pslot = &(psched->interrupt_vector[slotid]);
     187
     188    asm volatile ("li      $26,    0xB     \n"
     189            "mtc2    $26,    $1      \n"    /* desactivate DTLB */
     190            "sw      %1,     0(%0)   \n"    /* *pslot <= value  */
     191            "li      $26,    0xF     \n"
     192            "mtc2    $26,    $1      \n"    /* activate DTLB    */
     193            :
     194            :"r" (pslot), "r"(value)
     195            :"$26");
     196}
     197
    189198
    190199//////////////////////////////////////////////////////////////////////////////
     
    196205// - return the content of the slot
    197206//////////////////////////////////////////////////////////////////////////////
    198 unsigned int boot_scheduler_get_itvector( unsigned int gpid,
    199                                          unsigned int slotid)
    200 {
     207unsigned int boot_scheduler_get_itvector(unsigned int gpid, unsigned int slotid) {
    201208    unsigned int value;
    202209
    203210    // get scheduler physical address
    204     static_scheduler_t*    psched = boot_schedulers_paddr[gpid];
    205    
     211    static_scheduler_t * psched = boot_schedulers_paddr[gpid];
     212
    206213    // get slot physical address
    207     unsigned int*           pslot = &(psched->interrupt_vector[slotid]);
    208 
    209     asm volatile ( "li      $26,    0xB     \n"
    210                    "mtc2    $26,    $1      \n"     /* desactivate DTLB */
    211                    "lw      %0,     0(%1)   \n"     /* *pslot <= value  */
    212                    "li      $26,    0xF     \n"
    213                    "mtc2    $26,    $1      \n"     /* activate DTLB    */
    214                    : "=r"(value)
    215                    : "r"(pslot)
    216                    : "$26" );
     214    unsigned int * pslot = &(psched->interrupt_vector[slotid]);
     215
     216    asm volatile ("li      $26,    0xB     \n"
     217            "mtc2    $26,    $1      \n"    /* desactivate DTLB */
     218            "lw      %0,     0(%1)   \n"    /* *pslot <= value  */
     219            "li      $26,    0xF     \n"
     220            "mtc2    $26,    $1      \n"    /* activate DTLB    */
     221            :"=r" (value)
     222            :"r"(pslot)
     223            :"$26");
    217224    return value;
    218225}
     226
    219227
    220228//////////////////////////////////////////////////////////////////////////////
     
    224232// - gpid   : global processor/scheduler index
    225233//////////////////////////////////////////////////////////////////////////////
    226 inline unsigned int boot_scheduler_get_tasks( unsigned int gpid )
    227 {
    228     unsigned int    ret;
     234inline unsigned int boot_scheduler_get_tasks(unsigned int gpid) {
     235    unsigned int ret;
    229236
    230237    // get scheduler physical address
    231     static_scheduler_t*    psched = boot_schedulers_paddr[gpid];
    232    
     238    static_scheduler_t * psched = boot_schedulers_paddr[gpid];
     239
    233240    // get tasks physical address
    234     unsigned int*          ptasks = &(psched->tasks);
    235 
    236     asm volatile ( "li      $26,    0xB     \n"
    237                    "mtc2    $26,    $1      \n"     /* desactivate DTLB */
    238                    "lw      %0,     0(%1)   \n"     /* ret <= *ptasks   */
    239                    "li      $26,    0xF     \n"
    240                    "mtc2    $26,    $1      \n"     /* activate DTLB    */
    241                    : "=r"(ret)
    242                    : "r"(ptasks)
    243                    : "$26" );
     241    unsigned int * ptasks = &(psched->tasks);
     242
     243    asm volatile ("li      $26,    0xB     \n"
     244            "mtc2    $26,    $1      \n"    /* desactivate DTLB */
     245            "lw      %0,     0(%1)   \n"    /* ret <= *ptasks   */
     246            "li      $26,    0xF     \n"
     247            "mtc2    $26,    $1      \n"    /* activate DTLB    */
     248            :"=r" (ret)
     249            :"r"(ptasks)
     250            :"$26");
    244251    return ret;
    245252}
     253
     254
    246255//////////////////////////////////////////////////////////////////////////////
    247256// boot_scheduler_set_tasks()
     
    251260// - value  : value to be written
    252261//////////////////////////////////////////////////////////////////////////////
    253 inline void boot_scheduler_set_tasks( unsigned int gpid,
    254                                       unsigned int value )
    255 {
     262inline void boot_scheduler_set_tasks(unsigned int gpid, unsigned int value) {
    256263    // get scheduler physical address
    257     static_scheduler_t*    psched = boot_schedulers_paddr[gpid];
    258    
     264    static_scheduler_t * psched = boot_schedulers_paddr[gpid];
     265
    259266    // get tasks physical address
    260     unsigned int*           ptasks = &(psched->tasks);
    261 
    262     asm volatile ( "li      $26,    0xB     \n"
    263                    "mtc2    $26,    $1      \n"     /* desactivate DTLB */
    264                    "sw      %1,     0(%0)   \n"     /* *ptasks <= value */
    265                    "li      $26,    0xF     \n"
    266                    "mtc2    $26,    $1      \n"     /* activate DTLB    */
    267                    :
    268                    : "r"(ptasks), "r"(value)
    269                    : "$26" );
    270 }
     267    unsigned int * ptasks = &(psched->tasks);
     268
     269    asm volatile ("li      $26,    0xB     \n"
     270            "mtc2    $26,    $1      \n"    /* desactivate DTLB */
     271            "sw      %1,     0(%0)   \n"    /* *ptasks <= value */
     272            "li      $26,    0xF     \n"
     273            "mtc2    $26,    $1      \n"    /* activate DTLB    */
     274            :
     275            :"r" (ptasks), "r"(value)
     276            :"$26");
     277}
     278
     279
    271280//////////////////////////////////////////////////////////////////////////////
    272281// boot_scheduler_set_current()
     
    276285// - value  : value to be written
    277286//////////////////////////////////////////////////////////////////////////////
    278 inline void boot_scheduler_set_current( unsigned int gpid,
    279                                  unsigned int value )
    280 {
     287inline void boot_scheduler_set_current(unsigned int gpid, unsigned int value) {
    281288    // get scheduler physical address
    282     static_scheduler_t*     psched = boot_schedulers_paddr[gpid];
    283    
     289    static_scheduler_t *psched = boot_schedulers_paddr[gpid];
     290
    284291    // get tasks physical address
    285     unsigned int*           pcur   = &(psched->current);
    286 
    287     asm volatile ( "li      $26,    0xB     \n"
    288                    "mtc2    $26,    $1      \n"     /* desactivate DTLB */
    289                    "sw      %1,     0(%0)   \n"     /* *pcur   <= value */
    290                    "li      $26,    0xF     \n"
    291                    "mtc2    $26,    $1      \n"     /* activate DTLB    */
    292                    :
    293                    : "r"(pcur), "r"(value)
    294                    : "$26" );
    295 }
     292    unsigned int * pcur = &(psched->current);
     293
     294    asm volatile ("li      $26,    0xB     \n"
     295            "mtc2    $26,    $1      \n"    /* desactivate DTLB */
     296            "sw      %1,     0(%0)   \n"    /* *pcur   <= value */
     297            "li      $26,    0xF     \n"
     298            "mtc2    $26,    $1      \n"    /* activate DTLB    */
     299            :
     300            :"r" (pcur), "r"(value)
     301            :"$26");
     302}
     303
     304
    296305//////////////////////////////////////////////////////////////////////////////
    297306// boot_set_mmu_ptpr()
    298307// This function set a new value for the MMU PTPR register.
    299308//////////////////////////////////////////////////////////////////////////////
    300 inline void boot_set_mmu_ptpr( unsigned int val )
    301 {
    302     asm volatile("mtc2  %0, $0" : : "r"(val) );
    303 }
     309inline void boot_set_mmu_ptpr(unsigned int val) {
     310    asm volatile ("mtc2  %0, $0"::"r" (val));
     311}
     312
    304313
    305314//////////////////////////////////////////////////////////////////////////////
     
    307316// This function set a new value for the MMU MODE register.
    308317//////////////////////////////////////////////////////////////////////////////
    309 inline void boot_set_mmu_mode( unsigned int val )
    310 {
    311     asm volatile("mtc2  %0, $1" : : "r"(val) );
    312 }
     318inline void boot_set_mmu_mode(unsigned int val) {
     319    asm volatile ("mtc2  %0, $1"::"r" (val));
     320}
     321
     322
    313323////////////////////////////////////////////////////////////////////////////
    314324// boot_puts()
    315325// (it uses TTY0)
    316326////////////////////////////////////////////////////////////////////////////
    317 void boot_puts(const char *buffer)
    318 {
    319     unsigned int* tty_address = (unsigned int*) &seg_tty_base;
     327void boot_puts(const char * buffer) {
     328    unsigned int *tty_address = (unsigned int *) &seg_tty_base;
    320329    unsigned int n;
    321330
    322     for ( n=0; n<100; n++)
    323     {
    324         if (buffer[n] == 0) break;
    325         tty_address[TTY_WRITE] = (unsigned int)buffer[n];
    326     }
    327 }
     331    for (n = 0; n < 100; n++) {
     332        if (buffer[n] == 0) {
     333            break;
     334        }
     335        tty_address[TTY_WRITE] = (unsigned int) buffer[n];
     336    }
     337}
     338
     339
    328340////////////////////////////////////////////////////////////////////////////
    329341// boot_putx()
    330342// (it uses TTY0)
    331343////////////////////////////////////////////////////////////////////////////
    332 void boot_putx(unsigned int val)
    333 {
    334     static const char   HexaTab[] = "0123456789ABCDEF";
    335     char                buf[11];
    336     unsigned int        c;
    337 
    338     buf[0]  = '0';
    339     buf[1]  = 'x';
     344void boot_putx(unsigned int val) {
     345    static const char HexaTab[] = "0123456789ABCDEF";
     346    char buf[11];
     347    unsigned int c;
     348
     349    buf[0] = '0';
     350    buf[1] = 'x';
    340351    buf[10] = 0;
    341352
    342     for ( c = 0 ; c < 8 ; c++ )
    343     {
    344         buf[9-c] = HexaTab[val&0xF];
     353    for (c = 0; c < 8; c++) {
     354        buf[9 - c] = HexaTab[val & 0xF];
    345355        val = val >> 4;
    346356    }
    347357    boot_puts(buf);
    348358}
     359
     360
    349361////////////////////////////////////////////////////////////////////////////
    350362// boot_putd()
    351363// (it uses TTY0)
    352364////////////////////////////////////////////////////////////////////////////
    353 void boot_putd(unsigned int val)
    354 {
    355     static const char   DecTab[] = "0123456789";
    356     char                buf[11];
    357     unsigned int        i;
    358     unsigned int        first;
     365void boot_putd(unsigned int val) {
     366    static const char DecTab[] = "0123456789";
     367    char buf[11];
     368    unsigned int i;
     369    unsigned int first;
    359370
    360371    buf[10] = 0;
    361372
    362     for ( i = 0 ; i < 10 ; i++ )
    363     {
    364         if ((val != 0) || (i == 0))
    365         {
    366             buf[9-i] = DecTab[val % 10];
    367             first    = 9-i;
    368         }
    369         else
    370         {
     373    for (i = 0; i < 10; i++) {
     374        if ((val != 0) || (i == 0)) {
     375            buf[9 - i] = DecTab[val % 10];
     376            first = 9 - i;
     377        }
     378        else {
    371379            break;
    372380        }
    373381        val /= 10;
    374382    }
    375     boot_puts( &buf[first] );
    376 }
     383    boot_puts(&buf[first]);
     384}
     385
    377386
    378387/////////////////////////////////////////////////////////////////////////////
    379388//  mapping_info data structure access functions
    380389/////////////////////////////////////////////////////////////////////////////
    381 inline mapping_cluster_t* boot_get_cluster_base( mapping_header_t* header )
    382 {
    383     return   (mapping_cluster_t*) ((char*)header +
    384                                   MAPPING_HEADER_SIZE);
    385 }
     390inline mapping_cluster_t *boot_get_cluster_base(mapping_header_t * header) {
     391    return (mapping_cluster_t *) ((char *) header + MAPPING_HEADER_SIZE);
     392}
     393
     394
    386395/////////////////////////////////////////////////////////////////////////////
    387 inline mapping_pseg_t* boot_get_pseg_base( mapping_header_t* header )
    388 {
    389     return   (mapping_pseg_t*)    ((char*)header +
    390                                   MAPPING_HEADER_SIZE +
    391                                   MAPPING_CLUSTER_SIZE*header->clusters);
    392 }
     396inline mapping_pseg_t *boot_get_pseg_base(mapping_header_t * header) {
     397    return (mapping_pseg_t *) ((char *) header +
     398            MAPPING_HEADER_SIZE +
     399            MAPPING_CLUSTER_SIZE * header->clusters);
     400}
     401
     402
    393403/////////////////////////////////////////////////////////////////////////////
    394 inline mapping_vspace_t* boot_get_vspace_base( mapping_header_t* header )
    395 {
    396     return   (mapping_vspace_t*)  ((char*)header +
    397                                   MAPPING_HEADER_SIZE +
    398                                   MAPPING_CLUSTER_SIZE*header->clusters +
    399                                   MAPPING_PSEG_SIZE*header->psegs);
    400 }
     404inline mapping_vspace_t *boot_get_vspace_base(mapping_header_t * header) {
     405    return (mapping_vspace_t *) ((char *) header +
     406            MAPPING_HEADER_SIZE +
     407            MAPPING_CLUSTER_SIZE * header->clusters +
     408            MAPPING_PSEG_SIZE * header->psegs);
     409}
     410
     411
    401412/////////////////////////////////////////////////////////////////////////////
    402 inline mapping_vseg_t* boot_get_vseg_base( mapping_header_t* header )
    403 {
    404     return   (mapping_vseg_t*)    ((char*)header +
    405                                   MAPPING_HEADER_SIZE +
    406                                   MAPPING_CLUSTER_SIZE*header->clusters +
    407                                   MAPPING_PSEG_SIZE*header->psegs +
    408                                   MAPPING_VSPACE_SIZE*header->vspaces);
    409 }
     413inline mapping_vseg_t *boot_get_vseg_base(mapping_header_t * header) {
     414    return (mapping_vseg_t *) ((char *) header +
     415            MAPPING_HEADER_SIZE +
     416            MAPPING_CLUSTER_SIZE * header->clusters +
     417            MAPPING_PSEG_SIZE * header->psegs +
     418            MAPPING_VSPACE_SIZE * header->vspaces);
     419}
     420
     421
    410422/////////////////////////////////////////////////////////////////////////////
    411 inline mapping_vobj_t* boot_get_vobj_base( mapping_header_t* header )
    412 {
    413     return   (mapping_vobj_t*)   ((char*)header +
    414                                   MAPPING_HEADER_SIZE +
    415                                   MAPPING_CLUSTER_SIZE*header->clusters +
    416                                   MAPPING_PSEG_SIZE*header->psegs +
    417                                   MAPPING_VSPACE_SIZE*header->vspaces +
    418                                   MAPPING_VSEG_SIZE*header->vsegs );
    419 }
     423inline mapping_vobj_t *boot_get_vobj_base(mapping_header_t * header) {
     424    return (mapping_vobj_t *) ((char *) header +
     425            MAPPING_HEADER_SIZE +
     426            MAPPING_CLUSTER_SIZE * header->clusters +
     427            MAPPING_PSEG_SIZE * header->psegs +
     428            MAPPING_VSPACE_SIZE * header->vspaces +
     429            MAPPING_VSEG_SIZE * header->vsegs);
     430}
     431
     432
    420433/////////////////////////////////////////////////////////////////////////////
    421 inline mapping_task_t* boot_get_task_base( mapping_header_t* header )
    422 {
    423     return   (mapping_task_t*)    ((char*)header +
    424                                   MAPPING_HEADER_SIZE +
    425                                   MAPPING_CLUSTER_SIZE*header->clusters +
    426                                   MAPPING_PSEG_SIZE*header->psegs +
    427                                   MAPPING_VSPACE_SIZE*header->vspaces +
    428                                   MAPPING_VSEG_SIZE*header->vsegs +
    429                                   MAPPING_VOBJ_SIZE*header->vobjs );
    430 }
     434inline mapping_task_t *boot_get_task_base(mapping_header_t * header) {
     435    return (mapping_task_t *) ((char *) header +
     436            MAPPING_HEADER_SIZE +
     437            MAPPING_CLUSTER_SIZE * header->clusters +
     438            MAPPING_PSEG_SIZE * header->psegs +
     439            MAPPING_VSPACE_SIZE * header->vspaces +
     440            MAPPING_VSEG_SIZE * header->vsegs +
     441            MAPPING_VOBJ_SIZE * header->vobjs);
     442}
     443
     444
    431445/////////////////////////////////////////////////////////////////////////////
    432 inline mapping_proc_t* boot_get_proc_base( mapping_header_t* header )
    433 {
    434     return   (mapping_proc_t*)    ((char*)header +
    435                                   MAPPING_HEADER_SIZE +
    436                                   MAPPING_CLUSTER_SIZE*header->clusters +
    437                                   MAPPING_PSEG_SIZE*header->psegs +
    438                                   MAPPING_VSPACE_SIZE*header->vspaces +
    439                                   MAPPING_VSEG_SIZE*header->vsegs +
    440                                   MAPPING_VOBJ_SIZE*header->vobjs +
    441                                   MAPPING_TASK_SIZE*header->tasks );
    442 }
     446inline mapping_proc_t *boot_get_proc_base(mapping_header_t * header) {
     447    return (mapping_proc_t *) ((char *) header +
     448            MAPPING_HEADER_SIZE +
     449            MAPPING_CLUSTER_SIZE * header->clusters +
     450            MAPPING_PSEG_SIZE * header->psegs +
     451            MAPPING_VSPACE_SIZE * header->vspaces +
     452            MAPPING_VSEG_SIZE * header->vsegs +
     453            MAPPING_VOBJ_SIZE * header->vobjs +
     454            MAPPING_TASK_SIZE * header->tasks);
     455}
     456
     457
    443458/////////////////////////////////////////////////////////////////////////////
    444 inline mapping_irq_t* boot_get_irq_base( mapping_header_t* header )
    445 {
    446     return   (mapping_irq_t*)     ((char*)header +
    447                                   MAPPING_HEADER_SIZE +
    448                                   MAPPING_CLUSTER_SIZE*header->clusters +
    449                                   MAPPING_PSEG_SIZE*header->psegs +
    450                                   MAPPING_VSPACE_SIZE*header->vspaces +
    451                                   MAPPING_VSEG_SIZE*header->vsegs +
    452                                   MAPPING_VOBJ_SIZE*header->vobjs +
    453                                   MAPPING_TASK_SIZE*header->tasks +
    454                                   MAPPING_PROC_SIZE*header->procs );
    455 }
     459inline mapping_irq_t *boot_get_irq_base(mapping_header_t * header) {
     460    return (mapping_irq_t *) ((char *) header +
     461            MAPPING_HEADER_SIZE +
     462            MAPPING_CLUSTER_SIZE * header->clusters +
     463            MAPPING_PSEG_SIZE * header->psegs +
     464            MAPPING_VSPACE_SIZE * header->vspaces +
     465            MAPPING_VSEG_SIZE * header->vsegs +
     466            MAPPING_VOBJ_SIZE * header->vobjs +
     467            MAPPING_TASK_SIZE * header->tasks +
     468            MAPPING_PROC_SIZE * header->procs);
     469}
     470
     471
    456472/////////////////////////////////////////////////////////////////////////////
    457 inline mapping_coproc_t* boot_get_coproc_base( mapping_header_t* header )
    458 {
    459     return  (mapping_coproc_t*)   ((char*)header +
    460                                   MAPPING_HEADER_SIZE +
    461                                   MAPPING_CLUSTER_SIZE*header->clusters +
    462                                   MAPPING_PSEG_SIZE*header->psegs +
    463                                   MAPPING_VSPACE_SIZE*header->vspaces +
    464                                   MAPPING_VOBJ_SIZE*header->vobjs +
    465                                   MAPPING_VSEG_SIZE*header->vsegs +
    466                                   MAPPING_TASK_SIZE*header->tasks +
    467                                   MAPPING_PROC_SIZE*header->procs +
    468                                   MAPPING_IRQ_SIZE*header->irqs );
    469 }
     473inline mapping_coproc_t *boot_get_coproc_base(mapping_header_t * header) {
     474    return (mapping_coproc_t *) ((char *) header +
     475            MAPPING_HEADER_SIZE +
     476            MAPPING_CLUSTER_SIZE * header->clusters +
     477            MAPPING_PSEG_SIZE * header->psegs +
     478            MAPPING_VSPACE_SIZE * header->vspaces +
     479            MAPPING_VOBJ_SIZE * header->vobjs +
     480            MAPPING_VSEG_SIZE * header->vsegs +
     481            MAPPING_TASK_SIZE * header->tasks +
     482            MAPPING_PROC_SIZE * header->procs +
     483            MAPPING_IRQ_SIZE * header->irqs);
     484}
     485
     486
    470487///////////////////////////////////////////////////////////////////////////////////
    471 inline mapping_cp_port_t* boot_get_cp_port_base( mapping_header_t* header )
    472 {
    473     return (mapping_cp_port_t*)   ((char*)header +
    474                                   MAPPING_HEADER_SIZE +
    475                                   MAPPING_CLUSTER_SIZE*header->clusters +
    476                                   MAPPING_PSEG_SIZE*header->psegs +
    477                                   MAPPING_VSPACE_SIZE*header->vspaces +
    478                                   MAPPING_VOBJ_SIZE*header->vobjs +
    479                                   MAPPING_VSEG_SIZE*header->vsegs +
    480                                   MAPPING_TASK_SIZE*header->tasks +
    481                                   MAPPING_PROC_SIZE*header->procs +
    482                                   MAPPING_IRQ_SIZE*header->irqs +
    483                                   MAPPING_COPROC_SIZE*header->coprocs );
    484 }
     488inline mapping_cp_port_t *boot_get_cp_port_base(mapping_header_t * header) {
     489    return (mapping_cp_port_t *) ((char *) header +
     490            MAPPING_HEADER_SIZE +
     491            MAPPING_CLUSTER_SIZE * header->clusters +
     492            MAPPING_PSEG_SIZE * header->psegs +
     493            MAPPING_VSPACE_SIZE * header->vspaces +
     494            MAPPING_VOBJ_SIZE * header->vobjs +
     495            MAPPING_VSEG_SIZE * header->vsegs +
     496            MAPPING_TASK_SIZE * header->tasks +
     497            MAPPING_PROC_SIZE * header->procs +
     498            MAPPING_IRQ_SIZE * header->irqs +
     499            MAPPING_COPROC_SIZE * header->coprocs);
     500}
     501
     502
    485503///////////////////////////////////////////////////////////////////////////////////
    486 inline mapping_periph_t* boot_get_periph_base( mapping_header_t* header )
    487 {
    488     return (mapping_periph_t*)    ((char*)header +
    489                                   MAPPING_HEADER_SIZE +
    490                                   MAPPING_CLUSTER_SIZE*header->clusters +
    491                                   MAPPING_PSEG_SIZE*header->psegs +
    492                                   MAPPING_VSPACE_SIZE*header->vspaces +
    493                                   MAPPING_VOBJ_SIZE*header->vobjs +
    494                                   MAPPING_VSEG_SIZE*header->vsegs +
    495                                   MAPPING_TASK_SIZE*header->tasks +
    496                                   MAPPING_PROC_SIZE*header->procs +
    497                                   MAPPING_IRQ_SIZE*header->irqs +
    498                                   MAPPING_COPROC_SIZE*header->coprocs +
    499                                   MAPPING_CP_PORT_SIZE*header->cp_ports );
    500 }
     504inline mapping_periph_t *boot_get_periph_base(mapping_header_t * header) {
     505    return (mapping_periph_t *) ((char *) header +
     506            MAPPING_HEADER_SIZE +
     507            MAPPING_CLUSTER_SIZE * header->clusters +
     508            MAPPING_PSEG_SIZE * header->psegs +
     509            MAPPING_VSPACE_SIZE * header->vspaces +
     510            MAPPING_VOBJ_SIZE * header->vobjs +
     511            MAPPING_VSEG_SIZE * header->vsegs +
     512            MAPPING_TASK_SIZE * header->tasks +
     513            MAPPING_PROC_SIZE * header->procs +
     514            MAPPING_IRQ_SIZE * header->irqs +
     515            MAPPING_COPROC_SIZE * header->coprocs +
     516            MAPPING_CP_PORT_SIZE * header->cp_ports);
     517}
     518
    501519
    502520//////////////////////////////////////////////////////////////////////////////
     
    505523// identified  by the pseg index.
    506524//////////////////////////////////////////////////////////////////////////////
    507 mapping_pseg_t* boot_pseg_get( unsigned int seg_id)
    508 {
    509     mapping_header_t* header = (mapping_header_t*)&seg_mapping_base;
    510     mapping_pseg_t*   pseg   = boot_get_pseg_base( header );
     525mapping_pseg_t *boot_pseg_get(unsigned int seg_id) {
     526    mapping_header_t * header = (mapping_header_t *) & seg_mapping_base;
     527    mapping_pseg_t * pseg = boot_get_pseg_base(header);
    511528
    512529    // checking argument
    513     if ( seg_id >= header->psegs )
    514     {
     530    if (seg_id >= header->psegs) {
    515531        boot_puts("\n[BOOT ERROR] : seg_id argument too large\n");
    516532        boot_puts("               in function boot_pseg_get()\n");
     
    518534    }
    519535
    520     return &pseg[seg_id];                                   
    521 } // end boot_pseg_get()
     536    return &pseg[seg_id];
     537}                // end boot_pseg_get()
     538
    522539
    523540//////////////////////////////////////////////////////////////////////////////
     
    532549// being mapped.
    533550//////////////////////////////////////////////////////////////////////////////
    534 void boot_add_pte( unsigned int    vspace_id,   
    535                    unsigned int    vpn,           
    536                    unsigned int    flags,
    537                    unsigned int    ppn )
    538 {
    539     unsigned int    ix1;
    540     unsigned int    ix2;
    541     unsigned int    ptba;       // PT2 base address
    542     unsigned int    pt2_id;     // PT2 index
    543     unsigned int*   pt_flags;   // pointer on the pte_flags = &PT2[2*ix2]   
    544     unsigned int*   pt_ppn;     // pointer on the pte_ppn   = &PT2[2*ix2+1] 
    545 
    546     ix1 = vpn >> 9;             // 11 bits
    547     ix2 = vpn  & 0x1FF;         //  9 bits
     551void boot_add_pte(unsigned int vspace_id,
     552        unsigned int vpn, unsigned int flags, unsigned int ppn) {
     553    unsigned int ix1;
     554    unsigned int ix2;
     555    unsigned int ptba;      // PT2 base address
     556    unsigned int pt2_id;    // PT2 index
     557    unsigned int *pt_flags; // pointer on the pte_flags = &PT2[2*ix2]   
     558    unsigned int *pt_ppn;   // pointer on the pte_ppn   = &PT2[2*ix2+1] 
     559
     560    ix1 = vpn >> 9;         // 11 bits
     561    ix2 = vpn & 0x1FF;      //  9 bits
    548562
    549563    // check that the boot_max_pt2[vspace_id] has been set
    550     unsigned int max_pt2   = boot_max_pt2[vspace_id];
    551 
    552     if(max_pt2 == 0)
    553     {
     564    unsigned int max_pt2 = boot_max_pt2[vspace_id];
     565
     566    if (max_pt2 == 0) {
    554567        boot_puts("Unfound page table for vspace ");
    555568        boot_putd(vspace_id);
     
    557570        boot_exit();
    558571    }
    559 
    560572    // get page table physical address
    561     page_table_t* pt = boot_ptabs_paddr[vspace_id];
    562 
    563     if ( (pt->pt1[ix1] & PTE_V) == 0 )   // set a new PTD in PT1
    564     {
     573    page_table_t *pt = boot_ptabs_paddr[vspace_id];
     574
     575    if ((pt->pt1[ix1] & PTE_V) == 0) { // set a new PTD in PT1
    565576        pt2_id = boot_next_free_pt2[vspace_id];
    566         if ( pt2_id == max_pt2 )
    567         {
     577        if (pt2_id == max_pt2) {
    568578            boot_puts("\n[BOOT ERROR] in boot_add_pte() function\n");
    569             boot_puts("the length of the ptab vobj is too small\n"); 
     579            boot_puts("the length of the ptab vobj is too small\n");
    570580            boot_exit();
    571581        }
    572         else
    573         {
    574             ptba = (unsigned int)pt + PT1_SIZE + PT2_SIZE*pt2_id;
    575             pt->pt1[ix1] = PTE_V | PTE_T | (ptba >> 12);   
     582        else {
     583            ptba = (unsigned int) pt + PT1_SIZE + PT2_SIZE * pt2_id;
     584            pt->pt1[ix1] = PTE_V | PTE_T | (ptba >> 12);
    576585            boot_next_free_pt2[vspace_id] = pt2_id + 1;
    577586        }
    578587    }
    579     else
    580     {
     588    else {
    581589        ptba = pt->pt1[ix1] << 12;
    582590    }
    583591
    584592    // set PTE2 after checking double mapping error
    585     pt_flags = (unsigned int*)(ptba + 8*ix2);
    586     pt_ppn   = (unsigned int*)(ptba + 8*ix2 + 4);
    587 
    588     if ( ( *pt_flags & PTE_V) != 0 )    // page already mapped
    589     {
     593    pt_flags = (unsigned int *) (ptba + 8 * ix2);
     594    pt_ppn = (unsigned int *) (ptba + 8 * ix2 + 4);
     595
     596    if ((*pt_flags & PTE_V) != 0) {  // page already mapped
    590597        boot_puts("\n[BOOT ERROR] double mapping in vspace ");
    591         boot_putd( vspace_id );
     598        boot_putd(vspace_id);
    592599        boot_puts(" for vpn = ");
    593         boot_putx( vpn );
     600        boot_putx(vpn);
    594601        boot_puts("\n");
    595602        boot_exit();
    596603    }
    597 
    598604    // set PTE2
    599605    *pt_flags = flags;
    600     *pt_ppn   = ppn;
    601 
    602 } // end boot_add_pte()
    603                
     606    *pt_ppn = ppn;
     607
     608}                // end boot_add_pte()
     609
     610
    604611/////////////////////////////////////////////////////////////////////
    605612// This function build the page table for a given vspace.
     
    608615// It initializes the MWMR channels.
    609616/////////////////////////////////////////////////////////////////////
    610 void boot_vspace_pt_build( unsigned int vspace_id )
    611 {
    612     unsigned int    vseg_id;
    613     unsigned int    npages;
    614     unsigned int    ppn;
    615     unsigned int    vpn;
    616     unsigned int    flags;
    617     unsigned int    page_id;
    618 
    619     mapping_header_t*  header = (mapping_header_t*)&seg_mapping_base; 
    620     mapping_vspace_t*  vspace = boot_get_vspace_base( header );
    621     mapping_vseg_t*    vseg   = boot_get_vseg_base( header );
    622    
     617void boot_vspace_pt_build(unsigned int vspace_id) {
     618    unsigned int vseg_id;
     619    unsigned int npages;
     620    unsigned int ppn;
     621    unsigned int vpn;
     622    unsigned int flags;
     623    unsigned int page_id;
     624
     625    mapping_header_t * header = (mapping_header_t *) & seg_mapping_base;
     626    mapping_vspace_t * vspace = boot_get_vspace_base(header);
     627    mapping_vseg_t * vseg = boot_get_vseg_base(header);
     628
    623629    // private segments
    624     for ( vseg_id = vspace[vspace_id].vseg_offset ;
    625           vseg_id < (vspace[vspace_id].vseg_offset + vspace[vspace_id].vsegs) ;
    626           vseg_id++ )
    627     {
    628         vpn       = vseg[vseg_id].vbase >> 12;
    629         ppn       = vseg[vseg_id].pbase >> 12;
    630         npages    = vseg[vseg_id].length >> 12;
    631         if ( (vseg[vseg_id].length & 0xFFF) != 0 ) npages++;
     630    for (vseg_id = vspace[vspace_id].vseg_offset;
     631            vseg_id < (vspace[vspace_id].vseg_offset + vspace[vspace_id].vsegs);
     632            vseg_id++) {
     633        vpn = vseg[vseg_id].vbase >> 12;
     634        ppn = vseg[vseg_id].pbase >> 12;
     635        npages = vseg[vseg_id].length >> 12;
     636        if ((vseg[vseg_id].length & 0xFFF) != 0) {
     637            npages++;
     638        }
    632639
    633640        flags = PTE_V;
    634         if ( vseg[vseg_id].mode & C_MODE_MASK )  flags = flags | PTE_C;
    635         if ( vseg[vseg_id].mode & X_MODE_MASK )  flags = flags | PTE_X;
    636         if ( vseg[vseg_id].mode & W_MODE_MASK )  flags = flags | PTE_W;
    637         if ( vseg[vseg_id].mode & U_MODE_MASK )  flags = flags | PTE_U;
     641        if (vseg[vseg_id].mode & C_MODE_MASK) {
     642            flags = flags | PTE_C;
     643        }
     644        if (vseg[vseg_id].mode & X_MODE_MASK) {
     645            flags = flags | PTE_X;
     646        }
     647        if (vseg[vseg_id].mode & W_MODE_MASK) {
     648            flags = flags | PTE_W;
     649        }
     650        if (vseg[vseg_id].mode & U_MODE_MASK) {
     651            flags = flags | PTE_U;
     652        }
    638653
    639654#if BOOT_DEBUG_PT
    640 boot_puts( vseg[vseg_id].name );
    641 boot_puts(" : flags = ");
    642 boot_putx( flags );
    643 boot_puts(" / npages = ");
    644 boot_putd( npages );
    645 boot_puts(" / pbase = ");
    646 boot_putx( vseg[vseg_id].pbase );
    647 boot_puts("\n");
    648 #endif       
     655        boot_puts(vseg[vseg_id].name);
     656        boot_puts(" : flags = ");
     657        boot_putx(flags);
     658        boot_puts(" / npages = ");
     659        boot_putd(npages);
     660        boot_puts(" / pbase = ");
     661        boot_putx(vseg[vseg_id].pbase);
     662        boot_puts("\n");
     663#endif
    649664        // loop on 4K pages
    650         for ( page_id = 0 ; page_id < npages ; page_id++ )
    651         {
    652             boot_add_pte( vspace_id,
    653                           vpn,
    654                           flags,
    655                           ppn );
     665        for (page_id = 0; page_id < npages; page_id++) {
     666            boot_add_pte(vspace_id, vpn, flags, ppn);
    656667            vpn++;
    657668            ppn++;
     
    660671
    661672    // global segments
    662     for ( vseg_id = 0 ; vseg_id < header->globals ; vseg_id++ )
    663     {
    664         vpn       = vseg[vseg_id].vbase >> 12;
    665         ppn       = vseg[vseg_id].pbase >> 12;
    666         npages    = vseg[vseg_id].length >> 12;
    667         if ( (vseg[vseg_id].length & 0xFFF) != 0 ) npages++;
     673    for (vseg_id = 0; vseg_id < header->globals; vseg_id++) {
     674        vpn = vseg[vseg_id].vbase >> 12;
     675        ppn = vseg[vseg_id].pbase >> 12;
     676        npages = vseg[vseg_id].length >> 12;
     677        if ((vseg[vseg_id].length & 0xFFF) != 0) {
     678            npages++;
     679        }
    668680
    669681        flags = PTE_V;
    670         if ( vseg[vseg_id].mode & C_MODE_MASK )  flags = flags | PTE_C;
    671         if ( vseg[vseg_id].mode & X_MODE_MASK )  flags = flags | PTE_X;
    672         if ( vseg[vseg_id].mode & W_MODE_MASK )  flags = flags | PTE_W;
    673         if ( vseg[vseg_id].mode & U_MODE_MASK )  flags = flags | PTE_U;
     682        if (vseg[vseg_id].mode & C_MODE_MASK) {
     683            flags = flags | PTE_C;
     684        }
     685        if (vseg[vseg_id].mode & X_MODE_MASK) {
     686            flags = flags | PTE_X;
     687        }
     688        if (vseg[vseg_id].mode & W_MODE_MASK) {
     689            flags = flags | PTE_W;
     690        }
     691        if (vseg[vseg_id].mode & U_MODE_MASK) {
     692            flags = flags | PTE_U;
     693        }
    674694
    675695#if BOOT_DEBUG_PT
    676 boot_puts( vseg[vseg_id].name );
    677 boot_puts(" / flags = ");
    678 boot_putx( flags );
    679 boot_puts(" / npages = ");
    680 boot_putd( npages );
    681 boot_puts(" / pbase = ");
    682 boot_putx( vseg[vseg_id].pbase );
    683 boot_puts("\n");
    684 #endif       
     696        boot_puts(vseg[vseg_id].name);
     697        boot_puts(" / flags = ");
     698        boot_putx(flags);
     699        boot_puts(" / npages = ");
     700        boot_putd(npages);
     701        boot_puts(" / pbase = ");
     702        boot_putx(vseg[vseg_id].pbase);
     703        boot_puts("\n");
     704#endif
    685705        // loop on 4K pages
    686         for ( page_id = 0 ; page_id < npages ; page_id++ )
    687         {
    688             boot_add_pte( vspace_id,
    689                           vpn,
    690                           flags,
    691                           ppn );
     706        for (page_id = 0; page_id < npages; page_id++) {
     707            boot_add_pte(vspace_id, vpn, flags, ppn);
    692708            vpn++;
    693709            ppn++;
    694710        }
    695711    }
    696 
    697 } // end boot_vspace_pt_build()
     712}                // end boot_vspace_pt_build()
     713
    698714
    699715///////////////////////////////////////////////////////////////////////////
     
    701717// alignPow2 ( the logarithme of 2 the alignement).
    702718///////////////////////////////////////////////////////////////////////////
    703 unsigned int align_to( unsigned int toAlign,
    704                        unsigned int alignPow2)
    705 {
    706     unsigned int    mask = (1 << alignPow2) - 1;
    707     return ((toAlign + mask ) & ~mask );
    708 }
     719unsigned int align_to(unsigned int toAlign, unsigned int alignPow2) {
     720    unsigned int mask = (1 << alignPow2) - 1;
     721    return ((toAlign + mask) & ~mask);
     722}
     723
    709724
    710725///////////////////////////////////////////////////////////////////////////
     
    717732// It is a global vseg if vspace_id = (-1).
    718733///////////////////////////////////////////////////////////////////////////
    719 void boot_vseg_map( mapping_vseg_t*     vseg,
    720                     unsigned int        vspace_id )
    721 {
    722     unsigned int        vobj_id;
    723     unsigned int        cur_vaddr;
    724     unsigned int        cur_paddr;
    725     mapping_header_t*   header = (mapping_header_t*)&seg_mapping_base; 
    726     mapping_vobj_t*     vobj   = boot_get_vobj_base( header );
    727  
     734void boot_vseg_map(mapping_vseg_t * vseg, unsigned int vspace_id) {
     735    unsigned int vobj_id;
     736    unsigned int cur_vaddr;
     737    unsigned int cur_paddr;
     738    mapping_header_t * header = (mapping_header_t *) & seg_mapping_base;
     739    mapping_vobj_t * vobj = boot_get_vobj_base(header);
     740
    728741    // get physical segment pointer
    729     mapping_pseg_t*  pseg = boot_pseg_get( vseg->psegid );
     742    mapping_pseg_t *pseg = boot_pseg_get(vseg->psegid);
    730743
    731744    // compute vseg physical base address
    732     if ( vseg->ident != 0 )            // identity mapping required
    733     {
    734          vseg->pbase = vseg->vbase;
    735     }
    736     else                                // unconstrained mapping
    737     {
     745    if (vseg->ident != 0) {   // identity mapping required
     746        vseg->pbase = vseg->vbase;
     747    }
     748    else {  // unconstrained mapping
    738749        vseg->pbase = pseg->next_base;
    739750
    740751        // test alignment constraint
    741         if ( vobj[vseg->vobj_offset].align )
    742         {
    743             vseg->pbase = align_to( vseg->pbase, vobj[vseg->vobj_offset].align );
    744         }
    745     }
    746    
     752        if (vobj[vseg->vobj_offset].align) {
     753            vseg->pbase = align_to(vseg->pbase, vobj[vseg->vobj_offset].align);
     754        }
     755    }
     756
    747757    // loop on vobjs contained in vseg to :
    748758    // (1) computes the length of the vseg,
     
    753763    cur_paddr = vseg->pbase;
    754764
    755     for( vobj_id = vseg->vobj_offset;
    756          vobj_id < (vseg->vobj_offset + vseg->vobjs);
    757          vobj_id++)
    758     {
    759         if ( vobj[vobj_id].align )
    760         {
     765    for (vobj_id = vseg->vobj_offset; vobj_id < (vseg->vobj_offset + vseg->vobjs); vobj_id++) {
     766        if (vobj[vobj_id].align) {
    761767            cur_paddr = align_to(cur_paddr, vobj[vobj_id].align);
    762768        }
    763 
    764769        // set vaddr/paddr for current vobj
    765         vobj[vobj_id].vaddr = cur_vaddr;       
    766         vobj[vobj_id].paddr = cur_paddr; 
    767      
     770        vobj[vobj_id].vaddr = cur_vaddr;
     771        vobj[vobj_id].paddr = cur_paddr;
     772
    768773        // initialise boot_ptabs_vaddr[] if current vobj is a PTAB
    769         if ( vobj[vobj_id].type == VOBJ_TYPE_PTAB )
    770         {
    771             if(vspace_id == ((unsigned int) -1))    // global vseg
    772             {
    773                 boot_puts( "\n[BOOT ERROR] in boot_vseg_map() function: " );
    774                 boot_puts( "a PTAB vobj cannot be global" );
     774        if (vobj[vobj_id].type == VOBJ_TYPE_PTAB) {
     775            if (vspace_id == ((unsigned int) -1)) {   // global vseg
     776                boot_puts("\n[BOOT ERROR] in boot_vseg_map() function: ");
     777                boot_puts("a PTAB vobj cannot be global");
    775778                boot_exit();
    776779            }
    777 
    778780            // we need at least one PT2 => ( boot_max_pt2[vspace_id] >= 1)
    779             if(vobj[vobj_id].length < (PT1_SIZE + PT2_SIZE) )
    780             {
    781                 boot_puts( "\n[BOOT ERROR] in boot_vseg_map() function, " );
     781            if (vobj[vobj_id].length < (PT1_SIZE + PT2_SIZE)) {
     782                boot_puts("\n[BOOT ERROR] in boot_vseg_map() function, ");
    782783                boot_puts("PTAB too small, minumum size is: ");
    783                 boot_putx( PT1_SIZE + PT2_SIZE);
     784                boot_putx(PT1_SIZE + PT2_SIZE);
    784785                boot_exit();
    785786            }
    786 
    787787            // register both physical and virtual page table address
    788             boot_ptabs_vaddr[vspace_id] = (page_table_t*)vobj[vobj_id].vaddr;
    789             boot_ptabs_paddr[vspace_id] = (page_table_t*)vobj[vobj_id].paddr;
     788            boot_ptabs_vaddr[vspace_id] = (page_table_t *) vobj[vobj_id].vaddr;
     789            boot_ptabs_paddr[vspace_id] = (page_table_t *) vobj[vobj_id].paddr;
    790790
    791791            /* computing the number of second level page */
    792792            boot_max_pt2[vspace_id] = (vobj[vobj_id].length - PT1_SIZE) / PT2_SIZE;
    793793        }
    794 
    795794        // set next vaddr/paddr
    796795        cur_vaddr += vobj[vobj_id].length;
    797         cur_paddr += vobj[vobj_id].length; 
     796        cur_paddr += vobj[vobj_id].length;
    798797
    799798    } // end for vobjs
    800    
     799
    801800    //set the vseg length
    802     vseg->length = align_to( (cur_paddr - vseg->pbase), 12);
     801    vseg->length = align_to((cur_paddr - vseg->pbase), 12);
    803802
    804803    // checking pseg overflow
    805     if ( (vseg->pbase < pseg->base) ||
    806          ((vseg->pbase + vseg->length) > (pseg->base + pseg->length)) )
    807     {
     804    if ((vseg->pbase < pseg->base) ||
     805            ((vseg->pbase + vseg->length) > (pseg->base + pseg->length))) {
    808806        boot_puts("\n[BOOT ERROR] in boot_vseg_map() function\n");
    809807        boot_puts("impossible mapping for virtual segment: ");
    810         boot_puts( vseg->name );
    811         boot_puts("\n"); 
     808        boot_puts(vseg->name);
     809        boot_puts("\n");
    812810        boot_puts("vseg pbase = ");
    813         boot_putx( vseg->pbase );
    814         boot_puts("\n"); 
     811        boot_putx(vseg->pbase);
     812        boot_puts("\n");
    815813        boot_puts("vseg length = ");
    816         boot_putx( vseg->length );
    817         boot_puts("\n"); 
     814        boot_putx(vseg->length);
     815        boot_puts("\n");
    818816        boot_puts("pseg pbase = ");
    819         boot_putx( pseg->base );
    820         boot_puts("\n"); 
     817        boot_putx(pseg->base);
     818        boot_puts("\n");
    821819        boot_puts("pseg length = ");
    822         boot_putx( pseg->length );
    823         boot_puts("\n"); 
     820        boot_putx(pseg->length);
     821        boot_puts("\n");
    824822        boot_exit();
    825823    }
    826824
    827 
    828825#if BOOT_DEBUG_PT
    829 boot_puts( vseg->name );
    830 boot_puts(" : len = ");
    831 boot_putx( vseg->length );
    832 boot_puts(" / vbase = ");
    833 boot_putx( vseg->vbase );
    834 boot_puts(" / pbase = ");
    835 boot_putx( vseg->pbase );
    836 boot_puts("\n");
    837 #endif 
     826    boot_puts(vseg->name);
     827    boot_puts(" : len = ");
     828    boot_putx(vseg->length);
     829    boot_puts(" / vbase = ");
     830    boot_putx(vseg->vbase);
     831    boot_puts(" / pbase = ");
     832    boot_putx(vseg->pbase);
     833    boot_puts("\n");
     834#endif
    838835
    839836    // set the next_base field in vseg
    840     if ( vseg->ident == 0 && pseg->type != PSEG_TYPE_PERI )
     837    if (vseg->ident == 0 && pseg->type != PSEG_TYPE_PERI) {
    841838        pseg->next_base = vseg->pbase + vseg->length;
    842 
    843 } // end boot_vseg_map()
     839    }
     840
     841}                // end boot_vseg_map()
    844842
    845843/////////////////////////////////////////////////////////////////////
     
    847845// structure (soft), and the giet_config file (hard).
    848846/////////////////////////////////////////////////////////////////////
    849 void boot_check_mapping()
    850 {
    851     mapping_header_t*   header  = (mapping_header_t*)&seg_mapping_base; 
    852     mapping_cluster_t*  cluster = boot_get_cluster_base( header );
    853     mapping_periph_t*   periph  = boot_get_periph_base( header );
     847void boot_check_mapping() {
     848    mapping_header_t * header = (mapping_header_t *) & seg_mapping_base;
     849    mapping_cluster_t * cluster = boot_get_cluster_base(header);
     850    mapping_periph_t * periph = boot_get_periph_base(header);
    854851
    855852    // checking mapping availability
    856     if ( header->signature != IN_MAPPING_SIGNATURE )
    857     {
     853    if (header->signature != IN_MAPPING_SIGNATURE) {
    858854        boot_puts("\n[BOOT ERROR] Illegal mapping signature: ");
    859855        boot_putx(header->signature);
     
    861857        boot_exit();
    862858    }
    863 
    864859    // checking number of clusters
    865     if ( header->clusters != NB_CLUSTERS )
    866     {
     860    if (header->clusters != NB_CLUSTERS) {
    867861        boot_puts("\n[BOOT ERROR] Incoherent NB_CLUSTERS");
    868862        boot_puts("\n             - In giet_config,  value = ");
    869         boot_putd ( NB_CLUSTERS );
     863        boot_putd(NB_CLUSTERS);
    870864        boot_puts("\n             - In mapping_info, value = ");
    871         boot_putd ( header->clusters );
     865        boot_putd(header->clusters);
    872866        boot_puts("\n");
    873867        boot_exit();
    874868    }
    875 
    876869    // checking number of virtual spaces
    877     if ( header->vspaces > GIET_NB_VSPACE_MAX )
    878     {
     870    if (header->vspaces > GIET_NB_VSPACE_MAX) {
    879871        boot_puts("\n[BOOT ERROR] : number of vspaces > GIET_NB_VSPACE_MAX\n");
    880872        boot_puts("\n");
    881873        boot_exit();
    882874    }
    883 
    884875    // checking hardware
    885876    unsigned int periph_id;
     
    887878    unsigned int tty_found = 0;
    888879    unsigned int nic_found = 0;
    889     for ( cluster_id = 0 ; cluster_id < NB_CLUSTERS ; cluster_id++ )
    890     {
     880    for (cluster_id = 0; cluster_id < NB_CLUSTERS; cluster_id++) {
    891881        // NB_PROCS_MAX
    892         if ( cluster[cluster_id].procs > NB_PROCS_MAX )
    893         {
    894             boot_puts("\n[BOOT ERROR] too much processors in cluster ");
    895             boot_putd( cluster_id );
     882        if (cluster[cluster_id].procs > NB_PROCS_MAX) {
     883            boot_puts("\n[BOOT ERROR] too many processors in cluster ");
     884            boot_putd(cluster_id);
    896885            boot_puts(" : procs = ");
    897             boot_putd ( cluster[cluster_id].procs );
     886            boot_putd(cluster[cluster_id].procs);
    898887            boot_puts("\n");
    899888            boot_exit();
    900889        }
    901890
    902         for ( periph_id = cluster[cluster_id].periph_offset ;
    903               periph_id < cluster[cluster_id].periph_offset + cluster[cluster_id].periphs ;
    904               periph_id++ )
    905         {
     891        for (periph_id = cluster[cluster_id].periph_offset;
     892                periph_id < cluster[cluster_id].periph_offset + cluster[cluster_id].periphs;
     893                periph_id++) {
    906894            // NB_TTYS
    907             if ( periph[periph_id].type == PERIPH_TYPE_TTY )
    908             {
    909                 if ( tty_found )
    910                 {
     895            if (periph[periph_id].type == PERIPH_TYPE_TTY) {
     896                if (tty_found) {
    911897                    boot_puts("\n[BOOT ERROR] TTY component should not be replicated\n");
    912898                    boot_exit();
    913899                }
    914                 if ( periph[periph_id].channels > NB_TTYS )
    915                 {
     900                if (periph[periph_id].channels > NB_TTYS) {
    916901                    boot_puts("\n[BOOT ERROR] Wrong NB_TTYS in cluster ");
    917                     boot_putd( cluster_id );
     902                    boot_putd(cluster_id);
    918903                    boot_puts(" : ttys = ");
    919                     boot_putd ( periph[periph_id].channels );
     904                    boot_putd(periph[periph_id].channels);
    920905                    boot_puts("\n");
    921906                    boot_exit();
     
    924909            }
    925910            // NB_NICS
    926             if ( periph[periph_id].type == PERIPH_TYPE_NIC )
    927             {
    928                 if ( nic_found )
    929                 {
     911            if (periph[periph_id].type == PERIPH_TYPE_NIC) {
     912                if (nic_found) {
    930913                    boot_puts("\n[BOOT ERROR] NIC component should not be replicated\n");
    931914                    boot_exit();
    932915                }
    933                 if ( periph[periph_id].channels != NB_NICS )
    934                 {
     916                if (periph[periph_id].channels != NB_NICS) {
    935917                    boot_puts("\n[BOOT ERROR] Wrong NB_NICS in cluster ");
    936                     boot_putd( cluster_id );
     918                    boot_putd(cluster_id);
    937919                    boot_puts(" : nics = ");
    938                     boot_putd ( periph[periph_id].channels );
     920                    boot_putd(periph[periph_id].channels);
    939921                    boot_puts("\n");
    940922                    boot_exit();
     
    943925            }
    944926            // NB_TIMERS
    945             if ( periph[periph_id].type == PERIPH_TYPE_TIM )
    946             {
    947                 if ( periph[periph_id].channels > NB_TIMERS_MAX )
    948                 {
     927            if (periph[periph_id].type == PERIPH_TYPE_TIM) {
     928                if (periph[periph_id].channels > NB_TIMERS_MAX) {
    949929                    boot_puts("\n[BOOT ERROR] Too much user timers in cluster ");
    950                     boot_putd( cluster_id );
     930                    boot_putd(cluster_id);
    951931                    boot_puts(" : timers = ");
    952                     boot_putd ( periph[periph_id].channels );
     932                    boot_putd(periph[periph_id].channels);
    953933                    boot_puts("\n");
    954934                    boot_exit();
     
    956936            }
    957937            // NB_DMAS
    958             if ( periph[periph_id].type == PERIPH_TYPE_DMA )
    959             {
    960                 if ( periph[periph_id].channels != NB_DMAS_MAX )
    961                 {
     938            if (periph[periph_id].type == PERIPH_TYPE_DMA) {
     939                if (periph[periph_id].channels != NB_DMAS_MAX) {
    962940                    boot_puts("\n[BOOT ERROR] Too much DMA channels in cluster ");
    963                     boot_putd( cluster_id );
     941                    boot_putd(cluster_id);
    964942                    boot_puts(" : channels = ");
    965                     boot_putd ( periph[periph_id].channels );
     943                    boot_putd(periph[periph_id].channels);
     944                    boot_puts(" - NB_DMAS_MAX : ");
     945                    boot_putd(NB_DMAS_MAX);
    966946                    boot_puts("\n");
    967947                    boot_exit();
     
    971951    } // end for clusters
    972952} // end boot_check_mapping()
     953
    973954
    974955/////////////////////////////////////////////////////////////////////
     
    978959// schedulers in the first RAM pseg found (4k bytes per processor).
    979960/////////////////////////////////////////////////////////////////////
    980 void boot_psegs_init()
    981 {
    982     mapping_header_t*   header  = (mapping_header_t*)&seg_mapping_base; 
    983 
    984     mapping_cluster_t*  cluster = boot_get_cluster_base( header );
    985     mapping_pseg_t*     pseg    = boot_get_pseg_base( header );
     961void boot_psegs_init() {
     962    mapping_header_t * header = (mapping_header_t *) &seg_mapping_base;
     963
     964    mapping_cluster_t * cluster = boot_get_cluster_base(header);
     965    mapping_pseg_t * pseg = boot_get_pseg_base(header);
    986966
    987967    unsigned int cluster_id;
     
    990970
    991971#if BOOT_DEBUG_PT
    992 boot_puts("\n[BOOT DEBUG] ****** psegs allocators nitialisation ******\n");
    993 #endif
    994 
    995     for ( cluster_id = 0 ; cluster_id < header->clusters ; cluster_id++ )
    996     {
    997         if ( cluster[cluster_id].procs > NB_PROCS_MAX )
    998         {
     972    boot_puts
     973        ("\n[BOOT DEBUG] ****** psegs allocators nitialisation ******\n");
     974#endif
     975
     976    for (cluster_id = 0; cluster_id < header->clusters; cluster_id++) {
     977        if (cluster[cluster_id].procs > NB_PROCS_MAX) {
    999978            boot_puts("\n[BOOT ERROR] The number of processors in cluster ");
    1000             boot_putd( cluster_id );
     979            boot_putd(cluster_id);
    1001980            boot_puts(" is larger than NB_PROCS_MAX \n");
    1002981            boot_exit();
    1003982        }
    1004983
    1005         found    = 0;
    1006 
    1007         for ( pseg_id = cluster[cluster_id].pseg_offset ;
    1008               pseg_id < cluster[cluster_id].pseg_offset + cluster[cluster_id].psegs ;
    1009               pseg_id++ )
    1010         {
     984        found = 0;
     985
     986        for (pseg_id = cluster[cluster_id].pseg_offset;
     987                pseg_id < cluster[cluster_id].pseg_offset + cluster[cluster_id].psegs;
     988                pseg_id++) {
    1011989            unsigned int free = pseg[pseg_id].base;
    1012990
    1013             if ( (pseg[pseg_id].type == PSEG_TYPE_RAM) && (found == 0) )
    1014             {
     991            if ((pseg[pseg_id].type == PSEG_TYPE_RAM) && (found == 0)) {
    1015992                free = free + (cluster[cluster_id].procs << 12);
    1016993                found = 1;
     
    1019996
    1020997#if BOOT_DEBUG_PT
    1021 boot_puts("cluster ");
    1022 boot_putd(cluster_id);
    1023 boot_puts(" / pseg ");
    1024 boot_puts(pseg[pseg_id].name);
    1025 boot_puts(" : next_base = ");
    1026 boot_putx(pseg[pseg_id].next_base);
    1027 boot_puts("\n");
     998            boot_puts("cluster ");
     999            boot_putd(cluster_id);
     1000            boot_puts(" / pseg ");
     1001            boot_puts(pseg[pseg_id].name);
     1002            boot_puts(" : next_base = ");
     1003            boot_putx(pseg[pseg_id].next_base);
     1004            boot_puts("\n");
    10281005#endif
    10291006        }
    10301007    }
    10311008} // end boot_pseg_init()
     1009
    10321010
    10331011/////////////////////////////////////////////////////////////////////
     
    10371015// (replicated in all vspaces), and the private vsegs.
    10381016/////////////////////////////////////////////////////////////////////
    1039 void boot_pt_init()
    1040 {
    1041     mapping_header_t*   header = (mapping_header_t*)&seg_mapping_base; 
    1042 
    1043     mapping_vspace_t*   vspace = boot_get_vspace_base( header );     
    1044     mapping_vseg_t*     vseg   = boot_get_vseg_base( header );
    1045 
    1046     unsigned int        vspace_id; 
    1047     unsigned int        vseg_id;
     1017void boot_pt_init() {
     1018    mapping_header_t * header = (mapping_header_t *) &seg_mapping_base;
     1019
     1020    mapping_vspace_t * vspace = boot_get_vspace_base(header);
     1021    mapping_vseg_t * vseg = boot_get_vseg_base(header);
     1022
     1023    unsigned int vspace_id;
     1024    unsigned int vseg_id;
    10481025
    10491026#if BOOT_DEBUG_PT
    1050 boot_puts("\n[BOOT DEBUG] ****** mapping global vsegs ******\n");
    1051 #endif
    1052            
     1027    boot_puts("\n[BOOT DEBUG] ****** mapping global vsegs ******\n");
     1028#endif
     1029
    10531030    // step 1 : first loop on virtual spaces to map global vsegs
    1054     for ( vseg_id = 0 ; vseg_id < header->globals ; vseg_id++ )
    1055     {
    1056         boot_vseg_map( &vseg[vseg_id], ((unsigned int)(-1)) );
     1031    for (vseg_id = 0; vseg_id < header->globals; vseg_id++) {
     1032        boot_vseg_map(&vseg[vseg_id], ((unsigned int) (-1)));
    10571033    }
    10581034
    10591035    // step 2 : loop on virtual vspaces to map private vsegs
    1060     for ( vspace_id = 0 ; vspace_id < header->vspaces ; vspace_id++ )
    1061     {
     1036    for (vspace_id = 0; vspace_id < header->vspaces; vspace_id++) {
    10621037
    10631038#if BOOT_DEBUG_PT
    1064 boot_puts("\n[BOOT DEBUG] ****** mapping private vsegs in vspace ");
    1065 boot_puts(vspace[vspace_id].name);
    1066 boot_puts(" ******\n");
    1067 #endif
    1068            
    1069         for ( vseg_id = vspace[vspace_id].vseg_offset ;
    1070               vseg_id < (vspace[vspace_id].vseg_offset + vspace[vspace_id].vsegs) ;
    1071               vseg_id++ )
    1072         {
    1073             boot_vseg_map( &vseg[vseg_id], vspace_id );
    1074         }
    1075     } 
     1039        boot_puts
     1040            ("\n[BOOT DEBUG] ****** mapping private vsegs in vspace ");
     1041        boot_puts(vspace[vspace_id].name);
     1042        boot_puts(" ******\n");
     1043#endif
     1044
     1045        for (vseg_id = vspace[vspace_id].vseg_offset;
     1046                vseg_id < (vspace[vspace_id].vseg_offset + vspace[vspace_id].vsegs);
     1047                vseg_id++) {
     1048            boot_vseg_map(&vseg[vseg_id], vspace_id);
     1049        }
     1050    }
    10761051
    10771052    // step 3 : loop on the vspaces to build the page tables
    1078     for ( vspace_id = 0 ; vspace_id < header->vspaces ; vspace_id++ )
    1079     {
     1053    for (vspace_id = 0; vspace_id < header->vspaces; vspace_id++) {
    10801054
    10811055#if BOOT_DEBUG_PT
    1082 boot_puts("\n[BOOT DEBUG] ****** building page table for vspace ");
    1083 boot_puts(vspace[vspace_id].name);
    1084 boot_puts(" ******\n");
    1085 #endif
    1086            
    1087         boot_vspace_pt_build( vspace_id );
     1056        boot_puts("\n[BOOT DEBUG] ****** building page table for vspace ");
     1057        boot_puts(vspace[vspace_id].name);
     1058        boot_puts(" ******\n");
     1059#endif
     1060
     1061        boot_vspace_pt_build(vspace_id);
    10881062
    10891063#if BOOT_DEBUG_PT
    1090 boot_puts("\n>>> page table physical address = ");
    1091 boot_putx((unsigned int)boot_ptabs_paddr[vspace_id]);
    1092 boot_puts(", page table number of PT2 = ");
    1093 boot_putd((unsigned int)boot_max_pt2[vspace_id]);
    1094 boot_puts("\n");
    1095 #endif
    1096     } 
     1064        boot_puts("\n>>> page table physical address = ");
     1065        boot_putx((unsigned int) boot_ptabs_paddr[vspace_id]);
     1066        boot_puts(", page table number of PT2 = ");
     1067        boot_putd((unsigned int) boot_max_pt2[vspace_id]);
     1068        boot_puts("\n");
     1069#endif
     1070    }
    10971071} // end boot_pt_init()
     1072
    10981073
    10991074///////////////////////////////////////////////////////////////////////////////
    11001075// This function initializes all private vobjs defined in the vspaces,
    11011076// such as mwmr channels, barriers and locks, because these vobjs
    1102 // are not known, and not initialised by the compiler.
     1077// are not known, and not initialized by the compiler.
    11031078///////////////////////////////////////////////////////////////////////////////
    1104 void boot_vobjs_init()
    1105 {
    1106     mapping_header_t*   header  = (mapping_header_t*)&seg_mapping_base; 
    1107     mapping_vspace_t*   vspace  = boot_get_vspace_base( header );     
    1108     mapping_vobj_t*     vobj    = boot_get_vobj_base( header );
    1109 
    1110     unsigned int        vspace_id; 
    1111     unsigned int        vobj_id;
     1079void boot_vobjs_init() {
     1080    mapping_header_t * header = (mapping_header_t *) & seg_mapping_base;
     1081    mapping_vspace_t * vspace = boot_get_vspace_base(header);
     1082    mapping_vobj_t * vobj = boot_get_vobj_base(header);
     1083
     1084    unsigned int vspace_id;
     1085    unsigned int vobj_id;
    11121086
    11131087    // loop on the vspaces
    1114     for ( vspace_id = 0 ; vspace_id < header->vspaces ; vspace_id++ )
    1115     {
     1088    for (vspace_id = 0; vspace_id < header->vspaces; vspace_id++) {
    11161089
    11171090#if BOOT_DEBUG_VOBJS
    1118 boot_puts("\n[BOOT DEBUG] ****** vobjs initialisation in vspace ");
    1119 boot_puts(vspace[vspace_id].name);
    1120 boot_puts(" ******\n");
     1091        boot_puts("\n[BOOT DEBUG] ****** vobjs initialisation in vspace ");
     1092        boot_puts(vspace[vspace_id].name);
     1093        boot_puts(" ******\n");
    11211094#endif
    11221095
     
    11241097
    11251098        // loop on the vobjs
    1126             for(vobj_id= vspace[vspace_id].vobj_offset;
    1127                         vobj_id < (vspace[vspace_id].vobj_offset+ vspace[vspace_id].vobjs);
    1128                         vobj_id++)
    1129             {
    1130             switch( vobj[vobj_id].type )
    1131             {
    1132                 case VOBJ_TYPE_MWMR:    // storage capacity is (vobj.length/4 - 5) words
    1133                         {
    1134                     mwmr_channel_t* mwmr = (mwmr_channel_t*)(vobj[vobj_id].paddr);
    1135                     mwmr->ptw   = 0;
    1136                     mwmr->ptr   = 0;
    1137                     mwmr->sts   = 0;
     1099        for (vobj_id = vspace[vspace_id].vobj_offset;
     1100                vobj_id < (vspace[vspace_id].vobj_offset + vspace[vspace_id].vobjs);
     1101                vobj_id++) {
     1102            switch (vobj[vobj_id].type) {
     1103                case VOBJ_TYPE_MWMR:    // storage capacity is (vobj.length/4 - 5) words
     1104                {
     1105                    mwmr_channel_t * mwmr = (mwmr_channel_t *) (vobj[vobj_id].paddr);
     1106                    mwmr->ptw = 0;
     1107                    mwmr->ptr = 0;
     1108                    mwmr->sts = 0;
    11381109                    mwmr->width = vobj[vobj_id].init;
    1139                     mwmr->depth = (vobj[vobj_id].length>>2) - 6;
    1140                     mwmr->lock  = 0;
     1110                    mwmr->depth = (vobj[vobj_id].length >> 2) - 6;
     1111                    mwmr->lock = 0;
    11411112#if BOOT_DEBUG_VOBJS
    1142 boot_puts("MWMR    : ");
    1143 boot_puts( vobj[vobj_id].name);
    1144 boot_puts(" / depth = ");
    1145 boot_putd( mwmr->depth );
    1146 boot_puts(" / width = ");
    1147 boot_putd( mwmr->width );
    1148 boot_puts("\n");
     1113                    boot_puts("MWMR    : ");
     1114                    boot_puts(vobj[vobj_id].name);
     1115                    boot_puts(" / depth = ");
     1116                    boot_putd(mwmr->depth);
     1117                    boot_puts(" / width = ");
     1118                    boot_putd(mwmr->width);
     1119                    boot_puts("\n");
    11491120#endif
    11501121                    break;
    11511122                }
    1152                 case VOBJ_TYPE_ELF:             // initialisation done by the loader
     1123                case VOBJ_TYPE_ELF:    // initialisation done by the loader
    11531124                {
    11541125#if BOOT_DEBUG_VOBJS
    1155 boot_puts("ELF     : ");
    1156 boot_puts( vobj[vobj_id].name);
    1157 boot_puts(" / length = ");
    1158 boot_putx( vobj[vobj_id].length );
    1159 boot_puts("\n");
     1126                    boot_puts("ELF     : ");
     1127                    boot_puts(vobj[vobj_id].name);
     1128                    boot_puts(" / length = ");
     1129                    boot_putx(vobj[vobj_id].length);
     1130                    boot_puts("\n");
    11601131#endif
    11611132                    break;
    11621133                }
    1163                 case VOBJ_TYPE_BLOB:            // initialisation done by the loader
     1134                case VOBJ_TYPE_BLOB:    // initialisation done by the loader
    11641135                {
    11651136#if BOOT_DEBUG_VOBJS
    1166 boot_puts("BLOB     : ");
    1167 boot_puts( vobj[vobj_id].name);
    1168 boot_puts(" / length = ");
    1169 boot_putx( vobj[vobj_id].length );
    1170 boot_puts("\n");
     1137                    boot_puts("BLOB     : ");
     1138                    boot_puts(vobj[vobj_id].name);
     1139                    boot_puts(" / length = ");
     1140                    boot_putx(vobj[vobj_id].length);
     1141                    boot_puts("\n");
    11711142#endif
    11721143                    break;
    11731144                }
    1174                 case VOBJ_TYPE_BARRIER: // init is the number of participants
     1145                case VOBJ_TYPE_BARRIER:    // init is the number of participants
    11751146                {
    1176                     giet_barrier_t* barrier = (giet_barrier_t*)(vobj[vobj_id].paddr);
    1177                     barrier->count = 0;
    1178                     barrier->init  = vobj[vobj_id].init;
     1147                    giet_barrier_t * barrier = (giet_barrier_t *) (vobj[vobj_id].paddr);
     1148                    barrier->count = vobj[vobj_id].init;
     1149                    barrier->init = vobj[vobj_id].init;
    11791150#if BOOT_DEBUG_VOBJS
    1180 boot_puts("BARRIER : ");
    1181 boot_puts( vobj[vobj_id].name);
    1182 boot_puts(" / init_value = ");
    1183 boot_putd( barrier->init );
    1184 boot_puts("\n");
     1151                    boot_puts("BARRIER : ");
     1152                    boot_puts(vobj[vobj_id].name);
     1153                    boot_puts(" / init_value = ");
     1154                    boot_putd(barrier->init);
     1155                    boot_puts("\n");
    11851156#endif
    11861157                    break;
    11871158                }
    1188                 case VOBJ_TYPE_LOCK:    // init is "not taken"
     1159                case VOBJ_TYPE_LOCK:    // init is "not taken"
    11891160                {
    1190                     unsigned int* lock = (unsigned int*)(vobj[vobj_id].paddr);
     1161                    unsigned int * lock = (unsigned int *) (vobj[vobj_id].paddr);
    11911162                    *lock = 0;
    11921163#if BOOT_DEBUG_VOBJS
    1193 boot_puts("LOCK    : ");
    1194 boot_puts( vobj[vobj_id].name);
    1195 boot_puts("\n");
     1164                    boot_puts("LOCK    : ");
     1165                    boot_puts(vobj[vobj_id].name);
     1166                    boot_puts("\n");
    11961167#endif
    11971168                    break;
    11981169                }
    1199                 case VOBJ_TYPE_BUFFER:  // nothing to initialise
     1170                case VOBJ_TYPE_BUFFER:    // nothing to initialise
    12001171                {
    12011172#if BOOT_DEBUG_VOBJS
    1202 boot_puts("BUFFER  : ");
    1203 boot_puts( vobj[vobj_id].name);
    1204 boot_puts(" / length = ");
    1205 boot_putx( vobj[vobj_id].length );
    1206 boot_puts("\n");
     1173                    boot_puts("BUFFER  : ");
     1174                    boot_puts(vobj[vobj_id].name);
     1175                    boot_puts(" / paddr = ");
     1176                    boot_putx(vobj[vobj_id].paddr);
     1177                    boot_puts(" / length = ");
     1178                    boot_putx(vobj[vobj_id].length);
     1179                    boot_puts("\n");
    12071180#endif
    12081181                    break;
    12091182                }
    1210                 case VOBJ_TYPE_PTAB:    // nothing to initialise
     1183                case VOBJ_TYPE_MEMSPACE:
     1184                {
     1185                    giet_memspace_t * memspace = (giet_memspace_t *) vobj[vobj_id].paddr;
     1186                    memspace->buffer = (void *) vobj[vobj_id].vaddr + 8;
     1187                    memspace->size = vobj[vobj_id].length - 8;
     1188#if BOOT_DEBUG_VOBJS
     1189                    boot_puts("MEMSPACE  : ");
     1190                    boot_puts(vobj[vobj_id].name);
     1191                    boot_puts(" / paddr = ");
     1192                    boot_putx(vobj[vobj_id].paddr);
     1193                    boot_puts(" / length = ");
     1194                    boot_putx(vobj[vobj_id].length);
     1195                    boot_puts("\n");
     1196#endif
     1197                    break;
     1198                }
     1199                case VOBJ_TYPE_PTAB:    // nothing to initialise
    12111200                {
    12121201                    ptab_found = 1;
    12131202#if BOOT_DEBUG_VOBJS
    1214 boot_puts("PTAB    : ");
    1215 boot_puts( vobj[vobj_id].name);
    1216 boot_puts(" / length = ");
    1217 boot_putx( vobj[vobj_id].length );
    1218 boot_puts("\n");
    1219 #endif
     1203                    boot_puts("PTAB    : ");
     1204                    boot_puts(vobj[vobj_id].name);
     1205                    boot_puts(" / length = ");
     1206                    boot_putx(vobj[vobj_id].length);
     1207                    boot_puts("\n");
     1208#endif
     1209                    break;
     1210                }
     1211                case VOBJ_TYPE_CONST:
     1212                {
     1213#if BOOT_DEBUG_VOBJS
     1214                    boot_puts("CONST   : ");
     1215                    boot_puts(vobj[vobj_id].name);
     1216                    boot_puts(" / Paddr :");
     1217                    boot_putx(vobj[vobj_id].paddr);
     1218                    boot_puts(" / init = ");
     1219                    boot_putx(vobj[vobj_id].init);
     1220                    boot_puts("\n");
     1221#endif
     1222                    unsigned int *addr = (unsigned int *) vobj[vobj_id].paddr;
     1223                    *addr = vobj[vobj_id].init;
    12201224                    break;
    12211225                }
    12221226                default:
    12231227                {
    1224                     boot_puts("\n[INIT ERROR] illegal vobj of name ");
    1225                     boot_puts(vobj->name);
    1226                     boot_puts(" / in vspace = ");
    1227                     boot_puts(vobj->name);
     1228                    boot_puts("\n[INIT ERROR] illegal vobj type: ");
     1229                    boot_putd(vobj[vobj_id].type);
    12281230                    boot_puts("\n ");
    12291231                    boot_exit();
    12301232                }
    1231             } // end switch type
    1232         } // end loop on vobjs
    1233         if( ptab_found == 0 )
    1234         {
     1233            }            // end switch type
     1234        }            // end loop on vobjs
     1235        if (ptab_found == 0) {
    12351236            boot_puts("\n[INIT ERROR] Missing PTAB for vspace ");
    1236             boot_putd( vspace_id );
     1237            boot_putd(vspace_id);
    12371238            boot_exit();
    12381239        }
     
    12401241} // end boot_vobjs_init()
    12411242
    1242 void
    1243 mwmr_hw_init( void *coproc, enum mwmrPortDirection way,
    1244               unsigned int no, const mwmr_channel_t *pmwmr)
    1245 {
    1246     volatile unsigned int *cbase = (unsigned int*) coproc;
    1247    
    1248     cbase[MWMR_CONFIG_FIFO_WAY] = way ;
    1249     cbase[MWMR_CONFIG_FIFO_NO] = no ;
    1250     cbase[MWMR_CONFIG_STATUS_ADDR] = (unsigned int)pmwmr ;
    1251     cbase[MWMR_CONFIG_WIDTH] = pmwmr->width ;
     1243
     1244void mwmr_hw_init(void * coproc, enum mwmrPortDirection way,
     1245        unsigned int no, const mwmr_channel_t * pmwmr) {
     1246    volatile unsigned int *cbase = (unsigned int *) coproc;
     1247
     1248    cbase[MWMR_CONFIG_FIFO_WAY] = way;
     1249    cbase[MWMR_CONFIG_FIFO_NO] = no;
     1250    cbase[MWMR_CONFIG_STATUS_ADDR] = (unsigned int) pmwmr;
     1251    cbase[MWMR_CONFIG_WIDTH] = pmwmr->width;
    12521252    cbase[MWMR_CONFIG_DEPTH] = pmwmr->depth;
    1253     cbase[MWMR_CONFIG_BUFFER_ADDR] = (unsigned int)&pmwmr->data;
    1254     cbase[MWMR_CONFIG_RUNNING] = 1 ;
     1253    cbase[MWMR_CONFIG_BUFFER_ADDR] = (unsigned int) &pmwmr->data;
     1254    cbase[MWMR_CONFIG_RUNNING] = 1;
    12551255}
    12561256
     
    12601260// in the mapping_info file.
    12611261////////////////////////////////////////////////////////////////////////////////
    1262 void boot_peripherals_init()
    1263 {
    1264     mapping_header_t*   header  = (mapping_header_t*)&seg_mapping_base; 
    1265     mapping_cluster_t*  cluster = boot_get_cluster_base( header );     
    1266     mapping_periph_t*   periph  = boot_get_periph_base( header );
    1267     mapping_pseg_t*     pseg    = boot_get_pseg_base( header );
    1268     mapping_vobj_t*     vobj    = boot_get_vobj_base( header );
    1269     mapping_vspace_t*   vspace  = boot_get_vspace_base( header );     
    1270     mapping_coproc_t*   coproc  = boot_get_coproc_base( header );
    1271     mapping_cp_port_t*  cp_port = boot_get_cp_port_base( header );
    1272 
    1273     unsigned int        cluster_id;
    1274     unsigned int        periph_id; 
    1275     unsigned int        coproc_id; 
    1276     unsigned int        cp_port_id; 
    1277     unsigned int        channel_id;
    1278 
    1279     for ( cluster_id = 0 ; cluster_id < header->clusters ; cluster_id++ )
    1280     {
     1262void boot_peripherals_init() {
     1263    mapping_header_t * header = (mapping_header_t *) & seg_mapping_base;
     1264    mapping_cluster_t * cluster = boot_get_cluster_base(header);
     1265    mapping_periph_t * periph = boot_get_periph_base(header);
     1266    mapping_pseg_t * pseg = boot_get_pseg_base(header);
     1267    mapping_vobj_t * vobj = boot_get_vobj_base(header);
     1268    mapping_vspace_t * vspace = boot_get_vspace_base(header);
     1269    mapping_coproc_t * coproc = boot_get_coproc_base(header);
     1270    mapping_cp_port_t * cp_port = boot_get_cp_port_base(header);
     1271
     1272    unsigned int cluster_id;
     1273    unsigned int periph_id;
     1274    unsigned int coproc_id;
     1275    unsigned int cp_port_id;
     1276    unsigned int channel_id;
     1277
     1278    for (cluster_id = 0; cluster_id < header->clusters; cluster_id++) {
    12811279
    12821280#if BOOT_DEBUG_PERI
    1283 boot_puts("\n[BOOT DEBUG] ****** peripheral initialisation in cluster ");
    1284 boot_putd( cluster_id );
    1285 boot_puts(" ******\n");
    1286 #endif
    1287 
    1288         for ( periph_id = cluster[cluster_id].periph_offset ;
    1289               periph_id < cluster[cluster_id].periph_offset + cluster[cluster_id].periphs ;
    1290               periph_id++ )
    1291         {
    1292             unsigned int    type      = periph[periph_id].type;
    1293             unsigned int    channels = periph[periph_id].channels;
    1294             unsigned int    pseg_id  = periph[periph_id].psegid;
    1295 
    1296             unsigned int*   pseg_base = (unsigned int*)pseg[pseg_id].base;
     1281        boot_puts
     1282            ("\n[BOOT DEBUG] ****** peripheral initialisation in cluster ");
     1283        boot_putd(cluster_id);
     1284        boot_puts(" ******\n");
     1285#endif
     1286
     1287        for (periph_id = cluster[cluster_id].periph_offset;
     1288                periph_id < cluster[cluster_id].periph_offset +
     1289                cluster[cluster_id].periphs; periph_id++) {
     1290            unsigned int type = periph[periph_id].type;
     1291            unsigned int channels = periph[periph_id].channels;
     1292            unsigned int pseg_id = periph[periph_id].psegid;
     1293
     1294            unsigned int * pseg_base = (unsigned int *) pseg[pseg_id].base;
    12971295
    12981296#if BOOT_DEBUG_PERI
    1299 boot_puts("- peripheral type : ");
    1300 boot_putd( type );
    1301 boot_puts(" / address = ");
    1302 boot_putx( (unsigned int)pseg_base );
    1303 boot_puts(" / channels = ");
    1304 boot_putd( channels );
    1305 boot_puts("\n");
    1306 #endif
    1307 
    1308             switch ( type )
    1309             {
    1310                 case PERIPH_TYPE_IOC:   // vci_block_device component
    1311                     pseg_base[BLOCK_DEVICE_IRQ_ENABLE] = 1;
     1297            boot_puts("- peripheral type : ");
     1298            boot_putd(type);
     1299            boot_puts(" / address = ");
     1300            boot_putx((unsigned int) pseg_base);
     1301            boot_puts(" / channels = ");
     1302            boot_putd(channels);
     1303            boot_puts("\n");
     1304#endif
     1305
     1306            switch (type) {
     1307                case PERIPH_TYPE_IOC:    // vci_block_device component
     1308                    pseg_base[BLOCK_DEVICE_IRQ_ENABLE] = 1;
    13121309#if BOOT_DEBUG_PERI
    1313 boot_puts("- IOC initialised\n");
    1314 #endif
    1315                 break;
    1316                 case PERIPH_TYPE_DMA:   // vci_multi_dma component
    1317                     for ( channel_id = 0 ; channel_id < channels ; channel_id++ )
    1318                     {
    1319                         pseg_base[DMA_IRQ_DISABLE + channel_id*DMA_SPAN] = 0;
     1310                    boot_puts("- IOC initialised\n");
     1311#endif
     1312                    break;
     1313
     1314                case PERIPH_TYPE_DMA:    // vci_multi_dma component
     1315                    for (channel_id = 0; channel_id < channels; channel_id++) {
     1316                        pseg_base[DMA_IRQ_DISABLE + channel_id * DMA_SPAN] = 0;
    13201317                    }
    13211318#if BOOT_DEBUG_PERI
    1322 boot_puts("- DMA initialised\n");
    1323 #endif
    1324                 break;
    1325                 case PERIPH_TYPE_NIC:   // vci_multi_nic component
    1326                     for ( channel_id = 0 ; channel_id < channels ; channel_id++ )
    1327                     {
     1319                    boot_puts("- DMA initialised\n");
     1320#endif
     1321                    break;
     1322
     1323                case PERIPH_TYPE_NIC:    // vci_multi_nic component
     1324                    for (channel_id = 0; channel_id < channels; channel_id++) {
    13281325                        // TODO
    13291326                    }
    13301327#if BOOT_DEBUG_PERI
    1331 boot_puts("- NIC initialised\n");
    1332 #endif
    1333                 break;
    1334                 case PERIPH_TYPE_TTY:   // vci_multi_tty component
     1328                    boot_puts("- NIC initialised\n");
     1329#endif
     1330                    break;
     1331
     1332                case PERIPH_TYPE_TTY:    // vci_multi_tty component
    13351333#if BOOT_DEBUG_PERI
    1336 boot_puts("- TTY initialised\n");
    1337 #endif
    1338                 break;
    1339                 case PERIPH_TYPE_IOB:   // vci_io_bridge component
    1340                     if ( IOMMU_ACTIVE )
    1341                     {
     1334                    boot_puts("- TTY initialised\n");
     1335#endif
     1336                    break;
     1337
     1338                case PERIPH_TYPE_IOB:    // vci_io_bridge component
     1339                    if (IOMMU_ACTIVE) {
    13421340                        // TODO
    13431341                        // get the iommu page table physical address
     
    13491347                    }
    13501348#if BOOT_DEBUG_PERI
    1351 boot_puts("- IOB initialised\n");
    1352 #endif
    1353                 break;
    1354             } // end switch periph type
    1355         } // end for periphs
     1349                    boot_puts("- IOB initialised\n");
     1350#endif
     1351                    break;
     1352            }            // end switch periph type
     1353        }            // end for periphs
    13561354
    13571355#if BOOT_DEBUG_PERI
    1358 boot_puts("\n[BOOT DEBUG] ****** coprocessors initialisation in cluster ");
    1359 boot_putd( cluster_id );
    1360 boot_puts(" ******\n");
    1361 #endif
    1362 
    1363         for ( coproc_id = cluster[cluster_id].coproc_offset ;
    1364               coproc_id < cluster[cluster_id].coproc_offset + cluster[cluster_id].coprocs ;
    1365               coproc_id++ )
    1366         {
    1367             unsigned no_fifo_to  = 0;       //FIXME: should it be the map.xml who define the order?
     1356        boot_puts
     1357            ("\n[BOOT DEBUG] ****** coprocessors initialisation in cluster ");
     1358        boot_putd(cluster_id);
     1359        boot_puts(" ******\n");
     1360#endif
     1361
     1362        for (coproc_id = cluster[cluster_id].coproc_offset;
     1363                coproc_id < cluster[cluster_id].coproc_offset +
     1364                cluster[cluster_id].coprocs; coproc_id++) {
     1365            unsigned no_fifo_to = 0;    //FIXME: should it be the map.xml who define the order?
    13681366            unsigned no_fifo_from = 0;
    13691367            unsigned int cpseg = pseg[coproc[coproc_id].psegid].base;
    13701368
    13711369#if BOOT_DEBUG_PERI
    1372 boot_puts("- coprocessor name : ");
    1373 boot_puts( coproc[coproc_id].name );
    1374 boot_puts(" / nb ports = ");
    1375 boot_putd((unsigned int)coproc[coproc_id].ports);
    1376 boot_puts("\n");
    1377 #endif
    1378 
    1379             for ( cp_port_id = coproc[coproc_id].port_offset ;
    1380                   cp_port_id < coproc[coproc_id].port_offset + coproc[coproc_id].ports ;
    1381                   cp_port_id++ )
    1382             {
     1370            boot_puts("- coprocessor name : ");
     1371            boot_puts(coproc[coproc_id].name);
     1372            boot_puts(" / nb ports = ");
     1373            boot_putd((unsigned int) coproc[coproc_id].ports);
     1374            boot_puts("\n");
     1375#endif
     1376
     1377            for (cp_port_id = coproc[coproc_id].port_offset;
     1378                    cp_port_id < coproc[coproc_id].port_offset + coproc[coproc_id].ports;
     1379                    cp_port_id++) {
    13831380                //FIXME: the vspace_id should be the same for all ports: put it in the coproc?
    1384                 unsigned int vspace_id  = cp_port[cp_port_id].vspaceid;
    1385                 unsigned int vobj_id    = cp_port[cp_port_id].vobjlocid + vspace[vspace_id].vobj_offset;
    1386 
    1387                 mwmr_channel_t *pmwmr = (mwmr_channel_t*)(vobj[vobj_id].paddr);
    1388 
    1389                 if( cp_port[cp_port_id].direction == PORT_TO_COPROC)
    1390                 {
    1391 
     1381                unsigned int vspace_id = cp_port[cp_port_id].vspaceid;
     1382                unsigned int vobj_id = cp_port[cp_port_id].vobjlocid + vspace[vspace_id].vobj_offset;
     1383
     1384                mwmr_channel_t * pmwmr = (mwmr_channel_t *) (vobj[vobj_id].paddr);
     1385
     1386                if (cp_port[cp_port_id].direction == PORT_TO_COPROC) {
    13921387#if BOOT_DEBUG_PERI
    1393 boot_puts("     port direction: PORT_TO_COPROC");
    1394 #endif
    1395                     mwmr_hw_init((void*)cpseg, PORT_TO_COPROC, no_fifo_to, pmwmr );
     1388                    boot_puts("     port direction: PORT_TO_COPROC");
     1389#endif
     1390                    mwmr_hw_init((void *) cpseg, PORT_TO_COPROC, no_fifo_to, pmwmr);
    13961391                    no_fifo_to++;
    13971392                }
    1398                 else
    1399                 {
     1393                else {
    14001394#if BOOT_DEBUG_PERI
    1401 boot_puts("     port direction: PORT_FROM_COPROC");
    1402 #endif
    1403                     mwmr_hw_init((void*)cpseg, PORT_FROM_COPROC, no_fifo_from, pmwmr );
     1395                    boot_puts("     port direction: PORT_FROM_COPROC");
     1396#endif
     1397                    mwmr_hw_init((void *) cpseg, PORT_FROM_COPROC, no_fifo_from, pmwmr);
    14041398                    no_fifo_from++;
    14051399                }
    14061400#if BOOT_DEBUG_PERI
    1407 boot_puts(", with mwmr: ");
    1408 boot_puts(vobj[vobj_id].name);
    1409 boot_puts(" of vspace: ");
    1410 boot_puts(vspace[vspace_id].name);
     1401                boot_puts(", with mwmr: ");
     1402                boot_puts(vobj[vobj_id].name);
     1403                boot_puts(" of vspace: ");
     1404                boot_puts(vspace[vspace_id].name);
    14111405#endif
    14121406            }
    14131407        } // end for coprocs
    1414 
    14151408    } // end for clusters
    14161409} // end boot_peripherals_init()
     
    14261419// channel can be allocated if required.
    14271420///////////////////////////////////////////////////////////////////////////////
    1428 void boot_schedulers_init()
    1429 {
    1430     mapping_header_t*   header  = (mapping_header_t*)&seg_mapping_base; 
    1431     mapping_cluster_t*  cluster = boot_get_cluster_base( header );
    1432     mapping_pseg_t*     pseg    = boot_get_pseg_base( header );
    1433     mapping_vspace_t*   vspace  = boot_get_vspace_base( header );     
    1434     mapping_task_t*     task    = boot_get_task_base( header );
    1435     mapping_vobj_t*     vobj    = boot_get_vobj_base( header );
    1436     mapping_proc_t*     proc    = boot_get_proc_base( header );
    1437     mapping_irq_t*      irq     = boot_get_irq_base( header );
    1438 
    1439     unsigned int        alloc_tty_channel;                 // TTY channel allocator
    1440     unsigned int        alloc_nic_channel;                 // NIC channel allocator
    1441     unsigned int        alloc_dma_channel[NB_CLUSTERS];    // DMA channel allocators
    1442     unsigned int        alloc_timer_channel[NB_CLUSTERS];  // user TIMER allocators
    1443 
    1444     unsigned int        cluster_id;                        // cluster global index
    1445     unsigned int        proc_id;                           // processor global index
    1446     unsigned int        irq_id;                            // irq global index
    1447     unsigned int        pseg_id;                           // pseg global index
    1448     unsigned int        vspace_id;                         // vspace global index
    1449     unsigned int        task_id;                           // task global index;
     1421void boot_schedulers_init() {
     1422    mapping_header_t * header = (mapping_header_t *) & seg_mapping_base;
     1423    mapping_cluster_t * cluster = boot_get_cluster_base(header);
     1424    mapping_pseg_t * pseg = boot_get_pseg_base(header);
     1425    mapping_vspace_t * vspace = boot_get_vspace_base(header);
     1426    mapping_task_t * task = boot_get_task_base(header);
     1427    mapping_vobj_t * vobj = boot_get_vobj_base(header);
     1428    mapping_proc_t * proc = boot_get_proc_base(header);
     1429    mapping_irq_t * irq = boot_get_irq_base(header);
     1430
     1431    unsigned int alloc_tty_channel;    // TTY channel allocator
     1432    unsigned int alloc_nic_channel;    // NIC channel allocator
     1433    unsigned int alloc_dma_channel[NB_CLUSTERS];   // DMA channel allocators
     1434    unsigned int alloc_timer_channel[NB_CLUSTERS]; // user TIMER allocators
     1435
     1436    unsigned int cluster_id; // cluster global index
     1437    unsigned int proc_id;    // processor global index
     1438    unsigned int irq_id;     // irq global index
     1439    unsigned int pseg_id;    // pseg global index
     1440    unsigned int vspace_id;  // vspace global index
     1441    unsigned int task_id;    // task global index;
    14501442
    14511443    // Step 0 : TTY, NIC, TIMERS and DMA channels allocators initialisation
     
    14551447    //            are reserved for the kernel (context switch)
    14561448
    1457     alloc_tty_channel = 1; 
     1449    alloc_tty_channel = 1;
    14581450    alloc_nic_channel = 0;
    14591451
    1460     for ( cluster_id = 0 ; cluster_id < header->clusters ; cluster_id++ )
    1461     {
    1462         alloc_dma_channel[cluster_id]   = 0;
     1452    for (cluster_id = 0; cluster_id < header->clusters; cluster_id++) {
     1453        alloc_dma_channel[cluster_id] = 0;
    14631454        alloc_timer_channel[cluster_id] = 0;
    14641455    }
    1465                
     1456
    14661457    // Step 1 : loop on the clusters and on the processors
    14671458    //          - initialise the boot_schedulers_paddr[] pointers array
    14681459    //          - initialise the interrupt vectors for each processor.
    14691460
    1470     for ( cluster_id = 0 ; cluster_id < header->clusters ; cluster_id++ )
    1471     {
     1461    for (cluster_id = 0; cluster_id < header->clusters; cluster_id++) {
    14721462
    14731463#if BOOT_DEBUG_SCHED
    1474 boot_puts("\n[BOOT DEBUG] Initialise schedulers / IT vector in cluster ");
    1475 boot_putd( cluster_id );
    1476 boot_puts("\n");
     1464        boot_puts("\n[BOOT DEBUG] Initialise schedulers / IT vector in cluster ");
     1465        boot_putd(cluster_id);
     1466        boot_puts("\n");
    14771467#endif
    14781468        unsigned int found = 0;
    1479         unsigned int pseg_pbase;           // pseg base address
    1480         unsigned int lpid;                 // processor local index
     1469        unsigned int pseg_pbase;    // pseg base address
     1470        unsigned int lpid;    // processor local index
    14811471
    14821472        // get the physical base address of the first PSEG_TYPE_RAM pseg in cluster
    1483         for ( pseg_id = cluster[cluster_id].pseg_offset ;
    1484               pseg_id < cluster[cluster_id].pseg_offset + cluster[cluster_id].psegs ;
    1485               pseg_id++ )
    1486         {
    1487             if ( pseg[pseg_id].type == PSEG_TYPE_RAM )
    1488             {
     1473        for (pseg_id = cluster[cluster_id].pseg_offset;
     1474                pseg_id < cluster[cluster_id].pseg_offset + cluster[cluster_id].psegs;
     1475                pseg_id++) {
     1476            if (pseg[pseg_id].type == PSEG_TYPE_RAM) {
    14891477                pseg_pbase = pseg[pseg_id].base;
    14901478                found = 1;
     
    14931481        }
    14941482
    1495         if ( (cluster[cluster_id].procs > 0) && (found == 0) )
    1496         {
     1483        if ((cluster[cluster_id].procs > 0) && (found == 0)) {
    14971484            boot_puts("\n[BOOT ERROR] Missing RAM pseg in cluster ");
    1498             boot_putd( cluster_id );
     1485            boot_putd(cluster_id);
    14991486            boot_puts("\n");
    15001487            boot_exit();
    15011488        }
    1502 
    15031489        // 4 Kbytes per scheduler
    1504         for ( lpid = 0 ; lpid < cluster[cluster_id].procs ; lpid++ )
    1505         {
    1506             boot_schedulers_paddr[cluster_id*NB_PROCS_MAX + lpid] =
    1507                 (static_scheduler_t*)( pseg_pbase + (lpid<<12) );
    1508         }
    1509 
    1510         for ( proc_id = cluster[cluster_id].proc_offset ;
    1511               proc_id < cluster[cluster_id].proc_offset + cluster[cluster_id].procs ;
    1512               proc_id++ )
    1513         {
     1490        for (lpid = 0; lpid < cluster[cluster_id].procs; lpid++) {
     1491            boot_schedulers_paddr[cluster_id * NB_PROCS_MAX + lpid] = (static_scheduler_t *) (pseg_pbase + (lpid << 12));
     1492        }
     1493
     1494        for (proc_id = cluster[cluster_id].proc_offset;
     1495                proc_id < cluster[cluster_id].proc_offset + cluster[cluster_id].procs;
     1496                proc_id++) {
    15141497
    15151498#if BOOT_DEBUG_SCHED
    1516 boot_puts("\nProc ");
    1517 boot_putd( proc_id );
    1518 boot_puts(" : scheduler pbase = ");
    1519 boot_putx( pseg_pbase + (proc_id<<12) );
    1520 boot_puts("\n");
     1499            boot_puts("\nProc ");
     1500            boot_putd(proc_id);
     1501            boot_puts(" : scheduler pbase = ");
     1502            boot_putx(pseg_pbase + (proc_id << 12));
     1503            boot_puts("\n");
    15211504#endif
    15221505            // initialise the "tasks" variable in scheduler
    1523             boot_scheduler_set_tasks( proc_id , 0 );
    1524            
     1506            boot_scheduler_set_tasks(proc_id, 0);
     1507
    15251508            // initialise the interrupt_vector with ISR_DEFAULT
    15261509            unsigned int slot;
    1527             for ( slot = 0 ; slot < 32 ; slot++)
    1528             {
    1529                 boot_scheduler_set_itvector( proc_id, slot, 0);
     1510            for (slot = 0; slot < 32; slot++) {
     1511                boot_scheduler_set_itvector(proc_id, slot, 0);
    15301512            }
    15311513
    15321514            // scan the IRQs actually allocated to current processor
    1533             for ( irq_id = proc[proc_id].irq_offset ;
    1534                   irq_id < proc[proc_id].irq_offset + proc[proc_id].irqs ;
    1535                   irq_id++ )
    1536             {
    1537                 unsigned int type    = irq[irq_id].type;
    1538                 unsigned int icu_id  = irq[irq_id].icuid;
    1539                 unsigned int isr_id  = irq[irq_id].isr;
     1515            for (irq_id = proc[proc_id].irq_offset;
     1516                    irq_id < proc[proc_id].irq_offset + proc[proc_id].irqs;
     1517                    irq_id++) {
     1518                unsigned int type = irq[irq_id].type;
     1519                unsigned int icu_id = irq[irq_id].icuid;
     1520                unsigned int isr_id = irq[irq_id].isr;
    15401521                unsigned int channel = irq[irq_id].channel;
    1541                 unsigned int value   = isr_id | (type<<8) | (channel<<16);
    1542                 boot_scheduler_set_itvector( proc_id, icu_id, value );
     1522                unsigned int value = isr_id | (type << 8) | (channel << 16);
     1523                boot_scheduler_set_itvector(proc_id, icu_id, value);
    15431524
    15441525#if BOOT_DEBUG_SCHED
    1545 boot_puts("- IRQ : icu = ");
    1546 boot_putd( icu_id );
    1547 boot_puts(" / type = ");
    1548 boot_putd( type );
    1549 boot_puts(" / isr = ");
    1550 boot_putd( isr_id );
    1551 boot_puts(" / channel = ");
    1552 boot_putd( channel );
    1553 boot_puts("\n");
     1526                boot_puts("- IRQ : icu = ");
     1527                boot_putd(icu_id);
     1528                boot_puts(" / type = ");
     1529                boot_putd(type);
     1530                boot_puts(" / isr = ");
     1531                boot_putd(isr_id);
     1532                boot_puts(" / channel = ");
     1533                boot_putd(channel);
     1534                boot_puts("\n");
    15541535#endif
    15551536            }
     
    15601541    //          to initialise the schedulers and the task contexts.
    15611542
    1562     for ( vspace_id = 0 ; vspace_id < header->vspaces ; vspace_id++ )
    1563     {
     1543    for (vspace_id = 0; vspace_id < header->vspaces; vspace_id++) {
    15641544
    15651545#if BOOT_DEBUG_SCHED
    1566 boot_puts("\n[BOOT DEBUG] Initialise schedulers / task contexts for vspace ");
    1567 boot_puts(vspace[vspace_id].name);
    1568 boot_puts("\n");
     1546        boot_puts
     1547            ("\n[BOOT DEBUG] Initialise schedulers / task contexts for vspace ");
     1548        boot_puts(vspace[vspace_id].name);
     1549        boot_puts("\n");
    15691550#endif
    15701551        // We must set the PTPR depending on the vspace, because the start_vector
    15711552        // and the stack address are defined in virtual space.
    1572         boot_set_mmu_ptpr( (unsigned int)boot_ptabs_paddr[vspace_id] >> 13 );
     1553        boot_set_mmu_ptpr((unsigned int) boot_ptabs_paddr[vspace_id] >> 13);
    15731554
    15741555        // loop on the tasks in vspace (task_id is the global index)
    1575         for ( task_id = vspace[vspace_id].task_offset ;
    1576               task_id < (vspace[vspace_id].task_offset + vspace[vspace_id].tasks) ;
    1577               task_id++ )
    1578         {
     1556        for (task_id = vspace[vspace_id].task_offset;
     1557                task_id < (vspace[vspace_id].task_offset + vspace[vspace_id].tasks);
     1558                task_id++) {
    15791559            // ctx_ra :  the return address is &boot_eret()
    1580             unsigned int ctx_ra = (unsigned int)&boot_eret;
     1560            unsigned int ctx_ra = (unsigned int) &boot_eret;
    15811561
    15821562            // ctx_sr : value required before an eret instruction
    1583             unsigned int ctx_sr = 0x0000FF13; 
     1563            unsigned int ctx_sr = 0x0000FF13;
    15841564
    15851565            // ctx_ptpr : page table physical base address (shifted by 13 bit)
    1586             unsigned int ctx_ptpr = (unsigned int)boot_ptabs_paddr[vspace_id] >> 13;
     1566            unsigned int ctx_ptpr = (unsigned int) boot_ptabs_paddr[vspace_id] >> 13;
    15871567
    15881568            // compute gpid = global processor index
    1589             unsigned int gpid = task[task_id].clusterid*NB_PROCS_MAX +
    1590                                 task[task_id].proclocid;
     1569            unsigned int gpid = task[task_id].clusterid * NB_PROCS_MAX + task[task_id].proclocid;
    15911570
    15921571            // ctx_ptab : page_table virtual base address
    1593             unsigned int ctx_ptab = (unsigned int)boot_ptabs_vaddr[vspace_id];
     1572            unsigned int ctx_ptab = (unsigned int) boot_ptabs_vaddr[vspace_id];
    15941573
    15951574            // ctx_tty : terminal global index provided by a global allocator
    15961575            unsigned int ctx_tty = 0xFFFFFFFF;
    1597             if ( task[task_id].use_tty )
    1598             {
    1599                 if ( alloc_tty_channel >= NB_TTYS )
    1600                 {
     1576            if (task[task_id].use_tty) {
     1577                if (alloc_tty_channel >= NB_TTYS) {
    16011578                    boot_puts("\n[BOOT ERROR] TTY index too large for task ");
    1602                     boot_puts( task[task_id].name );
     1579                    boot_puts(task[task_id].name);
    16031580                    boot_puts(" in vspace ");
    1604                     boot_puts( vspace[vspace_id].name );
     1581                    boot_puts(vspace[vspace_id].name);
    16051582                    boot_puts("\n");
    16061583                    boot_exit();
     
    16091586                alloc_tty_channel++;
    16101587            }
    1611 
    16121588            // ctx_nic : NIC channel global index provided by a global allocator
    16131589            unsigned int ctx_nic = 0xFFFFFFFF;
    1614             if ( task[task_id].use_nic )
    1615             {
    1616                 if ( alloc_nic_channel >= NB_NICS )
    1617                 {
     1590            if (task[task_id].use_nic) {
     1591                if (alloc_nic_channel >= NB_NICS) {
    16181592                    boot_puts("\n[BOOT ERROR] NIC channel index too large for task ");
    1619                     boot_puts( task[task_id].name );
     1593                    boot_puts(task[task_id].name);
    16201594                    boot_puts(" in vspace ");
    1621                     boot_puts( vspace[vspace_id].name );
     1595                    boot_puts(vspace[vspace_id].name);
    16221596                    boot_puts("\n");
    16231597                    boot_exit();
     
    16261600                alloc_nic_channel++;
    16271601            }
    1628 
    16291602            // ctx_timer : user TIMER global index provided by a cluster allocator
    16301603            unsigned int ctx_timer = 0xFFFFFFFF;
    1631             if ( task[task_id].use_timer )
    1632             {
     1604            if (task[task_id].use_timer) {
    16331605                unsigned int cluster_id = task[task_id].clusterid;
    16341606                unsigned int allocated = alloc_timer_channel[cluster_id];
    16351607
    1636                 if ( allocated >= NB_TIMERS_MAX )
    1637                 {
     1608                if (allocated >= NB_TIMERS_MAX) {
    16381609                    boot_puts("\n[BOOT ERROR] local TIMER index too large for task ");
    1639                     boot_puts( task[task_id].name );
     1610                    boot_puts(task[task_id].name);
    16401611                    boot_puts(" in vspace ");
    1641                     boot_puts( vspace[vspace_id].name );
     1612                    boot_puts(vspace[vspace_id].name);
    16421613                    boot_puts("\n");
    16431614                    boot_exit();
    16441615                }
    1645                
    16461616                //assert(allocated >= 0);
    16471617                char found = 0;
    1648                 for( irq_id = 0; irq_id < 32; irq_id++)//look at the isr_timer isr channel
    1649                 {
    1650                     unsigned int isr = boot_scheduler_get_itvector(gpid, irq_id) && 0x000000FF;
    1651                     if(isr == ISR_TIMER)
    1652                     {
    1653                         if(allocated == 0)
    1654                         {
     1618                for (irq_id = 0; irq_id < 32; irq_id++) { //look at the isr_timer isr channel
     1619                    unsigned int isr = boot_scheduler_get_itvector(gpid, irq_id) & 0x000000FF;
     1620                    if (isr == ISR_TIMER) {
     1621                        if (allocated == 0) {
    16551622                            found = 1;
    16561623                            alloc_timer_channel[cluster_id]++;
    1657                             ctx_timer = cluster_id*NB_TIMERS_MAX + alloc_timer_channel[cluster_id];
     1624                            ctx_timer = cluster_id * NB_TIMERS_MAX + alloc_timer_channel[cluster_id];
    16581625                            break;
    1659                         }else
     1626                        }
     1627                        else {
    16601628                            allocated--;
     1629                        }
    16611630                    }
    16621631                }
    16631632
    1664                 if(!found)
    1665                 {
     1633                if (!found) {
    16661634                    boot_puts("\n[BOOT ERROR] No user timer available for task ");
    1667                     boot_puts( task[task_id].name );
     1635                    boot_puts(task[task_id].name);
    16681636                    boot_puts(" in vspace ");
    1669                     boot_puts( vspace[vspace_id].name );
     1637                    boot_puts(vspace[vspace_id].name);
    16701638                    boot_puts("\n");
    16711639                    boot_exit();
     
    16731641
    16741642            }
    1675 
    16761643            // ctx_dma : DMA global index provided by a cluster allocator 
    16771644            unsigned int ctx_dma = 0xFFFFFFFF;
    1678             if ( task[task_id].use_fbdma || task[task_id].use_nic )
    1679             {
     1645            if (task[task_id].use_fbdma || task[task_id].use_nic) {
    16801646                unsigned int cluster_id = task[task_id].clusterid;
    1681                 if ( alloc_dma_channel[cluster_id] >= NB_DMAS_MAX )
    1682                 {
     1647                if (alloc_dma_channel[cluster_id] >= NB_DMAS_MAX) {
    16831648                    boot_puts("\n[BOOT ERROR] local DMA index too large for task ");
    1684                     boot_puts( task[task_id].name );
     1649                    boot_puts(task[task_id].name);
    16851650                    boot_puts(" in vspace ");
    1686                     boot_puts( vspace[vspace_id].name );
     1651                    boot_puts(vspace[vspace_id].name);
    16871652                    boot_puts("\n");
    16881653                    boot_exit();
    16891654                }
    1690                 ctx_dma = cluster_id*NB_DMAS_MAX + alloc_dma_channel[cluster_id];
     1655                ctx_dma = cluster_id * NB_DMAS_MAX + alloc_dma_channel[cluster_id];
    16911656                alloc_dma_channel[cluster_id]++;
    16921657            }
    1693 
    16941658            // ctx_epc : Get the virtual address of the start function
    1695             mapping_vobj_t* pvobj = &vobj[vspace[vspace_id].vobj_offset +
    1696                                           vspace[vspace_id].start_offset];
    1697             unsigned int* start_vector_vbase = (unsigned int*)pvobj->vaddr;
     1659            mapping_vobj_t * pvobj = &vobj[vspace[vspace_id].vobj_offset + vspace[vspace_id].start_offset];
     1660            unsigned int * start_vector_vbase = (unsigned int *) pvobj->vaddr;
    16981661            unsigned int ctx_epc = start_vector_vbase[task[task_id].startid];
    16991662
     
    17071670
    17081671            // get local task index in scheduler[gpid]
    1709             unsigned int ltid = boot_scheduler_get_tasks( gpid );
    1710 
    1711             if ( ltid >= IDLE_TASK_INDEX )
    1712             {
     1672            unsigned int ltid = boot_scheduler_get_tasks(gpid);
     1673
     1674            if (ltid >= IDLE_TASK_INDEX) {
    17131675                boot_puts("\n[BOOT ERROR] : ");
    1714                 boot_putd( ltid );
     1676                boot_putd(ltid);
    17151677                boot_puts(" tasks allocated to processor ");
    1716                 boot_putd( gpid );
     1678                boot_putd(gpid);
    17171679                boot_puts(" / max is 15\n");
    17181680                boot_exit();
    17191681            }
    1720 
    17211682            // update the "tasks" field in scheduler[gpid]
    1722             boot_scheduler_set_tasks( gpid, ltid + 1);
     1683            boot_scheduler_set_tasks(gpid, ltid + 1);
    17231684
    17241685            // update the "current" field in scheduler[gpid]
    1725             boot_scheduler_set_current( gpid, 0 );
     1686            boot_scheduler_set_current(gpid, 0);
    17261687
    17271688            // initializes the task context in scheduler[gpid]
    1728             boot_scheduler_set_context( gpid, ltid, CTX_SR_ID    , ctx_sr    );
    1729             boot_scheduler_set_context( gpid, ltid, CTX_SP_ID    , ctx_sp    );
    1730             boot_scheduler_set_context( gpid, ltid, CTX_RA_ID    , ctx_ra    );
    1731             boot_scheduler_set_context( gpid, ltid, CTX_EPC_ID   , ctx_epc   );
    1732             boot_scheduler_set_context( gpid, ltid, CTX_PTPR_ID  , ctx_ptpr  );
    1733             boot_scheduler_set_context( gpid, ltid, CTX_TTY_ID   , ctx_tty   );
    1734             boot_scheduler_set_context( gpid, ltid, CTX_DMA_ID   , ctx_dma   );
    1735             boot_scheduler_set_context( gpid, ltid, CTX_NIC_ID   , ctx_nic   );
    1736             boot_scheduler_set_context( gpid, ltid, CTX_TIMER_ID , ctx_timer );
    1737             boot_scheduler_set_context( gpid, ltid, CTX_PTAB_ID  , ctx_ptab  );
    1738             boot_scheduler_set_context( gpid, ltid, CTX_LTID_ID  , ltid      );
    1739             boot_scheduler_set_context( gpid, ltid, CTX_VSID_ID  , vspace_id );
    1740             boot_scheduler_set_context( gpid, ltid, CTX_RUN_ID   , 1         );
    1741                                        
     1689            boot_scheduler_set_context(gpid, ltid, CTX_SR_ID, ctx_sr);
     1690            boot_scheduler_set_context(gpid, ltid, CTX_SP_ID, ctx_sp);
     1691            boot_scheduler_set_context(gpid, ltid, CTX_RA_ID, ctx_ra);
     1692            boot_scheduler_set_context(gpid, ltid, CTX_EPC_ID, ctx_epc);
     1693            boot_scheduler_set_context(gpid, ltid, CTX_PTPR_ID, ctx_ptpr);
     1694            boot_scheduler_set_context(gpid, ltid, CTX_TTY_ID, ctx_tty);
     1695            boot_scheduler_set_context(gpid, ltid, CTX_DMA_ID, ctx_dma);
     1696            boot_scheduler_set_context(gpid, ltid, CTX_NIC_ID, ctx_nic);
     1697            boot_scheduler_set_context(gpid, ltid, CTX_TIMER_ID, ctx_timer);
     1698            boot_scheduler_set_context(gpid, ltid, CTX_PTAB_ID, ctx_ptab);
     1699            boot_scheduler_set_context(gpid, ltid, CTX_LTID_ID, ltid);
     1700            boot_scheduler_set_context(gpid, ltid, CTX_VSID_ID, vspace_id);
     1701            boot_scheduler_set_context(gpid, ltid, CTX_RUN_ID, 1);
     1702
    17421703#if BOOT_DEBUG_SCHED
    1743 boot_puts("\nTask ");
    1744 boot_puts( task[task_id].name );
    1745 boot_puts(" allocated to processor ");
    1746 boot_putd( gpid );
    1747 boot_puts("  - ctx[LTID]   = ");
    1748 boot_putd( ltid );
    1749 boot_puts("\n");
    1750 
    1751 boot_puts("  - ctx[SR]     = ");
    1752 boot_putx( ctx_sr );
    1753 boot_puts("\n");
    1754 
    1755 boot_puts("  - ctx[SR]     = ");
    1756 boot_putx( ctx_sp );
    1757 boot_puts("\n");
    1758 
    1759 boot_puts("  - ctx[RA]     = ");
    1760 boot_putx( ctx_ra );
    1761 boot_puts("\n");
    1762 
    1763 boot_puts("  - ctx[EPC]    = ");
    1764 boot_putx( ctx_epc );
    1765 boot_puts("\n");
    1766 
    1767 boot_puts("  - ctx[PTPR]   = ");
    1768 boot_putx( ctx_ptpr );
    1769 boot_puts("\n");
    1770 
    1771 boot_puts("  - ctx[TTY]    = ");
    1772 boot_putd( ctx_tty );
    1773 boot_puts("\n");
    1774 
    1775 boot_puts("  - ctx[NIC]    = ");
    1776 boot_putd( ctx_nic );
    1777 boot_puts("\n");
    1778 
    1779 boot_puts("  - ctx[TIMER]  = ");
    1780 boot_putd( ctx_timer );
    1781 boot_puts("\n");
    1782 
    1783 boot_puts("  - ctx[DMA]    = ");
    1784 boot_putd( ctx_dma );
    1785 boot_puts("\n");
    1786 
    1787 boot_puts("  - ctx[PTAB]   = ");
    1788 boot_putx( ctx_ptab );
    1789 boot_puts("\n");
    1790 
    1791 boot_puts("  - ctx[VSID]   = ");
    1792 boot_putd( vspace_id );
    1793 boot_puts("\n");
     1704            boot_puts("\nTask ");
     1705            boot_puts(task[task_id].name);
     1706            boot_puts(" (");
     1707            boot_putd(task_id);
     1708            boot_puts(") allocated to processor ");
     1709            boot_putd(gpid);
     1710            boot_puts("  - ctx[LTID]   = ");
     1711            boot_putd(ltid);
     1712            boot_puts("\n");
     1713
     1714            boot_puts("  - ctx[SR]     = ");
     1715            boot_putx(ctx_sr);
     1716            boot_puts("\n");
     1717
     1718            boot_puts("  - ctx[SR]     = ");
     1719            boot_putx(ctx_sp);
     1720            boot_puts("\n");
     1721
     1722            boot_puts("  - ctx[RA]     = ");
     1723            boot_putx(ctx_ra);
     1724            boot_puts("\n");
     1725
     1726            boot_puts("  - ctx[EPC]    = ");
     1727            boot_putx(ctx_epc);
     1728            boot_puts("\n");
     1729
     1730            boot_puts("  - ctx[PTPR]   = ");
     1731            boot_putx(ctx_ptpr);
     1732            boot_puts("\n");
     1733
     1734            boot_puts("  - ctx[TTY]    = ");
     1735            boot_putd(ctx_tty);
     1736            boot_puts("\n");
     1737
     1738            boot_puts("  - ctx[NIC]    = ");
     1739            boot_putd(ctx_nic);
     1740            boot_puts("\n");
     1741
     1742            boot_puts("  - ctx[TIMER]  = ");
     1743            boot_putd(ctx_timer);
     1744            boot_puts("\n");
     1745
     1746            boot_puts("  - ctx[DMA]    = ");
     1747            boot_putd(ctx_dma);
     1748            boot_puts("\n");
     1749
     1750            boot_puts("  - ctx[PTAB]   = ");
     1751            boot_putx(ctx_ptab);
     1752            boot_puts("\n");
     1753
     1754            boot_puts("  - ctx[VSID]   = ");
     1755            boot_putd(vspace_id);
     1756            boot_puts("\n");
    17941757
    17951758#endif
     
    17991762} // end boot_schedulers_init()
    18001763
     1764
    18011765//////////////////////////////////////////////////////////////////////////////////
    18021766// This function is executed by P[0] to wakeup all processors.
    18031767//////////////////////////////////////////////////////////////////////////////////
    1804 void boot_start_all_procs()
    1805 {
    1806     mapping_header_t*   header = (mapping_header_t*)&seg_mapping_base; 
     1768void boot_start_all_procs() {
     1769    mapping_header_t * header = (mapping_header_t *) &seg_mapping_base;
    18071770    header->signature = OUT_MAPPING_SIGNATURE;
    18081771}
     1772
    18091773
    18101774/////////////////////////////////////////////////////////////////////
    18111775// This function is the entry point of the initialisation procedure
    18121776/////////////////////////////////////////////////////////////////////
    1813 void boot_init()
    1814 {
     1777void boot_init() {
    18151778    // mapping_info checking
    18161779    boot_check_mapping();
    18171780
    18181781    boot_puts("\n[BOOT] Mapping check completed at cycle ");
    1819     boot_putd( boot_proctime() );
     1782    boot_putd(boot_proctime());
    18201783    boot_puts("\n");
    18211784
     
    18231786    boot_psegs_init();
    18241787
    1825     boot_puts("\n[BOOT] Pseg allocators initialisation completed at cycle ");
    1826     boot_putd( boot_proctime() );
     1788    boot_puts
     1789        ("\n[BOOT] Pseg allocators initialisation completed at cycle ");
     1790    boot_putd(boot_proctime());
    18271791    boot_puts("\n");
    18281792
     
    18311795
    18321796    boot_puts("\n[BOOT] Page Tables initialisation completed at cycle ");
    1833     boot_putd( boot_proctime() );
     1797    boot_putd(boot_proctime());
    18341798    boot_puts("\n");
    18351799
     
    18381802
    18391803    boot_puts("\n[BOOT] Vobjs initialisation completed at cycle : ");
    1840     boot_putd( boot_proctime() );
     1804    boot_putd(boot_proctime());
    18411805    boot_puts("\n");
    18421806
     
    18451809
    18461810    boot_puts("\n[BOOT] Peripherals initialisation completed at cycle ");
    1847     boot_putd( boot_proctime() );
     1811    boot_putd(boot_proctime());
    18481812    boot_puts("\n");
    18491813
    18501814    // mmu activation
    1851     boot_set_mmu_ptpr( (unsigned int)boot_ptabs_paddr[0] >> 13 );
    1852     boot_set_mmu_mode( 0xF );
     1815    boot_set_mmu_ptpr((unsigned int) boot_ptabs_paddr[0] >> 13);
     1816    boot_set_mmu_mode(0xF);
    18531817
    18541818    boot_puts("\n[BOOT] MMU activation completed at cycle ");
    1855     boot_putd( boot_proctime() );
     1819    boot_putd(boot_proctime());
    18561820    boot_puts("\n");
    18571821
     
    18601824
    18611825    boot_puts("\n[BOOT] Schedulers initialisation completed at cycle ");
    1862     boot_putd( boot_proctime() );
     1826    boot_putd(boot_proctime());
    18631827    boot_puts("\n");
    18641828
     
    18671831
    18681832} // end boot_init()
     1833
    18691834
    18701835// Local Variables:
     
    18741839// indent-tabs-mode: nil
    18751840// End:
    1876 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
    1877 
     1841// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     1842
Note: See TracChangeset for help on using the changeset viewer.