Ignore:
Timestamp:
Jul 4, 2012, 2:51:18 PM (12 years ago)
Author:
alain
Message:

Introducing various modifications in kernel initialisation

File:
1 edited

Legend:

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

    r162 r165  
    5252unsigned int            vobj_index     = 0;
    5353unsigned int            vobj_loc_index = 0;
    54 unsigned int            vobj_loc_vspace_index = 0;
     54unsigned int            vobj_count     = 0;
     55
     56unsigned int            tty_index      = 1;
     57unsigned int            fb_index       = 0;
    5558           
    56 char one_elf_found = 0;//bool: wether a first vobj of type elf was found
    57 
    5859//////////////////////////////////////////////////
    5960unsigned int getIntValue( xmlTextReaderPtr reader,
     
    144145    unsigned int vobj_id;
    145146    unsigned int vobj_min = vspace[vspace_id]->vobj_offset;
    146     unsigned int vobj_max = vobj_min + vobj_loc_vspace_index;
     147    unsigned int vobj_max = vobj_min + vobj_loc_index;
    147148
    148149    for ( vobj_id = vobj_min ; vobj_id < vobj_max ; vobj_id++ )
     
    199200printf("      clusterid = %x\n", value);
    200201#endif
     202        if ( value >= header->clusters )
     203        {
     204            printf("[XML ERROR] <clusterid> too large for task (%d,%d)\n",
     205                   vspace_index, task_loc_index);
     206            exit(1);
     207        }
    201208        task[task_index]->clusterid = value;
    202209    } 
     
    215222printf("      proclocid = %x\n", value);
    216223#endif
     224        if ( value >= cluster[task[task_index]->clusterid]->procs )
     225        {
     226            printf("[XML ERROR] <proclocid> too large for task (%d,%d)\n",
     227                   vspace_index, task_loc_index);
     228            exit(1);
     229        }
    217230        task[task_index]->proclocid = value;
    218231    } 
     
    233246#if XML_PARSER_DEBUG
    234247printf("      stackname = %s\n", str);
    235 printf("      vsegid    = %d\n", index);
     248printf("      stackid   = %d\n", index);
    236249#endif
    237250            task[task_index]->vobjlocid = index;
     
    239252        else             
    240253        {
    241             printf("[XML ERROR] illegal or missing <psegname> for vseg %d\n",
    242                      vseg_loc_index);
     254            printf("[XML ERROR] illegal or missing <stackname> for task (%d,%d)\n",
     255                    vspace_index, task_loc_index);
    243256            exit(1);
    244257        }
     
    246259    else
    247260    {
    248         printf("[XML ERROR] illegal or missing <vsegname> for task (%d,%d)\n",
     261        printf("[XML ERROR] illegal or missing <stackname> for task (%d,%d)\n",
    249262                vspace_index, task_loc_index);
    250263        exit(1);
     
    267280    }
    268281
    269     /////////// get ttylocid  attribute
    270     value = getIntValue(reader,"ttylocid", &ok);
    271     if ( ok )
    272     {
    273 #if XML_PARSER_DEBUG
    274 printf("      ttylocid = %x\n", value);
    275 #endif
    276         if ( value >= vspace[vspace_index]->ttys )
    277         {
    278             printf("[XML ERROR] The ttylocid value is too large for task (%d,%d)\n",
     282    /////////// get use_tty  attribute (optionnal : 0 if missing)
     283    value = getIntValue(reader,"usetty", &ok);
     284    if ( ok )
     285    {
     286#if XML_PARSER_DEBUG
     287printf("      usetty = %x\n", value);
     288#endif
     289        if ( (value != 0) && (tty_index >= header->ttys) )
     290        {
     291            printf("[XML ERROR] The tty index is too large for task (%d,%d)\n",
    279292                vspace_index, task_loc_index);
    280293            exit(1);
    281294        }
    282         task[task_index]->ttylocid = value;
     295        task[task_index]->use_tty = value;
     296        if (value != 0) tty_index++;
    283297    } 
    284298    else
    285299    {
    286         printf("[XML ERROR] illegal or missing <ttylocid> attribute for task (%d,%d)\n",
     300        task[task_index]->use_tty = 0;
     301    }
     302
     303    /////////// get use_fb  attribute (optionnal : 0 if missing)
     304    value = getIntValue(reader,"usefb", &ok);
     305    if ( ok )
     306    {
     307#if XML_PARSER_DEBUG
     308printf("      usefb = %x\n", value);
     309#endif
     310        if ( (value != 0) && (fb_index >= header->fbs) )
     311        {
     312            printf("[XML ERROR] The fb channel index is too large for task (%d,%d)\n",
    287313                vspace_index, task_loc_index);
    288         exit(1);
     314            exit(1);
     315        }
     316        task[task_index]->use_fb = value;
     317        if (value != 0) fb_index++;
     318    } 
     319    else
     320    {
     321        task[task_index]->use_fb = 0;
    289322    }
    290323
     
    293326} // end taskNode()
    294327
     328//////////////////////////////////////////
    295329void  vobjNode ( xmlTextReaderPtr reader )
    296330{
     
    307341    }
    308342
    309     if(one_elf_found != 0)
    310     {
    311         printf("[XML ERROR] a vobj of the type ELF must be defined alone in a vseg (%d,%d)\n",
    312                 vspace_index, vobj_loc_vspace_index);
    313         exit(1);
    314 
    315     }
    316 
    317 #if XML_PARSER_DEBUG
    318 printf("    vobj %d\n", vobj_loc_index);
     343#if XML_PARSER_DEBUG
     344printf("      vobj %d\n", vobj_loc_index);
    319345#endif
    320346
     
    326352    {
    327353#if XML_PARSER_DEBUG
    328 printf("      name = %s\n", str);
     354printf("        name = %s\n", str);
    329355#endif
    330356        strncpy( vobj[vobj_index]->name, str, 31);
     
    337363    }
    338364
    339 
    340     // get type attribute
     365    //////// get type attribute
    341366    str = getStringValue(reader, "type", &ok);
    342367#if XML_PARSER_DEBUG
    343 printf("      type = %s\n", str);
    344 #endif
    345     if (ok && (strcmp(str, "ELF") == 0)){
    346         vobj[vobj_index]->type = ELF;
    347         one_elf_found = 1;
    348         if(vobj_loc_index != 0) //check that this vobj is the first
    349         {
    350             printf("[XML ERROR] a vobj of the type ELF must be defined alone in a vobj (%d,%d)\n",
    351                     vspace_index, vobj_loc_vspace_index);
    352             exit(1);
    353 
    354         }
    355     }
    356     else if (ok && (strcmp(str, "PTAB") == 0)) vobj[vobj_index]->type = PTAB;
    357     else if (ok && (strcmp(str, "PERI") == 0)) vobj[vobj_index]->type = PERI;
    358     else if (ok && (strcmp(str, "MWMR") == 0)) vobj[vobj_index]->type = MWMR;
    359     else if (ok && (strcmp(str, "LOCK") == 0)) vobj[vobj_index]->type = LOCK;
    360     else if (ok && (strcmp(str, "BUFFER") == 0)) vobj[vobj_index]->type = BUFFER;
    361     else if (ok && (strcmp(str, "BARRIER") == 0)) vobj[vobj_index]->type = BARRIER;
     368printf("        type = %s\n", str);
     369#endif
     370    if (ok && (strcmp(str, "ELF") == 0))
     371    {
     372        vobj[vobj_index]->type = VOBJ_TYPE_ELF;
     373
     374        //check that this vobj is the first in vseg
     375        if(vobj_count != 0)
     376        {
     377            printf("[XML ERROR] an ELF vobj must be alone in a vseg (%d,%d)\n",
     378                    vspace_index, vobj_loc_index);
     379            exit(1);
     380        }
     381    }
     382    else if (ok && (strcmp(str, "PTAB")    == 0)) vobj[vobj_index]->type = VOBJ_TYPE_PTAB;
     383    else if (ok && (strcmp(str, "PERI")    == 0)) vobj[vobj_index]->type = VOBJ_TYPE_PERI;
     384    else if (ok && (strcmp(str, "MWMR")    == 0)) vobj[vobj_index]->type = VOBJ_TYPE_MWMR;
     385    else if (ok && (strcmp(str, "LOCK")    == 0)) vobj[vobj_index]->type = VOBJ_TYPE_LOCK;
     386    else if (ok && (strcmp(str, "BUFFER")  == 0)) vobj[vobj_index]->type = VOBJ_TYPE_BUFFER;
     387    else if (ok && (strcmp(str, "BARRIER") == 0)) vobj[vobj_index]->type = VOBJ_TYPE_BARRIER;
    362388    else
    363389    {
    364390        printf("[XML ERROR] illegal or missing <type> attribute for vobj (%d,%d)\n",
    365                 vspace_index, vobj_loc_vspace_index);
    366         exit(1);
    367     }
    368 
    369 
    370     ////////// get length attribute (0 if missing)
     391                vspace_index, vobj_loc_index);
     392        exit(1);
     393    }
     394
     395    ////////// get length attribute
    371396    value = getIntValue(reader,"length", &ok);
    372397    if ( ok )
    373398    {
    374399#if XML_PARSER_DEBUG
    375 printf("      length = %d\n", value);
     400printf("        length = %d\n", value);
    376401#endif
    377402        vobj[vobj_index]->length = value;
     
    379404    else
    380405    {
    381         vobj[vobj_index]->length = 0;
    382     }
    383 
    384     ////////// get align attribute (0 if missing)
     406        printf("[XML ERROR] illegal or missing <length> attribute for vobj (%d,%d)\n",
     407                vspace_index, vobj_loc_index);
     408        exit(1);
     409    }
     410
     411    ////////// get align attribute (optional : 0 if missing)
    385412    value = getIntValue(reader,"align", &ok);
    386413    if ( ok )
    387414    {
    388415#if XML_PARSER_DEBUG
    389 printf("      align = %d\n", value);
     416printf("        align = %d\n", value);
    390417#endif
    391418        vobj[vobj_index]->align = value;
     
    396423    }
    397424
    398     ////////// get binpath attribute ('\0' if missing)
     425    ////////// get binpath attribute (optional : '\0' if missing)
    399426    str = getStringValue(reader, "binpath", &ok);
    400427    if ( ok )
    401428    {
    402429#if XML_PARSER_DEBUG
    403 printf("      binpath = %s\n", str);
     430printf("        binpath = %s\n", str);
    404431#endif
    405432        strncpy(vobj[vobj_index]->binpath, str, 63);
     
    410437    }
    411438   
     439    ////////// get init attribute (optional : 0 if missing)
     440    value = getIntValue(reader,"init", &ok);
     441    if ( ok )
     442    {
     443#if XML_PARSER_DEBUG
     444printf("        init  = %d\n", value);
     445#endif
     446        vobj[vobj_index]->init = value;
     447    } 
     448    else
     449    {
     450        vobj[vobj_index]->init = 0;
     451    }
     452
    412453    vobj_index++;
     454    vobj_count++;
    413455    vobj_loc_index++;
    414     vobj_loc_vspace_index++;
    415 }
    416 
    417 
    418 ///////////////////////////////////////////////////////////////
     456} // end vobjNode()
     457
     458//////////////////////////////////////////
    419459void  vsegNode ( xmlTextReaderPtr reader )
    420460{
     
    422462    unsigned int        value;
    423463    char*               str;
    424         vobj_loc_index = 0;
    425         one_elf_found = 0;
     464
     465        vobj_count = 0;
    426466
    427467    if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;
     
    442482    vseg[vseg_index]->vobj_offset = vobj_index;
    443483#if XML_PARSER_DEBUG
    444 printf("- vobj_offset = %d\n", vobj_index);
     484printf("      vobj_offset = %d\n", vobj_index);
    445485#endif
    446486
     
    477517    }
    478518
    479 
    480     ////////// get ident attribute (0 if missing)
     519    ////////// get ident attribute (optional : 0 if missing)
    481520    value = getIntValue(reader,"ident", &ok);
    482521    if ( ok )
     
    492531    }
    493532
    494 
    495533    ////////// get psegname attribute
    496534    str = getStringValue(reader,"psegname", &ok);
     
    520558    }
    521559
    522     // get mode attribute
     560    //////// get mode attribute
    523561    str = getStringValue(reader,"mode", &ok);
    524562#if XML_PARSER_DEBUG
     
    548586    }
    549587   
    550    
    551588    ////////// set the length attribute to 0
    552     //the final value will be set by the VLoader
    553589    vseg[vseg_index]->length = value;
    554590
     
    564600        {
    565601            //  checking source file consistency?
    566             vseg[vseg_index]->vobjs = vobj_loc_index;
     602            vseg[vseg_index]->vobjs = vobj_count;
    567603            vseg_index++;
    568604            vseg_loc_index++;
     
    576612        status = xmlTextReaderRead ( reader );
    577613    }
    578    
    579 
    580614} // end vsegNode()
    581615
     
    585619    char*               str;
    586620    unsigned int        ok;
    587     unsigned int        value;
    588     vobj_loc_vspace_index = 0;
     621
     622    vobj_loc_index = 0;
    589623        vseg_loc_index = 0;
    590624        task_loc_index = 0;
     
    601635
    602636#if XML_PARSER_DEBUG
    603 printf("  vspace %d\n", vspace_index);
     637printf("\n  vspace %d\n", vspace_index);
    604638#endif
    605639
    606640    vspace[vspace_index] = (mapping_vspace_t*)malloc(sizeof(mapping_vspace_t));
    607641
    608     ////////// set vseg_offsetand task_offset attributes
     642    ////////// get name attribute
     643    str = getStringValue(reader, "name", &ok);
     644    if ( ok )
     645    {
     646#if XML_PARSER_DEBUG
     647printf("  name = %s\n", str);
     648#endif
     649        strncpy(vspace[vspace_index]->name, str, 31);
     650    }
     651    else
     652    {
     653        printf("[XML ERROR] illegal or missing <name> attribute for vspace %d\n",
     654                 vspace_index);
     655        exit(1);
     656    }
     657
     658    ////////// set vseg_offset and task_offset attributes
    609659    vspace[vspace_index]->vseg_offset = vseg_index;
    610660    vspace[vspace_index]->vobj_offset = vobj_index;
     
    612662   
    613663#if XML_PARSER_DEBUG
    614 printf("- vseg_offset = %d\n", vseg_index);
    615 printf("- vobj_offset = %d\n", vobj_index);
    616 printf("- task_offset = %d\n", task_index);
    617 #endif
    618 
    619     ////////// get name attribute
    620     str = getStringValue(reader, "name", &ok);
    621     if ( ok )
    622     {
    623 #if XML_PARSER_DEBUG
    624 printf("    name = %s\n", str);
    625 #endif
    626         strncpy(vspace[vspace_index]->name, str, 31);
    627     }
    628     else
    629     {
    630         printf("[XML ERROR] illegal or missing <name> attribute for vspace %d",
     664printf("  vseg_offset = %d\n", vseg_index);
     665printf("  vobj_offset = %d\n", vobj_index);
     666printf("  task_offset = %d\n", task_index);
     667#endif
     668
     669    ////////// get startname attribute
     670    str = getStringValue(reader, "startname", &ok);
     671    if ( ok )
     672    {
     673        //used after parsing the vobjs
     674    }
     675    else
     676    {
     677        printf("[XML ERROR] illegal or missing <startname> attribute for vspace %d\n",
    631678                 vspace_index);
    632         exit(1);
    633     }
    634 
    635     ////////// get funcs_entry attribute
    636     str = getStringValue(reader, "funcs", &ok);
    637     if ( ok )
    638     {
    639 #if XML_PARSER_DEBUG
    640 printf("    name = %s\n", str);
    641 #endif
    642         //used after parsing all the vobjs
    643     }
    644     else
    645     {
    646         printf("[XML ERROR] illegal or missing <name> attribute for vspace %d",
    647                  vspace_index);
    648         exit(1);
    649     }
    650 
    651     // get ttys attribute
    652     value = getIntValue(reader,"ttys", &ok);
    653 #if XML_PARSER_DEBUG
    654 printf("    ttys = %d\n", value);
    655 #endif
    656     if ( ok )
    657     {
    658         vspace[vspace_index]->ttys = value;
    659     }
    660     else
    661     {
    662         printf("[XML ERROR] illegal or missing <ttys> attribute for vspace %d",
    663                   vspace_index);
    664679        exit(1);
    665680    }
     
    675690        else if ( strcmp(tag,"vspace") == 0  )
    676691        {
    677             vspace[vspace_index]->vobjs = vobj_loc_vspace_index;
     692            vspace[vspace_index]->vobjs = vobj_loc_index;
    678693            vspace[vspace_index]->tasks = task_loc_index ;
    679694            vspace[vspace_index]->vsegs = vseg_loc_index ;
     695
     696            // get index of the vobj containing the start vector
    680697            int index =  getVobjLocId( vspace_index, str );
    681698            if(index == -1)
    682699            {
    683                 printf("Error funcs entry vobj not found %s\n",str);
     700                printf("[XML ERROR] vobj containing the start vector not found %s\n",str);
    684701                exit(-1);
    685702            }
    686             vspace[vspace_index]->funcs_offset = index;
     703            else
     704            {
     705                vspace[vspace_index]->start_offset = index;
     706#if XML_PARSER_DEBUG
     707printf("  startname = %s\n", str);
     708printf("  startid   = %d\n", index);
     709#endif
     710            }
     711
     712            // checking startid values for all tasks in vspace
     713            int task_id;
     714            int task_min = vspace[vspace_index]->task_offset;
     715            int task_max = task_min + vspace[vspace_index]->tasks;
     716            for ( task_id = task_min ; task_id < task_max ; task_id++ )
     717            {
     718                if ( task[task_id]->startid >= vspace[vspace_index]->tasks )
     719                {
     720                    printf("[XML ERROR] <startid> too large for task (%d,%d)\n",
     721                           vspace_index, task_id );
     722                    exit(1);
     723                }
     724            }
    687725
    688726            vspace_index++;
     
    722760    str = getStringValue( reader, "name", &ok );
    723761#if XML_PARSER_DEBUG
    724 printf("  - name = %s\n", str);
     762printf("    name = %s\n", str);
    725763#endif
    726764    if ( ok )
     
    737775    value = getIntValue( reader, "base", &ok );
    738776#if XML_PARSER_DEBUG
    739 printf("  - base = %x\n", value);
     777printf("    base = %x\n", value);
    740778#endif
    741779    if ( ok )
     
    752790    value = getIntValue( reader, "length", &ok );
    753791#if XML_PARSER_DEBUG
    754 printf("  - length = %x\n\n", value);
     792printf("    length = %x\n\n", value);
    755793#endif
    756794    if ( ok )
     
    789827    cluster[cluster_index] = (mapping_cluster_t*)malloc(sizeof(mapping_cluster_t));
    790828
     829    // get index attribute (optional)
     830    value = getIntValue(reader,"index",&ok);
     831#if XML_PARSER_DEBUG
     832printf("    index = %d\n", value);
     833#endif
     834    if ( ok && (value != cluster_index) )
     835    {
     836            printf("[XML ERROR] wrong cluster index / expected value is %d",
     837                cluster_index);
     838            exit(1);
     839    }
     840
    791841    // get procs attribute
    792842    value = getIntValue(reader,"procs",&ok);
    793843#if XML_PARSER_DEBUG
    794 printf("  - procs = %d\n", value);
     844printf("    procs = %d\n", value);
    795845#endif
    796846    if ( ok )
     
    805855    }
    806856
    807     // get timers attribute
    808     value = getIntValue(reader,"timers",&ok);
    809 #if XML_PARSER_DEBUG
    810 printf("  - timers = %d\n", value);
    811 #endif
    812     if ( ok )
    813     {
    814         cluster[cluster_index]->timers = value;
    815     }
    816     else
    817     {
    818         printf("[XML ERROR] illegal or missing <timers> attribute for cluster %d",
    819                 cluster_index);
    820         exit(1);
    821     }
    822 
    823     // get dmas attribute
    824     value = getIntValue(reader,"dmas",&ok);
    825 #if XML_PARSER_DEBUG
    826 printf("  - dmas = %d\n\n", value);
    827 #endif
    828     if ( ok )
    829     {
    830         cluster[cluster_index]->dmas = value;
    831     }
    832     else
    833     {
    834         printf("[XML ERROR] illegal or missing <dmas> attribute for cluster %d",
    835                 cluster_index);
    836         exit(1);
    837     }
    838 
    839857    cluster_index++;
    840858} // end clusterNode()
     
    846864
    847865#if XML_PARSER_DEBUG
    848 printf("  clusters set\n");
     866printf("\n  clusters set\n");
    849867#endif
    850868
     
    922940
    923941#if XML_PARSER_DEBUG
    924 printf("  global vsegs set\n");
     942printf("  globals set\n");
    925943#endif
    926944
     
    961979
    962980#if XML_PARSER_DEBUG
    963 printf("  vspaces set\n");
     981printf("\n  vspaces set\n");
    964982#endif
    965983
     
    10111029    header = (mapping_header_t*)malloc(sizeof(mapping_header_t));
    10121030
    1013     // get name attribute
     1031    ////////// get name attribute
    10141032    name = getStringValue(reader, "name", &ok);
    10151033    if ( ok )
    10161034    {
    10171035#if XML_PARSER_DEBUG
    1018 printf("- name = %s\n", name);
     1036printf("  name = %s\n", name);
    10191037#endif
    10201038        strncpy( header->name, name, 31);
     
    10261044    }
    10271045
    1028     // get clusters attribute
     1046    /////////// get clusters attribute
    10291047    value = getIntValue(reader, "clusters", &ok);
    10301048    if ( ok )
     
    10361054        }
    10371055#if XML_PARSER_DEBUG
    1038 printf("- clusters = %d\n", value);
     1056printf("  clusters = %d\n", value);
    10391057#endif
    10401058        header->clusters  = value;
     
    10461064    }
    10471065
    1048     // get psegs attribute
     1066    ////////// get psegs attribute
    10491067    value = getIntValue(reader, "psegs", &ok);
    10501068    if ( ok )
     
    10561074        }
    10571075#if XML_PARSER_DEBUG
    1058 printf("- psegs = %d\n", value);
     1076printf("  psegs = %d\n", value);
    10591077#endif
    10601078        header->psegs = value;
     
    10661084    }
    10671085
    1068     // get ttys attribute
     1086    ///////// get ttys attribute
    10691087    value = getIntValue(reader, "ttys", &ok);
    10701088    if ( ok )
    10711089    {
    10721090#if XML_PARSER_DEBUG
    1073 printf("- ttys = %d\n", value);
     1091printf("  ttys = %d\n", value);
    10741092#endif
    10751093        header->ttys  = value;
     
    10811099    }
    10821100
    1083     // get vspaces attribute
     1101    ///////// get fbs attribute
     1102    value = getIntValue(reader, "fbs", &ok);
     1103    if ( ok )
     1104    {
     1105#if XML_PARSER_DEBUG
     1106printf("  fbs = %d\n", value);
     1107#endif
     1108        header->fbs  = value;
     1109    }
     1110    else
     1111    {
     1112        printf("[XML ERROR] illegal or missing <fbs> attribute in header\n");
     1113        exit(1);
     1114    }
     1115
     1116    ///////// get vspaces attribute
    10841117    value = getIntValue(reader, "vspaces", &ok);
    10851118    if ( ok )
     
    10911124        }
    10921125#if XML_PARSER_DEBUG
    1093 printf("- vspaces = %d\n", value);
     1126printf("  vspaces = %d\n", value);
    10941127#endif
    10951128        header->vspaces  = value;
     
    11011134    }
    11021135
    1103     // get globals attribute
     1136    ////////// get globals attribute
    11041137    value = getIntValue(reader, "globals", &ok);
    11051138    if ( ok )
     
    11111144        }
    11121145#if XML_PARSER_DEBUG
    1113 printf("- globals = %d\n", value);
     1146printf("  globals = %d\n", value);
    11141147#endif
    11151148        header->globals  = value;
Note: See TracChangeset for help on using the changeset viewer.