Changeset 511


Ignore:
Timestamp:
Feb 14, 2015, 5:08:13 PM (9 years ago)
Author:
alain
Message:

Removing the vobj objects fro the mapping_info structure.

Location:
soft/giet_vm/giet_xml
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_xml/mapping_info.h

    r491 r511  
    1717// variable (can be one). Multi-Writer/Multi-Reader communication channels
    1818// betwwen tasks are supported. Each vspace contains a variable number
    19 // of virtual segments (called vsegs).
     19// of virtual segments (called vsegs). The number of virtual space can be one.
    2020//
    2121// 3/ the mapping directives: both tasks on processors, and software objects
    22 // (vobjs and vsegs) on the physical memory banks (called psegs).
    23 // and a variable number of tasks. The number of virtual space can be one.
     22// (called vsegs) on the physical memory banks (called psegs).
    2423//
    2524// The mapping_info data structure is organised as the concatenation of
     
    3029// - mapping_vspace_t   vspace[] 
    3130// - mapping_vseg_t     vseg[]     
    32 // - mapping_vobj_t     vobj[]   
    3331// - mapping_task_t     task[] 
    3432// - mapping_proc_t     proc[] 
     
    4846#define MAPPING_VSPACE_SIZE   sizeof(mapping_vspace_t)
    4947#define MAPPING_VSEG_SIZE     sizeof(mapping_vseg_t)
    50 #define MAPPING_VOBJ_SIZE     sizeof(mapping_vobj_t)
    5148#define MAPPING_PSEG_SIZE     sizeof(mapping_pseg_t)
    5249#define MAPPING_TASK_SIZE     sizeof(mapping_task_t)
     
    6663typedef unsigned long long  paddr_t;
    6764
    68 enum vobjType
    69 {
    70     VOBJ_TYPE_ELF      = 0,  // loadable code/data object of elf files
    71     VOBJ_TYPE_BLOB     = 1,  // loadable blob object
    72     VOBJ_TYPE_PTAB     = 2,  // page table
    73     VOBJ_TYPE_PERI     = 3,  // hardware component
    74     VOBJ_TYPE_MWMR     = 4,  // MWMR channel
    75     VOBJ_TYPE_LOCK     = 5,  // Lock
    76     VOBJ_TYPE_BUFFER   = 6,  // Any "no initialization" objects (stacks...)
    77     VOBJ_TYPE_BARRIER  = 7,  // Barrier
    78     VOBJ_TYPE_CONST    = 8,  // Constant
    79     VOBJ_TYPE_MEMSPACE = 9,  // Memspace (descriptor must be initialised)
    80     VOBJ_TYPE_SCHED    = 10, // Array of schedulers (one per cluster)
    81     VOBJ_TYPE_HEAP     = 11, // Heap   f schedulers (one per cluster)
     65enum vsegType
     66{
     67    VSEG_TYPE_ELF      = 0,  // loadable code/data object of elf files
     68    VSEG_TYPE_BLOB     = 1,  // loadable blob object
     69    VSEG_TYPE_PTAB     = 2,  // page table
     70    VSEG_TYPE_PERI     = 3,  // hardware component
     71    VSEG_TYPE_MWMR     = 4,  // MWMR channel
     72    VSEG_TYPE_LOCK     = 5,  // Lock
     73    VSEG_TYPE_BUFFER   = 6,  // Any "no initialization" objects (stacks...)
     74    VSEG_TYPE_BARRIER  = 7,  // Barrier
     75    VSEG_TYPE_CONST    = 8,  // Constant
     76    VSEG_TYPE_MEMSPACE = 9,  // Memspace (descriptor must be initialised)
     77    VSEG_TYPE_SCHED    = 10, // Array of schedulers (one per cluster)
     78    VSEG_TYPE_HEAP     = 11, // Heap   f schedulers (one per cluster)
    8279};
    8380
     
    149146    unsigned int globals;            // total number of global vsegs
    150147    unsigned int vspaces;            // total number of virtual spaces
    151     unsigned int psegs;              // total number of physical segments (all clusters)
    152     unsigned int vsegs;              // total number of virtual segments (all vspaces)
    153     unsigned int vobjs;              // total number of virtual objects (all vspaces)
    154     unsigned int tasks;              // total number of tasks (all vspaces)
    155     unsigned int procs;              // total number of procs (all clusters)
    156     unsigned int irqs;               // total number of irqs (all clusters)
    157     unsigned int coprocs;            // total number of coprocs (all clusters)
    158     unsigned int cp_ports;           // total number of cp_ports (all coprocs)
    159     unsigned int periphs;            // total number of peripherals (all clusters)
    160 
     148    unsigned int psegs;              // total number of physical segments
     149    unsigned int vsegs;              // total number of virtual segments
     150    unsigned int tasks;              // total number of tasks
     151    unsigned int procs;              // total number of procs
     152    unsigned int irqs;               // total number of irqs
     153    unsigned int coprocs;            // total number of coprocs
     154    unsigned int cp_ports;           // total number of cp_ports
     155    unsigned int periphs;            // total number of peripherals
    161156    char name[32];                   // mapping name
    162157} mapping_header_t;
     
    170165
    171166    unsigned int    psegs;           // number of psegs in cluster
    172     unsigned int    pseg_offset;     // global index of first pseg in psegs set
     167    unsigned int    pseg_offset;     // global index of first pseg in psegs
    173168
    174169    unsigned int    procs;           // number of processors in cluster
    175     unsigned int    proc_offset;     // global index of first proc in procs set
     170    unsigned int    proc_offset;     // global index of first proc in procs
    176171 
    177172    unsigned int    coprocs;         // number of coprocessors in cluster
    178     unsigned int    coproc_offset;   // global index of first coproc in coprocs set
     173    unsigned int    coproc_offset;   // global index of first coproc in coprocs
    179174
    180175    unsigned int    periphs;         // number of peripherals in cluster
    181     unsigned int    periph_offset;   // global index of first coproc in periphs set
     176    unsigned int    periph_offset;   // global index of first coproc in periphs
    182177} mapping_cluster_t;
    183178
     
    187182{
    188183    char            name[32];        // virtual space name
    189     unsigned int    start_vobj_id;   // vobj containing start vector index
     184    unsigned int    start_vseg_id;   // vseg containing start vector index
    190185    unsigned int    vsegs;           // number of vsegs in vspace
    191     unsigned int    vobjs;           // number of vobjs in vspace
    192186    unsigned int    tasks;           // number of tasks in vspace
    193187    unsigned int    vseg_offset;     // global index of first vseg in vspace
    194     unsigned int    vobj_offset;     // global index of first vobj in vspace
    195188    unsigned int    task_offset;     // global index of first task in vspace
    196189} mapping_vspace_t;
     
    201194{
    202195    char            name[32];        // vseg name (unique in vspace)
     196    char            binpath[64];     // path for the binary code (if required)
    203197    unsigned int    vbase;           // base address in virtual space
    204198    paddr_t         pbase;           // base address in physical space
     
    206200    unsigned int    psegid;          // physical segment global index
    207201    unsigned int    mode;            // C-X-W-U flags
    208     unsigned int    vobjs;           // number of vobjs in vseg
    209     unsigned int    vobj_offset;     // global index of first vobj in vseg
    210     unsigned int    next_vseg;       // linked list of vsegs mapped on pseg
     202    unsigned int    type;            // vseg type
    211203    char            mapped;          // mapped if non zero
    212204    char            ident;           // identity mapping if non zero
     
    235227    unsigned int    proclocid;       // processor local index (inside cluster)
    236228    unsigned int    trdid;           // thread index in vspace
    237     unsigned int    stack_vobj_id;   // global index for vobj containing stack
    238     unsigned int    heap_vobj_id;    // global index for vobj containing heap
     229    unsigned int    stack_vseg_id;   // global index for vseg containing stack
     230    unsigned int    heap_vseg_id;    // global index for vseg containing heap
    239231    unsigned int    startid;         // index in start_vector
    240232} mapping_task_t;
    241 
    242 
    243 //////////////////////////////////////////////////////
    244 typedef struct __attribute__((packed))  mapping_vobj_s
    245 {
    246     char            name[32];        // vobj name (unique in a vspace)
    247     char            binpath[64];     // path for the binary code ("*.elf")
    248     unsigned int    type;            // type of vobj
    249     unsigned int    length;          // size (bytes)
    250     unsigned int    align;           // required alignement (logarithm of 2)
    251     unsigned int    vbase;           // virtual base addresse of the vobj
    252     unsigned int    init;            // init value (used by barrier or mwmr channel)
    253 } mapping_vobj_t;
    254233
    255234
     
    276255    unsigned int    direction;       // TO_COPROC == 0 / FROM_COPROC == 1
    277256    unsigned int    vspaceid;        // index of the vspace containing MWMR channel
    278     unsigned int    mwmr_vobj_id;    // global index of vobj containing MWMR channel
     257    unsigned int    mwmr_vseg_id;    // global index of vseg containing MWMR channel
    279258} mapping_cp_port_t;
    280259
  • soft/giet_vm/giet_xml/xml_driver.c

    r491 r511  
    2121{
    2222    // mnemonics defined in mapping_info.h
    23     const char * vobj_type[] =
     23    const char * vseg_type[] =
    2424    {
    2525        "ELF",        // binary code generated by GCC
     
    4141    {
    4242        "RAM",
    43         "ROM",        // deprecated => use PERI
    4443        "PERI",
    4544    };
     
    129128    unsigned int pseg_id;
    130129    unsigned int vseg_id;
    131     unsigned int vobj_id;
    132130    unsigned int task_id;
    133131    unsigned int proc_id;
     
    141139    mapping_vspace_t * vspace;
    142140    mapping_vseg_t * vseg;
    143     mapping_vobj_t * vobj;
    144141    mapping_task_t * task;
    145142    mapping_proc_t * proc;
     
    171168            MAPPING_VSPACE_SIZE * header->vspaces);
    172169
    173     // computes the base adresss for vobjs array,
    174     vobj = (mapping_vobj_t *) ((char *) header +
    175             MAPPING_HEADER_SIZE +
    176             MAPPING_CLUSTER_SIZE * header->x_size * header->y_size +
    177             MAPPING_PSEG_SIZE * header->psegs +
    178             MAPPING_VSPACE_SIZE * header->vspaces +
    179             MAPPING_VSEG_SIZE * header->vsegs);
    180 
    181170    // computes the base address for tasks array
    182171    task = (mapping_task_t *) ((char *) header +
     
    185174            MAPPING_PSEG_SIZE * header->psegs +
    186175            MAPPING_VSPACE_SIZE * header->vspaces +
    187             MAPPING_VOBJ_SIZE * header->vobjs +
    188176            MAPPING_VSEG_SIZE * header->vsegs);
    189177
     
    194182            MAPPING_PSEG_SIZE * header->psegs +
    195183            MAPPING_VSPACE_SIZE * header->vspaces +
    196             MAPPING_VOBJ_SIZE * header->vobjs +
    197184            MAPPING_VSEG_SIZE * header->vsegs +
    198185            MAPPING_TASK_SIZE * header->tasks);
     
    204191            MAPPING_PSEG_SIZE * header->psegs +
    205192            MAPPING_VSPACE_SIZE * header->vspaces +
    206             MAPPING_VOBJ_SIZE * header->vobjs +
    207193            MAPPING_VSEG_SIZE * header->vsegs +
    208194            MAPPING_TASK_SIZE * header->tasks +
     
    215201            MAPPING_PSEG_SIZE * header->psegs +
    216202            MAPPING_VSPACE_SIZE * header->vspaces +
    217             MAPPING_VOBJ_SIZE * header->vobjs +
    218203            MAPPING_VSEG_SIZE * header->vsegs +
    219204            MAPPING_TASK_SIZE * header->tasks +
     
    227212            MAPPING_PSEG_SIZE * header->psegs +
    228213            MAPPING_VSPACE_SIZE * header->vspaces +
    229             MAPPING_VOBJ_SIZE * header->vobjs +
    230214            MAPPING_VSEG_SIZE * header->vsegs +
    231215            MAPPING_TASK_SIZE * header->tasks +
     
    240224            MAPPING_PSEG_SIZE * header->psegs +
    241225            MAPPING_VSPACE_SIZE * header->vspaces +
    242             MAPPING_VOBJ_SIZE * header->vobjs +
    243226            MAPPING_VSEG_SIZE * header->vsegs +
    244227            MAPPING_TASK_SIZE * header->tasks +
     
    305288                 port_id++)
    306289            {
    307                 unsigned int vobj_id = cp_port[port_id].mwmr_vobj_id;
     290                unsigned int vseg_id = cp_port[port_id].mwmr_vseg_id;
    308291                fprintf(fpout, "             <port direction=\"%s\"", port_direction[cp_port[port_id].direction]);
    309292                fprintf(fpout, " vspacename=\"%s\"", vspace[cp_port[port_id].vspaceid].name);
    310                 fprintf(fpout, " vobjname=\"%s\" />\n",  vobj[vobj_id].name);
     293                fprintf(fpout, " vsegname=\"%s\" />\n",  vseg[vseg_id].name);
    311294            }
    312295            fprintf(fpout, "            </coproc>\n" );
     
    356339        fprintf(fpout, "        <vseg name=\"%s\"", vseg[vseg_id].name);
    357340        fprintf(fpout, " vbase=\"0x%x\"", vseg[vseg_id].vbase);
     341        fprintf(fpout, " length=\"0x%x\"", vseg[vseg_id].length);
     342        fprintf(fpout, " type=\"%s\"", vseg_type[vseg[vseg_id].type]);
    358343        fprintf(fpout, " mode=\"%s\"", mode_str[vseg[vseg_id].mode]);
     344        fprintf(fpout, "\n             ");     
    359345        fprintf(fpout, " x=\"%d\"", cluster[cluster_id].x);
    360346        fprintf(fpout, " y=\"%d\"", cluster[cluster_id].y);
    361347        fprintf(fpout, " psegname=\"%s\"", pseg[pseg_id].name);
    362         if( vseg[vseg_id].ident ) fprintf(fpout, " ident=\"1\"");
    363         if( vseg[vseg_id].local ) fprintf(fpout, " local=\"1\"");
     348        if( vseg[vseg_id].ident )
     349        fprintf(fpout, " ident=\"1\"");
     350        if( vseg[vseg_id].local )
     351        fprintf(fpout, " local=\"1\"");
     352        if( vseg[vseg_id].big )
     353        fprintf(fpout, " big=\"1\"");
     354        if( vseg[vseg_id].binpath[0] != 0 )
     355        fprintf(fpout, " binpath=\"%s\"", vseg[vseg_id].binpath);
    364356        fprintf(fpout, " >\n");
    365 
    366         for (vobj_id = vseg[vseg_id].vobj_offset;
    367              vobj_id < (vseg[vseg_id].vobj_offset + vseg[vseg_id].vobjs);
    368              vobj_id++)
    369         {
    370             fprintf(fpout, "            <vobj name=\"%s\"", vobj[vobj_id].name);
    371             fprintf(fpout, " type=\"%s\"", vobj_type[vobj[vobj_id].type]);
    372             fprintf(fpout, " length=\"0x%x\"", vobj[vobj_id].length);
    373             if( vobj[vobj_id].align )
    374                 fprintf(fpout, " align=\"%d\"", vobj[vobj_id].align);
    375             if( vobj[vobj_id].binpath[0] != 0 )
    376                 fprintf(fpout, " binpath=\"%s\"", vobj[vobj_id].binpath);
    377             if( (vobj[vobj_id].type == VOBJ_TYPE_BARRIER) ||
    378                 (vobj[vobj_id].type == VOBJ_TYPE_MWMR   ) ||
    379                 (vobj[vobj_id].type == VOBJ_TYPE_CONST  ) )
    380                 fprintf(fpout, " init=\"%d\"", vobj[vobj_id].init);
    381             fprintf(fpout, " />\n");
    382         }
    383         fprintf(fpout, "        </vseg>\n");
    384357    }
    385358    fprintf(fpout, "    </globalset>\n" );
     
    390363    for (vspace_id = 0; vspace_id < header->vspaces; vspace_id++)
    391364    {
    392         unsigned int vobj_id = vspace[vspace_id].start_vobj_id;
     365        unsigned int vseg_id = vspace[vspace_id].start_vseg_id;
    393366        fprintf(fpout, "        <vspace name = \"%s\" ", vspace[vspace_id].name);
    394         fprintf(fpout, " startname = \"%s\" >\n", vobj[vobj_id].name);
     367        fprintf(fpout, " startname = \"%s\" >\n", vseg[vseg_id].name);
    395368
    396369        //////////////////// vsegs //////////////////////////////////////////////
     
    405378            fprintf(fpout, "            <vseg name=\"%s\"", vseg[vseg_id].name);
    406379            fprintf(fpout, " vbase=\"0x%x\"", vseg[vseg_id].vbase);
     380            fprintf(fpout, " length=\"0x%x\"", vseg[vseg_id].length);
     381            fprintf(fpout, " type=\"%s\"", vseg_type[vseg[vseg_id].type]);
    407382            fprintf(fpout, " mode=\"%s\"", mode_str[vseg[vseg_id].mode]);
     383            fprintf(fpout, "\n                 ");     
    408384            fprintf(fpout, " x=\"%d\"", cluster[cluster_id].x);
    409385            fprintf(fpout, " y=\"%d\"", cluster[cluster_id].y);
    410386            fprintf(fpout, " psegname=\"%s\"", pseg[pseg_id].name);
    411             if( vseg[vseg_id].ident ) fprintf(fpout, " ident=\"1\"");
    412             if( vseg[vseg_id].local ) fprintf(fpout, " local=\"1\"");
     387            if( vseg[vseg_id].ident )
     388            fprintf(fpout, " ident=\"1\"");
     389            if( vseg[vseg_id].local )
     390            fprintf(fpout, " local=\"1\"");
     391            if( vseg[vseg_id].big )
     392            fprintf(fpout, " big=\"1\"");
     393            if( vseg[vseg_id].binpath[0] != 0 )
     394            fprintf(fpout, " binpath=\"%s\"", vseg[vseg_id].binpath);
    413395            fprintf(fpout, " >\n");
    414 
    415             for (vobj_id = vseg[vseg_id].vobj_offset;
    416                  vobj_id < (vseg[vseg_id].vobj_offset + vseg[vseg_id].vobjs);
    417                  vobj_id++)
    418             {
    419                 fprintf(fpout, "             <vobj name=\"%s\"", vobj[vobj_id].name);
    420                 fprintf(fpout, " type=\"%s\"", vobj_type[vobj[vobj_id].type]);
    421                 fprintf(fpout, " length=\"0x%x\"", vobj[vobj_id].length);
    422                 if( vobj[vobj_id].align )
    423                     fprintf(fpout, " align=\"%d\"", vobj[vobj_id].align);
    424                 if( vobj[vobj_id].binpath[0] != 0 )
    425                     fprintf(fpout, " binpath=\"%s\"", vobj[vobj_id].binpath);
    426                 if( (vobj[vobj_id].type == VOBJ_TYPE_BARRIER) ||
    427                     (vobj[vobj_id].type == VOBJ_TYPE_MWMR   ) ||
    428                     (vobj[vobj_id].type == VOBJ_TYPE_CONST  ) )
    429                     fprintf(fpout, " init=\"%d\"", vobj[vobj_id].init);
    430                 fprintf(fpout, " />\n");
    431             }
    432             fprintf(fpout, "            </vseg>\n\n");
    433396        }
    434397
     
    439402             task_id++)
    440403        {
    441             unsigned int stack_vobj_id = task[task_id].stack_vobj_id;
    442             unsigned int heap_vobj_id  = task[task_id].heap_vobj_id;
     404            unsigned int stack_vseg_id = task[task_id].stack_vseg_id;
     405            unsigned int heap_vseg_id  = task[task_id].heap_vseg_id;
    443406            unsigned int cluster_id    = task[task_id].clusterid;
    444407
     
    448411            fprintf(fpout, " y=\"%d\"", cluster[cluster_id].y);
    449412            fprintf(fpout, " p=\"%d\"", task[task_id].proclocid);
    450             fprintf(fpout, " stackname=\"%s\"", vobj[stack_vobj_id].name);
    451             if (heap_vobj_id != -1)
    452             {
    453                 fprintf(fpout, " heapname=\"%s\"", vobj[heap_vobj_id].name);
    454             }
     413            fprintf(fpout, "\n                 ");     
     414            fprintf(fpout, " stackname=\"%s\"", vseg[stack_vseg_id].name);
     415            if (heap_vseg_id != -1)
     416            fprintf(fpout, " heapname=\"%s\"", vseg[heap_vseg_id].name);
    455417            fprintf(fpout, " startid = \"%d\"", task[task_id].startid);
    456418            fprintf(fpout, " />\n");
  • soft/giet_vm/giet_xml/xml_parser.c

    r491 r511  
    1313// 3) the mapping directives bor both the tasks and the virtual segments.
    1414// The corresponding C structures are defined in the "mapping_info.h" file.
    15 //
    16 // This parser also generates the "hard_config.h" and the "giet_vsegs.ld" files,
    17 // required  to compile the GIET-VM code.
    1815///////////////////////////////////////////////////////////////////////////////////////
    1916
     
    3431#define MAX_VSPACES    1024
    3532#define MAX_TASKS      4096
    36 #define MAX_MWMRS      4096
    3733#define MAX_VSEGS      4096
    38 #define MAX_VOBJS      8192
    3934#define MAX_PROCS      1024
    4035#define MAX_IRQS       8192
     
    4338#define MAX_PERIPHS    8192
    4439
    45 #define XML_PARSER_DEBUG  0
     40#define XML_PARSER_DEBUG  1
    4641
    4742///////////////////////////////////////////////////////////////////////////////////
     
    5449mapping_vspace_t *   vspace[MAX_VSPACES];    // vspace array
    5550mapping_vseg_t *     vseg[MAX_VSEGS];        // vseg array
    56 mapping_vobj_t *     vobj[MAX_VOBJS];        // vobj array
    5751mapping_task_t *     task[MAX_TASKS];        // task array
    5852mapping_proc_t *     proc[MAX_PROCS];        // proc array
     
    8983unsigned int task_index = 0;
    9084unsigned int task_loc_index = 0;
    91 
    92 unsigned int vobj_index = 0;
    93 unsigned int vobj_loc_index = 0;
    94 unsigned int vobj_count = 0;
    9585
    9686
     
    10494char found_mmc   = 0;
    10595
     96/*
    10697////////////////////////////////////////////////////////////////////////
    10798// These variables are used to generate the hard_config.h file.
    10899////////////////////////////////////////////////////////////////////////
    109100
    110 unsigned int total_procs      = 0; // total number of processors
    111 unsigned int nb_procs_max     = 0; // max number of processors per cluster
    112 unsigned int nb_tasks_max     = 0; // max number of tasks (in all vspaces)
    113101
    114102unsigned int tim_channels     = 0; // number of user timers  (per cluster)
     
    138126unsigned int periph_vbase_array[PERIPH_TYPE_MAX_VALUE]
    139127         = { [0 ... (PERIPH_TYPE_MAX_VALUE - 1)] = 0xFFFFFFFF };
    140 
    141 //////////////////////////////////////////////////////////////////////
    142 // This arrray is useful to build a temporary list of vobj references.
    143 // The struct vobj_ref_s is formed by a vspace_name and a vobj_name.
    144 // This array is used to set the attribute vobj_id of a cp_port
    145 // once all the vspace have been parsed.
    146 /////////////////////////////////////////////////////////////////////
    147 typedef struct vobj_ref_s
    148 {
    149     char vspace_name[32];
    150     char vobj_name[32];
    151 } vobj_ref_t;
    152 
    153 vobj_ref_t * cp_port_vobj_ref[MAX_CP_PORTS];   
     128*/
    154129
    155130
     
    285260} // end getStringValue()
    286261
    287 ///////////////////////////////////////////////////////////////////////////////////
    288 // This function set the vbase addresses for all peripheral types, in order
    289 // to generate the ldscript file, that contains one single virtual address
    290 // for peripherals replicated in all clusters, and one virtual addresses for
    291 // each non replicated peripheral type.
    292 //
    293 // It makes the following checks on the virtual addresses:
    294 //
    295 // - For replicated peripherals the virtual base address must be:
    296 //   vbase = seg_type_base & 0XFF000000 + (cluster_xy * 0x00010000) & 0x00FF0000
    297 //
    298 // - For non-replicated peripherals, the cluster index must be cluster_io.
    299 ///////////////////////////////////////////////////////////////////////////////////
    300 void set_periph_vbase_array()
    301 {
    302     unsigned int vseg_id;      // vseg global index
    303     unsigned int periph_id;    // periph global index
    304     unsigned int pseg_id;      // pseg global index
    305     unsigned int cluster_id;   // cluster linear index
    306     unsigned int cluster_xy;   // cluster topological index
    307     unsigned int type;         // peripheral type
    308 
    309     unsigned int type_mask      = 0xFF000000;
    310     unsigned int cluster_mask   = 0x00FF0000;
    311     unsigned int vseg_increment = 0x00010000;
    312 
    313 #if XML_PARSER_DEBUG
    314 printf("\n set peripherals vbase array\n");
    315 #endif
    316 
    317     // scan all vsegs
    318     for (vseg_id = 0 ; vseg_id < header->vsegs ; vseg_id++)
    319     {
    320         // keep only vseg corresponding to a periph       
    321         if ( vobj[vseg[vseg_id]->vobj_offset]->type == VOBJ_TYPE_PERI )
    322         {
    323             pseg_id = vseg[vseg_id]->psegid;
    324 
    325 #if XML_PARSER_DEBUG
    326 printf(" - found vseg %s associated to pseg %d", vseg[vseg_id]->name, pseg_id );
    327 #endif
    328 
    329             // scan all periphs to retrieve peripheral type (same psegid)
    330             for ( periph_id = 0 ; periph_id < header->periphs ; periph_id++)
    331             {
    332                 if( periph[periph_id]->psegid == pseg_id ) // matching !!!
    333                 {
    334                     cluster_id = pseg[pseg_id]->clusterid;
    335                     type       = periph[periph_id]->type;
    336 
    337 #if XML_PARSER_DEBUG
    338 printf(" / matching periph type %d\n", type );
    339 #endif
    340 
    341                     if ( (type == PERIPH_TYPE_DMA) ||
    342                          (type == PERIPH_TYPE_MMC) ||
    343                          (type == PERIPH_TYPE_XCU) )   // replicated peripheral
    344                     {
    345                         cluster_xy = (cluster[cluster_id]->x << header->y_width) +
    346                                       cluster[cluster_id]->y;
    347 
    348                         if( (vseg[vseg_id]->vbase & cluster_mask) !=
    349                             (vseg_increment * cluster_xy) )
    350                         {
    351                             printf("[XML ERROR] All replicated peripherals "
    352                                    "must have cluster bits = cluster_xy * increment\n");
    353                             printf("periph index = %d / periph type = %d / vbase = %x\n",
    354                                     periph_id, type, vseg[vseg_id]->vbase);
    355                             exit(1);
    356                         }
    357                         else if ( periph_vbase_array[type] == 0xFFFFFFFF ) // vbase not set
    358                         {
    359                             periph_vbase_array[type] = vseg[vseg_id]->vbase & type_mask;   
    360                         }
    361                         else if ((vseg[vseg_id]->vbase & type_mask) != (periph_vbase_array[type]))
    362                         {
    363                             printf("[XML ERROR] All peripherals with same type"
    364                                    " should share the same 8 MSB bits in vbase address\n");
    365                             printf("periph index = %d / periph type = %d / vbase = %x\n",
    366                                     periph_id, type, vseg[vseg_id]->vbase);
    367                             exit(1);
    368                         }
    369                     }
    370                     else                               // non replicated peripheral
    371                     {
    372                         if ( (cluster[cluster_id]->x == header->x_io) && 
    373                              (cluster[cluster_id]->y == header->y_io) )   
    374                         {
    375                             periph_vbase_array[type] = vseg[vseg_id]->vbase;   
    376                         }
    377                         else
    378                         {
    379                             printf("[XML ERROR] Non replicated peripherals must be in cluster_io\n");
    380                             printf(" periph index = %d / periph type = %d / vbase = %x"
    381                                    " / pseg index = %d / cluster index = %d\n",
    382                                     periph_id, type, vseg[vseg_id]->vbase, pseg_id, cluster_id);
    383                             exit(1);
    384                         }
    385                     }
    386                 }
    387             }
    388         }   
    389     }
    390 }  // end set_periph_vbase_array()
    391 
    392262///////////////////////////////////////////////////////////////
    393263int getClusterId( unsigned int x, unsigned int y )
     
    443313}
    444314
    445 ////////////////////////////////////////////////////////////////////////////////
    446 int getVobjId(unsigned int vspace_id, char * vobj_name, unsigned int vspace_max)
    447 {
    448     unsigned int vobj_id;
    449     unsigned int vobj_min = vspace[vspace_id]->vobj_offset;
    450     unsigned int vobj_max = vobj_min + vspace_max;
    451 
    452     for (vobj_id = vobj_min; vobj_id < vobj_max; vobj_id++)
    453     {
    454         if (strcmp(vobj[vobj_id]->name, vobj_name) == 0) return vobj_id;
     315///////////////////////////////////////////////////
     316int getVsegId( unsigned int vspace_id, char *name )
     317{
     318    unsigned int vseg_id;
     319    unsigned int vseg_min = vspace[vspace_id]->vseg_offset;
     320    unsigned int vseg_max = vseg_min + vspace[vspace_id]->vsegs;
     321
     322    for (vseg_id = vseg_min ; vseg_id < vseg_max ; vseg_id++)
     323    {
     324        if (strcmp(vseg[vseg_id]->name, name) == 0) return vseg_id;
    455325    }
    456326    return -1;
    457327}
    458328
    459 ///////////////////////////////////////////////////////////
    460 unsigned int alignTo( unsigned int value, unsigned int pow2 )
    461 {
    462     unsigned int mask = (1 << pow2) - 1;
    463     return ( (value + mask) & ~mask);
    464 }
    465 
    466 ////////////////////
    467 void setVsegLength()
    468 {
    469     // for a given vseg identified vseg_index
    470     // scan all contained vobjs to compute the vseg lenth
    471 
    472     unsigned int vobj_id;
    473     unsigned int cur_length = 0;
    474 
    475     unsigned int first = vseg[vseg_index]->vobj_offset;
    476     unsigned int last  = first + vseg[vseg_index]->vobjs;
    477 
    478     for ( vobj_id = first ; vobj_id < last ; vobj_id++ )
    479     {
    480         if (vobj[vobj_id]->align)
    481         {
    482             cur_length = alignTo( cur_length, vobj[vobj_id]->align );
    483         }
    484         cur_length += vobj[vobj_id]->length;
    485     }
    486     vseg[vseg_index]->length = alignTo( cur_length, 12 );
    487 }
    488 
    489 ///////////////////////
    490 void checkVsegOverlap()
    491 {
    492     // for a given vseg identified by vseg_index,
    493     // check overlap with all vsegs in same vspace,
    494     // and check overlap with all global vsegs.
    495 
    496     unsigned int vseg_id;
    497     unsigned int prev_vbase;                          // previous vseg vbase
    498     unsigned int prev_length;                         // previous vseg length
    499 
    500     unsigned int vbase  = vseg[vseg_index]->vbase;    // new vseg vbase
    501     unsigned int length = vseg[vseg_index]->length;   // new vseg length
    502  
    503     // checking overlap with other vsegs in same vspace
    504     if ( header->vspaces > 0 )
    505     {
    506         unsigned int first = vspace[vspace_index]->vseg_offset;   
    507         unsigned int last  = vseg_index;
    508    
    509         for( vseg_id = first ; vseg_id < last ; vseg_id++ )
    510         {
    511             prev_vbase  = vseg[vseg_id]->vbase;
    512             prev_length = vseg[vseg_id]->length;
    513             if ( ((vbase + length) > prev_vbase) && ((prev_vbase + prev_length) > vbase) )
    514             {
    515                 printf("[XML ERROR] vseg %s in vspace %s overlaps other vseg %s\n",
    516                 vseg[vseg_index]->name, vspace[vspace_index]->name, vseg[vseg_id]->name );
    517                 exit(1);
    518             }
    519         }
    520     }
    521 
    522     // checking overlap with existing global vsegs
    523     for ( vseg_id = 0 ; vseg_id < header->globals ; vseg_id++ )
    524     {
    525         prev_vbase  = vseg[vseg_id]->vbase;
    526         prev_length = vseg[vseg_id]->length;
    527         if ( ((vbase + length) > prev_vbase) && ((prev_vbase + prev_length) > vbase) )
    528         {
    529             printf("[XML ERROR] vseg %s in vspace %s overlaps global vseg %s\n",
    530             vseg[vseg_index]->name, vspace[vspace_index]->name, vseg[vseg_id]->name );
    531             exit(1);
    532         }
    533     }
    534 }
    535329
    536330//////////////////////////////////////
     
    645439
    646440    ////////// get stackname attribute
    647     str = getStringValue(reader, "stackname" , &ok);
    648     if (ok)
    649     {
    650         int index = getVobjId(vspace_index, str , vobj_loc_index);
     441    char* stack_name = getStringValue(reader, "stackname" , &ok);
     442    if (ok)
     443    {
     444#if XML_PARSER_DEBUG
     445printf("      stackname = %s\n", str);
     446#endif
     447        int index = getVsegId( vspace_index , stack_name );
    651448        if (index >= 0)
    652449        {
    653450#if XML_PARSER_DEBUG
    654 printf("      stackname = %s\n", str);
    655451printf("      stack_id  = %d\n", index);
    656452#endif
    657             task[task_index]->stack_vobj_id = index;
     453            task[task_index]->stack_vseg_id = index;
    658454        }
    659455        else
     
    672468
    673469    ////////// get heap attribute
    674     str = getStringValue(reader, "heapname", &ok);
    675     if (ok)
    676     {
    677         int index = getVobjId(vspace_index, str, vobj_loc_index);
     470    char* heap_name = getStringValue(reader, "heapname", &ok);
     471    if (ok)
     472    {
     473#if XML_PARSER_DEBUG
     474printf("      heapname  = %s\n", str);
     475#endif
     476        int index = getVsegId( vspace_index , heap_name );
    678477        if (index >= 0)
    679478        {
    680479#if XML_PARSER_DEBUG
    681 printf("      heapname  = %s\n", str);
    682480printf("      heap_id   = %d\n", index );
    683481#endif
    684             task[task_index]->heap_vobj_id = index;
     482            task[task_index]->heap_vseg_id = index;
    685483        }
    686484        else
     
    693491    else
    694492    {
    695         task[task_index]->heap_vobj_id = -1;
     493        task[task_index]->heap_vseg_id = -1;
    696494    }
    697495
     
    716514} // end taskNode()
    717515
    718 //////////////////////////////////////
    719 void vobjNode(xmlTextReaderPtr reader)
    720 {
    721     unsigned int ok;
    722     unsigned int value;
    723     char * str;
    724 
    725     if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) return;
    726 
    727     if (vobj_index >= MAX_VOBJS)
    728     {
    729         printf("[XML ERROR] The number of vobjs is larger than %d\n", MAX_VOBJS);
    730         exit(1);
    731     }
    732 
    733 #if XML_PARSER_DEBUG
    734 printf("      vobj %d\n", vobj_loc_index);
    735 #endif
    736 
    737     vobj[vobj_index] = (mapping_vobj_t *) malloc(sizeof(mapping_vobj_t));
    738 
    739     ///////// get name attribute
    740     str = getStringValue(reader, "name", &ok);
    741     if (ok)
    742     {
    743 #if XML_PARSER_DEBUG
    744 printf("        name = %s\n", str);
    745 #endif
    746         strncpy(vobj[vobj_index]->name, str, 31);
    747     }
    748     else
    749     {
    750         printf("[XML ERROR] illegal or missing <name> attribute for vobj (%d,%d)\n",
    751                 vseg_index, vobj_loc_index);
    752         exit(1);
    753     }
    754 
    755     //////// get type attribute
    756     str = getStringValue(reader, "type", &ok);
    757 #if XML_PARSER_DEBUG
    758 printf("        type = %s\n", str);
    759 #endif
    760 
    761     if      (ok && (strcmp(str, "ELF")      == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_ELF;      }
    762     else if (ok && (strcmp(str, "PERI")     == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_PERI;     }
    763     else if (ok && (strcmp(str, "BLOB")     == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_BLOB;     }
    764     else if (ok && (strcmp(str, "PTAB")     == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_PTAB;     }
    765     else if (ok && (strcmp(str, "MWMR")     == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_MWMR;     }
    766     else if (ok && (strcmp(str, "LOCK")     == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_LOCK;     }
    767     else if (ok && (strcmp(str, "BUFFER")   == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_BUFFER;   }
    768     else if (ok && (strcmp(str, "BARRIER")  == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_BARRIER;  }
    769     else if (ok && (strcmp(str, "CONST")    == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_CONST;    }
    770     else if (ok && (strcmp(str, "MEMSPACE") == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_MEMSPACE; }
    771     else if (ok && (strcmp(str, "SCHED")    == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_SCHED;    }
    772     else if (ok && (strcmp(str, "HEAP")     == 0)) { vobj[vobj_index]->type = VOBJ_TYPE_HEAP;     }
    773     else
    774     {
    775         printf("[XML ERROR] illegal or missing <type> attribute for vobj (%d,%d)\n",
    776                 vspace_index, vobj_loc_index);
    777         exit(1);
    778     }
    779     // some more checking
    780     if ( (vobj[vobj_index]->type == VOBJ_TYPE_ELF) ||
    781          (vobj[vobj_index]->type == VOBJ_TYPE_PERI) )
    782     {
    783         assert( (vobj_count == 0) &&
    784         "[XML ERROR] an ELF or PERI vobj must be alone in a vseg");
    785     }
    786        
    787 
    788     ////////// get length attribute
    789     value = getIntValue(reader, "length", &ok);
    790     if (ok)
    791     {
    792 #if XML_PARSER_DEBUG
    793 printf("        length = %x\n", value);
    794 #endif
    795         vobj[vobj_index]->length = value;
    796     } 
    797     else {
    798         printf("[XML ERROR] illegal or missing <length> attribute for vobj (%d,%d)\n",
    799                 vspace_index, vobj_loc_index);
    800         exit(1);
    801     }
    802 
    803     ////////// get align attribute (optional : 0 if missing)
    804     value = getIntValue(reader, "align", &ok);
    805     if (ok)
    806     {
    807 #if XML_PARSER_DEBUG
    808 printf("        align = %d\n", value);
    809 #endif
    810         vobj[vobj_index]->align = value;
    811     } 
    812     else
    813     {
    814         vobj[vobj_index]->align = 0;
    815     }
    816 
    817     ////////// get binpath attribute (optional : "" if missing)
    818     str = getStringValue(reader, "binpath", &ok);
    819     if (ok)
    820     {
    821 #if XML_PARSER_DEBUG
    822 printf("        binpath = %s\n", str);
    823 #endif
    824         strncpy(vobj[vobj_index]->binpath, str, 63);
    825     } 
    826     else
    827     {
    828         vobj[vobj_index]->binpath[0] = 0;
    829     }
    830 
    831     ////////// get init attribute (optional, mandatory for mwmr and barrier)
    832     value = getIntValue(reader, "init", &ok);
    833     if (ok)
    834     {
    835 #if XML_PARSER_DEBUG
    836 printf("        init  = %d\n", value);
    837 #endif
    838         vobj[vobj_index]->init = value;
    839     } 
    840     else
    841     {
    842         if ((vobj[vobj_index]->type == VOBJ_TYPE_MWMR) ||
    843             (vobj[vobj_index]->type == VOBJ_TYPE_BARRIER) ||
    844             (vobj[vobj_index]->type == VOBJ_TYPE_CONST))
    845         {
    846             printf("[XML ERROR] illegal or missing <value> attribute for vobj (%d,%d). \
    847                     All MWMR or BARRIER or CONST vobj must have a init value \n",
    848                     vspace_index, vobj_loc_index);
    849             exit(1);
    850         }
    851         vobj[vobj_index]->init = 0;
    852     }
    853 
    854     vobj_index++;
    855     vobj_count++;
    856     vobj_loc_index++;
    857 } // end vobjNode()
    858516
    859517//////////////////////////////////////
     
    865523    char * str;
    866524
    867     vobj_count = 0;
    868 
    869525    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) return;
    870526
     
    880536
    881537    vseg[vseg_index] = (mapping_vseg_t *) malloc(sizeof(mapping_vseg_t));
    882 
    883     ////////// set vobj_offset attribute
    884     vseg[vseg_index]->vobj_offset = vobj_index;
    885 
    886 #if XML_PARSER_DEBUG
    887 printf("      vobj_offset = %d\n", vobj_index);
    888 #endif
    889538
    890539    ///////// set mapped attribute
    891540    vseg[vseg_index]->mapped = 0;
    892541
    893     //////// set next_vseg attribute
    894     vseg[vseg_index]->next_vseg = 0;
    895  
    896542    ///////// get name attribute
    897543    str = getStringValue(reader, "name", &ok);
     
    938584    }
    939585
     586    ////////// get big attribute (optional : 0 if missing)
     587    value = getIntValue(reader, "big", &ok);
     588    if (ok)
     589    {
     590#if XML_PARSER_DEBUG
     591printf("      big         = %d\n", value);
     592#endif
     593        vseg[vseg_index]->big = value;
     594    } 
     595    else
     596    {
     597        vseg[vseg_index]->big = 0;
     598    }
     599
    940600    /////////// get vbase attribute
    941601    value = getIntValue(reader, "vbase", &ok);
     
    950610    {
    951611        printf("[XML ERROR] illegal or missing <vbase> attribute for vseg (%d,%d)\n",
     612                vspace_index, vseg_loc_index);
     613        exit(1);
     614    }
     615
     616    ////////// get length attribute
     617    value = getIntValue(reader, "length", &ok);
     618    if (ok)
     619    {
     620#if XML_PARSER_DEBUG
     621printf("      length      = %x\n", value);
     622#endif
     623        vseg[vseg_index]->length = value;
     624    }
     625    else
     626    {
     627        printf("[XML ERROR] illegal or missing <length> attribute for vseg (%d,%d)\n",
     628                vspace_index, vseg_loc_index);
     629        exit(1);
     630    }
     631
     632    //////// get type attribute
     633    str = getStringValue(reader, "type", &ok);
     634
     635#if XML_PARSER_DEBUG
     636printf("      type        = %s\n", str);
     637#endif
     638
     639    if      (ok && (strcmp(str, "ELF")    == 0)) vseg[vseg_index]->type = VSEG_TYPE_ELF;
     640    else if (ok && (strcmp(str, "PERI")   == 0)) vseg[vseg_index]->type = VSEG_TYPE_PERI;
     641    else if (ok && (strcmp(str, "BLOB")   == 0)) vseg[vseg_index]->type = VSEG_TYPE_BLOB;
     642    else if (ok && (strcmp(str, "PTAB")   == 0)) vseg[vseg_index]->type = VSEG_TYPE_PTAB;
     643    else if (ok && (strcmp(str, "BUFFER") == 0)) vseg[vseg_index]->type = VSEG_TYPE_BUFFER;
     644    else if (ok && (strcmp(str, "SCHED")  == 0)) vseg[vseg_index]->type = VSEG_TYPE_SCHED;
     645    else if (ok && (strcmp(str, "HEAP")   == 0)) vseg[vseg_index]->type = VSEG_TYPE_HEAP;
     646    else
     647    {
     648        printf("[XML ERROR] illegal or missing <type> attribute for vseg (%d,%d)\n",
    952649                vspace_index, vseg_loc_index);
    953650        exit(1);
     
    1033730    }
    1034731
    1035     ////////// get vobjs in vseg
     732    ////////// get binpath attribute (optional : "" if missing)
     733    str = getStringValue(reader, "binpath", &ok);
     734    if (ok)
     735    {
     736#if XML_PARSER_DEBUG
     737printf("      binpath = %s\n", str);
     738#endif
     739        strncpy(vseg[vseg_index]->binpath, str, 63);
     740    }
     741    else
     742    {
     743        vseg[vseg_index]->binpath[0] = 0;
     744    }
     745
     746    vseg_index++;
     747    vseg_loc_index++;
     748} // end vsegNode()
     749
     750////////////////////////////////////////
     751void vspaceNode(xmlTextReaderPtr reader)
     752{
     753    unsigned int ok;
     754
     755    vseg_loc_index = 0;
     756    task_loc_index = 0;
     757
     758    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) return;
     759
     760    vspace[vspace_index] = (mapping_vspace_t *) malloc(sizeof(mapping_vspace_t));
     761    header->vspaces      = header->vspaces + 1;
     762
     763    ////////// get name attribute
     764    char* vspace_name = getStringValue(reader, "name", &ok);
     765    if (ok)
     766    {
     767#if XML_PARSER_DEBUG
     768printf("\n  vspace = %s\n", vspace_name );
     769#endif
     770        strncpy( vspace[vspace_index]->name, vspace_name , 31 );
     771    }
     772    else
     773    {
     774        printf("[XML ERROR] illegal or missing <name> attribute for vspace %d\n",
     775                vspace_index);
     776        exit(1);
     777    }
     778
     779    ////////// set vseg_offset and task_offset attributes
     780    vspace[vspace_index]->vseg_offset = vseg_index;
     781    vspace[vspace_index]->task_offset = task_index;
     782
     783    ////////// initialise vsegs and tasks attributes
     784    vspace[vspace_index]->vsegs = 0;
     785    vspace[vspace_index]->tasks = 0;
     786
     787    ////////// get startname attribute
     788    char* start_name = getStringValue(reader, "startname", &ok);
     789    if (ok == 0)
     790    {
     791        printf("[XML ERROR] illegal or missing <startname> attribute for vspace %s\n",
     792                vspace[vspace_index]->name);
     793        exit(1);
     794    }
     795
    1036796    int status = xmlTextReaderRead(reader);
    1037797    while (status == 1)
     
    1039799        const char * tag = (const char *) xmlTextReaderConstName(reader);
    1040800
    1041         if      (strcmp(tag, "vobj")     == 0 ) { vobjNode(reader); }
    1042         else if (strcmp(tag, "#text"  )  == 0 ) { }
    1043         else if (strcmp(tag, "#comment") == 0 ) { }
    1044         else if (strcmp(tag, "vseg")     == 0 )
    1045         {
    1046             vseg[vseg_index]->vobjs = vobj_count;
    1047             setVsegLength();
    1048             checkVsegOverlap();
    1049             vseg_index++;
    1050             vseg_loc_index++;
    1051             return;
    1052         }
    1053         else
    1054         {
    1055             printf("[XML ERROR] Unknown tag %s", tag);
    1056             exit(1);
    1057         }
    1058         status = xmlTextReaderRead (reader);
    1059     }
    1060 } // end vsegNode()
    1061 
    1062 ////////////////////////////////////////
    1063 void vspaceNode(xmlTextReaderPtr reader)
    1064 {
    1065     char * str;
    1066     unsigned int ok;
    1067     unsigned int nb_task_vspace = 0;
    1068 
    1069     vobj_loc_index = 0;
    1070     vseg_loc_index = 0;
    1071     task_loc_index = 0;
    1072 
    1073     if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) return;
    1074 
    1075 #if XML_PARSER_DEBUG
    1076 printf("\n  vspace %d\n", vspace_index);
    1077 #endif
    1078 
    1079     vspace[vspace_index] = (mapping_vspace_t *) malloc(sizeof(mapping_vspace_t));
    1080     header->vspaces      = header->vspaces + 1;
    1081 
    1082     ////////// get name attribute
    1083     str = getStringValue(reader, "name", &ok);
    1084     if (ok) {
    1085 #if XML_PARSER_DEBUG
    1086 printf("  name = %s\n", str);
    1087 #endif
    1088         strncpy(vspace[vspace_index]->name, str, 31);
    1089     }
    1090     else
    1091     {
    1092         printf("[XML ERROR] illegal or missing <name> attribute for vspace %d\n",
    1093                 vspace_index);
    1094         exit(1);
    1095     }
    1096 
    1097     ////////// set vseg_offset and task_offset attributes
    1098     vspace[vspace_index]->vseg_offset = vseg_index;
    1099     vspace[vspace_index]->vobj_offset = vobj_index;
    1100     vspace[vspace_index]->task_offset = task_index;
    1101 
    1102 #if XML_PARSER_DEBUG
    1103     printf("  vseg_offset = %d\n", vseg_index);
    1104     printf("  vobj_offset = %d\n", vobj_index);
    1105     printf("  task_offset = %d\n", task_index);
    1106 #endif
    1107 
    1108     ////////// get startname attribute
    1109     str = getStringValue(reader, "startname", &ok);
    1110     if (ok)
    1111     {
    1112         //used after parsing the vobjs
    1113     }
    1114     else
    1115     {
    1116         printf("[XML ERROR] illegal or missing <startname> attribute for vspace %s\n",
    1117                 vspace[vspace_index]->name);
    1118         exit(1);
    1119     }
    1120 
    1121     int status = xmlTextReaderRead(reader);
    1122     while (status == 1)
    1123     {
    1124         const char * tag = (const char *) xmlTextReaderConstName(reader);
    1125 
    1126801        if (strcmp(tag, "vseg") == 0)
    1127802        {
    1128803            vsegNode(reader);
     804            vspace[vspace_index]->vsegs += 1;
    1129805        }
    1130806        else if (strcmp(tag, "task") == 0)
    1131807        {
    1132808            taskNode(reader);
    1133             nb_task_vspace++;
     809            vspace[vspace_index]->tasks += 1;
    1134810        }
    1135811        else if (strcmp(tag, "#text")    == 0) { }
     
    1137813        else if (strcmp(tag, "vspace")   == 0)
    1138814        {
    1139             vspace[vspace_index]->vobjs = vobj_loc_index;
    1140             vspace[vspace_index]->tasks = task_loc_index ;
    1141             vspace[vspace_index]->vsegs = vseg_loc_index ;
    1142 
    1143             // get index of the vobj containing the start vector
    1144             int index = getVobjId(vspace_index, str , vobj_loc_index);
     815            // get index of the vseg containing the start vector
     816            int index = getVsegId( vspace_index, start_name );
    1145817            if (index == -1)
    1146818            {
    1147                 printf("[XML ERROR] vobj containing start vector not found in vspace %s\n",
     819                printf("[XML ERROR] vseg containing start vector not found in vspace %s\n",
    1148820                        vspace[vspace_index]->name);
    1149821                exit(1);
     
    1151823            else
    1152824            {
    1153                 vspace[vspace_index]->start_vobj_id = index;
    1154 #if XML_PARSER_DEBUG
    1155                 printf("      startname = %s\n", str);
    1156                 printf("      start_id  = %d\n", index);
    1157                 printf("  end vspace %d\n\n", vspace_index);
    1158 #endif
     825                vspace[vspace_index]->start_vseg_id = index;
    1159826            }
    1160827
    1161             // checking for all tasks that the startid
    1162             // is smaller than the number of tasks in vspace
    1163             int task_id;
    1164             int task_min = vspace[vspace_index]->task_offset;
    1165             int task_max = task_min + vspace[vspace_index]->tasks;
    1166             for (task_id = task_min; task_id < task_max; task_id++)
    1167             {
    1168                 if (task[task_id]->startid >= vspace[vspace_index]->tasks)
    1169                 {
    1170                     printf("[XML ERROR] <startid> too large for task (%d,%d)\n",
    1171                             vspace_index, task_id );
    1172                     exit(1);
    1173                 }
    1174             }
    1175 
    1176             nb_tasks_max += nb_task_vspace;
     828#if XML_PARSER_DEBUG
     829printf("      vsegs       = %d\n", vspace[vspace_index]->vsegs );
     830printf("      tasks       = %d\n", vspace[vspace_index]->tasks );
     831printf("      vseg_offset = %d\n", vspace[vspace_index]->vseg_offset );
     832printf("      task_offset = %d\n", vspace[vspace_index]->task_offset );
     833printf("      startname   = %s\n", start_name);
     834printf("      start_id    = %d\n", index);
     835printf("  end vspace %d\n\n", vspace_index);
     836#endif
    1177837            vspace_index++;
    1178838            return;
     
    1328988
    1329989    cp_port[cp_port_index] = (mapping_cp_port_t *) malloc(sizeof(mapping_cp_port_t));
    1330     cp_port_vobj_ref[cp_port_index] = (vobj_ref_t *) malloc(sizeof(vobj_ref_t));
    1331990
    1332991    ///////// get direction attribute
     
    13591018    }
    13601019
    1361     /////////// get vspacename attribute
    1362     str = getStringValue(reader, "vspacename", &ok);
    1363 #if XML_PARSER_DEBUG
    1364 printf("      vspacename = %s\n", str);
    1365 #endif
    1366     if (ok)
    1367     {
    1368         strncpy(cp_port_vobj_ref[cp_port_index]->vspace_name, str, 31);
    1369     }
    1370     else
    1371     {
    1372         printf("[XML ERROR] missing <vspacename> for cp_port %d in cluster %d\n",
    1373                 cp_port_index, cluster_index);
    1374         exit(1);
    1375     }
    1376 
    1377     /////////// get vobjname attribute
    1378     str = getStringValue(reader, "vobjname", &ok);
    1379 #if XML_PARSER_DEBUG
    1380 printf("      vobjname = %s\n", str);
    1381 #endif
    1382     if (ok)
    1383     {
    1384         strncpy(cp_port_vobj_ref[cp_port_index]->vobj_name, str, 31);
    1385     }
    1386     else
    1387     {
    1388         printf("[XML ERROR] missing <vobjname> for cp_port %d in cluster %d\n",
    1389                 cp_port_index, cluster_index);
    1390         exit(1);
    1391     }
    13921020    cp_port_index++;
    13931021    cp_port_loc_index++;
     
    14791107printf("      type        = %s\n", str);
    14801108#endif
    1481         unsigned int error = 0;
    1482 
    1483         // initialize peripheral subtype
    1484         periph[periph_index]->subtype = 0xFFFFFFFF;
    1485 
    1486         // The CMA, FBF, HBA, IOB, IOC, NIC, ROM, SIM, TTY, PIC, DROM peripherals are not
    1487         // replicated in all clusters but can be instanciated twice.
    1488 
    1489         ////////////////////////////
    1490         if (strcmp(str, "CMA") == 0)
    1491         {
    1492             periph[periph_index]->type = PERIPH_TYPE_CMA;
    1493             if ( cma_channels < periph[periph_index]->channels )
    1494             {
    1495                 cma_channels = periph[periph_index]->channels;
    1496             }
    1497         }
    1498         /////////////////////////////////
    1499         else if (strcmp(str, "FBF") == 0)
    1500         {
    1501             periph[periph_index]->type = PERIPH_TYPE_FBF;
    1502             use_fbf = 1;
    1503         }
    1504         /////////////////////////////////
    1505         else if (strcmp(str, "IOB") == 0)
    1506         {
    1507             periph[periph_index]->type = PERIPH_TYPE_IOB;
    1508             use_iob = 1;
    1509         }
    1510         /////////////////////////////////
    1511         else if (strcmp(str, "IOC") == 0)
    1512         {
    1513             char* subtype = getStringValue(reader, "subtype", &ok);
    1514             if (!ok)
    1515             {
    1516                 printf("[XML ERROR] IOC peripheral needs a subtype: BDV, HBA or SPI\n");
    1517                 exit(1);
    1518             }
    1519 
    1520             if ( strcmp(subtype, "BDV") == 0 )
    1521             {
    1522                 periph[periph_index]->type    = PERIPH_TYPE_IOC;
    1523                 periph[periph_index]->subtype = PERIPH_SUBTYPE_BDV;
    1524                 ioc_channels = 1;
    1525                 if ( header->use_ram_disk == 0 ) use_bdv = 1;
    1526             }
    1527             else if ( strcmp(subtype, "HBA") == 0 )
    1528             {
    1529                 periph[periph_index]->type    = PERIPH_TYPE_IOC;
    1530                 periph[periph_index]->subtype = PERIPH_SUBTYPE_HBA;
    1531                 ioc_channels = periph[periph_index]->channels;
    1532                 if ( header->use_ram_disk == 0 ) use_hba = 1;
    1533             }
    1534             else if ( strcmp(subtype, "SPI") == 0 )
    1535             {
    1536                 periph[periph_index]->type    = PERIPH_TYPE_IOC;
    1537                 periph[periph_index]->subtype = PERIPH_SUBTYPE_SPI;
    1538                 ioc_channels = periph[periph_index]->channels;
    1539                 if ( header->use_ram_disk == 0 ) use_spi = 1;
    1540             }
    1541             else
    1542             {
    1543                 printf("[XML ERROR] illegal subtype for IOC peripheral\n");
    1544                 exit(1);
    1545             }
    1546         }
    1547         /////////////////////////////////
    1548         else if (strcmp(str, "NIC") == 0)
    1549         {
    1550             periph[periph_index]->type = PERIPH_TYPE_NIC;
    1551             if ( nic_channels < periph[periph_index]->channels )
    1552             {
    1553                 nic_channels = periph[periph_index]->channels;
    1554             }
    1555         }
    1556         /////////////////////////////////
    1557         else if (strcmp(str, "ROM") == 0)
    1558         {
    1559             periph[periph_index]->type = PERIPH_TYPE_ROM;
    1560         }
    1561         /////////////////////////////////
    1562         else if (strcmp(str, "SIM") == 0)
    1563         {
    1564             periph[periph_index]->type = PERIPH_TYPE_SIM;
    1565         }
    1566         /////////////////////////////////
    1567         else if (strcmp(str, "TTY") == 0)
    1568         {
    1569             periph[periph_index]->type = PERIPH_TYPE_TTY;
    1570             if ( tty_channels < periph[periph_index]->channels )
    1571             {
    1572                 tty_channels = periph[periph_index]->channels;
    1573             }
    1574         }
    1575         /////////////////////////////////
    1576         else if (strcmp(str, "PIC") == 0)
    1577         {
    1578             periph[periph_index]->type = PERIPH_TYPE_PIC;
    1579             if ( pic_channels < periph[periph_index]->channels )
    1580             {
    1581                 pic_channels = periph[periph_index]->channels;
    1582             }
    1583             use_pic = 1;
    1584         }
    1585 
    1586 
    1587         // The DMA, MMC, XCU peripherals can be replicated in all clusters
    1588         // but no more than one component of each type per cluster
    1589 
    1590         /////////////////////////////////
    1591         else if (strcmp(str, "DMA") == 0)
    1592         {
    1593             periph[periph_index]->type = PERIPH_TYPE_DMA;
    1594             if (found_dma)  error = 1;
    1595             found_dma = 1;
    1596             if (dma_channels < periph[periph_index]->channels)
    1597                 dma_channels = periph[periph_index]->channels;
    1598         }
    1599         //////////////////////////////////
    1600         else if (strcmp(str, "MMC") == 0)
    1601         {
    1602             periph[periph_index]->type = PERIPH_TYPE_MMC;
    1603             if (found_mmc)  error = 1;
    1604             found_mmc = 1;
    1605             if ( periph[periph_index]->channels != 1 ) error = 1;
    1606         }
    1607         //////////////////////////////////
    1608         else if (strcmp(str, "XCU") == 0)
    1609         {
    1610             periph[periph_index]->type = PERIPH_TYPE_XCU;
    1611             if (found_xcu || found_icu || found_timer)  error = 1;
    1612             found_xcu    = 1;
    1613             found_timer  = 1;
    1614             tim_channels = 32;
    1615             use_xcu      = 1;
    1616 
    1617             if ( periph[periph_index]->channels <
    1618                  (header->irq_per_proc * cluster[cluster_index]->procs) )
    1619             {
    1620                 printf("[XML ERROR] XCU channels smaller than PROCS * IRQ_PER_PROC\n");
    1621                 printf(" - xcu channels = %d\n - nprocs = %d\n - irq_per_proc = %d\n",
    1622                        periph[periph_index]->channels,
    1623                        cluster[cluster_index]->procs,
    1624                        header->irq_per_proc );
    1625                 exit(1);
    1626             }
    1627         }
    1628         /////////////////////////////////
    1629         else if (strcmp(str, "DROM") == 0)
    1630         {
    1631             periph[periph_index]->type = PERIPH_TYPE_DROM;
    1632         }
     1109        if      (strcmp(str, "CMA" ) == 0) periph[periph_index]->type = PERIPH_TYPE_CMA;
     1110        else if (strcmp(str, "FBF" ) == 0) periph[periph_index]->type = PERIPH_TYPE_FBF;
     1111        else if (strcmp(str, "IOB" ) == 0) periph[periph_index]->type = PERIPH_TYPE_IOB;
     1112        else if (strcmp(str, "IOC" ) == 0) periph[periph_index]->type = PERIPH_TYPE_IOC;
     1113        else if (strcmp(str, "NIC" ) == 0) periph[periph_index]->type = PERIPH_TYPE_NIC;
     1114        else if (strcmp(str, "ROM" ) == 0) periph[periph_index]->type = PERIPH_TYPE_ROM;
     1115        else if (strcmp(str, "SIM" ) == 0) periph[periph_index]->type = PERIPH_TYPE_SIM;
     1116        else if (strcmp(str, "TTY" ) == 0) periph[periph_index]->type = PERIPH_TYPE_TTY;
     1117        else if (strcmp(str, "PIC" ) == 0) periph[periph_index]->type = PERIPH_TYPE_PIC;
     1118        else if (strcmp(str, "DMA" ) == 0) periph[periph_index]->type = PERIPH_TYPE_DMA;
     1119        else if (strcmp(str, "MMC" ) == 0) periph[periph_index]->type = PERIPH_TYPE_MMC;
     1120        else if (strcmp(str, "XCU" ) == 0) periph[periph_index]->type = PERIPH_TYPE_XCU;
     1121        else if (strcmp(str, "DROM") == 0) periph[periph_index]->type = PERIPH_TYPE_DROM;
    16331122        else
    16341123        {
     
    16371126            exit(1);
    16381127        }
    1639 
    1640         if (error)
    1641         {
    1642             printf("[XML ERROR] illegal peripheral %s in cluster %d\n",
    1643                     str, cluster_index);
     1128    }
     1129
     1130    ////////// get subtype if IOC
     1131    if (periph[periph_index]->type == PERIPH_TYPE_IOC )
     1132    {
     1133        char* subtype = getStringValue(reader, "subtype", &ok);
     1134        if (ok)
     1135        {
     1136#if XML_PARSER_DEBUG
     1137printf("      subtype     = %s\n", str);
     1138#endif
     1139            if      (strcmp(subtype, "BDV") == 0)
     1140            periph[periph_index]->subtype = PERIPH_SUBTYPE_BDV;
     1141            else if (strcmp(subtype, "HBA") == 0)
     1142            periph[periph_index]->subtype = PERIPH_SUBTYPE_HBA;
     1143            else if (strcmp(subtype, "SPI") == 0)
     1144            periph[periph_index]->subtype = PERIPH_SUBTYPE_SPI;
     1145        }
     1146        else
     1147        {
     1148            printf("[XML ERROR] illegal subtype for IOC peripheral\n");
    16441149            exit(1);
    16451150        }
    16461151    }
    1647     else
    1648     {
    1649         printf("[XML ERROR] illegal or missing <type> for peripheral  %d in cluster %d\n",
    1650                 periph_loc_index, cluster_index);
    1651         exit(1);
     1152    else
     1153    {
     1154        periph[periph_index]->subtype = 0XFFFFFFFF;
    16521155    }
    16531156
     
    18361339    proc_loc_index++;
    18371340    proc_index++;
    1838     total_procs++;
    18391341} // end procNode()
    18401342
     
    20271529        else if (strcmp(tag, "cluster")  == 0)
    20281530        {
    2029             ///////// TIMER and ICU peripheral are mandatory when nprocs != 0
    2030 
    2031             unsigned int procs = cluster[cluster_index]->procs;
    2032             if ( procs && !found_timer && !found_xcu)
    2033             {
    2034                 printf("[XML ERROR] missing timer peripheral in cluster %d\n", cluster_index);
    2035                 exit(1);
    2036             }
    2037 
    2038             if ( procs && !found_icu && !found_xcu)
    2039             {
    2040                 printf("[XML ERROR] missing icu peripheral in cluster %d\n", cluster_index);
    2041                 exit(1);
    2042             }
    2043 
    2044             if (nb_procs_max < procs) nb_procs_max = procs;
    20451531
    20461532#if XML_PARSER_DEBUG
     
    20821568            {
    20831569                printf("[XML ERROR] Wrong number of clusters\n");
    2084                 exit(1);
    2085             }
    2086 
    2087             // checking TTY terminal for system boot
    2088             if ( tty_channels == 0 )
    2089             {
    2090                 printf("[XML ERROR] missing TTY peripheral\n");
    2091                 exit(1);
    2092             }
    2093 
    2094             // checking IOC sub-types
    2095             if ( (use_bdv + use_hba + use_spi) > 1 )
    2096             {
    2097                 printf("[XML ERROR] all IOC peripherals must have the same type\n");
    20981570                exit(1);
    20991571            }
     
    21821654        {
    21831655            header->vsegs = vseg_index;
    2184             header->vobjs = vobj_index;
    21851656            header->tasks = task_index;
    21861657            return;
     
    23631834    header->psegs     = 0;
    23641835    header->vsegs     = 0;
    2365     header->vobjs     = 0;
    23661836    header->tasks     = 0;
    23671837    header->procs     = 0;
     
    23991869
    24001870
    2401 ///////////////////////////////////////
    2402 void BuildTable(int fdout, const char * type, unsigned int nb_elem,
    2403                 unsigned int elem_size, char ** table)
     1871////////////////////////////////////
     1872void BuildTable( int          fdout,
     1873                 const char * type,
     1874                 unsigned int nb_elem,
     1875                 unsigned int elem_size,
     1876                 char ** table )
    24041877{
    24051878    unsigned int i;
    2406     // write element
    2407     for (i = 0; i < nb_elem; i++) {
    2408         if (elem_size != write(fdout, table[i], elem_size)) {
     1879    for (i = 0; i < nb_elem; i++)
     1880    {
     1881        if (elem_size != write(fdout, table[i], elem_size))
     1882        {
    24091883            printf("function %s: %s(%d) write  error \n", __FUNCTION__, type, i);
    24101884            exit(1);
     
    24591933printf("vspaces   = %d\n", header->vspaces);
    24601934printf("psegs     = %d\n", header->psegs);
    2461 printf("vobjs     = %d\n", header->vobjs);
    24621935printf("vsegs     = %d\n", header->vsegs);
    24631936printf("tasks     = %d\n", header->tasks);
     
    24841957    // write vsegs
    24851958    BuildTable(fdout, "vseg", vseg_index, sizeof(mapping_vseg_t), (char **) vseg);
    2486     // write vobjs
    2487     BuildTable(fdout, "vobj", vobj_index, sizeof(mapping_vobj_t), (char **) vobj);
    24881959    // write tasks array
    24891960    BuildTable(fdout, "task", task_index, sizeof(mapping_task_t), (char **) task);
     
    25041975
    25051976
    2506 ///////////////////////////////////////////////////////////////////////////////////
    2507 // this function set the values of vspace_id and vobj_id fields for all cp_ports
    2508 ///////////////////////////////////////////////////////////////////////////////////
    2509 void prepareBuild()
    2510 {
    2511     unsigned int i;
    2512    
    2513     for (i = 0; i < cp_port_index; i++)
    2514     {
    2515         int vspace_id = getVspaceId(cp_port_vobj_ref[i]->vspace_name);
    2516         if (vspace_id < 0)
    2517         {
    2518             printf("[XML ERROR] illegal  <vspacename> for cp_port %d,\n", i);
    2519             exit(1);
    2520         }
    2521         cp_port[i]->vspaceid = vspace_id;
    2522 
    2523         int vobj_id = getVobjId( vspace_id,
    2524                                  cp_port_vobj_ref[i]->vobj_name,
    2525                                  vspace[vspace_id]->vobjs );
    2526         if (vobj_id >= 0)
    2527         {
    2528 
    2529 #if XML_PARSER_DEBUG
    2530             printf("\ncp_port = %d\n", i);
    2531             printf("      vspace_name  = %s\n", cp_port_vobj_ref[i]->vspace_name);
    2532             printf("      vobj_name    = %s\n", cp_port_vobj_ref[i]->vobj_name);
    2533             printf("      vobj_index   = %d\n", vobj_id);
    2534 #endif
    2535             cp_port[i]->mwmr_vobj_id = vobj_id;
    2536 
    2537             assert((vobj[vspace[vspace_id]->vobj_offset + vobj_id]->type == VOBJ_TYPE_MWMR)
    2538                     && "coproc ports must refer a vobj of type MWMR");
    2539         }
    2540         else
    2541         {
    2542             printf("[XML ERROR]  <vobjname> not found for cp_port %d,\n", i);
    2543             exit(1);
    2544         }
    2545     }
    2546 }
    2547 
    2548 //////////////////////////////////////////
    2549 void file_write(int fdout, char * towrite)
    2550 {
    2551     unsigned int size = strlen(towrite);
    2552     if (size != write(fdout, towrite, size))
    2553     {
    2554         printf("file_write error");
    2555         exit(1);
    2556     }
    2557 }
    2558 
    2559 //////////////////////////////////////////////////
    2560 void def_int_write(int fdout, char * def, int num)
    2561 {
    2562     char  buf[64];
    2563     sprintf(buf, "#define\t %s  %d\n", def, num);
    2564     file_write(fdout, buf);
    2565 }
    2566 
    2567 //////////////////////////////////////////////////
    2568 void def_hex_write(int fdout, char * def, int num)
    2569 {
    2570     char  buf[64];
    2571     sprintf(buf, "#define\t %s  0x%x\n", def, num);
    2572     file_write(fdout, buf);
    2573 }
    2574 
    2575 ///////////////////////////////////
    2576 void  genHd(const char * file_path)
    2577 {
    2578     int fdout = open_file(file_path);
    2579 
    2580     char prol[80];
    2581     sprintf(prol, "/* Generated from file %s.xml */\n\n",header->name);
    2582 
    2583     char * ifdef  = "#ifndef _HARD_CONFIG_H\n#define _HARD_CONFIG_H\n\n";
    2584     char * epil   = "\n#endif //_HARD_CONFIG_H";
    2585 
    2586     file_write(fdout, prol);
    2587     file_write(fdout, ifdef);
    2588 
    2589     def_int_write(fdout, "X_SIZE            ", header->x_size);
    2590     def_int_write(fdout, "Y_SIZE            ", header->y_size);
    2591     def_int_write(fdout, "X_WIDTH           ", header->x_width);
    2592     def_int_write(fdout, "Y_WIDTH           ", header->y_width);
    2593     def_int_write(fdout, "X_IO              ", header->x_io);
    2594     def_int_write(fdout, "Y_IO              ", header->y_io);
    2595 
    2596     file_write(fdout, "\n");
    2597 
    2598     def_int_write(fdout, "TOTAL_PROCS       ", total_procs);
    2599     def_int_write(fdout, "NB_PROCS_MAX      ", nb_procs_max);
    2600     def_int_write(fdout, "NB_TASKS_MAX      ", nb_tasks_max);
    2601 
    2602     file_write(fdout, "\n");
    2603 
    2604     def_int_write(fdout, "NB_TIM_CHANNELS   ", tim_channels);
    2605     def_int_write(fdout, "NB_DMA_CHANNELS   ", dma_channels);
    2606 
    2607     file_write(fdout, "\n");
    2608 
    2609     def_int_write(fdout, "NB_TTY_CHANNELS   ", tty_channels);
    2610     def_int_write(fdout, "NB_IOC_CHANNELS   ", ioc_channels);
    2611     def_int_write(fdout, "NB_NIC_CHANNELS   ", nic_channels);
    2612     def_int_write(fdout, "NB_CMA_CHANNELS   ", cma_channels);
    2613 
    2614     file_write(fdout, "\n");
    2615 
    2616     def_int_write(fdout, "USE_XICU          ", use_xcu);
    2617     def_int_write(fdout, "USE_IOB           ", use_iob);
    2618     def_int_write(fdout, "USE_PIC           ", use_pic);
    2619     def_int_write(fdout, "USE_FBF           ", use_fbf);
    2620 
    2621     file_write(fdout, "\n");
    2622 
    2623     def_int_write(fdout, "USE_IOC_RDK       ", header->use_ram_disk);
    2624     def_int_write(fdout, "USE_IOC_HBA       ", use_hba);
    2625     def_int_write(fdout, "USE_IOC_BDV       ", use_bdv);
    2626     def_int_write(fdout, "USE_IOC_SPI       ", use_spi);
    2627 
    2628     file_write(fdout, "\n");
    2629 
    2630     def_int_write(fdout, "IRQ_PER_PROCESSOR ", header->irq_per_proc);
    2631 
    2632     file_write(fdout, epil);
    2633 
    2634     close(fdout);
    2635 }
    2636 
    2637 ////////////////////////////////////////////////////////
    2638 void ld_write(int fdout, char * seg, unsigned int addr)
    2639 {
    2640     char buf[64];
    2641     sprintf(buf, "%s = 0x%x;\n", seg, addr);
    2642     file_write(fdout, buf);
    2643 }
    2644 
    2645 //////////////////////////////////
    2646 void genLd(const char * file_path)
    2647 {
    2648     int          fdout = open_file(file_path);
    2649     unsigned int count;
    2650     unsigned int vseg_id;
    2651     unsigned int base;      // vseg base
    2652     unsigned int size;      // vseg size
    2653 
    2654     char prol[80];
    2655     sprintf(prol, "/* Generated from file %s.xml */\n\n",header->name);
    2656 
    2657     file_write(fdout, prol);
    2658 
    2659     // boot mandatory global vsegs
    2660     for (vseg_id = 0 , count = 0 ; vseg_id < header->vsegs ; vseg_id++)
    2661     {
    2662         if ( strcmp(vseg[vseg_id]->name, "seg_boot_code") == 0 )
    2663         {
    2664             base = vseg[vseg_id]->vbase;
    2665             size = vobj[vseg[vseg_id]->vobj_offset]->length;
    2666             ld_write(fdout, "seg_boot_code_base      ", base);
    2667             ld_write(fdout, "seg_boot_code_size      ", size);
    2668             count++;
    2669         }
    2670         else if ( strcmp(vseg[vseg_id]->name, "seg_boot_data") == 0 )
    2671         {
    2672             base = vseg[vseg_id]->vbase;
    2673             size = vobj[vseg[vseg_id]->vobj_offset]->length;
    2674             ld_write(fdout, "seg_boot_data_base      ", base);
    2675             ld_write(fdout, "seg_boot_data_size      ", size);
    2676             count++;
    2677         }
    2678         else if ( strcmp(vseg[vseg_id]->name, "seg_boot_stack") == 0 )
    2679         {
    2680             base = vseg[vseg_id]->vbase;
    2681             size = vobj[vseg[vseg_id]->vobj_offset]->length;
    2682             ld_write(fdout, "seg_boot_stack_base     ", base);
    2683             ld_write(fdout, "seg_boot_stack_size     ", size);
    2684             count++;       
    2685         }
    2686         else if ( strcmp(vseg[vseg_id]->name, "seg_boot_mapping") == 0 )
    2687         {
    2688             base = vseg[vseg_id]->vbase;
    2689             size = vobj[vseg[vseg_id]->vobj_offset]->length;
    2690             ld_write(fdout, "seg_boot_mapping_base   ", base);
    2691             ld_write(fdout, "seg_boot_mapping_size   ", size);
    2692             count++;
    2693         }
    2694     }
    2695 
    2696     if ( count != 4 )
    2697     {
    2698         printf ("[XML ERROR] Missing mandatory Boot global vseg : only %d\n", count);
    2699         printf ("Mandatory segments are :\n");
    2700         printf (" - seg_boot_code\n");
    2701         printf (" - seg_boot_data\n");
    2702         printf (" - seg_boot_stack\n");
    2703         printf (" - seg_boot_mapping\n");
    2704         exit(0);
    2705     }
    2706 
    2707     file_write(fdout, "\n");
    2708 
    2709     // kernel mandatory global vsegs
    2710     for (vseg_id = 0, count = 0 ; vseg_id < header->vsegs ; vseg_id++)
    2711     {
    2712         if ( strcmp(vseg[vseg_id]->name, "seg_kernel_code") == 0 )
    2713         {
    2714             base = vseg[vseg_id]->vbase;
    2715             size = vobj[vseg[vseg_id]->vobj_offset]->length;
    2716             ld_write(fdout, "seg_kernel_code_base    ", base);
    2717             ld_write(fdout, "seg_kernel_code_size    ", size);
    2718             count++;
    2719         }
    2720         else if ( strcmp(vseg[vseg_id]->name, "seg_kernel_data") == 0 )
    2721         {
    2722             base = vseg[vseg_id]->vbase;
    2723             size = vobj[vseg[vseg_id]->vobj_offset]->length;
    2724             ld_write(fdout, "seg_kernel_data_base    ", base);
    2725             ld_write(fdout, "seg_kernel_data_size    ", size);
    2726             count++;
    2727         }
    2728         else if ( strcmp(vseg[vseg_id]->name, "seg_kernel_uncdata") == 0 )
    2729         {
    2730             base = vseg[vseg_id]->vbase;
    2731             size = vobj[vseg[vseg_id]->vobj_offset]->length;
    2732             ld_write(fdout, "seg_kernel_uncdata_base ", base);
    2733             ld_write(fdout, "seg_kernel_uncdata_size ", size);
    2734             count++;
    2735         }
    2736         else if ( strcmp(vseg[vseg_id]->name, "seg_kernel_init") == 0 )
    2737         {
    2738             base = vseg[vseg_id]->vbase;
    2739             size = vobj[vseg[vseg_id]->vobj_offset]->length;
    2740             ld_write(fdout, "seg_kernel_init_base    ", base);
    2741             ld_write(fdout, "seg_kernel_init_size    ", size);
    2742             count++;
    2743         }
    2744     }
    2745     if ( count != 4 )
    2746     {
    2747         printf ("[XML ERROR] Missing mandatory Kernel global vseg : only %d\n", count);
    2748         printf ("Mandatory segments are :\n");
    2749         printf (" - seg_kernel_code\n");
    2750         printf (" - seg_kernel_data\n");
    2751         printf (" - seg_kernel_uncdata\n");
    2752         printf (" - seg_kernel_init\n");
    2753         exit(0);
    2754     }
    2755 
    2756     file_write(fdout, "\n");
    2757 
    2758     // boot and kernel optionnal global vsegs (pseudo ROMs)
    2759     unsigned int seg_ram_disk_base    = 0xFFFFFFFF;
    2760     unsigned int seg_ram_disk_size    = 0;
    2761     unsigned int seg_reset_code_base  = 0xFFFFFFFF;
    2762     unsigned int seg_reset_code_size  = 0;
    2763     for (vseg_id = 0 ; vseg_id < header->vsegs ; vseg_id++)
    2764     {
    2765         if ( strcmp(vseg[vseg_id]->name, "seg_reset_code") == 0 )
    2766         {
    2767             seg_reset_code_base = vseg[vseg_id]->vbase;
    2768             seg_reset_code_size = vobj[vseg[vseg_id]->vobj_offset]->length;
    2769         }
    2770         if ( strcmp(vseg[vseg_id]->name, "seg_ram_disk") == 0 )
    2771         {
    2772             seg_ram_disk_base   = vseg[vseg_id]->vbase;
    2773             seg_ram_disk_size   = vobj[vseg[vseg_id]->vobj_offset]->length;
    2774         }
    2775     }
    2776 
    2777     ld_write(fdout, "seg_reset_code_base     ", seg_reset_code_base);
    2778     ld_write(fdout, "seg_reset_code_size     ", seg_reset_code_size);
    2779     ld_write(fdout, "seg_ram_disk_base       ", seg_ram_disk_base);
    2780     ld_write(fdout, "seg_ram_disk_size       ", seg_ram_disk_size);
    2781    
    2782     file_write(fdout, "\n");
    2783 
    2784     // fill the peripherals base address array
    2785     set_periph_vbase_array();
    2786 
    2787     //  non replicated peripherals
    2788     ld_write(fdout, "seg_cma_base            ",   periph_vbase_array[PERIPH_TYPE_CMA]);
    2789     ld_write(fdout, "seg_fbf_base            ",   periph_vbase_array[PERIPH_TYPE_FBF]);
    2790     ld_write(fdout, "seg_iob_base            ",   periph_vbase_array[PERIPH_TYPE_IOB]);
    2791     ld_write(fdout, "seg_ioc_base            ",   periph_vbase_array[PERIPH_TYPE_IOC]);
    2792     ld_write(fdout, "seg_nic_base            ",   periph_vbase_array[PERIPH_TYPE_NIC]);
    2793     ld_write(fdout, "seg_rom_base            ",   periph_vbase_array[PERIPH_TYPE_ROM]);
    2794     ld_write(fdout, "seg_sim_base            ",   periph_vbase_array[PERIPH_TYPE_SIM]);
    2795     ld_write(fdout, "seg_tty_base            ",   periph_vbase_array[PERIPH_TYPE_TTY]);
    2796     ld_write(fdout, "seg_pic_base            ",   periph_vbase_array[PERIPH_TYPE_PIC]);
    2797 
    2798     file_write(fdout, "\n");
    2799 
    2800     // replicated peripherals
    2801     ld_write(fdout, "seg_dma_base            ",   periph_vbase_array[PERIPH_TYPE_DMA]);
    2802     ld_write(fdout, "seg_mmc_base            ",   periph_vbase_array[PERIPH_TYPE_MMC]);
    2803     ld_write(fdout, "seg_xcu_base            ",   periph_vbase_array[PERIPH_TYPE_XCU]);
    2804 
    2805     file_write(fdout, "\n");
    2806 
    2807     ld_write(fdout, "vseg_cluster_increment  ",   0x00010000);
    2808 
    2809     close(fdout);
    2810 }
    2811 
    28121977//////////////////////////////////////////////////////
    28131978char * buildPath(const char * path, const char * name)
     
    28241989int main(int argc, char * argv[])
    28251990{
    2826     if (argc < 3) {
     1991    if (argc < 3)
     1992    {
    28271993        printf("Usage: xml2bin <input_file_path> <output_path>\n");
    28281994        return 1;
     
    28301996
    28311997    struct stat dir_st;
    2832     if (stat( argv[2], &dir_st)) {
     1998    if (stat( argv[2], &dir_st))
     1999    {
    28332000        perror("bad path");
    28342001        exit(1);
    28352002    }
    28362003
    2837     if ((dir_st.st_mode & S_IFDIR) == 0) {
     2004    if ((dir_st.st_mode & S_IFDIR) == 0)
     2005    {
    28382006        printf("path is not a dir: %s", argv[2] );
    28392007        exit(1);
     
    28412009
    28422010    char * map_path = buildPath(argv[2], "map.bin");
    2843     char * ld_path = buildPath(argv[2], "giet_vsegs.ld");
    2844     char * hd_path = buildPath(argv[2], "hard_config.h");
    28452011
    28462012    LIBXML_TEST_VERSION;
     
    28592025            {
    28602026                headerNode(reader);
    2861                 prepareBuild();
    28622027                buildBin(map_path);
    2863                 genHd(hd_path);
    2864                 genLd(ld_path);
    28652028            }
    28662029            else
Note: See TracChangeset for help on using the changeset viewer.