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/xml/xml_driver.c

    r215 r228  
    1818
    1919//////////////////////////////////////////////////////
    20 void buildXml( mapping_header_t* header, FILE* fpout )
    21 {
    22     const char* vobj_type[] =
     20void buildXml(mapping_header_t * header, FILE * fpout) {
     21    const char * vobj_type[] =
    2322    {
    24         "ELF",          // binary code generated by GCC
    25         "BLOB",         // binary code generated by GCC
    26         "PTAB",         // page table
    27         "PERI",         // hardware component
    28         "MWMR",         // MWMR channel
    29         "LOCK",         // Spin-Lock
    30         "BUFFER",       // Any "no intialiasation needed" objects (stacks...)
    31         "BARRIER",      // Barrier
    32     };
    33 
    34     const char* pseg_type[] =
     23        "ELF",        // binary code generated by GCC
     24        "BLOB",       // binary code generated by GCC
     25        "PTAB",       // page table
     26        "PERI",       // hardware component
     27        "MWMR",       // MWMR channel
     28        "LOCK",       // Spin-Lock
     29        "BUFFER",     // Any "no intialiasation needed" objects (stacks...)
     30        "BARRIER",    // Barrier
     31        "CONST",      // Constant
     32        "MEMSPACE",   // Memspace
     33    };
     34
     35    const char * pseg_type[] =
    3536    {
    3637        "RAM",
     
    3940    };
    4041
    41     const char* irq_type[] =
     42    const char * irq_type[] =
    4243    {
    4344        "HARD",
     
    4546    };
    4647
    47     const char* isr_type[] =
     48    const char * isr_type[] =
    4849    {
    4950        "ISR_DEFAULT",
     
    5556    };
    5657
    57     const char* periph_type[] =
     58    const char * periph_type[] =
    5859    {
    5960        "ICU",
     
    6869    };
    6970
    70     const char* port_direction[] =
     71    const char * port_direction[] =
    7172    {
    7273        "TO_COPROC",
     
    7475    };
    7576
    76     const char* mode_str[] =
    77     { "____",
    78       "___U",
    79       "__W_",
    80       "__WU",
    81       "_X__",
    82       "_X_U",
    83       "_XW_",
    84       "_XWU",
    85       "C___",
    86       "C__U",
    87       "C_W_",
    88       "C_WU",
    89       "CX__",
    90       "CX_U",
    91       "CXW_",
    92       "CXWU",
    93     };
    94 
    95     unsigned int                vspace_id;
    96     unsigned int                cluster_id;
    97     unsigned int                pseg_id;
    98     unsigned int                vseg_id;
    99     unsigned int                vobj_id;
    100     unsigned int                task_id;
    101     unsigned int                proc_id;
    102     unsigned int                irq_id;
    103     unsigned int                coproc_id;
    104     unsigned int                port_id;
    105     unsigned int                periph_id;
    106 
    107     mapping_cluster_t*  cluster;
    108     mapping_pseg_t*         pseg;
    109     mapping_vspace_t*   vspace;
    110     mapping_vseg_t*         vseg;
    111     mapping_vobj_t*         vobj;
    112     mapping_task_t*         task;
    113     mapping_proc_t*         proc;
    114     mapping_irq_t*          irq;       
    115     mapping_coproc_t*   coproc;
    116     mapping_cp_port_t*  cp_port;
    117     mapping_periph_t*   periph;
     77    const char * mode_str[] =
     78    {
     79        "____",
     80        "___U",
     81        "__W_",
     82        "__WU",
     83        "_X__",
     84        "_X_U",
     85        "_XW_",
     86        "_XWU",
     87        "C___",
     88        "C__U",
     89        "C_W_",
     90        "C_WU",
     91        "CX__",
     92        "CX_U",
     93        "CXW_",
     94        "CXWU",
     95    };
     96
     97    unsigned int vspace_id;
     98    unsigned int cluster_id;
     99    unsigned int pseg_id;
     100    unsigned int vseg_id;
     101    unsigned int vobj_id;
     102    unsigned int task_id;
     103    unsigned int proc_id;
     104    unsigned int irq_id;
     105    unsigned int coproc_id;
     106    unsigned int port_id;
     107    unsigned int periph_id;
     108
     109    mapping_cluster_t * cluster;
     110    mapping_pseg_t * pseg;
     111    mapping_vspace_t * vspace;
     112    mapping_vseg_t * vseg;
     113    mapping_vobj_t * vobj;
     114    mapping_task_t * task;
     115    mapping_proc_t * proc;
     116    mapping_irq_t * irq;   
     117    mapping_coproc_t * coproc;
     118    mapping_cp_port_t * cp_port;
     119    mapping_periph_t * periph;
    118120
    119121    // computes the base adresss for clusters array,
    120     cluster = (mapping_cluster_t*)((char*)header +
    121                                   MAPPING_HEADER_SIZE );
     122    cluster = (mapping_cluster_t *)((char *) header +
     123            MAPPING_HEADER_SIZE);
    122124
    123125    // computes the base adresss for psegs array,
    124     pseg    = (mapping_pseg_t*)   ((char*)header +
    125                                   MAPPING_HEADER_SIZE +
    126                                   MAPPING_CLUSTER_SIZE*header->clusters );
     126    pseg = (mapping_pseg_t *) ((char *) header +
     127            MAPPING_HEADER_SIZE +
     128            MAPPING_CLUSTER_SIZE * header->clusters);
    127129
    128130    // computes the base adresss for vspaces array,
    129     vspace  = (mapping_vspace_t*) ((char*)header +
    130                                   MAPPING_HEADER_SIZE +
    131                                   MAPPING_CLUSTER_SIZE*header->clusters +
    132                                   MAPPING_PSEG_SIZE*header->psegs );
     131    vspace = (mapping_vspace_t *) ((char *) header +
     132            MAPPING_HEADER_SIZE +
     133            MAPPING_CLUSTER_SIZE * header->clusters +
     134            MAPPING_PSEG_SIZE * header->psegs);
    133135
    134136    // computes the base adresss for vsegs array,
    135     vseg    = (mapping_vseg_t*)   ((char*)header +
    136                                   MAPPING_HEADER_SIZE +
    137                                   MAPPING_CLUSTER_SIZE*header->clusters +
    138                                   MAPPING_PSEG_SIZE*header->psegs +
    139                                   MAPPING_VSPACE_SIZE*header->vspaces );
     137    vseg = (mapping_vseg_t *) ((char *) header +
     138            MAPPING_HEADER_SIZE +
     139            MAPPING_CLUSTER_SIZE * header->clusters +
     140            MAPPING_PSEG_SIZE * header->psegs +
     141            MAPPING_VSPACE_SIZE * header->vspaces);
    140142
    141143    // computes the base adresss for vobjs array,
    142     vobj    = (mapping_vobj_t*)   ((char*)header +
    143                                   MAPPING_HEADER_SIZE +
    144                                   MAPPING_CLUSTER_SIZE*header->clusters +
    145                                   MAPPING_PSEG_SIZE*header->psegs +
    146                                   MAPPING_VSPACE_SIZE*header->vspaces +
    147                                   MAPPING_VSEG_SIZE*header->vsegs );
     144    vobj = (mapping_vobj_t *) ((char *) header +
     145            MAPPING_HEADER_SIZE +
     146            MAPPING_CLUSTER_SIZE * header->clusters +
     147            MAPPING_PSEG_SIZE * header->psegs +
     148            MAPPING_VSPACE_SIZE * header->vspaces +
     149            MAPPING_VSEG_SIZE * header->vsegs);
    148150
    149151    // computes the base address for tasks array
    150     task    = (mapping_task_t*)   ((char*)header +
    151                                   MAPPING_HEADER_SIZE +
    152                                   MAPPING_CLUSTER_SIZE*header->clusters +
    153                                   MAPPING_PSEG_SIZE*header->psegs +
    154                                   MAPPING_VSPACE_SIZE*header->vspaces +
    155                                   MAPPING_VOBJ_SIZE*header->vobjs +
    156                                   MAPPING_VSEG_SIZE*header->vsegs );
     152    task = (mapping_task_t *) ((char *) header +
     153            MAPPING_HEADER_SIZE +
     154            MAPPING_CLUSTER_SIZE * header->clusters +
     155            MAPPING_PSEG_SIZE * header->psegs +
     156            MAPPING_VSPACE_SIZE * header->vspaces +
     157            MAPPING_VOBJ_SIZE * header->vobjs +
     158            MAPPING_VSEG_SIZE * header->vsegs);
    157159
    158160    // computes the base address for procs array
    159     proc    = (mapping_proc_t*)   ((char*)header +
    160                                   MAPPING_HEADER_SIZE +
    161                                   MAPPING_CLUSTER_SIZE*header->clusters +
    162                                   MAPPING_PSEG_SIZE*header->psegs +
    163                                   MAPPING_VSPACE_SIZE*header->vspaces +
    164                                   MAPPING_VOBJ_SIZE*header->vobjs +
    165                                   MAPPING_VSEG_SIZE*header->vsegs +
    166                                   MAPPING_TASK_SIZE*header->tasks);
     161    proc = (mapping_proc_t *) ((char *) header +
     162            MAPPING_HEADER_SIZE +
     163            MAPPING_CLUSTER_SIZE * header->clusters +
     164            MAPPING_PSEG_SIZE * header->psegs +
     165            MAPPING_VSPACE_SIZE * header->vspaces +
     166            MAPPING_VOBJ_SIZE * header->vobjs +
     167            MAPPING_VSEG_SIZE * header->vsegs +
     168            MAPPING_TASK_SIZE * header->tasks);
    167169
    168170    // computes the base address for irqs array
    169     irq    = (mapping_irq_t*)    ((char*)header +
    170                                   MAPPING_HEADER_SIZE +
    171                                   MAPPING_CLUSTER_SIZE*header->clusters +
    172                                   MAPPING_PSEG_SIZE*header->psegs +
    173                                   MAPPING_VSPACE_SIZE*header->vspaces +
    174                                   MAPPING_VOBJ_SIZE*header->vobjs +
    175                                   MAPPING_VSEG_SIZE*header->vsegs +
    176                                   MAPPING_TASK_SIZE*header->tasks +
    177                                   MAPPING_PROC_SIZE*header->procs);
     171    irq = (mapping_irq_t *) ((char *) header +
     172            MAPPING_HEADER_SIZE +
     173            MAPPING_CLUSTER_SIZE * header->clusters +
     174            MAPPING_PSEG_SIZE * header->psegs +
     175            MAPPING_VSPACE_SIZE * header->vspaces +
     176            MAPPING_VOBJ_SIZE * header->vobjs +
     177            MAPPING_VSEG_SIZE * header->vsegs +
     178            MAPPING_TASK_SIZE * header->tasks +
     179            MAPPING_PROC_SIZE * header->procs);
    178180
    179181    // computes the base address for coprocs array
    180     coproc = (mapping_coproc_t*)  ((char*)header +
    181                                   MAPPING_HEADER_SIZE +
    182                                   MAPPING_CLUSTER_SIZE*header->clusters +
    183                                   MAPPING_PSEG_SIZE*header->psegs +
    184                                   MAPPING_VSPACE_SIZE*header->vspaces +
    185                                   MAPPING_VOBJ_SIZE*header->vobjs +
    186                                   MAPPING_VSEG_SIZE*header->vsegs +
    187                                   MAPPING_TASK_SIZE*header->tasks +
    188                                   MAPPING_PROC_SIZE*header->procs +
    189                                   MAPPING_IRQ_SIZE*header->irqs);
     182    coproc = (mapping_coproc_t *) ((char *) header +
     183            MAPPING_HEADER_SIZE +
     184            MAPPING_CLUSTER_SIZE * header->clusters +
     185            MAPPING_PSEG_SIZE * header->psegs +
     186            MAPPING_VSPACE_SIZE * header->vspaces +
     187            MAPPING_VOBJ_SIZE * header->vobjs +
     188            MAPPING_VSEG_SIZE * header->vsegs +
     189            MAPPING_TASK_SIZE * header->tasks +
     190            MAPPING_PROC_SIZE * header->procs +
     191            MAPPING_IRQ_SIZE * header->irqs);
    190192
    191193    // computes the base address for cp_ports array
    192     cp_port = (mapping_cp_port_t*)((char*)header +
    193                                   MAPPING_HEADER_SIZE +
    194                                   MAPPING_CLUSTER_SIZE*header->clusters +
    195                                   MAPPING_PSEG_SIZE*header->psegs +
    196                                   MAPPING_VSPACE_SIZE*header->vspaces +
    197                                   MAPPING_VOBJ_SIZE*header->vobjs +
    198                                   MAPPING_VSEG_SIZE*header->vsegs +
    199                                   MAPPING_TASK_SIZE*header->tasks +
    200                                   MAPPING_PROC_SIZE*header->procs +
    201                                   MAPPING_IRQ_SIZE*header->irqs +
    202                                   MAPPING_COPROC_SIZE*header->coprocs);
     194    cp_port = (mapping_cp_port_t *) ((char *) header +
     195            MAPPING_HEADER_SIZE +
     196            MAPPING_CLUSTER_SIZE * header->clusters +
     197            MAPPING_PSEG_SIZE * header->psegs +
     198            MAPPING_VSPACE_SIZE * header->vspaces +
     199            MAPPING_VOBJ_SIZE * header->vobjs +
     200            MAPPING_VSEG_SIZE * header->vsegs +
     201            MAPPING_TASK_SIZE * header->tasks +
     202            MAPPING_PROC_SIZE * header->procs +
     203            MAPPING_IRQ_SIZE * header->irqs +
     204            MAPPING_COPROC_SIZE * header->coprocs);
    203205
    204206    // computes the base address for periphs array
    205     periph = (mapping_periph_t*)  ((char*)header +
    206                                   MAPPING_HEADER_SIZE +
    207                                   MAPPING_CLUSTER_SIZE*header->clusters +
    208                                   MAPPING_PSEG_SIZE*header->psegs +
    209                                   MAPPING_VSPACE_SIZE*header->vspaces +
    210                                   MAPPING_VOBJ_SIZE*header->vobjs +
    211                                   MAPPING_VSEG_SIZE*header->vsegs +
    212                                   MAPPING_TASK_SIZE*header->tasks +
    213                                   MAPPING_PROC_SIZE*header->procs +
    214                                   MAPPING_IRQ_SIZE*header->irqs +
    215                                   MAPPING_COPROC_SIZE*header->coprocs +
    216                                   MAPPING_CP_PORT_SIZE*header->cp_ports);
     207    periph = (mapping_periph_t *) ((char *) header +
     208            MAPPING_HEADER_SIZE +
     209            MAPPING_CLUSTER_SIZE * header->clusters +
     210            MAPPING_PSEG_SIZE * header->psegs +
     211            MAPPING_VSPACE_SIZE * header->vspaces +
     212            MAPPING_VOBJ_SIZE * header->vobjs +
     213            MAPPING_VSEG_SIZE * header->vsegs +
     214            MAPPING_TASK_SIZE * header->tasks +
     215            MAPPING_PROC_SIZE * header->procs +
     216            MAPPING_IRQ_SIZE * header->irqs +
     217            MAPPING_COPROC_SIZE * header->coprocs +
     218            MAPPING_CP_PORT_SIZE * header->cp_ports);
    217219
    218220    ///////////////////////// header /////////////////////////////////////////////
    219221
    220     fprintf( fpout, "<?xml version = \"1.0\"?>\n\n");
    221 
    222     fprintf( fpout, "<mapping_info signature = \"0x%x\" ", header->signature);
    223     fprintf( fpout, " name = \"%s\" ", header->name);
    224     fprintf( fpout, " cluster_x = \"%d\" ", header->cluster_x);
    225     fprintf( fpout, " cluster_y = \"%d\" ", header->cluster_y);
    226     fprintf( fpout, " vspaces = \"%d\" >\n\n", header->vspaces);
     222    fprintf(fpout, "<?xml version = \"1.0\"?>\n\n");
     223
     224    fprintf(fpout, "<mapping_info signature = \"0x%x\" ", header->signature);
     225    fprintf(fpout, " name = \"%s\" ", header->name);
     226    fprintf(fpout, " cluster_x = \"%d\" ", header->cluster_x);
     227    fprintf(fpout, " cluster_y = \"%d\" ", header->cluster_y);
     228    fprintf(fpout, " vspaces = \"%d\" >\n\n", header->vspaces);
    227229
    228230    ///////////////////// clusters ///////////////////////////////////////////////
    229231
    230     fprintf( fpout, "    <clusterset>\n" );
    231     for ( cluster_id = 0 ; cluster_id < header->clusters ; cluster_id++ )
    232     {
    233         fprintf( fpout, "        <cluster index  = \"%d\" >\n",   cluster_id);
    234         for ( pseg_id = cluster[cluster_id].pseg_offset ;
    235               pseg_id < cluster[cluster_id].pseg_offset + cluster[cluster_id].psegs ;
    236               pseg_id++ )
    237         {
    238             fprintf( fpout, "            <pseg name = \"%s\" ", pseg[pseg_id].name);
    239             fprintf( fpout, " type = \"%s\" ", pseg_type[pseg[pseg_id].type]);
    240             fprintf( fpout, " base = \"0x%x\" ", pseg[pseg_id].base);
    241             fprintf( fpout, " length = \"0x%x\" />\n",   pseg[pseg_id].length);
    242         }
    243 
    244     ///////////////////// processors /////////////////////////////////////////////
     232    fprintf( fpout, "    <clusterset>\n");
     233    for (cluster_id = 0; cluster_id < header->clusters; cluster_id++) {
     234        fprintf(fpout, "        <cluster index  = \"%d\" >\n", cluster_id);
     235        for (pseg_id = cluster[cluster_id].pseg_offset;
     236                pseg_id < cluster[cluster_id].pseg_offset + cluster[cluster_id].psegs;
     237                pseg_id++) {
     238            fprintf(fpout, "            <pseg name = \"%s\" ", pseg[pseg_id].name);
     239            fprintf(fpout, " type = \"%s\" ", pseg_type[pseg[pseg_id].type]);
     240            fprintf(fpout, " base = \"0x%x\" ", pseg[pseg_id].base);
     241            fprintf(fpout, " length = \"0x%x\" />\n",   pseg[pseg_id].length);
     242        }
     243
     244        ///////////////////// processors /////////////////////////////////////////////
    245245
    246246        unsigned int proc_index = 0;
    247         for ( proc_id = cluster[cluster_id].proc_offset ;
    248               proc_id < cluster[cluster_id].proc_offset + cluster[cluster_id].procs ;
    249               proc_id++ )
    250         {
    251             fprintf( fpout, "            <proc index = \"%d\" >\n", proc_index);
    252             for ( irq_id = proc[proc_id].irq_offset ;
    253                   irq_id < proc[proc_id].irq_offset + proc[proc_id].irqs ;
    254                   irq_id++ )
    255             {
    256                 fprintf( fpout, "                <irq type = \"%s\" ", irq_type[irq[irq_id].type]);
    257                 fprintf( fpout, " icuid = \"0x%x\" ", irq[irq_id].icuid);
    258                 fprintf( fpout, " isr = \"%s\" ", isr_type[irq[irq_id].isr]);
    259                 fprintf( fpout, " channel = \"0x%x\" />\n", irq[irq_id].channel);
     247        for (proc_id = cluster[cluster_id].proc_offset;
     248                proc_id < cluster[cluster_id].proc_offset + cluster[cluster_id].procs;
     249                proc_id++) {
     250            fprintf(fpout, "            <proc index = \"%d\" >\n", proc_index);
     251            for (irq_id = proc[proc_id].irq_offset;
     252                    irq_id < proc[proc_id].irq_offset + proc[proc_id].irqs;
     253                    irq_id++) {
     254                fprintf(fpout, "                <irq type = \"%s\" ", irq_type[irq[irq_id].type]);
     255                fprintf(fpout, " icuid = \"0x%x\" ", irq[irq_id].icuid);
     256                fprintf(fpout, " isr = \"%s\" ", isr_type[irq[irq_id].isr]);
     257                fprintf(fpout, " channel = \"0x%x\" />\n", irq[irq_id].channel);
    260258            }
    261             fprintf( fpout, "            </proc>\n" );
    262         }
    263 
    264 
    265     ///////////////////// coprocessors ///////////////////////////////////////////
    266 
    267         for ( coproc_id = cluster[cluster_id].coproc_offset ;
    268               coproc_id < cluster[cluster_id].coproc_offset + cluster[cluster_id].coprocs ;
    269               coproc_id++ )
    270         {
    271             fprintf( fpout, "            <coproc name = \"%s\" ", coproc[coproc_id].name);
    272             fprintf( fpout, " psegname = \"%s\" >\n", pseg[coproc[coproc_id].psegid].name);
    273             for ( port_id = coproc[coproc_id].port_offset ;
    274                   port_id < coproc[coproc_id].port_offset + coproc[coproc_id].ports ;
    275                   port_id++ )
    276             {
     259            fprintf(fpout, "            </proc>\n" );
     260        }
     261
     262
     263        ///////////////////// coprocessors ///////////////////////////////////////////
     264
     265        for (coproc_id = cluster[cluster_id].coproc_offset;
     266                coproc_id < cluster[cluster_id].coproc_offset + cluster[cluster_id].coprocs;
     267                coproc_id++) {
     268            fprintf(fpout, "            <coproc name = \"%s\" ", coproc[coproc_id].name);
     269            fprintf(fpout, " psegname = \"%s\" >\n", pseg[coproc[coproc_id].psegid].name);
     270            for (port_id = coproc[coproc_id].port_offset;
     271                    port_id < coproc[coproc_id].port_offset + coproc[coproc_id].ports;
     272                    port_id++) {
    277273                unsigned int vobj_id = cp_port[port_id].vobjlocid + vspace[cp_port[port_id].vspaceid].vobj_offset;
    278                 fprintf( fpout, "             <port direction = \"%s\" ",  port_direction[ cp_port[port_id].direction]);
    279                 fprintf( fpout, " vspacename = \"%s\" ", vspace[cp_port[port_id].vspaceid].name);
    280                 fprintf( fpout, " vobjname = \"%s\" />\n",  vobj[vobj_id].name);
     274                fprintf(fpout, "             <port direction = \"%s\" ",  port_direction[cp_port[port_id].direction]);
     275                fprintf(fpout, " vspacename = \"%s\" ", vspace[cp_port[port_id].vspaceid].name);
     276                fprintf(fpout, " vobjname = \"%s\" />\n",  vobj[vobj_id].name);
    281277            }
    282             fprintf( fpout, "            </coproc>\n" );
    283         }
    284 
    285     ///////////////////// periphs  ///////////////////////////////////////////////
    286 
    287         for ( periph_id = cluster[cluster_id].periph_offset ;
    288               periph_id < cluster[cluster_id].periph_offset + cluster[cluster_id].periphs ;
    289               periph_id++ )
    290         {
    291             fprintf( fpout, "            <periph type = \"%s\" ", periph_type[periph[periph_id].type]);
    292             fprintf( fpout, " psegname = \"%s\" ", pseg[periph[periph_id].psegid].name);
    293             fprintf( fpout, " channels = \"%d\" />\n",  periph[periph_id].channels);
    294         }
    295         fprintf( fpout, "        </cluster>\n" );
    296     }
    297     fprintf( fpout, "    </clusterset>\n\n" );
     278            fprintf(fpout, "            </coproc>\n" );
     279        }
     280
     281        ///////////////////// periphs  ///////////////////////////////////////////////
     282
     283        for (periph_id = cluster[cluster_id].periph_offset;
     284                periph_id < cluster[cluster_id].periph_offset + cluster[cluster_id].periphs;
     285                periph_id++) {
     286            fprintf(fpout, "            <periph type = \"%s\" ", periph_type[periph[periph_id].type]);
     287            fprintf(fpout, " psegname = \"%s\" ", pseg[periph[periph_id].psegid].name);
     288            fprintf(fpout, " channels = \"%d\" />\n",  periph[periph_id].channels);
     289        }
     290        fprintf(fpout, "        </cluster>\n" );
     291    }
     292    fprintf(fpout, "    </clusterset>\n\n" );
    298293
    299294    /////////////////// globals /////////////////////////////////////////////////
    300295
    301     fprintf( fpout, "    <globalset>\n" );
    302     for ( vseg_id = 0 ; vseg_id < header->globals ; vseg_id++ )
    303     {
     296    fprintf(fpout, "    <globalset>\n" );
     297    for (vseg_id = 0; vseg_id < header->globals; vseg_id++) {
    304298        unsigned int pseg_id = vseg[vseg_id].psegid;
    305299
    306         fprintf( fpout, "        <vseg name = \"%s\" ", vseg[vseg_id].name);
    307         fprintf( fpout, "vbase = \"0x%x\" ", vseg[vseg_id].vbase);
    308         fprintf( fpout, "mode  = \"%s\" ", mode_str[vseg[vseg_id].mode]);
    309         fprintf( fpout, "clusterid = \"%d\" ", pseg[pseg_id].cluster);
    310         fprintf( fpout, "psegname = \"%s\" ", pseg[pseg_id].name);
    311         fprintf( fpout, "ident = \"%d\" >\n", vseg[vseg_id].ident);
    312         for ( vobj_id = vseg[vseg_id].vobj_offset;
    313               vobj_id < (vseg[vseg_id].vobj_offset + vseg[vseg_id].vobjs);
    314               vobj_id++ )
    315         {
    316             fprintf( fpout, "            <vobj name = \"%s\" ", vobj[vobj_id].name);
    317             fprintf( fpout, "type = \"%s\" ", vobj_type[vobj[vobj_id].type]);
    318             fprintf( fpout, "length = \"0x%x\" ", vobj[vobj_id].length);
    319             fprintf( fpout, "align = \"%d\" ", vobj[vobj_id].align);
    320             fprintf( fpout, "init = \"%d\" ", vobj[vobj_id].init);
    321             fprintf( fpout, "binpath = \"%s\" />\n", vobj[vobj_id].binpath);
    322         }
    323         fprintf( fpout, "        </vseg>\n");
    324     }
    325     fprintf( fpout, "    </globalset>\n" );
     300        fprintf(fpout, "        <vseg name = \"%s\" ", vseg[vseg_id].name);
     301        fprintf(fpout, "vbase = \"0x%x\" ", vseg[vseg_id].vbase);
     302        fprintf(fpout, "mode  = \"%s\" ", mode_str[vseg[vseg_id].mode]);
     303        fprintf(fpout, "clusterid = \"%d\" ", pseg[pseg_id].cluster);
     304        fprintf(fpout, "psegname = \"%s\" ", pseg[pseg_id].name);
     305        fprintf(fpout, "ident = \"%d\" >\n", vseg[vseg_id].ident);
     306        for (vobj_id = vseg[vseg_id].vobj_offset;
     307                vobj_id < (vseg[vseg_id].vobj_offset + vseg[vseg_id].vobjs);
     308                vobj_id++) {
     309            fprintf(fpout, "            <vobj name = \"%s\" ", vobj[vobj_id].name);
     310            fprintf(fpout, "type = \"%s\" ", vobj_type[vobj[vobj_id].type]);
     311            fprintf(fpout, "length = \"0x%x\" ", vobj[vobj_id].length);
     312            fprintf(fpout, "align = \"%d\" ", vobj[vobj_id].align);
     313            fprintf(fpout, "init = \"%d\" ", vobj[vobj_id].init);
     314            fprintf(fpout, "binpath = \"%s\" />\n", vobj[vobj_id].binpath);
     315        }
     316        fprintf(fpout, "        </vseg>\n");
     317    }
     318    fprintf(fpout, "    </globalset>\n" );
    326319
    327320    //////////////////// vspaces ////////////////////////////////////////////////
    328321
    329322    fprintf( fpout, "\n    <vspaceset>\n\n" );
    330     for ( vspace_id = 0 ; vspace_id < header->vspaces ; vspace_id++ )
    331     {
     323    for (vspace_id = 0; vspace_id < header->vspaces; vspace_id++) {
    332324        unsigned int func_id = vspace[vspace_id].vobj_offset + vspace[vspace_id].start_offset;
    333         fprintf( fpout, "        <vspace name = \"%s\" ", vspace[vspace_id].name);
    334         fprintf( fpout, " startname = \"%s\" >\n", vobj[func_id].name);
    335 
    336         for ( vseg_id = vspace[vspace_id].vseg_offset ;
    337               vseg_id < (vspace[vspace_id].vseg_offset + vspace[vspace_id].vsegs) ;
    338               vseg_id++ )
    339         {
     325        fprintf(fpout, "        <vspace name = \"%s\" ", vspace[vspace_id].name);
     326        fprintf(fpout, " startname = \"%s\" >\n", vobj[func_id].name);
     327
     328        for (vseg_id = vspace[vspace_id].vseg_offset;
     329                vseg_id < (vspace[vspace_id].vseg_offset + vspace[vspace_id].vsegs);
     330                vseg_id++) {
    340331            unsigned int pseg_id = vseg[vseg_id].psegid;
    341332
    342             fprintf( fpout, "            <vseg name = \"%s\" ", vseg[vseg_id].name);
    343             fprintf( fpout, "vbase = \"0x%x\" ", vseg[vseg_id].vbase);
    344             fprintf( fpout, "mode  = \"%s\" ", mode_str[vseg[vseg_id].mode]);
    345             fprintf( fpout, "clusterid = \"%d\" ", pseg[pseg_id].cluster);
    346             fprintf( fpout, "psegname = \"%s\" ", pseg[pseg_id].name);
    347             fprintf( fpout, "ident = \"%d\" >\n", vseg[vseg_id].ident);
    348 
    349             for ( vobj_id = vseg[vseg_id].vobj_offset ;
    350                   vobj_id < (vseg[vseg_id].vobj_offset + vseg[vseg_id].vobjs) ;
    351                   vobj_id++ )
    352             {
    353                 fprintf( fpout, "             <vobj name = \"%s\" ", vobj[vobj_id].name);
    354                 fprintf( fpout, "type = \"%s\" ", vobj_type[vobj[vobj_id].type]);
    355                 fprintf( fpout, "length = \"0x%x\" ", vobj[vobj_id].length);
    356                 fprintf( fpout, "align = \"%d\" ", vobj[vobj_id].align);
    357                 fprintf( fpout, "init = \"%d\" ", vobj[vobj_id].init);
    358                 fprintf( fpout, "binpath = \"%s\" />\n", vobj[vobj_id].binpath);
     333            fprintf(fpout, "            <vseg name = \"%s\" ", vseg[vseg_id].name);
     334            fprintf(fpout, "vbase = \"0x%x\" ", vseg[vseg_id].vbase);
     335            fprintf(fpout, "mode  = \"%s\" ", mode_str[vseg[vseg_id].mode]);
     336            fprintf(fpout, "clusterid = \"%d\" ", pseg[pseg_id].cluster);
     337            fprintf(fpout, "psegname = \"%s\" ", pseg[pseg_id].name);
     338            fprintf(fpout, "ident = \"%d\" >\n", vseg[vseg_id].ident);
     339
     340            for (vobj_id = vseg[vseg_id].vobj_offset;
     341                    vobj_id < (vseg[vseg_id].vobj_offset + vseg[vseg_id].vobjs);
     342                    vobj_id++) {
     343                fprintf(fpout, "             <vobj name = \"%s\" ", vobj[vobj_id].name);
     344                fprintf(fpout, "type = \"%s\" ", vobj_type[vobj[vobj_id].type]);
     345                fprintf(fpout, "length = \"0x%x\" ", vobj[vobj_id].length);
     346                fprintf(fpout, "align = \"%d\" ", vobj[vobj_id].align);
     347                fprintf(fpout, "init = \"%d\" ", vobj[vobj_id].init);
     348                fprintf(fpout, "binpath = \"%s\" />\n", vobj[vobj_id].binpath);
    359349            }
    360             fprintf( fpout, "            </vseg>\n\n");
    361         }
    362         for ( task_id = vspace[vspace_id].task_offset ;
    363               task_id < (vspace[vspace_id].task_offset + vspace[vspace_id].tasks) ;
    364               task_id++ )
    365         {
     350            fprintf(fpout, "            </vseg>\n\n");
     351        }
     352        for (task_id = vspace[vspace_id].task_offset;
     353                task_id < (vspace[vspace_id].task_offset + vspace[vspace_id].tasks);
     354                task_id++) {
    366355            unsigned int vobj_id = task[task_id].vobjlocid + vspace[vspace_id].vobj_offset;
    367356
    368             fprintf( fpout, "            <task name = \"%s\" ", task[task_id].name);
    369             fprintf( fpout, "clusterid = \"%d\" ", task[task_id].clusterid);
    370             fprintf( fpout, "proclocid = \"%d\" ", task[task_id].proclocid);
    371             fprintf( fpout, "stackname = \"%s\" ", vobj[vobj_id].name);
    372             fprintf( fpout, "startid = \"%d\" ", task[task_id].startid);
    373             fprintf( fpout, "usetty = \"%d\" ", task[task_id].use_tty);
    374             fprintf( fpout, "usenic = \"%d\" ", task[task_id].use_nic);
    375             fprintf( fpout, "usetimer = \"%d\" ", task[task_id].use_timer);
    376             fprintf( fpout, "usefbma = \"%d\" />\n", task[task_id].use_fbdma);
    377         }
    378         fprintf( fpout, "        </vspace>\n\n");
    379     }
    380     fprintf( fpout, "    </vspaceset>\n" );
    381     fprintf( fpout, "</mapping_info>\n");
     357            fprintf(fpout, "            <task name = \"%s\" ", task[task_id].name);
     358            fprintf(fpout, "clusterid = \"%d\" ", task[task_id].clusterid);
     359            fprintf(fpout, "proclocid = \"%d\" ", task[task_id].proclocid);
     360            fprintf(fpout, "stackname = \"%s\" ", vobj[vobj_id].name);
     361            fprintf(fpout, "startid = \"%d\" ", task[task_id].startid);
     362            fprintf(fpout, "usetty = \"%d\" ", task[task_id].use_tty);
     363            fprintf(fpout, "usenic = \"%d\" ", task[task_id].use_nic);
     364            fprintf(fpout, "usetimer = \"%d\" ", task[task_id].use_timer);
     365            fprintf(fpout, "usefbma = \"%d\" />\n", task[task_id].use_fbdma);
     366        }
     367        fprintf(fpout, "        </vspace>\n\n");
     368    }
     369    fprintf(fpout, "    </vspaceset>\n");
     370    fprintf(fpout, "</mapping_info>\n");
    382371} // end buildXml()
    383372
     373
    384374/////////////////////////////////////
    385 int  main ( int argc, char* argv[] )
    386 {
    387     if ( argc < 2 )
    388     {
     375int main(int argc, char * argv[]) {
     376    if (argc < 2) {
    389377        printf("Usage: bin2xml <input_file_path> <output_file_path>\n");
    390378        return 1;
    391379    }
    392380
    393     unsigned int      bin[0x10000];             // 64 K int = 256 Kbytes
    394 
    395     int fdin = open( argv[1], O_RDONLY );
    396     if (fdin < 0)
    397     {
     381    unsigned int bin[0x10000]; // 64 K int = 256 Kbytes
     382
     383    int fdin = open(argv[1], O_RDONLY);
     384    if (fdin < 0) {
    398385        perror("open");
    399386        exit(1);
    400387    }
    401388
    402     FILE* fpout = fopen( argv[2], "w" );
    403     if (fpout == NULL)
    404     {
     389    FILE * fpout = fopen( argv[2], "w");
     390    if (fpout == NULL) {
    405391        perror("open");
    406392        exit(1);
     
    409395    unsigned int length = read(fdin, bin, 0x40000);
    410396
    411     if ( length <= 0 )
    412     {
     397    if (length <= 0) {
    413398        perror("read");
    414399        exit(1);
    415400    }
    416401
    417     if ( bin[0] == IN_MAPPING_SIGNATURE )
    418     {
    419         buildXml( (mapping_header_t*)bin, fpout );
     402    if (bin[0] == IN_MAPPING_SIGNATURE) {
     403        buildXml((mapping_header_t *) bin, fpout);
    420404    }
    421     else
    422     {
     405    else {
    423406        printf("[ERROR] Wrong file format\n");
    424407        exit(1);
     
    426409    return 0;
    427410} // end main()
     411
     412
     413
     414// Local Variables:
     415// tab-width: 4
     416// c-basic-offset: 4
     417// c-file-offsets:((innamespace . 0)(inline-open . 0))
     418// indent-tabs-mode: nil
     419// End:
     420// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     421
Note: See TracChangeset for help on using the changeset viewer.