Ignore:
Timestamp:
Mar 26, 2014, 6:44:44 PM (10 years ago)
Author:
alain
Message:

Introducing a major release, to suppoort the tsar_generic_leti platform
and the various (external or internal) peripherals configurations.
The map.xml format has been modified, in order to support the new
vci_iopic componentand a new policy for peripherals initialisation.
The IRQs are nom described in the XICU and IOPIC components
(and not anymore in the processors).
To enforce this major change, the map.xml file signature changed:
The signature value must be: 0xDACE2014

This new release has been tested on the tsar_generic_leti platform
for the following mappings:

  • 4c_4p_sort_leti
  • 4c_4p_sort_leti_ext
  • 4c_4p_transpose_leti
  • 4c_4p_transpose_leti_ext
  • 4c_1p_four_leti_ext
File:
1 edited

Legend:

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

    r289 r295  
    104104char found_mmc   = 0;
    105105
    106 
    107 ////////////////////////////////////////////////////////////////////
    108 // These variables are used to generate the hard_config.h file
    109 ////////////////////////////////////////////////////////////////////
    110 
    111 unsigned int nb_proc_max      = 0; // max number of processors per cluster
     106////////////////////////////////////////////////////////////////////////
     107// These variables are used to generate the hard_config.h file.
     108////////////////////////////////////////////////////////////////////////
     109
     110unsigned int nb_procs_max     = 0; // max number of processors per cluster
    112111unsigned int nb_tasks_max     = 0; // max number of tasks (in all vspaces)
    113112
    114 unsigned int tim_channels     = 0; // max number of user timers (per cluster)
    115 unsigned int dma_channels     = 0; // max number of DMA channels (per cluster)
    116 
    117 unsigned int icu_channels     = 0; // total number of channels  in ICU/XICU
    118 unsigned int tty_channels     = 0; // total number of terminals in TTY
    119 unsigned int hba_channels     = 0; // total number of channels  in HBA
    120 unsigned int nic_channels     = 0; // total number of channels  in NIC
    121 unsigned int cma_channels     = 0; // total number of channels  in CMA
     113unsigned int tim_channels     = 0; // number of user timers (per cluster)
     114unsigned int dma_channels     = 0; // number of DMA channels (per cluster)
     115
     116unsigned int tty_channels     = 0; // number of TTY channels
     117unsigned int ioc_channels     = 0; // number of HBA channels
     118unsigned int nic_channels     = 0; // number of NIC channels
     119unsigned int cma_channels     = 0; // number of CMA channels
     120unsigned int pic_channels     = 0; // number of PIC channels
    122121
    123122unsigned int use_iob          = 0; // using IOB component
     123unsigned int use_pic          = 0; // using PIC component
    124124unsigned int use_xcu          = 0; // using XCU (not ICU)
    125125
    126126// These variables define the IOC peripheral subtype
    127 unsigned int use_hba          = 0; // using HBA
    128 unsigned int use_bdv          = 0; // using SoCLIB block device
    129 unsigned int use_spi          = 0; // using SD Card-SPI
     127
     128unsigned int use_hba          = 0; // using SoClib AHCI controller
     129unsigned int use_bdv          = 0; // using SoCLIB block device controller
     130unsigned int use_spi          = 0; // using SDCard-SPI
    130131
    131132////////////////////////////////////////////////////////////////
     
    283284
    284285///////////////////////////////////////////////////////////////////////////////////
    285 // This function set the vbase address for all peripheral types.
    286 // For replicated peripherals with the same type the virtual base address must be:
    287 //   vbase = seg_type_base & 0XFF000000 +
    288 //          (cluster_id * vbase_cluster_increment) & 0x00FF0000
     286// This function set the vbase addresses for all peripheral types, in order
     287// to generate the ldscript file, that contains one single virtual address
     288// for peripherals replicated in all clusters, and one virtual addresses for
     289// each non replicated peripheral type.
     290//
     291// It makes the following checks on the virtual addresses:
     292//
     293// - For replicated peripherals the virtual base address must be:
     294//   vbase = seg_type_base & 0XFF000000 + (cluster_xy * increment) & 0x00FF0000
     295//
     296// - For non-replicated peripherals, the cluster index must be cluster_io.
    289297///////////////////////////////////////////////////////////////////////////////////
    290298void set_periph_vbase_array()
     
    300308    unsigned int cluster_mask = 0x00FF0000;
    301309
    302     // We are analysing all vsegs corresponding to a peripheral
     310#if XML_PARSER_DEBUG
     311printf("\n set peripherals vbase array\n");
     312#endif
    303313
    304314    // scan all vsegs
     
    308318        if ( vobj[vseg[vseg_id]->vobj_offset]->type == VOBJ_TYPE_PERI )
    309319        {
    310             pseg_id    = vseg[vseg_id]->psegid;
     320            pseg_id = vseg[vseg_id]->psegid;
     321
     322#if XML_PARSER_DEBUG
     323printf(" - found vseg %s with psegid = %d", vseg[vseg_id]->name, pseg_id );
     324#endif
    311325
    312326            // scan all periphs to retrieve peripheral type (same psegid)
     
    315329                if( periph[periph_id]->psegid == pseg_id ) // matching !!!
    316330                {
    317                     type = periph[periph_id]->type;
    318                     if ( periph_vbase_array[type] == 0xFFFFFFFF )  // vbase not set
     331                    cluster_id = pseg[pseg_id]->clusterid;
     332                    type       = periph[periph_id]->type;
     333
     334#if XML_PARSER_DEBUG
     335printf(" / matching periph type %d\n", type );
     336#endif
     337
     338                    if ( (type == PERIPH_TYPE_DMA) ||
     339                         (type == PERIPH_TYPE_MMC) ||
     340                         (type == PERIPH_TYPE_ICU) ||
     341                         (type == PERIPH_TYPE_XCU) ||
     342                         (type == PERIPH_TYPE_TIM) )   // replicated peripheral
    319343                    {
    320                         periph_vbase_array[type] = vseg[vseg_id]->vbase & type_mask;   
    321                     }
    322                     else                                 // vbase already set
    323                     {
    324                         // checking mask bits
    325                         if( (vseg[vseg_id]->vbase & type_mask) !=
    326                             (periph_vbase_array[type]) )
     344                        cluster_xy = (cluster[cluster_id]->x << header->y_width) +
     345                                      cluster[cluster_id]->y;
     346
     347                        if( (vseg[vseg_id]->vbase & cluster_mask) !=
     348                            (header->increment * cluster_xy) )
    327349                        {
    328                             printf("[XML ERROR] All peripherals with same type ");
    329                             printf(" should share the same 8 MSB bits in base address\n");
     350                            printf("[XML ERROR] All replicated peripherals "
     351                                   "must have cluster bits = cluster_xy * increment\n");
     352                            printf("periph index = %d / periph type = %d / vbase = %x\n",
     353                                    periph_id, type, vseg[vseg_id]->vbase);
     354                            exit(1);
     355                        }
     356                        else if ( periph_vbase_array[type] == 0xFFFFFFFF ) // vbase not set
     357                        {
     358                            periph_vbase_array[type] = vseg[vseg_id]->vbase & type_mask;   
     359                        }
     360                        else if ((vseg[vseg_id]->vbase & type_mask) != (periph_vbase_array[type]))
     361                        {
     362                            printf("[XML ERROR] All peripherals with same type"
     363                                   " should share the same 8 MSB bits in vbase address\n");
    330364                            printf("periph index = %d / periph type = %d / vbase = %x\n",
    331365                                    periph_id, type, vseg[vseg_id]->vbase);
     
    333367                        }
    334368                    }
    335    
    336                     // checking cluster bits for all replicated peripherals
    337                     if ( (type == PERIPH_TYPE_DMA) ||
    338                          (type == PERIPH_TYPE_MMC) ||
    339                          (type == PERIPH_TYPE_ICU) ||
    340                          (type == PERIPH_TYPE_XCU) ||
    341                          (type == PERIPH_TYPE_TIM) )
     369                    else                               // non replicated peripheral
    342370                    {
    343                         cluster_id = pseg[pseg_id]->clusterid;
    344                         cluster_xy = (cluster[cluster_id]->x << header->y_width) +
    345                                       cluster[cluster_id]->y;
    346 
    347                         if( (vseg[vseg_id]->vbase & cluster_mask) !=
    348                             (header->increment * cluster_xy) )
     371                        if ( (cluster[cluster_id]->x == header->x_io) && 
     372                             (cluster[cluster_id]->y == header->y_io) )   
    349373                        {
    350                             printf("[XML ERROR] All replicated peripherals ");
    351                             printf("must have cluster bits = cluster_id * increment");
    352                             printf("periph index = %d / periph type = %d / vbase = %x\n",
    353                                     periph_id, type, vseg[vseg_id]->vbase);
     374                            periph_vbase_array[type] = vseg[vseg_id]->vbase;   
     375                        }
     376                        else
     377                        {
     378                            printf("[XML ERROR] Non replicated peripherals must be in cluster_io\n");
     379                            printf(" periph index = %d / periph type = %d / vbase = %x"
     380                                   " / pseg index = %d / cluster index = %d\n",
     381                                    periph_id, type, vseg[vseg_id]->vbase, pseg_id, cluster_id);
    354382                            exit(1);
    355383                        }
    356                     } 
     384                    }
    357385                }
    358386            }
     
    428456}
    429457
     458///////////////////////////////////////////////////////////
     459unsigned int alignTo( unsigned int value, unsigned int pow2 )
     460{
     461    unsigned int mask = (1 << pow2) - 1;
     462    return ( (value + mask) & ~mask);
     463}
     464
     465////////////////////
     466void setVsegLength()
     467{
     468    // for a given vseg identified vseg_index
     469    // scan all contained vobjs to compute the vseg lenth
     470
     471    unsigned int vobj_id;
     472    unsigned int cur_length = 0;
     473
     474    unsigned int first = vseg[vseg_index]->vobj_offset;
     475    unsigned int last  = first + vseg[vseg_index]->vobjs;
     476
     477    for ( vobj_id = first ; vobj_id < last ; vobj_id++ )
     478    {
     479        if (vobj[vobj_id]->align)
     480        {
     481            cur_length = alignTo( cur_length, vobj[vobj_id]->align );
     482        }
     483        cur_length += vobj[vobj_id]->length;
     484    }
     485    vseg[vseg_index]->length = alignTo( cur_length, 12 );
     486}
     487
     488///////////////////////
     489void checkVsegOverlap()
     490{
     491    // for a given vseg identified by vseg_index,
     492    // check overlap with all vsegs in same vspace,
     493    // and check overlap with all global vsegs.
     494
     495    unsigned int vseg_id;
     496    unsigned int prev_vbase;                          // previous vseg vbase
     497    unsigned int prev_length;                         // previous vseg length
     498
     499    unsigned int vbase  = vseg[vseg_index]->vbase;    // new vseg vbase
     500    unsigned int length = vseg[vseg_index]->length;   // new vseg length
     501 
     502    // checking overlap with other vsegs in same vspace
     503    if ( header->vspaces > 0 )
     504    {
     505        unsigned int first = vspace[vspace_index]->vseg_offset;   
     506        unsigned int last  = vseg_index;
     507   
     508        for( vseg_id = first ; vseg_id < last ; vseg_id++ )
     509        {
     510            prev_vbase  = vseg[vseg_id]->vbase;
     511            prev_length = vseg[vseg_id]->length;
     512            if ( ((vbase + length) > prev_vbase) && ((prev_vbase + prev_length) > vbase) )
     513            {
     514                printf("[XML ERROR] vseg %s in vspace %s overlaps other vseg %s\n",
     515                vseg[vseg_index]->name, vspace[vspace_index]->name, vseg[vseg_id]->name );
     516                exit(1);
     517            }
     518        }
     519    }
     520
     521    // checking overlap with existing global vsegs
     522    for ( vseg_id = 0 ; vseg_id < header->globals ; vseg_id++ )
     523    {
     524        prev_vbase  = vseg[vseg_id]->vbase;
     525        prev_length = vseg[vseg_id]->length;
     526        if ( ((vbase + length) > prev_vbase) && ((prev_vbase + prev_length) > vbase) )
     527        {
     528            printf("[XML ERROR] vseg %s in vspace %s overlaps global vseg %s\n",
     529            vseg[vseg_index]->name, vspace[vspace_index]->name, vseg[vseg_id]->name );
     530            exit(1);
     531        }
     532    }
     533}
     534
    430535//////////////////////////////////////
    431536void taskNode(xmlTextReaderPtr reader)
     
    466571    }
    467572
    468     ///////// get x coordinate
     573    ///////// get trdid attribute (optional)
    469574    task[task_index]->trdid = getIntValue(reader, "trdid", &ok);
    470575#if XML_PARSER_DEBUG
    471 printf("      x         = %d\n", x);
     576printf("      trdid     = %d\n", x);
    472577#endif
    473578    if ( !ok )
    474579    {
    475580        task[task_index]->trdid = task_loc_index;
    476         printf("[XML WARNING] missing trdid (thread index) attribute "
    477                "for task in vspace %d. Using value %d\n"
    478                , vspace_index, task_loc_index);
    479581    } 
    480582
     
    720822    ////////// get length attribute
    721823    value = getIntValue(reader, "length", &ok);
    722     if (ok) {
    723 #if XML_PARSER_DEBUG
    724 printf("        length = %d\n", value);
     824    if (ok)
     825    {
     826#if XML_PARSER_DEBUG
     827printf("        length = %x\n", value);
    725828#endif
    726829        vobj[vobj_index]->length = value;
     
    734837    ////////// get align attribute (optional : 0 if missing)
    735838    value = getIntValue(reader, "align", &ok);
    736     if (ok) {
     839    if (ok)
     840    {
    737841#if XML_PARSER_DEBUG
    738842printf("        align = %d\n", value);
     
    740844        vobj[vobj_index]->align = value;
    741845    } 
    742     else {
     846    else
     847    {
    743848        vobj[vobj_index]->align = 0;
    744849    }
     
    746851    ////////// get binpath attribute (optional : '\0' if missing)
    747852    str = getStringValue(reader, "binpath", &ok);
    748     if (ok) {
     853    if (ok)
     854    {
    749855#if XML_PARSER_DEBUG
    750856printf("        binpath = %s\n", str);
     
    9581064        {
    9591065            vseg[vseg_index]->vobjs = vobj_count;
     1066            setVsegLength();
     1067            checkVsegOverlap();
    9601068            vseg_index++;
    9611069            vseg_loc_index++;
     
    9841092    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) return;
    9851093
    986     // checking source file consistency
    987     if (vspace_index >= header->vspaces) {
    988         printf("[XML ERROR] The vspace index is too large : %d\n",
    989                 vspace_index);
    990         exit(1);
    991     }
    992 
    9931094#if XML_PARSER_DEBUG
    9941095printf("\n  vspace %d\n", vspace_index);
     
    9961097
    9971098    vspace[vspace_index] = (mapping_vspace_t *) malloc(sizeof(mapping_vspace_t));
     1099    header->vspaces      = header->vspaces + 1;
    9981100
    9991101    ////////// get name attribute
     
    10361138
    10371139    int status = xmlTextReaderRead(reader);
    1038     while (status == 1) {
     1140    while (status == 1)
     1141    {
    10391142        const char * tag = (const char *) xmlTextReaderConstName(reader);
    10401143
     
    10501153        else if (strcmp(tag, "#text")    == 0) { }
    10511154        else if (strcmp(tag, "#comment") == 0) { }
    1052         else if (strcmp(tag, "vspace")   == 0) {
     1155        else if (strcmp(tag, "vspace")   == 0)
     1156        {
    10531157            vspace[vspace_index]->vobjs = vobj_loc_index;
    10541158            vspace[vspace_index]->tasks = task_loc_index ;
     
    10991203} // end vspaceNode()
    11001204
     1205/////////////////////////////////////
     1206void irqNode(xmlTextReaderPtr reader)
     1207{
     1208    unsigned int ok;
     1209    unsigned int value;
     1210    char * str;
     1211
     1212    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) return;
     1213
     1214    if (irq_index >= MAX_IRQS)
     1215    {
     1216        printf("[XML ERROR] The number of irqs is larger than %d\n", MAX_IRQS);
     1217    }
     1218
     1219#if XML_PARSER_DEBUG
     1220printf("      irq %d\n", irq_loc_index);
     1221#endif
     1222
     1223    irq[irq_index] = (mapping_irq_t *) malloc(sizeof(mapping_irq_t));
     1224
     1225    ///////// get srctype attribute
     1226    str = getStringValue(reader, "srctype", &ok);
     1227    if (ok)
     1228    {
     1229#if XML_PARSER_DEBUG
     1230printf("        srctype = %s\n", str);
     1231#endif
     1232        if      ( strcmp(str, "HWI") == 0 ) irq[irq_index]->srctype = IRQ_TYPE_HWI;
     1233        else if ( strcmp(str, "WTI") == 0 ) irq[irq_index]->srctype = IRQ_TYPE_WTI;
     1234        else if ( strcmp(str, "PTI") == 0 ) irq[irq_index]->srctype = IRQ_TYPE_PTI;
     1235        else   
     1236        {
     1237            printf("[XML ERROR] illegal IRQ <srctype> for periph %d in cluster %d\n",
     1238                    cluster_index, periph_loc_index);
     1239            exit(1);
     1240        }
     1241    }
     1242    else
     1243    {
     1244        printf("[XML ERROR] missing IRQ <srctype> for periph %d in cluster %d\n",
     1245                cluster_index, periph_loc_index);
     1246        exit(1);
     1247    }
     1248
     1249    ///////// get srcid attribute
     1250    value = getIntValue(reader, "srcid", &ok);
     1251    if (ok)
     1252    {
     1253#if XML_PARSER_DEBUG
     1254printf("        srcid   = %d\n", value);
     1255#endif
     1256        irq[irq_index]->srcid = value;
     1257        if (value >= 32)
     1258        {
     1259            printf("[XML ERROR] IRQ <srcid> too large for periph %d in cluster %d\n",
     1260                    cluster_index, periph_loc_index);
     1261            exit(1);
     1262        }
     1263    }
     1264    else
     1265    {
     1266        printf("[XML ERROR] missing IRQ <icuid> for periph %d in cluster %d\n",
     1267                cluster_index, periph_loc_index);
     1268        exit(1);
     1269    }
     1270
     1271    ///////// get isr attribute
     1272    str = getStringValue(reader, "isr", &ok);
     1273    if (ok)
     1274    {
     1275#if XML_PARSER_DEBUG
     1276printf("        isr     = %s\n", str);
     1277#endif
     1278        if      (strcmp(str, "ISR_TICK"   ) == 0)  irq[irq_index]->isr = ISR_TICK;
     1279        else if (strcmp(str, "ISR_BDV"    ) == 0)  irq[irq_index]->isr = ISR_BDV;
     1280        else if (strcmp(str, "ISR_CMA"    ) == 0)  irq[irq_index]->isr = ISR_CMA;
     1281        else if (strcmp(str, "ISR_TTY_RX" ) == 0)  irq[irq_index]->isr = ISR_TTY_RX;
     1282        else if (strcmp(str, "ISR_TTY_TX" ) == 0)  irq[irq_index]->isr = ISR_TTY_TX;
     1283        else if (strcmp(str, "ISR_TIMER"  ) == 0)  irq[irq_index]->isr = ISR_TIMER;
     1284        else if (strcmp(str, "ISR_WAKUP"  ) == 0)  irq[irq_index]->isr = ISR_WAKUP;
     1285        else if (strcmp(str, "ISR_NIC_RX" ) == 0)  irq[irq_index]->isr = ISR_NIC_RX;
     1286        else if (strcmp(str, "ISR_NIC_TX" ) == 0)  irq[irq_index]->isr = ISR_NIC_TX;
     1287        else if (strcmp(str, "ISR_DEFAULT") == 0)  irq[irq_index]->isr = ISR_DEFAULT;
     1288        else
     1289        {
     1290            printf("[XML ERROR] illegal IRQ <isr> for periph %d in cluster %d\n",
     1291                    cluster_index, periph_loc_index);
     1292            exit(1);
     1293        }
     1294    } 
     1295    else
     1296    {
     1297        printf("[XML ERROR] missing IRQ <isr> for periph %d in cluster %d\n",
     1298                cluster_index, periph_loc_index);
     1299        exit(1);
     1300    }
     1301
     1302    ///////// get channel attribute (optionnal : 0 if missing)
     1303    value = getIntValue(reader, "channel", &ok);
     1304    if (ok)
     1305    {
     1306#if XML_PARSER_DEBUG
     1307printf("        channel = %d\n", value);
     1308#endif
     1309        irq[irq_index]->channel = value;
     1310    }
     1311    else
     1312    {
     1313        irq[irq_index]->channel = 0;
     1314    }
     1315
     1316    ///////// get dstx attribute
     1317    value = getIntValue(reader, "dstx", &ok);
     1318    if (ok)
     1319    {
     1320#if XML_PARSER_DEBUG
     1321printf("        dstx    = %d\n", value);
     1322#endif
     1323
     1324        if ( value < header->x_size )
     1325        {
     1326            irq[irq_index]->dstx = value;
     1327        }
     1328        else
     1329        {
     1330            printf("[XML ERROR] IRQ <dstx> too large for periph %d in cluster %d\n",
     1331                    cluster_index, periph_loc_index);
     1332            exit(1);
     1333        }
     1334    }
     1335    else
     1336    {
     1337        printf("[XML ERROR] missing IRQ <dstx> for periph %d in cluster %d\n",
     1338                cluster_index, periph_loc_index);
     1339        exit(1);
     1340    }
     1341
     1342    ///////// get dsty attribute
     1343    value = getIntValue(reader, "dsty", &ok);
     1344    if (ok)
     1345    {
     1346#if XML_PARSER_DEBUG
     1347printf("        dsty    = %d\n", value);
     1348#endif
     1349
     1350        if ( value < header->y_size )
     1351        {
     1352            irq[irq_index]->dsty = value;
     1353        }
     1354        else
     1355        {
     1356            printf("[XML ERROR] IRQ <dsty> too large for periph %d in cluster %d\n",
     1357                    cluster_index, periph_loc_index);
     1358            exit(1);
     1359        }
     1360    }
     1361    else
     1362    {
     1363        printf("[XML ERROR] missing IRQ <dsty> for periph %d in cluster %d\n",
     1364                cluster_index, periph_loc_index);
     1365        exit(1);
     1366    }
     1367
     1368    ///////// get dstid attribute
     1369    value = getIntValue(reader, "dstid", &ok);
     1370    if (ok)
     1371    {
     1372#if XML_PARSER_DEBUG
     1373printf("        dstid   = %d\n", value);
     1374#endif
     1375        irq[irq_index]->dstid = value;
     1376        if (value >= 32)
     1377        {
     1378            printf("[XML ERROR] IRQ <dstid> too large for periph %d in cluster %d\n",
     1379                    cluster_index, periph_loc_index);
     1380            exit(1);
     1381        }
     1382    }
     1383    else
     1384    {
     1385        printf("[XML ERROR] missing IRQ <dstid> for periph %d in cluster %d\n",
     1386                cluster_index, periph_loc_index);
     1387        exit(1);
     1388    }
     1389
     1390    irq_index++;
     1391    irq_loc_index++;
     1392
     1393} // end irqNode
     1394
     1395
     1396
    11011397////////////////////////////////////////
    11021398void cpPortNode(xmlTextReaderPtr reader)
     
    11151411
    11161412#if XML_PARSER_DEBUG
    1117     printf("\n  port %d\n", cp_port_index);
     1413printf("\n  port %d\n", cp_port_index);
    11181414#endif
    11191415
     
    11261422    {
    11271423#if XML_PARSER_DEBUG
    1128         printf("      direction = %s\n", str);
     1424printf("      direction = %s\n", str);
    11291425#endif
    11301426        if (strcmp(str, "TO_COPROC")   ==  0)
     
    11531449    str = getStringValue(reader, "vspacename", &ok);
    11541450#if XML_PARSER_DEBUG
    1155     printf("      vspacename = %s\n", str);
     1451printf("      vspacename = %s\n", str);
    11561452#endif
    11571453    if (ok)
     
    11691465    str = getStringValue(reader, "vobjname", &ok);
    11701466#if XML_PARSER_DEBUG
    1171     printf("      vobjname = %s\n", str);
     1467printf("      vobjname = %s\n", str);
    11721468#endif
    11731469    if (ok)
     
    11921488    unsigned int ok;
    11931489
     1490    irq_loc_index = 0;
     1491
    11941492    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) return;
    11951493
     
    12011499
    12021500#if XML_PARSER_DEBUG
    1203     printf("\n  periph %d\n", periph_index);
     1501printf("\n    periph %d\n", periph_index);
    12041502#endif
    12051503
     
    12111509    {
    12121510#if XML_PARSER_DEBUG
    1213         printf("      channels = %d\n", value);
     1511printf("      channels    = %d\n", value);
    12141512#endif
    12151513        periph[periph_index]->channels = value;
     
    12341532    {
    12351533#if XML_PARSER_DEBUG
    1236         printf("      clusterid = %d\n", cluster_index);
    1237         printf("      psegname  = %s\n", str);
    1238         printf("      psegid    = %d\n", index);
     1534printf("      clusterid  = %d\n", cluster_index);
     1535printf("      psegname    = %s\n", str);
     1536printf("      psegid      = %d\n", index);
    12391537#endif
    12401538        periph[periph_index]->psegid = index;
     
    12521550    {
    12531551#if XML_PARSER_DEBUG
    1254         printf("      type      = %s\n", str);
     1552printf("      type        = %s\n", str);
    12551553#endif
    12561554        unsigned int error = 0;
     
    12601558
    12611559        // The CMA, FBF, HBA, IOB, IOC, NIC, ROM, SIM, TTY, peripherals are not
    1262         // replicated in all clusters but can be replicated in two clusters (fault tolerance)
    1263         // In case of replication, the two copies must have same number of channels.
     1560        // replicated in all clusters but can be instanciated twice.
    12641561
    12651562        ////////////////////////////
     
    12671564        {
    12681565            periph[periph_index]->type = PERIPH_TYPE_CMA;
    1269             if (header->cma_cluster == 0xFFFFFFFF) 
     1566            if ( cma_channels < periph[periph_index]->channels )
    12701567            {
    1271                 header->cma_cluster = cluster_index;
    12721568                cma_channels = periph[periph_index]->channels;
    12731569            }
    1274             else if (header->cma_cluster_bis == 0xFFFFFFFF)
    1275             {
    1276                 header->cma_cluster_bis = cluster_index;
    1277                 assert( (cma_channels == periph[periph_index]->channels) &&
    1278                 "[XML ERROR] unconsistent non replicated peripheral");
    1279             }
    1280             else 
    1281             {
    1282                 error = 1;
    1283             }
    12841570        }
    12851571        /////////////////////////////////
     
    12871573        {
    12881574            periph[periph_index]->type = PERIPH_TYPE_FBF;
    1289             if (header->fbf_cluster == 0xFFFFFFFF) 
    1290             {
    1291                 header->fbf_cluster = cluster_index;
    1292             }
    1293             else if (header->fbf_cluster_bis == 0xFFFFFFFF)
    1294             {
    1295                 header->fbf_cluster_bis = cluster_index;
    1296             }
    1297             else 
    1298             {
    1299                 error = 1;
    1300             }
    13011575        }
    13021576        /////////////////////////////////
     
    13051579            periph[periph_index]->type = PERIPH_TYPE_IOB;
    13061580            use_iob = 1;
    1307             if (header->iob_cluster == 0xFFFFFFFF) 
    1308             {
    1309                 header->iob_cluster = cluster_index;
    1310             }
    1311             else if (header->iob_cluster_bis == 0xFFFFFFFF)
    1312             {
    1313                 header->iob_cluster_bis = cluster_index;
    1314             }
    1315             else 
    1316             {
    1317                 error = 1;
    1318             }
    13191581        }
    13201582        /////////////////////////////////
    13211583        else if (strcmp(str, "IOC") == 0)
    13221584        {
    1323             periph[periph_index]->type = PERIPH_TYPE_IOC;
    1324             if (header->ioc_cluster == 0xFFFFFFFF)
    1325             {
    1326                 header->ioc_cluster  = cluster_index;
    1327             }
    1328             else if (header->ioc_cluster_bis == 0xFFFFFFFF)
    1329             {
    1330                 header->ioc_cluster_bis = cluster_index;
    1331             }
    1332             else
    1333             {
    1334                 printf("[XML ERROR] At most two copies for non replicated "
    1335                         "peripheral\n");
    1336                 exit(1);
    1337             }
    1338 
    1339             str = getStringValue(reader, "subtype", &ok);
    1340    
     1585            char* subtype = getStringValue(reader, "subtype", &ok);
    13411586            if (!ok)
    13421587            {
    1343                 printf("[XML ERROR] IOC peripheral needs a subtype parameter: "
    1344                        "BDV, HBA or SPI\n");
     1588                printf("[XML ERROR] IOC peripheral needs a subtype: BDV, HBA or SPI\n");
    13451589                exit(1);
    13461590            }
    13471591
    1348             if (strcmp(str, "BDV") == 0)
    1349             {
     1592            if ( strcmp(subtype, "BDV") == 0 )
     1593            {
     1594                periph[periph_index]->type    = PERIPH_TYPE_IOC;
    13501595                periph[periph_index]->subtype = PERIPH_SUBTYPE_BDV;
    1351                 use_bdv = 1;
     1596                ioc_channels = 1;
     1597                if ( header->use_ramdisk == 0 ) use_bdv = 1;
    13521598            }
    1353             else if (strcmp(str, "HBA") == 0)
     1599            else if ( strcmp(subtype, "HBA") == 0 )
    13541600            {
     1601                periph[periph_index]->type    = PERIPH_TYPE_IOC;
    13551602                periph[periph_index]->subtype = PERIPH_SUBTYPE_HBA;
    1356 
    1357                 if (use_hba == 0)
    1358                 {
    1359                     use_hba      = 1;
    1360                     hba_channels = periph[periph_index]->channels;
    1361                 }
    1362                 else
    1363                 {
    1364                     assert( (hba_channels == periph[periph_index]->channels) &&
    1365                     "[XML ERROR] unconsistent non replicated peripheral");
    1366                 }
     1603                ioc_channels = periph[periph_index]->channels;
     1604                if ( header->use_ramdisk == 0 ) use_hba = 1;
    13671605            }
    1368             else if (strcmp(str, "SPI") == 0)
     1606            else if ( strcmp(subtype, "SPI") == 0 )
    13691607            {
     1608                periph[periph_index]->type    = PERIPH_TYPE_IOC;
    13701609                periph[periph_index]->subtype = PERIPH_SUBTYPE_SPI;
    1371                 use_spi = 1;
     1610                ioc_channels = periph[periph_index]->channels;
     1611                if ( header->use_ramdisk == 0 ) use_spi = 1;
    13721612            }
    13731613            else
     
    13811621        {
    13821622            periph[periph_index]->type = PERIPH_TYPE_NIC;
    1383             if (header->nic_cluster == 0xFFFFFFFF) 
     1623            if ( nic_channels < periph[periph_index]->channels )
    13841624            {
    1385                 header->nic_cluster = cluster_index;
    13861625                nic_channels = periph[periph_index]->channels;
    13871626            }
    1388             else if (header->nic_cluster_bis == 0xFFFFFFFF)
    1389             {
    1390                 header->nic_cluster_bis = cluster_index;
    1391                 assert( (nic_channels == periph[periph_index]->channels) &&
    1392                 "[XML ERROR] unconsistent non replicated peripheral");
    1393             }
    1394             else 
    1395             {
    1396                 error = 1;
    1397             }
    13981627        }
    13991628        /////////////////////////////////
     
    14011630        {
    14021631            periph[periph_index]->type = PERIPH_TYPE_ROM;
    1403             if (header->rom_cluster == 0xFFFFFFFF)
    1404             {
    1405                 header->rom_cluster  = cluster_index;
    1406             }
    1407             else if (header->rom_cluster_bis == 0xFFFFFFFF)
    1408             {
    1409                 header->rom_cluster_bis = cluster_index;
    1410             }
    1411             else
    1412             {
    1413                 error = 1;
    1414             }
    14151632        }
    14161633        /////////////////////////////////
     
    14181635        {
    14191636            periph[periph_index]->type = PERIPH_TYPE_SIM;
    1420             if (header->sim_cluster == 0xFFFFFFFF)
    1421             {
    1422                 header->sim_cluster  = cluster_index;
    1423             }
    1424             else if (header->sim_cluster_bis == 0xFFFFFFFF)
    1425             {
    1426                 header->sim_cluster_bis = cluster_index;
    1427             }
    1428             else
    1429             {
    1430                 error = 1;
    1431             }
    14321637        }
    14331638        /////////////////////////////////
     
    14351640        {
    14361641            periph[periph_index]->type = PERIPH_TYPE_TTY;
    1437             if (header->tty_cluster == 0xFFFFFFFF)
     1642            if ( tty_channels < periph[periph_index]->channels )
    14381643            {
    1439                 header->tty_cluster = cluster_index;
    14401644                tty_channels = periph[periph_index]->channels;
    14411645            }
    1442             else if (header->tty_cluster_bis == 0xFFFFFFFF)
     1646        }
     1647        /////////////////////////////////
     1648        else if (strcmp(str, "PIC") == 0)
     1649        {
     1650            periph[periph_index]->type = PERIPH_TYPE_PIC;
     1651            if ( pic_channels < periph[periph_index]->channels )
    14431652            {
    1444                 header->tty_cluster_bis = cluster_index;
    1445                 assert( (tty_channels == periph[periph_index]->channels) &&
    1446                 "[XML ERROR] unconsistent non replicated peripheral");
     1653                pic_channels = periph[periph_index]->channels;
    14471654            }
    1448             else 
    1449             {
    1450                 error = 1;
    1451             }
    1452         }
     1655            use_pic = 1;
     1656        }
     1657
    14531658
    14541659        // The DMA, ICU, MMC, TIM, XCU peripherals can be replicated in all clusters
    1455         // but it must exist only one component of each type per cluster
     1660        // but no more than one component of each type per cluster
    14561661
    14571662        /////////////////////////////////
     
    14711676            found_icu = 1;
    14721677
    1473             if (icu_channels > 0)
     1678            if ( periph[periph_index]->channels <
     1679                 (header->irq_per_proc * cluster[cluster_index]->procs) )
    14741680            {
    1475                 assert( (periph[periph_index]->channels == icu_channels) &&
    1476                         "[XML ERROR] the number of interruptions per processor "
    1477                         "from the ICU (icu channels) must be the same on all "
    1478                         "clusters");
    1479             }
    1480             else
    1481             {
    1482                 icu_channels = periph[periph_index]->channels;
     1681                printf("[XML ERROR] ICU channels smaller than PROCS * IRQ_PER_PROC\n");
     1682                printf(" - icu channels = %d\n - nprocs = %d\n - irq_per_proc = %d\n",
     1683                       periph[periph_index]->channels,
     1684                       cluster[cluster_index]->procs,
     1685                       header->irq_per_proc );
     1686                exit(1);
    14831687            }
    14841688        }
     
    14981702            found_timer = 1;
    14991703            if (tim_channels < periph[periph_index]->channels)
    1500             {
    15011704                tim_channels = periph[periph_index]->channels;
    1502             }
    15031705        }
    15041706        //////////////////////////////////
     
    15121714            use_xcu      = 1;
    15131715
    1514             if (icu_channels > 0)
     1716            if ( periph[periph_index]->channels <
     1717                 (header->irq_per_proc * cluster[cluster_index]->procs) )
    15151718            {
    1516                 assert( (periph[periph_index]->channels == icu_channels) &&
    1517                         "[XML ERROR] the number of interruptions per processor "
    1518                         "from the ICU (icu channels) must be the same on all "
    1519                         "clusters");
     1719                printf("[XML ERROR] XCU channels smaller than PROCS * IRQ_PER_PROC\n");
     1720                printf(" - xcu channels = %d\n - nprocs = %d\n - irq_per_proc = %d\n",
     1721                       periph[periph_index]->channels,
     1722                       cluster[cluster_index]->procs,
     1723                       header->irq_per_proc );
     1724                exit(1);
     1725            }
     1726        }
     1727        else
     1728        {
     1729            printf("[XML ERROR] illegal peripheral type: %s in cluster %d\n",
     1730                    str, cluster_index);
     1731            exit(1);
     1732        }
     1733
     1734        if (error)
     1735        {
     1736            printf("[XML ERROR] illegal peripheral %s in cluster %d\n",
     1737                    str, cluster_index);
     1738            exit(1);
     1739        }
     1740    }
     1741    else
     1742    {
     1743        printf("[XML ERROR] illegal or missing <type> for peripheral  %d in cluster %d\n",
     1744                periph_loc_index, cluster_index);
     1745        exit(1);
     1746    }
     1747
     1748    ////////////// set irq_offset attribute
     1749    periph[periph_index]->irq_offset = irq_index;
     1750
     1751#if XML_PARSER_DEBUG
     1752printf("      irq_offset  = %d\n", irq_index );
     1753#endif
     1754
     1755    ///////////// get IRQs
     1756    int status = xmlTextReaderRead(reader);
     1757    while (status == 1)
     1758    {
     1759        const char * tag = (const char *) xmlTextReaderConstName(reader);
     1760
     1761        if (strcmp(tag, "irq") == 0)
     1762        {
     1763            if ( (periph[periph_index]->type != PERIPH_TYPE_ICU) &&
     1764                 (periph[periph_index]->type != PERIPH_TYPE_XCU) &&
     1765                 (periph[periph_index]->type != PERIPH_TYPE_PIC) )
     1766            {
     1767                printf("[XML ERROR] periph %d in cluster(%d,%d) "
     1768                       " only ICU, XCU and PIC can contain IRQs",
     1769                periph_loc_index, cluster[cluster_index]->x, cluster[cluster_index]->y);
     1770                exit(1);
    15201771            }
    15211772            else
    15221773            {
    1523                 icu_channels = periph[periph_index]->channels;
     1774                  irqNode(reader);
    15241775            }
    15251776        }
     1777        else if (strcmp(tag, "#text")    == 0) { }
     1778        else if (strcmp(tag, "#comment") == 0) { }
     1779        else if (strcmp(tag, "periph")   == 0)
     1780        {
     1781            periph[periph_index]->irqs = irq_loc_index;
     1782            cluster[cluster_index]->periphs++;
     1783            periph_loc_index++;
     1784            periph_index++;
     1785
     1786#if XML_PARSER_DEBUG
     1787printf("      irqs        = %d\n", irq_loc_index);
     1788printf("      irq_offset  = %d\n", irq_index);
     1789#endif
     1790            return;
     1791        }
    15261792        else
    15271793        {
    1528             printf("[XML ERROR] illegal <type>: %s for peripheral %d in cluster %d\n",
    1529                     str, periph_loc_index, cluster_index);
     1794            printf("[XML ERROR] Unknown tag %s", tag);
    15301795            exit(1);
    15311796        }
    1532 
    1533         if (error)
    1534         {
    1535             printf("[XML ERROR] illegal <type>: %s for peripheral %d in cluster %d\n",
    1536                     str, periph_loc_index, cluster_index);
    1537             exit(1);
    1538         }
    1539     }
    1540     else
    1541     {
    1542         printf("[XML ERROR] missing <type> for peripheral  %d in cluster %d\n",
    1543                 periph_loc_index, cluster_index);
    1544         exit(1);
    1545     }
    1546 
    1547     periph_index++;
    1548     periph_loc_index++;
    1549     cluster[cluster_index]->periphs++;
    1550 
     1797        status = xmlTextReaderRead(reader);
     1798    }
    15511799} // end periphNode
    15521800
     
    15681816
    15691817#if XML_PARSER_DEBUG
    1570     printf("\n  coproc %d\n", coproc_index);
     1818printf("\n  coproc %d\n", coproc_index);
    15711819#endif
    15721820
     
    15781826    {
    15791827#if XML_PARSER_DEBUG
    1580         printf("      name = %s\n", str);
     1828printf("      name = %s\n", str);
    15811829#endif
    15821830        strncpy(coproc[coproc_index]->name, str, 31);
     
    16031851    {
    16041852#if XML_PARSER_DEBUG
    1605         printf("      clusterid = %d\n", cluster_index);
    1606         printf("      psegname  = %s\n", str);
    1607         printf("      psegid    = %d\n", index);
     1853printf("      clusterid = %d\n", cluster_index);
     1854printf("      psegname  = %s\n", str);
     1855printf("      psegid    = %d\n", index);
    16081856#endif
    16091857        coproc[coproc_index]->psegid = index;
    1610         assert(pseg[index]->type == PSEG_TYPE_PERI && "coproc psegname attribute must refer to a pseg of type PERI" );
     1858        assert(pseg[index]->type == PSEG_TYPE_PERI &&
     1859        "coproc psegname attribute must refer to a pseg of type PERI" );
    16111860    }
    16121861    else
     
    16211870
    16221871#if XML_PARSER_DEBUG
    1623     printf("      port_offset = %d\n", cp_port_index);
     1872printf("      port_offset = %d\n", cp_port_index);
    16241873#endif
    16251874
     
    16531902
    16541903
    1655 /////////////////////////////////////
    1656 void irqNode(xmlTextReaderPtr reader)
     1904//////////////////////////////////////
     1905void procNode(xmlTextReaderPtr reader)
    16571906{
    16581907    unsigned int ok;
    16591908    unsigned int value;
    1660     char * str;
    16611909
    16621910    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) return;
    16631911
    1664     if (irq_index >= MAX_IRQS) {
    1665         printf("[XML ERROR] The number of irqs is larger than %d\n", MAX_IRQS);
    1666     }
    1667 
    1668 #if XML_PARSER_DEBUG
    1669     printf("     irq %d\n", irq_loc_index);
    1670 #endif
    1671 
    1672     irq[irq_index] = (mapping_irq_t *) malloc(sizeof(mapping_irq_t));
    1673 
    1674     ///////// get type attribute
    1675     str = getStringValue(reader, "type", &ok);
    1676     if (ok)
    1677     {
    1678 #if XML_PARSER_DEBUG
    1679         printf("        type    = %s\n", str);
    1680 #endif
    1681         if      ( strcmp(str, "HARD") == 0 ) irq[irq_index]->type = IRQ_TYPE_HWI;
    1682         else if ( strcmp(str, "SOFT") == 0 ) irq[irq_index]->type = IRQ_TYPE_SWI;
    1683         else if ( strcmp(str, "TIME") == 0 ) irq[irq_index]->type = IRQ_TYPE_PTI;
    1684         else   
    1685         {
    1686             printf("[XML ERROR] illegal IRQ <type> for processor %d in cluster %d\n",
    1687                     cluster_index, proc_loc_index);
    1688             exit(1);
    1689         }
    1690     }
    1691     else
    1692     {
    1693         printf("[XML ERROR] missing IRQ <type> for processor %d in cluster %d\n",
    1694                 cluster_index, proc_loc_index);
    1695         exit(1);
    1696     }
    1697 
    1698     ///////// get icuid attribute
    1699     value = getIntValue(reader, "icuid", &ok);
    1700     if (ok)
    1701     {
    1702 #if XML_PARSER_DEBUG
    1703         printf("        icuid   = %d\n", value);
    1704 #endif
    1705         irq[irq_index]->icuid = value;
    1706         if (value >= 32)
    1707         {
    1708             printf("[XML ERROR] IRQ <icuid> too large for processor %d in cluster %d\n",
    1709                     cluster_index, proc_loc_index);
    1710             exit(1);
    1711         }
    1712     }
    1713     else
    1714     {
    1715         printf("[XML ERROR] missing IRQ <icuid> for processor %d in cluster %d\n",
    1716                 cluster_index, proc_loc_index);
    1717         exit(1);
    1718     }
    1719 
    1720     ///////// get isr attribute
    1721     str = getStringValue(reader, "isr", &ok);
    1722     if (ok)
    1723     {
    1724 #if XML_PARSER_DEBUG
    1725         printf("        isr     = %s\n", str);
    1726 #endif
    1727         if      (strcmp(str, "ISR_SWITCH" ) == 0)  irq[irq_index]->isr = ISR_SWITCH;
    1728         else if (strcmp(str, "ISR_IOC"    ) == 0)  irq[irq_index]->isr = ISR_IOC;
    1729         else if (strcmp(str, "ISR_DMA"    ) == 0)  irq[irq_index]->isr = ISR_DMA;
    1730         else if (strcmp(str, "ISR_TTY"    ) == 0)  irq[irq_index]->isr = ISR_TTY;
    1731         else if (strcmp(str, "ISR_TIMER"  ) == 0)  irq[irq_index]->isr = ISR_TIMER;
    1732         else if (strcmp(str, "ISR_WAKUP"  ) == 0)  irq[irq_index]->isr = ISR_WAKUP;
    1733         else if (strcmp(str, "ISR_DEFAULT") == 0)  irq[irq_index]->isr = ISR_DEFAULT;
    1734         else
    1735         {
    1736             printf("[XML ERROR] illegal IRQ <isr> for processor %d in cluster %d\n",
    1737                     cluster_index, proc_loc_index);
    1738             exit(1);
    1739         }
    1740 #if XML_PARSER_DEBUG
    1741         printf("        isrnum  = %d\n", irq[irq_index]->isr);
    1742 #endif
    1743     } 
    1744     else
    1745     {
    1746         printf("[XML ERROR] missing IRQ <isr> for processor %d in cluster %d\n",
    1747                 cluster_index, proc_loc_index);
    1748         exit(1);
    1749     }
    1750 
    1751     ///////// get channel attribute (optionnal : 0 if missing)
    1752     value = getIntValue(reader, "channel", &ok);
    1753     if (ok)
    1754     {
    1755 #if XML_PARSER_DEBUG
    1756         printf("        channel = %d\n", value);
    1757 #endif
    1758         irq[irq_index]->channel = value;
    1759     }
    1760     else
    1761     {
    1762         irq[irq_index]->channel = 0;
    1763     }
    1764 
    1765     irq_index++;
    1766     irq_loc_index++;
    1767 
    1768 } // end irqNode
    1769 
    1770 
    1771 //////////////////////////////////////
    1772 void procNode(xmlTextReaderPtr reader)
    1773 {
    1774     unsigned int ok;
    1775     unsigned int value;
    1776 
    1777     irq_loc_index = 0;
    1778 
    1779     if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) return;
    1780 
    17811912    if (proc_index >= MAX_PROCS)
    17821913    {
     
    17861917
    17871918#if XML_PARSER_DEBUG
    1788     printf("\n  proc %d\n", proc_index);
     1919printf("\n    proc %d\n", proc_index);
    17891920#endif
    17901921
     
    17991930        exit(1);
    18001931    }
    1801 
    1802     ////////// set irq_offset attribute
    1803     proc[proc_index]->irq_offset = irq_index;
    1804 
    1805 #if XML_PARSER_DEBUG
    1806     printf("    irq_offset = %d\n", irq_index);
    1807 #endif
    1808 
    1809     int status = xmlTextReaderRead(reader);
    1810     while (status == 1)
    1811     {
    1812         const char * tag = (const char *) xmlTextReaderConstName(reader);
    1813 
    1814         if (strcmp(tag, "irq") == 0)
    1815         {
    1816             irqNode(reader);
    1817         }
    1818         else if (strcmp(tag, "#text")    == 0) { }
    1819         else if (strcmp(tag, "#comment") == 0) { }
    1820         else if (strcmp(tag, "proc")     == 0)
    1821         {
    1822             proc[proc_index]->irqs = irq_loc_index;
    1823             cluster[cluster_index]->procs++;
    1824             proc_loc_index++;
    1825             proc_index++;
    1826             return;
    1827         }
    1828         else
    1829         {
    1830             printf("[XML ERROR] Unknown tag %s", tag);
    1831             exit(1);
    1832         }
    1833         status = xmlTextReaderRead(reader);
    1834     }
     1932    proc[proc_index]->index = proc_loc_index;
     1933
     1934    cluster[cluster_index]->procs++;
     1935    proc_loc_index++;
     1936    proc_index++;
    18351937} // end procNode()
    18361938
     
    18521954
    18531955#if XML_PARSER_DEBUG
    1854     printf("    pseg %d\n", pseg_index);
     1956printf("    pseg %d\n", pseg_index);
    18551957#endif
    18561958
     
    18601962    str = getStringValue(reader, "name", &ok);
    18611963#if XML_PARSER_DEBUG
    1862     printf("      name = %s\n", str);
     1964printf("      name = %s\n", str);
    18631965#endif
    18641966    if (ok)
     
    18761978    str = getStringValue(reader, "type", &ok);
    18771979#if XML_PARSER_DEBUG
    1878     printf("      type = %s\n", str);
     1980printf("      type = %s\n", str);
    18791981#endif
    18801982    if      (ok && (strcmp(str, "RAM" ) == 0)) { pseg[pseg_index]->type = PSEG_TYPE_RAM; }
     
    18911993    ll_value = getPaddrValue(reader, "base", &ok);
    18921994#if XML_PARSER_DEBUG
    1893     printf("      base = 0x%llx\n", ll_value);
     1995printf("      base = 0x%llx\n", ll_value);
    18941996#endif
    18951997    if (ok)
     
    19062008    ll_value = getPaddrValue(reader, "length", &ok);
    19072009#if XML_PARSER_DEBUG
    1908     printf("      length = 0x%llx\n", ll_value);
     2010printf("      length = 0x%llx\n", ll_value);
    19092011#endif
    19102012    if (ok)
     
    19562058    found_mmc   = 0;
    19572059
    1958     if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) {
    1959         return;
    1960     }
     2060    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT)  return;
    19612061
    19622062#if XML_PARSER_DEBUG
     
    20242124        else if (strcmp(tag, "cluster")  == 0)
    20252125        {
    2026 
    2027             ///////// TIMER and ICU peripheral are mandatory //////////////
    2028             if (!found_timer && !found_xcu)
     2126            ///////// TIMER and ICU peripheral are mandatory when nprocs != 0
     2127            unsigned int procs = cluster[cluster_index]->procs;
     2128            if ( procs && !found_timer && !found_xcu)
    20292129            {
    20302130                printf("[XML ERROR] missing timer peripheral in cluster %d\n", cluster_index);
     
    20322132            }
    20332133
    2034             if (!found_icu && !found_xcu)
     2134            if ( procs && !found_icu && !found_xcu)
    20352135            {
    20362136                printf("[XML ERROR] missing icu peripheral in cluster %d\n", cluster_index);
     
    20382138            }
    20392139
    2040             if (nb_proc_max < cluster[cluster_index]->procs)
    2041             {
    2042                 nb_proc_max = cluster[cluster_index]->procs;
    2043             }
     2140            if (nb_procs_max < procs) nb_procs_max = procs;
    20442141
    20452142#if XML_PARSER_DEBUG
     
    20772174        else if (strcmp(tag, "clusterset") == 0)
    20782175        {
    2079             // checking source file consistency
     2176            // checking number of clusters
    20802177            if ( cluster_index != (header->x_size * header->y_size) )
    20812178            {
     
    20842181            }
    20852182
    2086             // At least one TTY terminal for system boot
    2087             if (header->tty_cluster == 0xFFFFFFFF)
     2183            // checking TTY terminal for system boot
     2184            if ( tty_channels == 0 )
    20882185            {
    2089                 printf("[XML ERROR] illegal or missing tty peripheral");
     2186                printf("[XML ERROR] missing TTY peripheral\n");
    20902187                exit(1);
    20912188            }
    20922189
    2093             // the number of ICU channels must be NB_PROCS * irq_per_proc
    2094             if (icu_channels != (header->irq_per_proc * proc_loc_index))
     2190            // checking IOC sub-types
     2191            if ( (use_bdv + use_hba + use_spi) > 1 )
    20952192            {
    2096                 printf("[XML ERROR] illegal ICU number of channels. "
    2097                        "It must be equal to NB_PROCS * IRQ_PER_PROC\n");
     2193                printf("[XML ERROR] all IOC peripherals must have the same type\n");
    20982194                exit(1);
    20992195            }
     
    21342230        const char * tag = (const char *) xmlTextReaderConstName(reader);
    21352231
    2136         if      (strcmp(tag, "vseg")      == 0) { vsegNode(reader); }
     2232        if      (strcmp(tag, "vseg")      == 0)
     2233        {
     2234            vsegNode( reader );
     2235            header->globals = header->globals + 1;
     2236        }
    21372237        else if (strcmp(tag, "#text")     == 0) { }
    21382238        else if (strcmp(tag, "#comment")  == 0) { }
     
    21422242            printf("  end global set\n\n");
    21432243#endif
    2144             header->globals = vseg_index;
    21452244            vseg_loc_index = 0;
    21462245            return;
     
    21782277        else if (strcmp(tag, "vspaceset") == 0 )
    21792278        {
    2180             // checking source file consistency
    2181             if (vspace_index != header->vspaces)
    2182             {
    2183                 printf("[XML ERROR] Wrong number of vspaces\n");
    2184                 exit(1);
    2185             }
    2186             else
    2187             {
    2188                 header->vsegs = vseg_index;
    2189                 header->vobjs = vobj_index;
    2190                 header->tasks = task_index;
    2191                 return;
    2192             }
     2279            header->vsegs = vseg_index;
     2280            header->vobjs = vobj_index;
     2281            header->tasks = task_index;
     2282            return;
    21932283        }
    21942284        else
     
    22822372    }
    22832373
    2284     //check the number of cluster
     2374    /////////// get x_io attribute
     2375    unsigned int x_io = getIntValue(reader, "x_io", &ok);
     2376#if XML_PARSER_DEBUG
     2377        printf("  x_io      = %d\n", x_io);
     2378#endif
     2379    if ( ok && (x_io < x_size) )
     2380    {
     2381        header->x_io = x_io;
     2382    }
     2383    else
     2384    {
     2385        printf("[XML ERROR] illegal or missing <x_io> attribute in header\n");
     2386        exit(1);
     2387    }
     2388
     2389    /////////// get y_io attribute
     2390    unsigned int y_io = getIntValue(reader, "y_io", &ok);
     2391#if XML_PARSER_DEBUG
     2392        printf("  y_io      = %d\n", y_size);
     2393#endif
     2394    if ( ok &&(y_io < y_size) )
     2395    {
     2396        header->y_io = y_io;
     2397    }
     2398    else
     2399    {
     2400        printf("[XML ERROR] illegal or missing <y_io> attribute in header\n");
     2401        exit(1);
     2402    }
     2403
     2404    // check the number of cluster
    22852405    if ( (x_size * y_size) >= MAX_CLUSTERS )
    22862406    {
     
    22892409    }
    22902410
    2291     ///////// get vspaces attribute
    2292     value = getIntValue(reader, "vspaces", &ok);
    2293     if (ok)
    2294     {
    2295         if (value >= MAX_VSPACES)
    2296         {
    2297             printf("[XML ERROR] The number of vspaces is larger than %d\n", MAX_VSPACES);
    2298             exit(1);
    2299         }
    2300 #if XML_PARSER_DEBUG
    2301         printf("  vspaces = %d\n", value);
    2302 #endif
    2303         header->vspaces  = value;
    2304     }
    2305     else
    2306     {
    2307         printf("[XML ERROR] illegal or missing <vspaces> attribute in mapping\n");
    2308         exit(1);
    2309     }
    2310 
    2311     ///////// get increment attribute
    2312     value = getIntValue(reader, "increment", &ok);
    2313     if (ok)
    2314     {
    2315         if ( (value != 0x10000) && (value != 0x8000) &&
    2316              (value != 0x4000)  && (value != 0x2000) )
    2317        
    2318         {
    2319             printf("[XML ERROR] The vseg increment must be one of the following: ");
    2320             printf(" 0x00010000 / 0x00008000 / 0x00004000 / 0x00002000");
    2321             exit(1);
    2322         }
    2323 #if XML_PARSER_DEBUG
    2324         printf("  increment = %d\n", value);
    2325 #endif
    2326         header->increment  = value;
    2327     }
    2328     else
    2329     {
    2330         printf("[XML ERROR] illegal or missing <increment> attribute in mapping\n");
    2331         exit(1);
    2332     }
    2333 
    2334     ///////// get increment attribute
     2411    ///////// get irq_per_proc attribute
    23352412    value = getIntValue(reader, "irq_per_proc", &ok);
    23362413    if (ok)
     
    23472424    }
    23482425
    2349     //////// initialise non replicated peripherals cluster index
    2350     header->cma_cluster     = 0xFFFFFFFF;
    2351     header->cma_cluster_bis = 0xFFFFFFFF;
    2352 
    2353     header->fbf_cluster     = 0xFFFFFFFF;
    2354     header->fbf_cluster_bis = 0xFFFFFFFF;
    2355 
    2356     header->iob_cluster     = 0xFFFFFFFF;
    2357     header->iob_cluster_bis = 0xFFFFFFFF;
    2358 
    2359     header->ioc_cluster     = 0xFFFFFFFF;
    2360     header->ioc_cluster_bis = 0xFFFFFFFF;
    2361 
    2362     header->nic_cluster     = 0xFFFFFFFF;
    2363     header->nic_cluster_bis = 0xFFFFFFFF;
    2364 
    2365     header->rom_cluster     = 0xFFFFFFFF;
    2366     header->rom_cluster_bis = 0xFFFFFFFF;
    2367 
    2368     header->sim_cluster     = 0xFFFFFFFF;
    2369     header->sim_cluster_bis = 0xFFFFFFFF;
    2370 
    2371     header->tty_cluster     = 0xFFFFFFFF;
    2372     header->tty_cluster_bis = 0xFFFFFFFF;
    2373 
    2374     ///////// set signature
     2426    ///////// get use_ramdisk attribute (default = 0)
     2427    value = getIntValue(reader, "use_ramdisk", &ok);
     2428    if (ok)
     2429    {
     2430#if XML_PARSER_DEBUG
     2431        printf("  use_ramdisk = %d\n", value);
     2432#endif
     2433        header->use_ramdisk = value;
     2434    }
     2435    else
     2436    {
     2437        header->use_ramdisk = 0;
     2438    }
     2439
     2440    ///////// set other header fields
     2441    header->increment = 0x10000;
    23752442    header->signature = IN_MAPPING_SIGNATURE;
     2443    header->globals   = 0;
     2444    header->vspaces   = 0;
     2445    header->psegs     = 0;
     2446    header->vsegs     = 0;
     2447    header->vobjs     = 0;
     2448    header->tasks     = 0;
     2449    header->procs     = 0;
     2450    header->irqs      = 0;
     2451    header->coprocs   = 0;
     2452    header->cp_ports  = 0;
     2453    header->periphs   = 0;
     2454
    23762455
    23772456    int status = xmlTextReaderRead(reader);
     
    23802459        const char * tag = (const char *) xmlTextReaderConstName(reader);
    23812460
    2382         if (strcmp(tag, "clusterset") == 0)
    2383         {
    2384             clusterSetNode(reader);
    2385         }
     2461        if      (strcmp(tag, "clusterset")   == 0) { clusterSetNode(reader); }
    23862462        else if (strcmp(tag, "globalset")    == 0) { globalSetNode(reader); }
    23872463        else if (strcmp(tag, "vspaceset")    == 0) { vspaceSetNode(reader); }
     
    25912667    def_int_write(fdout, "X_WIDTH           ", header->x_width);
    25922668    def_int_write(fdout, "Y_WIDTH           ", header->y_width);
     2669    def_int_write(fdout, "X_IO              ", header->x_io);
     2670    def_int_write(fdout, "Y_IO              ", header->y_io);
    25932671
    25942672    file_write(fdout, "\n");
    25952673
    2596     def_int_write(fdout, "NB_PROCS_MAX      ", nb_proc_max);
     2674    def_int_write(fdout, "NB_PROCS_MAX      ", nb_procs_max);
    25972675    def_int_write(fdout, "NB_TASKS_MAX      ", nb_tasks_max);
    25982676
     
    26052683
    26062684    def_int_write(fdout, "NB_TTY_CHANNELS   ", tty_channels);
    2607     def_int_write(fdout, "NB_HBA_CHANNELS   ", hba_channels);
     2685    def_int_write(fdout, "NB_IOC_CHANNELS   ", ioc_channels);
    26082686    def_int_write(fdout, "NB_NIC_CHANNELS   ", nic_channels);
    26092687    def_int_write(fdout, "NB_CMA_CHANNELS   ", cma_channels);
     
    26132691    def_int_write(fdout, "USE_XICU          ", use_xcu);
    26142692    def_int_write(fdout, "USE_IOB           ", use_iob);
    2615     def_int_write(fdout, "USE_HBA           ", use_hba);
    2616     def_int_write(fdout, "USE_BDV           ", use_bdv);
    2617     def_int_write(fdout, "USE_SPI           ", use_spi);
     2693    def_int_write(fdout, "USE_PIC           ", use_pic);
     2694
     2695    file_write(fdout, "\n");
     2696
     2697    def_int_write(fdout, "USE_IOC_RDK       ", header->use_ramdisk);
     2698    def_int_write(fdout, "USE_IOC_HBA       ", use_hba);
     2699    def_int_write(fdout, "USE_IOC_BDV       ", use_bdv);
     2700    def_int_write(fdout, "USE_IOC_SPI       ", use_spi);
    26182701
    26192702    file_write(fdout, "\n");
     
    26382721{
    26392722    int          fdout = open_file(file_path);
    2640     unsigned int count = 0;
     2723    unsigned int count;
    26412724    unsigned int vseg_id;
    26422725    unsigned int base;      // vseg base
     
    26482731    file_write(fdout, prol);
    26492732
    2650     // boot and kernel segments
    2651     for (vseg_id = 0 ; vseg_id < header->vsegs ; vseg_id++)
     2733    // boot mandatory global vsegs
     2734    for (vseg_id = 0 , count = 0 ; vseg_id < header->vsegs ; vseg_id++)
    26522735    {
    26532736        if ( strcmp(vseg[vseg_id]->name, "seg_boot_code") == 0 )
     
    26912774            count++;
    26922775        }
    2693         else if ( strcmp(vseg[vseg_id]->name, "seg_kernel_code") == 0 )
    2694         {
    2695             base = vseg[vseg_id]->vbase;
    2696             size = vobj[vseg[vseg_id]->vobj_offset]->length;
    2697             ld_write(fdout, "seg_kernel_code_base    ", base);
    2698             ld_write(fdout, "seg_kernel_code_size    ", size);
    2699             count++;
    2700         }
    2701         else if ( strcmp(vseg[vseg_id]->name, "seg_kernel_data") == 0 )
    2702         {
    2703             base = vseg[vseg_id]->vbase;
    2704             size = vobj[vseg[vseg_id]->vobj_offset]->length;
    2705             ld_write(fdout, "seg_kernel_data_base    ", base);
    2706             ld_write(fdout, "seg_kernel_data_size    ", size);
    2707             count++;
    2708         }
    2709         else if ( strcmp(vseg[vseg_id]->name, "seg_kernel_uncdata") == 0 )
    2710         {
    2711             base = vseg[vseg_id]->vbase;
    2712             size = vobj[vseg[vseg_id]->vobj_offset]->length;
    2713             ld_write(fdout, "seg_kernel_uncdata_base ", base);
    2714             ld_write(fdout, "seg_kernel_uncdata_size ", size);
    2715             count++;
    2716         }
    2717         else if ( strcmp(vseg[vseg_id]->name, "seg_kernel_init") == 0 )
    2718         {
    2719             base = vseg[vseg_id]->vbase;
    2720             size = vobj[vseg[vseg_id]->vobj_offset]->length;
    2721             ld_write(fdout, "seg_kernel_init_base    ", base);
    2722             ld_write(fdout, "seg_kernel_init_size    ", size);
    2723             count++;
    2724         }
    2725     }
    2726     if ( count != 9 )
     2776    }
     2777
     2778    if ( count != 5 )
    27272779    {
    2728         printf ("[XML ERROR] Missing Boot or Kernel vseg : only %d\n", count);
     2780        printf ("[XML ERROR] Missing mandatory Boot global vseg : only %d\n", count);
    27292781        printf ("Mandatory segments are :\n");
    27302782        printf (" - seg_boot_code\n");
     
    27332785        printf (" - seg_boot_mapping\n");
    27342786        printf (" - seg_boot_buffer\n");
     2787        exit(0);
     2788    }
     2789
     2790    file_write(fdout, "\n");
     2791
     2792    // kernel mandatory global vsegs
     2793    for (vseg_id = 0, count = 0 ; vseg_id < header->vsegs ; vseg_id++)
     2794    {
     2795        if ( strcmp(vseg[vseg_id]->name, "seg_kernel_code") == 0 )
     2796        {
     2797            base = vseg[vseg_id]->vbase;
     2798            size = vobj[vseg[vseg_id]->vobj_offset]->length;
     2799            ld_write(fdout, "seg_kernel_code_base    ", base);
     2800            ld_write(fdout, "seg_kernel_code_size    ", size);
     2801            count++;
     2802        }
     2803        else if ( strcmp(vseg[vseg_id]->name, "seg_kernel_data") == 0 )
     2804        {
     2805            base = vseg[vseg_id]->vbase;
     2806            size = vobj[vseg[vseg_id]->vobj_offset]->length;
     2807            ld_write(fdout, "seg_kernel_data_base    ", base);
     2808            ld_write(fdout, "seg_kernel_data_size    ", size);
     2809            count++;
     2810        }
     2811        else if ( strcmp(vseg[vseg_id]->name, "seg_kernel_uncdata") == 0 )
     2812        {
     2813            base = vseg[vseg_id]->vbase;
     2814            size = vobj[vseg[vseg_id]->vobj_offset]->length;
     2815            ld_write(fdout, "seg_kernel_uncdata_base ", base);
     2816            ld_write(fdout, "seg_kernel_uncdata_size ", size);
     2817            count++;
     2818        }
     2819        else if ( strcmp(vseg[vseg_id]->name, "seg_kernel_init") == 0 )
     2820        {
     2821            base = vseg[vseg_id]->vbase;
     2822            size = vobj[vseg[vseg_id]->vobj_offset]->length;
     2823            ld_write(fdout, "seg_kernel_init_base    ", base);
     2824            ld_write(fdout, "seg_kernel_init_size    ", size);
     2825            count++;
     2826        }
     2827    }
     2828    if ( count != 4 )
     2829    {
     2830        printf ("[XML ERROR] Missing mandatory Kernel global vseg : only %d\n", count);
     2831        printf ("Mandatory segments are :\n");
    27352832        printf (" - seg_kernel_code\n");
    27362833        printf (" - seg_kernel_data\n");
    27372834        printf (" - seg_kernel_uncdata\n");
    27382835        printf (" - seg_kernel_init\n");
    2739     }
    2740 
     2836        exit(0);
     2837    }
     2838
     2839    file_write(fdout, "\n");
     2840
     2841    // boot and kernel optionnal global vsegs (pseudo ROMs)
     2842    unsigned int seg_ram_disk_base    = 0xFFFFFFFF;
     2843    unsigned int seg_ram_disk_size    = 0;
     2844    unsigned int seg_reset_code_base  = 0xFFFFFFFF;
     2845    unsigned int seg_reset_code_size  = 0;
     2846    for (vseg_id = 0 ; vseg_id < header->vsegs ; vseg_id++)
     2847    {
     2848        if ( strcmp(vseg[vseg_id]->name, "seg_reset_code") == 0 )
     2849        {
     2850            seg_reset_code_base = vseg[vseg_id]->vbase;
     2851            seg_reset_code_size = vobj[vseg[vseg_id]->vobj_offset]->length;
     2852        }
     2853        if ( strcmp(vseg[vseg_id]->name, "seg_ram_disk") == 0 )
     2854        {
     2855            seg_ram_disk_base   = vseg[vseg_id]->vbase;
     2856            seg_ram_disk_size   = vobj[vseg[vseg_id]->vobj_offset]->length;
     2857        }
     2858    }
     2859
     2860    ld_write(fdout, "seg_reset_code_base     ", seg_reset_code_base);
     2861    ld_write(fdout, "seg_reset_code_size     ", seg_reset_code_size);
     2862    ld_write(fdout, "seg_ram_disk_base       ", seg_ram_disk_base);
     2863    ld_write(fdout, "seg_ram_disk_size       ", seg_ram_disk_size);
     2864   
    27412865    file_write(fdout, "\n");
    27422866
     
    27442868    set_periph_vbase_array();
    27452869
    2746     // non replicated peripherals
     2870    //  non replicated peripherals
    27472871    ld_write(fdout, "seg_cma_base            ",   periph_vbase_array[PERIPH_TYPE_CMA]);
    27482872    ld_write(fdout, "seg_fbf_base            ",   periph_vbase_array[PERIPH_TYPE_FBF]);
     
    27532877    ld_write(fdout, "seg_sim_base            ",   periph_vbase_array[PERIPH_TYPE_SIM]);
    27542878    ld_write(fdout, "seg_tty_base            ",   periph_vbase_array[PERIPH_TYPE_TTY]);
     2879    ld_write(fdout, "seg_pic_base            ",   periph_vbase_array[PERIPH_TYPE_PIC]);
    27552880
    27562881    file_write(fdout, "\n");
Note: See TracChangeset for help on using the changeset viewer.