Ignore:
Timestamp:
Aug 7, 2012, 6:37:49 PM (12 years ago)
Author:
alain
Message:

Introducing a new release where all initialisation
is done in the boot code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/xml/xml_parser.c

    r188 r189  
    2020#include  <libxml/xmlreader.h>
    2121#include  <mapping_info.h>
     22#include  <irq_handler.h>
    2223
    2324#define MAX_CLUSTERS    1024
     
    3233#define MAX_COPROCS             4096
    3334#define MAX_CP_PORTS    8192
    34 #define MAX_CP_REGS             8192
     35#define MAX_PERIPHS             8192
    3536
    3637#define XML_PARSER_DEBUG        0
     
    4950mapping_proc_t*         proc[MAX_PROCS];                // proc array
    5051mapping_irq_t*          irq[MAX_IRQS];                  // irq array
    51 mapping_coproc_t*       coproc[MAX_COPROCS];            // coproc array
    52 mapping_coproc_port_t*  cp_port[MAX_CP_PORTS];  // coproc port array
    53 mapping_coproc_reg_t*   cp_reg[MAX_CP_REGS];     // coproc reg array
    54 
    55 typedef struct vobj_ref_s
    56 {
    57     char vspace_name[32];
    58     char vobj_name[32];
    59 }vobj_ref_t;
    60 
    61 // This arrray is useful to temporary save the a vobj referece
    62 // formed by a vspace_name and a vobj_name (struct vobj_ref_s).
    63 // This arry will be used to set the attribute vobj_id of coproc_port
    64 // once all the vspace have been parsed.
    65 vobj_ref_t*                 cp_port_vobj_ref[MAX_CP_PORTS];     
     52mapping_coproc_t*       coproc[MAX_COPROCS];    // coproc array
     53mapping_cp_port_t*          cp_port[MAX_CP_PORTS];      // coproc port array
     54mapping_periph_t*       periph[MAX_PERIPHS];    // peripheral array
     55
     56// Index for the various arrays
    6657
    6758unsigned int            cluster_index  = 0;
     
    8273unsigned int            cp_port_loc_index = 0;
    8374
    84 unsigned int            cp_reg_index     = 0;
    85 unsigned int            cp_reg_loc_index = 0;
     75unsigned int            periph_index     = 0;
     76unsigned int            periph_loc_index = 0;
    8677
    8778unsigned int            vseg_index     = 0;
    8879unsigned int            vseg_loc_index = 0;
     80
    8981unsigned int            task_index     = 0;
    9082unsigned int            task_loc_index = 0;
     83
    9184unsigned int            vobj_index     = 0;
    9285unsigned int            vobj_loc_index = 0;
    9386unsigned int            vobj_count     = 0;
    9487
    95 unsigned int            tty_index      = 1;
    96 unsigned int            fb_index       = 0;
    97            
     88///////////////////////////////////////////////////////////////////////
     89// This arrray is useful to build a temporary list of vobj references.
     90// The struct vobj_ref_s is formed by a vspace_name and a vobj_name.
     91// This array is used to set the attribute vobj_id of a cp_port
     92// once all the vspace have been parsed.
     93
     94typedef struct vobj_ref_s
     95{
     96    char vspace_name[32];
     97    char vobj_name[32];
     98}vobj_ref_t;
     99
     100vobj_ref_t*             cp_port_vobj_ref[MAX_CP_PORTS];
     101
     102
    98103//////////////////////////////////////////////////
    99104unsigned int getIntValue( xmlTextReaderPtr reader,
     
    183188////////////////////////////////////////////
    184189int getVspaceId( char*         vspace_name)
    185 ////////////////////////////////////////////
    186190{
    187191    unsigned int vspace_id;
     
    201205                  char*             vobj_name,
    202206                  unsigned int  vspace_max)
    203 ////////////////////////////////////////////
    204207{
    205208    unsigned int vobj_id;
     
    235238#endif
    236239
    237     cp_port[cp_port_index] = (mapping_coproc_port_t*)malloc(sizeof(mapping_coproc_port_t));
     240    cp_port[cp_port_index] = (mapping_cp_port_t*)malloc(sizeof(mapping_cp_port_t));
    238241    cp_port_vobj_ref[cp_port_index] = (vobj_ref_t*)malloc(sizeof(vobj_ref_t));
    239242
     
    251254        else
    252255        {
    253             printf("[XML ERROR] illegal <direction> for coproc_port %d in cluster %d\n",
     256            printf("[XML ERROR] illegal <direction> for cp_port %d in cluster %d\n",
    254257                   cp_port_index, cluster_index);
    255258            exit(1);
     
    258261    else
    259262    {
    260         printf("[XML ERROR] missing <direction> for coproc_port %d in cluster %d\n",
     263        printf("[XML ERROR] missing <direction> for cp_port %d in cluster %d\n",
    261264               cp_port_index, cluster_index);
    262265        exit(1);
     
    274277    else
    275278    {
    276         printf("[XML ERROR] missing <vspacename> for coproc_port %d in cluster %d\n",
     279        printf("[XML ERROR] missing <vspacename> for cp_port %d in cluster %d\n",
    277280               cp_port_index, cluster_index);
    278281        exit(1);
     
    290293    else
    291294    {
    292         printf("[XML ERROR] missing <vobjname> for coproc_port %d in cluster %d\n",
     295        printf("[XML ERROR] missing <vobjname> for cp_port %d in cluster %d\n",
    293296               cp_port_index, cluster_index);
    294297        exit(1);
     
    300303} // end cpPortNode()
    301304
    302 /////////////////////////////////////////
    303 void cpRegNode ( xmlTextReaderPtr reader )
    304 /////////////////////////////////////////
     305///////////////////////////////////////////
     306void periphNode ( xmlTextReaderPtr reader )
     307///////////////////////////////////////////
    305308{
    306309    char*           str;
    307310    unsigned int    value;
    308     unsigned int    ok;
     311    unsigned int        ok;
    309312
    310313    if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;
    311314
    312     /* TWO: check source file consistency if possible */
    313     if ( cp_reg_index >= MAX_CP_REGS )
    314     {
    315         printf("[XML ERROR] The number of regs (for coprocs) is larger than %d\n", MAX_CP_REGS);
    316     }
    317 
    318 #if XML_PARSER_DEBUG
    319 printf("\n  reg %d\n", cp_reg_index);
    320 #endif
    321 
    322     /* THIRD*/
    323     cp_reg[cp_reg_index] = (mapping_coproc_reg_t*)malloc(sizeof(mapping_coproc_reg_t));
    324 
    325     /* FOURTH: read all attribute*/
    326 
    327     /////////// get name attribute
    328     str = getStringValue( reader, "name", &ok );
    329 #if XML_PARSER_DEBUG
    330 printf("      name = %s\n", str);
    331 #endif
     315    if ( periph_index >= MAX_PERIPHS )
     316    {
     317        printf("[XML ERROR] The number of periphs is larger than %d\n", MAX_PERIPHS);
     318    }
     319
     320#if XML_PARSER_DEBUG
     321printf("\n  periph %d\n", periph_index);
     322#endif
     323
     324    periph[periph_index] = (mapping_periph_t*)malloc(sizeof(mapping_periph_t));
     325
     326    /////////// get type attribute
     327    str = getStringValue( reader, "type", &ok );
    332328    if ( ok )
    333329    {
    334         strncpy(cp_reg[cp_reg_index]->name, str, 31);
    335     }
    336     else
    337     {
    338         printf("[XML ERROR] illegal or missing <name> for coproc_reg %d in cluster %d\n",
    339                cp_reg_index, cluster_index);
    340         exit(1);
    341     }
     330#if XML_PARSER_DEBUG
     331printf("      type     = %s\n", str);
     332#endif
     333        unsigned int error = 0;
     334 
     335        // The TTY, IOC, NIC, FBF and IOB peripherals cannot be replicated
     336        if      ( strcmp( str, "IOC" ) == 0 )
     337        {
     338            periph[periph_index]->type = PERIPH_TYPE_IOC;
     339            if ( header->ioc_clusterid == 0xFFFFFFFF) header->ioc_clusterid = cluster_index;
     340            else  error = 1;
     341        }
     342        else if ( strcmp( str, "TTY" ) == 0 )
     343        {
     344            periph[periph_index]->type = PERIPH_TYPE_TTY;
     345            if ( header->ioc_clusterid == 0xFFFFFFFF) header->ioc_clusterid = cluster_index;
     346            else  error = 1;
     347        }
     348        else if ( strcmp( str, "FBF" ) == 0 )
     349        {
     350            periph[periph_index]->type = PERIPH_TYPE_FBF;
     351            if ( header->ioc_clusterid == 0xFFFFFFFF) header->ioc_clusterid = cluster_index;
     352            else  error = 1;
     353        }
     354        else if ( strcmp( str, "NIC" ) == 0 )
     355        {
     356            periph[periph_index]->type = PERIPH_TYPE_NIC;
     357            if ( header->ioc_clusterid == 0xFFFFFFFF) header->ioc_clusterid = cluster_index;
     358            else  error = 1;
     359        }
     360        // The TIM, DMA and IOB peripherals can be replicated in several clusters
     361        else if ( strcmp( str, "TIM" ) == 0 )
     362        {
     363            periph[periph_index]->type = PERIPH_TYPE_TIM;
     364        }
     365        else if ( strcmp( str, "DMA" ) == 0 )
     366        {
     367            periph[periph_index]->type = PERIPH_TYPE_DMA;
     368        }
     369        else if ( strcmp( str, "IOB" ) == 0 )
     370        {
     371            periph[periph_index]->type = PERIPH_TYPE_IOB;
     372        }
     373        else
     374        {
     375            printf("[XML ERROR] illegal <type> for peripheral %d in cluster %d\n",
     376                   periph_loc_index, cluster_index);
     377            exit(1);
     378        }
     379    }
     380    else
     381    {
     382        printf("[XML ERROR] missing <type> for peripheral  %d in cluster %d\n",
     383               periph_loc_index, cluster_index);
     384        exit(1);
     385    }
     386
     387    ///////// get channels attribute (optionnal : 1 if missing)
     388    value = getIntValue( reader, "channels", &ok );
     389    if ( ok )
     390    {
     391#if XML_PARSER_DEBUG
     392printf("      channels = %d\n", value);
     393#endif
     394        periph[periph_index]->channels = value;
     395    }
     396    else
     397    {
     398        periph[periph_index]->channels = 1;
     399    }
     400
     401    /////////// get psegname attribute
     402    str = getStringValue(reader,"psegname", &ok);
     403    if ( ok == 0 )
     404    {
     405        printf("[XML ERROR] illegal or missing <psegname> for coproc %d in cluster %d\n",
     406                 coproc_index, cluster_index);
     407        exit(1);
     408    }
     409
     410    /////////// set psegid attribute
     411    int index = getPsegId( cluster_index, str );
     412    if ( index >= 0 )
     413    {
     414#if XML_PARSER_DEBUG
     415printf("      clusterid = %d\n", cluster_index);
     416printf("      psegname  = %s\n", str);
     417printf("      psegid    = %d\n", index);
     418#endif
     419        periph[periph_index]->psegid = index;
     420        assert(pseg[index]->type == PSEG_TYPE_PERI &&
     421        "peripheral psegname attribute must refer to a pseg of type PERI" );
     422    }
     423    else             
     424    {
     425        printf("[XML ERROR] pseg not found for periph %d / clusterid = %d / psegname = %s\n",
     426                   periph_loc_index, cluster_index, str );
     427        exit(1);
     428    } 
    342429   
    343     ///////// get type attribute
    344     str = getStringValue( reader, "type", &ok );
    345     if ( ok )
    346     {
    347 #if XML_PARSER_DEBUG
    348 printf("      type = %s\n", str);
    349 #endif
    350         if      ( strcmp(str, "STATUS")   ) cp_reg[cp_reg_index]->type = REG_TYPE_STATUS;
    351         else if ( strcmp(str, "CONFIG")   ) cp_reg[cp_reg_index]->type = REG_TYPE_CONFIG;
    352         else
    353         {
    354             printf("[XML ERROR] illegal <type> for coproc_reg %d in cluster %d\n",
    355                    cp_reg_index, cluster_index);
    356             exit(1);
    357         }
    358     } 
    359     else
    360     {
    361         printf("[XML ERROR] missing <type> for coproc_reg %d in cluster %d\n",
    362                cp_reg_index, cluster_index);
    363         exit(1);
    364     }
    365 
    366     ///////// get value attribute
    367     value = getIntValue(reader, "value", &ok);
    368     if ( ok )
    369     {
    370 #if XML_PARSER_DEBUG
    371 printf("        value   = %d\n", value);
    372 #endif
    373         cp_reg[cp_reg_index]->value = value;
    374     }
    375     else
    376     {
    377         printf("[XML ERROR] illegal or missing <value> for coproc_reg %d in cluster %d\n",
    378                cp_reg_index, cluster_index);
    379         exit(1);
    380     }
    381 
    382     ///////// get channel attribute
    383     value = getIntValue(reader, "channel", &ok);
    384     if ( ok )
    385     {
    386 #if XML_PARSER_DEBUG
    387 printf("        channel   = %d\n", value);
    388 #endif
    389         cp_reg[cp_reg_index]->channel_id = value;
    390     }
    391     else
    392     {
    393         printf("[XML ERROR] illegal or missing <channel> for coproc_reg %d in cluster %d\n",
    394                cp_reg_index, cluster_index);
    395         exit(1);
    396     }
    397 
    398     ///////// get index attribute
    399     value = getIntValue(reader, "index", &ok);
    400     if ( ok )
    401     {
    402 #if XML_PARSER_DEBUG
    403 printf("        index   = %d\n", value);
    404 #endif
    405         cp_reg[cp_reg_index]->loc_id = value;
    406     }
    407     else
    408     {
    409         printf("[XML ERROR] illegal or missing <index> for coproc_reg %d in cluster %d\n",
    410                cp_reg_index, cluster_index);
    411         exit(1);
    412     }
    413    
    414     cp_reg_index++;
    415     cp_reg_loc_index++;
    416 
    417 } // end cpRegNode()
     430    periph_index++;
     431    periph_loc_index++;
     432
     433} // end periphNode
    418434
    419435/////////////////////////////////////////
     
    425441
    426442    cp_port_loc_index = 0;
    427     cp_reg_loc_index = 0;
    428443
    429444    if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;
     
    439454
    440455    coproc[coproc_index] = (mapping_coproc_t*)malloc(sizeof(mapping_coproc_t));
    441 
    442456
    443457    /////////// get name attribute
     
    485499    } 
    486500
    487     ////////// set port_offset and reg_offset attribute
     501    ////////// set port_offset
    488502    coproc[coproc_index]->port_offset = cp_port_index;
    489     coproc[coproc_index]->reg_offset = cp_reg_index;
    490 
    491 #if XML_PARSER_DEBUG
    492 printf("    port_offset = %d\n", cp_port_index);
    493 printf("    reg_offset = %d\n", cp_reg_index);
     503
     504#if XML_PARSER_DEBUG
     505printf("      port_offset = %d\n", cp_port_index);
    494506#endif
    495507
     
    499511        const char* tag = (const char*)xmlTextReaderConstName(reader);
    500512
    501         if      ( strcmp(tag,"port")    == 0 ) cpPortNode(reader);
    502         else if ( strcmp(tag,"reg")   == 0 ) cpRegNode(reader);
    503         else if ( strcmp(tag,"#text"  ) == 0 ) { }
    504         else if ( strcmp(tag,"#comment") == 0 );
    505         else if ( strcmp(tag,"coproc")  == 0 )
     513        if      ( strcmp(tag, "port")     == 0 ) cpPortNode(reader);
     514        else if ( strcmp(tag, "#text")    == 0 ) { }
     515        else if ( strcmp(tag, "#comment") == 0 ) { }
     516        else if ( strcmp(tag, "coproc")   == 0 )
    506517        {
    507518            coproc[coproc_index]->ports = cp_port_loc_index;
    508             coproc[coproc_index]->regs = cp_reg_loc_index;
    509519            coproc_loc_index++;
    510520            coproc_index++;
     
    548558printf("        type    = %s\n", str);
    549559#endif
    550         if      ( strcmp(str, "HARD") ) irq[irq_index]->type = IRQ_TYPE_HARD;
    551         else if ( strcmp(str, "SOFT") ) irq[irq_index]->type = IRQ_TYPE_SOFT;
     560        if      ( strcmp(str, "HARD") == 0 ) irq[irq_index]->type = 0;
     561        else if ( strcmp(str, "SOFT") == 0 ) irq[irq_index]->type = 1;
    552562        else
    553563        {
     
    564574    }
    565575
    566     ///////// get irqid attribute
     576    ///////// get icuid attribute
    567577    value = getIntValue(reader, "icuid", &ok);
    568578    if ( ok )
     
    593603printf("        isr     = %s\n", str);
    594604#endif
    595         if      ( strcmp(str, "ISR_SWITCH") ) irq[irq_index]->isr = ISR_SWITCH;
    596         else if ( strcmp(str, "ISR_IOC")    ) irq[irq_index]->isr = ISR_IOC;
    597         else if ( strcmp(str, "ISR_FBDMA")  ) irq[irq_index]->isr = ISR_FBDMA;
    598         else if ( strcmp(str, "ISR_TTY")    ) irq[irq_index]->isr = ISR_TTY;
     605        if      ( strcmp(str, "ISR_SWITCH" ) == 0 ) irq[irq_index]->isr = ISR_SWITCH;
     606        else if ( strcmp(str, "ISR_IOC"    ) == 0 ) irq[irq_index]->isr = ISR_IOC;
     607        else if ( strcmp(str, "ISR_DMA"    ) == 0 ) irq[irq_index]->isr = ISR_DMA;
     608        else if ( strcmp(str, "ISR_TTY"    ) == 0 ) irq[irq_index]->isr = ISR_TTY;
     609        else if ( strcmp(str, "ISR_TIMER"  ) == 0 ) irq[irq_index]->isr = ISR_TIMER;
    599610        else
    600611        {
     
    603614            exit(1);
    604615        }
     616#if XML_PARSER_DEBUG
     617printf("        isrnum  = %d\n", irq[irq_index]->isr);
     618#endif
    605619    } 
    606620    else
     
    664678    ////////// set irq_offset attribute
    665679    proc[proc_index]->irq_offset = irq_index;
     680
    666681#if XML_PARSER_DEBUG
    667682printf("    irq_offset = %d\n", irq_index);
     
    673688        const char* tag = (const char*)xmlTextReaderConstName(reader);
    674689
    675         if      ( strcmp(tag,"irq")    == 0 ) irqNode(reader);
    676         else if ( strcmp(tag,"#text")   == 0 ) { }
    677         else if ( strcmp(tag,"#comment") == 0 );
    678         else if ( strcmp(tag,"proc")  == 0 )
     690        if      ( strcmp(tag, "irq")      == 0 ) irqNode(reader);
     691        else if ( strcmp(tag, "#text")    == 0 ) { }
     692        else if ( strcmp(tag, "#comment") == 0 ) { }
     693        else if ( strcmp(tag, "proc")     == 0 )
    679694        {
    680695            proc[proc_index]->irqs = irq_loc_index;
     
    817832    }
    818833
    819     /////////// get use_tty  attribute (optionnal : 0 if missing)
     834    /////////// get usetty  attribute (optionnal : 0 if missing)
    820835    value = getIntValue(reader,"usetty", &ok);
    821836    if ( ok )
     
    824839printf("      usetty = %x\n", value);
    825840#endif
    826         if ( (value != 0) && (tty_index >= header->ttys) )
    827         {
    828             printf("[XML ERROR] The tty index is too large for task (%d,%d)\n",
    829                 vspace_index, task_loc_index);
    830             exit(1);
    831         }
    832841        task[task_index]->use_tty = value;
    833         if (value != 0) tty_index++;
    834842    } 
    835843    else
     
    838846    }
    839847
    840     /////////// get use_fb  attribute (optionnal : 0 if missing)
    841     value = getIntValue(reader,"usefb", &ok);
    842     if ( ok )
    843     {
    844 #if XML_PARSER_DEBUG
    845 printf("      usefb = %x\n", value);
    846 #endif
    847         if ( (value != 0) && (fb_index >= header->fbs) )
    848         {
    849             printf("[XML ERROR] The fb channel index is too large for task (%d,%d)\n",
    850                 vspace_index, task_loc_index);
    851             exit(1);
    852         }
    853         task[task_index]->use_fb = value;
    854         if (value != 0) fb_index++;
     848    /////////// get usenic  attribute (optionnal : 0 if missing)
     849    value = getIntValue(reader,"usenic", &ok);
     850    if ( ok )
     851    {
     852#if XML_PARSER_DEBUG
     853printf("      usenic = %x\n", value);
     854#endif
     855        task[task_index]->use_nic = value;
    855856    } 
    856857    else
    857858    {
    858         task[task_index]->use_fb = 0;
     859        task[task_index]->use_nic = 0;
     860    }
     861
     862    /////////// get usetimer attribute (optionnal : 0 if missing)
     863    value = getIntValue(reader,"usetimer", &ok);
     864    if ( ok )
     865    {
     866#if XML_PARSER_DEBUG
     867printf("      usetimer = %x\n", value);
     868#endif
     869        task[task_index]->use_timer = value;
     870    } 
     871    else
     872    {
     873        task[task_index]->use_timer = 0;
     874    }
     875
     876    /////////// get usefbdma  attribute (optionnal : 0 if missing)
     877    value = getIntValue(reader,"usefbdma", &ok);
     878    if ( ok )
     879    {
     880#if XML_PARSER_DEBUG
     881printf("      usefbdma = %x\n", value);
     882#endif
     883        task[task_index]->use_fbdma = value;
     884    } 
     885    else
     886    {
     887        task[task_index]->use_fbdma = 0;
    859888    }
    860889
     
    865894//////////////////////////////////////////
    866895void  vobjNode ( xmlTextReaderPtr reader )
     896//////////////////////////////////////////
    867897{
    868898    unsigned int        ok;
     
    9861016    else
    9871017    {
    988         if((vobj[vobj_index]->type == VOBJ_TYPE_MWMR || vobj[vobj_index]->type == VOBJ_TYPE_BARRIER ))
     1018        if( (vobj[vobj_index]->type == VOBJ_TYPE_MWMR) ||
     1019            (vobj[vobj_index]->type == VOBJ_TYPE_BARRIER) )
    9891020        {
    9901021            printf("[XML ERROR] illegal or missing <value> attribute for vobj (%d,%d). \
     
    10031034//////////////////////////////////////////
    10041035void  vsegNode ( xmlTextReaderPtr reader )
     1036//////////////////////////////////////////
    10051037{
    10061038    unsigned int        ok;
     
    11441176        const char* tag = (const char*)xmlTextReaderConstName(reader);
    11451177
    1146         if      ( strcmp(tag,"vobj")    == 0 ) vobjNode(reader);
    1147         else if ( strcmp(tag,"#text"  ) == 0 ) { }
    1148         else if ( strcmp(tag,"vseg")    == 0 )
     1178        if      ( strcmp(tag, "vobj")     == 0 ) vobjNode(reader);
     1179        else if ( strcmp(tag, "#text"  )  == 0 ) { }
     1180        else if ( strcmp(tag, "#comment") == 0 ) { }
     1181        else if ( strcmp(tag, "vseg")     == 0 )
    11491182        {
    11501183            vseg[vseg_index]->vobjs = vobj_count;
     
    11641197//////////////////////////////////////////
    11651198void vspaceNode( xmlTextReaderPtr reader )
     1199//////////////////////////////////////////
    11661200{
    11671201    char*               str;
     
    12331267        const char* tag = (const char*)xmlTextReaderConstName(reader);
    12341268
    1235         if      ( strcmp(tag,"vseg")    == 0 ) vsegNode(reader);
    1236         else if ( strcmp(tag,"task")    == 0 ) taskNode(reader);
    1237         else if ( strcmp(tag,"#text")   == 0 ) { }
    1238         else if ( strcmp(tag,"#comment") == 0 );
    1239         else if ( strcmp(tag,"vspace")  == 0 )
     1269        if      ( strcmp(tag, "vseg")     == 0 ) vsegNode(reader);
     1270        else if ( strcmp(tag, "task")     == 0 ) taskNode(reader);
     1271        else if ( strcmp(tag, "#text")    == 0 ) { }
     1272        else if ( strcmp(tag, "#comment") == 0 ) { }
     1273        else if ( strcmp(tag, "vspace")   == 0 )
    12401274        {
    12411275            vspace[vspace_index]->vobjs = vobj_loc_index;
     
    12881322//////////////////////////////////////////
    12891323void  psegNode ( xmlTextReaderPtr reader )
     1324//////////////////////////////////////////
    12901325{
    12911326    unsigned int        ok;
     
    13791414/////////////////////////////////////////////
    13801415void  clusterNode ( xmlTextReaderPtr reader )
     1416/////////////////////////////////////////////
    13811417{
    13821418    unsigned int ok;
     
    13851421    proc_loc_index = 0;
    13861422    coproc_loc_index = 0;
    1387     cluster[cluster_index] = 0;
     1423    periph_loc_index = 0;
    13881424
    13891425    if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;
     
    14021438    cluster[cluster_index] = (mapping_cluster_t*)malloc(sizeof(mapping_cluster_t));
    14031439
    1404     /////////// get index attribute (optional)
     1440    /////////// check cluster index attribute (optional)
    14051441    value = getIntValue(reader,"index",&ok);
    14061442    if ( ok && (value != cluster_index) )
     
    14111447    }
    14121448
    1413 
    1414     ////////// set pseg_offset attribute
    1415     cluster[cluster_index]->pseg_offset = pseg_index;
    1416     cluster[cluster_index]->proc_offset = proc_index;
     1449    ////////// set offsets
     1450    cluster[cluster_index]->pseg_offset   = pseg_index;
     1451    cluster[cluster_index]->proc_offset   = proc_index;
    14171452    cluster[cluster_index]->coproc_offset = coproc_index;
    1418 #if XML_PARSER_DEBUG
    1419 printf("    pseg_offset = %d\n", pseg_index);
    1420 printf("    proc_offset = %d\n", proc_index);
     1453    cluster[cluster_index]->periph_offset = periph_index;
     1454
     1455#if XML_PARSER_DEBUG
     1456printf("    pseg_offset   = %d\n", pseg_index);
     1457printf("    proc_offset   = %d\n", proc_index);
    14211458printf("    coproc_offset = %d\n", coproc_index);
    1422 #endif
    1423 
    1424     ////////// get psegs, coproc and/or procs
     1459printf("    periph_offset = %d\n", coproc_index);
     1460#endif
     1461
     1462    ////////// get psegs, procs, coprocs and periphs
    14251463    int status = xmlTextReaderRead(reader);
    14261464
     
    14291467        const char* tag = (const char*)xmlTextReaderConstName(reader);
    14301468
    1431         if      ( strcmp(tag, "pseg")    == 0 ) psegNode(reader);
    1432         else if ( strcmp(tag, "proc")    == 0 ) procNode(reader);
    1433         else if ( strcmp(tag, "coproc")    == 0 ) coprocNode(reader);
    1434         else if ( strcmp(tag, "#text")   == 0 ) { }
    1435         else if ( strcmp(tag,"#comment") == 0 );
    1436         else if ( strcmp(tag, "cluster") == 0 )
    1437         {
    1438 #if XML_PARSER_DEBUG
     1469        if      ( strcmp(tag, "pseg")     == 0 ) psegNode(reader);
     1470        else if ( strcmp(tag, "proc")     == 0 ) procNode(reader);
     1471        else if ( strcmp(tag, "coproc")   == 0 ) coprocNode(reader);
     1472        else if ( strcmp(tag, "periph")   == 0 ) periphNode(reader);
     1473        else if ( strcmp(tag, "#text")    == 0 ) { }
     1474        else if ( strcmp(tag, "#comment") == 0 ) { }
     1475        else if ( strcmp(tag, "cluster")  == 0 )
     1476        {
     1477            cluster[cluster_index]->procs   = proc_loc_index;
     1478            cluster[cluster_index]->coprocs = coproc_loc_index;
     1479            cluster[cluster_index]->periphs = periph_loc_index;
     1480
     1481            // cluster[cluster_index]psegs update is done in psegNode(),
     1482            // because the coprocNode() call to getPsegId() need it
     1483
     1484#if XML_PARSER_DEBUG
     1485printf("    psegs   = %d\n", cluster[cluster_index]->psegs);
     1486printf("    procs   = %d\n", cluster[cluster_index]->procs);
     1487printf("    coprocs = %d\n", cluster[cluster_index]->coprocs);
     1488printf("    periphs = %d\n", cluster[cluster_index]->periphs);
    14391489printf("  end cluster %d\n", cluster_index);
    14401490#endif
    1441             cluster[cluster_index]->procs = proc_loc_index;
    1442             cluster[cluster_index]->coprocs = coproc_loc_index;
    1443             //psegs = pseg_loc_index is done in psegNode(), so coprocNode() call to getPsegId() success
    14441491            cluster_index++;
    14451492            return;
     
    14511498//////////////////////////////////////////////
    14521499void clusterSetNode( xmlTextReaderPtr reader )
     1500//////////////////////////////////////////////
    14531501{
    14541502    if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;
     
    14631511        const char* tag = (const char*)xmlTextReaderConstName(reader);
    14641512
    1465         if      ( strcmp(tag,"cluster") == 0 ) clusterNode(reader);
    1466         else if ( strcmp(tag,"#text") == 0 ) { }
    1467         else if ( strcmp(tag,"#comment") == 0 );
    1468         else if ( strcmp(tag,"clusterset") == 0 )
     1513        if      ( strcmp(tag, "cluster")    == 0 ) clusterNode(reader);
     1514        else if ( strcmp(tag, "#text")      == 0 ) { }
     1515        else if ( strcmp(tag, "#comment")   == 0 ) { }
     1516        else if ( strcmp(tag, "clusterset") == 0 )
    14691517        {
    14701518            // checking source file consistency
     
    14791527printf("  end cluster set\n\n");
    14801528#endif
    1481                 header->psegs = pseg_index;
    1482                 header->procs = proc_index;
    1483                 header->irqs  = irq_index;
    1484                 header->coprocs = coproc_index;
     1529                header->psegs    = pseg_index;
     1530                header->procs    = proc_index;
     1531                header->irqs     = irq_index;
     1532                header->coprocs  = coproc_index;
    14851533                header->cp_ports = cp_port_index;
    1486                 header->cp_regs = cp_reg_index;
    14871534                return;
    14881535            }
     
    14991546/////////////////////////////////////////////
    15001547void globalSetNode( xmlTextReaderPtr reader )
     1548/////////////////////////////////////////////
    15011549{
    15021550    if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;
     
    15111559        const char* tag = (const char*)xmlTextReaderConstName(reader);
    15121560
    1513         if      ( strcmp(tag,"vseg") == 0    ) vsegNode(reader);
    1514         else if ( strcmp(tag,"#text"  ) == 0 ) { }
    1515         else if ( strcmp(tag,"#comment") == 0 );
    1516         else if ( strcmp(tag,"globalset") == 0 )
     1561        if      ( strcmp(tag, "vseg")      == 0 ) vsegNode(reader);
     1562        else if ( strcmp(tag, "#text"  )  == 0 ) { }
     1563        else if ( strcmp(tag, "#comment")  == 0 ) { }
     1564        else if ( strcmp(tag, "globalset") == 0 )
    15171565        {
    15181566            // checking source file consistency
     
    15421590/////////////////////////////////////////////
    15431591void vspaceSetNode( xmlTextReaderPtr reader )
     1592/////////////////////////////////////////////
    15441593{
    15451594    if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;
     
    15541603        const char* tag = (const char*)xmlTextReaderConstName(reader);
    15551604
    1556         if      ( strcmp(tag,"vspace") == 0    ) vspaceNode(reader);
    1557         else if ( strcmp(tag,"#text"  ) == 0 ) { }
    1558         else if ( strcmp(tag,"#comment") == 0 );
    1559         else if ( strcmp(tag,"vspaceset") == 0 )
     1605        if      ( strcmp(tag, "vspace"   ) == 0 ) vspaceNode(reader);
     1606        else if ( strcmp(tag, "#text"    ) == 0 ) { }
     1607        else if ( strcmp(tag, "#comment" ) == 0 ) { }
     1608        else if ( strcmp(tag, "vspaceset") == 0 )
    15601609        {
    15611610            // checking source file consistency
     
    15841633//////////////////////////////////////////
    15851634void headerNode(xmlTextReaderPtr reader )
     1635//////////////////////////////////////////
    15861636{
    15871637    char*               name;
     
    16321682    }
    16331683
    1634     ///////// get ttys attribute
    1635     value = getIntValue(reader, "ttys", &ok);
    1636     if ( ok )
    1637     {
    1638 #if XML_PARSER_DEBUG
    1639 printf("  ttys = %d\n", value);
    1640 #endif
    1641         header->ttys  = value;
    1642     }
    1643     else
    1644     {
    1645         printf("[XML ERROR] illegal or missing <ttys> attribute in header\n");
    1646         exit(1);
    1647     }
    1648 
    1649     ///////// get fbs attribute
    1650     value = getIntValue(reader, "fbs", &ok);
    1651     if ( ok )
    1652     {
    1653 #if XML_PARSER_DEBUG
    1654 printf("  fbs = %d\n", value);
    1655 #endif
    1656         header->fbs  = value;
    1657     }
    1658     else
    1659     {
    1660         printf("[XML ERROR] illegal or missing <fbs> attribute in header\n");
    1661         exit(1);
    1662     }
    1663 
    16641684    ///////// get vspaces attribute
    16651685    value = getIntValue(reader, "vspaces", &ok);
     
    17021722    }
    17031723
     1724    //////// initialise non replicated peripherals cluster_id
     1725    header->tty_clusterid = 0xFFFFFFFF;
     1726    header->nic_clusterid = 0xFFFFFFFF;
     1727    header->ioc_clusterid = 0xFFFFFFFF;
     1728    header->fbf_clusterid = 0xFFFFFFFF;
     1729
     1730    ///////// set signature
    17041731    header->signature = IN_MAPPING_SIGNATURE;
    17051732
     
    17091736        const char* tag = (const char*)xmlTextReaderConstName(reader);
    17101737
    1711         if      ( strcmp(tag,"clusterset")   == 0 ) clusterSetNode(reader);
    1712         else if ( strcmp(tag,"globalset")    == 0 ) globalSetNode(reader);
    1713         else if ( strcmp(tag,"vspaceset")    == 0 ) vspaceSetNode(reader);
    1714         else if ( strcmp(tag,"#text")        == 0 ) ;
    1715         else if ( strcmp(tag,"#comment")     == 0 ) ;
    1716         else if ( strcmp(tag,"mapping_info") == 0 )
     1738        if      ( strcmp(tag, "clusterset")   == 0 ) clusterSetNode(reader);
     1739        else if ( strcmp(tag, "globalset")    == 0 ) globalSetNode(reader);
     1740        else if ( strcmp(tag, "vspaceset")    == 0 ) vspaceSetNode(reader);
     1741        else if ( strcmp(tag, "#text")        == 0 ) { }
     1742        else if ( strcmp(tag, "#comment")     == 0 ) { }
     1743        else if ( strcmp(tag, "mapping_info") == 0 )
    17171744        {
    17181745#if XML_PARSER_DEBUG
     
    17301757} // end headerNode()
    17311758   
     1759///////////////////////////////////////
    17321760void BuildTable( int fdout,
    17331761               const char* type,
     
    17351763               unsigned int elem_size,
    17361764               char** table)       
     1765////////////////////////////////////////
    17371766{
    17381767    unsigned int i;
     
    17581787///////////////////////////
    17591788void  buildBin( int fdout )
     1789///////////////////////////
    17601790{
    17611791    unsigned int    vspace_id;
     
    18231853    }
    18241854
    1825     // write tasks
     1855    // write tasks array
    18261856    BuildTable(fdout, "task", task_index, sizeof(mapping_task_t), (char**) task);
    1827     //building proc
     1857    //building procs array
    18281858    BuildTable(fdout, "proc", proc_index, sizeof(mapping_proc_t), (char**) proc);
    1829     //building irq
     1859    //building irqs array
    18301860    BuildTable(fdout, "irq", irq_index, sizeof(mapping_irq_t), (char**)irq);
    1831     //building coproc
     1861    //building coprocs array
    18321862    BuildTable(fdout, "coproc", coproc_index, sizeof(mapping_coproc_t), (char**)coproc);
    1833     //building cp_port
    1834     BuildTable(fdout, "cp_port", cp_port_index, sizeof(mapping_coproc_port_t),(char**) cp_port);
    1835     //building cp_reg
    1836     BuildTable(fdout, "cp_reg", cp_reg_index, sizeof(mapping_coproc_reg_t), (char**)cp_reg);
     1863    //building cp_ports array
     1864    BuildTable(fdout, "cp_port", cp_port_index, sizeof(mapping_cp_port_t),(char**) cp_port);
     1865    //building periphs array
     1866    BuildTable(fdout, "periph", periph_index, sizeof(mapping_periph_t), (char**)periph);
    18371867
    18381868} // end buildBin()
    18391869
    1840 /////////////////////////////////////////
    1841 // this function set the value of vobj_id
    1842 // of the coproc_ports.
    1843 ///////////////////
     1870///////////////////////////////////////////////////////////////////////
     1871// this function set the value the vobj_id fiels of all cp_ports
     1872///////////////////////////////////////////////////////////////////////
    18441873void prepareBuild()
    18451874{
     
    18501879        if ( vspace_id < 0 )
    18511880        {
    1852             printf("[XML ERROR] illegal  <vspacename> for coproc_port %d,\n",
     1881            printf("[XML ERROR] illegal  <vspacename> for cp_port %d,\n",
    18531882                    i);
    18541883            exit(1);
     
    18561885        cp_port[i]->vspaceid = vspace_id;
    18571886       
    1858         int vobj_id = getVobjLocId( vspace_id, cp_port_vobj_ref[i]->vobj_name, vspace[vspace_id]->vobjs );
     1887        int vobj_id = getVobjLocId( vspace_id,
     1888                                    cp_port_vobj_ref[i]->vobj_name,
     1889                                    vspace[vspace_id]->vobjs );
    18591890        if ( vobj_id >= 0 )
    18601891        {
    1861 #if XML_PARSER_DEBUG
    1862 printf("coproc_port = %d\n", i);
     1892
     1893#if XML_PARSER_DEBUG
     1894printf("\ncp_port = %d\n", i);
    18631895printf("      vspace_name  = %s\n", cp_port_vobj_ref[i]->vspace_name);
    18641896printf("      vobj_name    = %s\n", cp_port_vobj_ref[i]->vobj_name);
     
    18661898#endif
    18671899            cp_port[i]->vobjlocid = vobj_id;
    1868             assert((vobj[ vspace[vspace_id]->vobj_offset + vobj_id]->type == VOBJ_TYPE_MWMR) && "coproc ports has to refere to a vobj of type MWMR");
     1900
     1901            assert((vobj[ vspace[vspace_id]->vobj_offset + vobj_id]->type == VOBJ_TYPE_MWMR)
     1902            && "coproc ports has to refere to a vobj of type MWMR");
    18691903        }
    18701904        else             
    18711905        {
    1872             printf("[XML ERROR] illegal  <vobjname> for coproc_port %d,\n",
     1906            printf("[XML ERROR] illegal  <vobjname> for cp_port %d,\n",
    18731907                    i);
    18741908            exit(1);
    18751909        }
    1876        
    18771910    }
    18781911}
     
    18801913/////////////////////////////////////
    18811914int  main ( int argc, char* argv[] )
     1915/////////////////////////////////////
    18821916{
    18831917    if ( argc < 3 )
     
    19131947            }
    19141948            else
    1915             if ( strcmp(tag,"#comment") == 0 );// a way to skips comment
    1916             else
    19171949            {
    19181950                printf("[XML ERROR] Wrong file type: \"%s\"\n", argv[1]);
Note: See TracChangeset for help on using the changeset viewer.