Ignore:
Timestamp:
Mar 10, 2015, 3:17:57 PM (9 years ago)
Author:
alain
Message:

Simplification in the mapping_info.h file:
The coproc and cp_port objects have been removed,
because the coprocessors are now described as peripherals.

The xml parser and driver have been modified accordingly.

File:
1 edited

Legend:

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

    r511 r522  
    3434#define MAX_PROCS      1024
    3535#define MAX_IRQS       8192
    36 #define MAX_COPROCS    4096
    37 #define MAX_CP_PORTS   8192
    3836#define MAX_PERIPHS    8192
    3937
     
    5250mapping_proc_t *     proc[MAX_PROCS];        // proc array
    5351mapping_irq_t *      irq[MAX_IRQS];          // irq array
    54 mapping_coproc_t *   coproc[MAX_COPROCS];    // coproc array
    55 mapping_cp_port_t *  cp_port[MAX_CP_PORTS];  // coproc port array
    5652mapping_periph_t *   periph[MAX_PERIPHS];    // peripheral array
    5753
     
    6965unsigned int irq_loc_index  = 0;
    7066
    71 unsigned int coproc_index = 0;
    72 unsigned int coproc_loc_index = 0;
    73 
    74 unsigned int cp_port_index = 0;
    75 unsigned int cp_port_loc_index = 0;
    76 
    7767unsigned int periph_index = 0;
    7868unsigned int periph_loc_index = 0;
     
    8373unsigned int task_index = 0;
    8474unsigned int task_loc_index = 0;
    85 
    86 
    87 //////////////////////////////
    88 // for replicated peripheral
    89 //////////////////////////////
    90 char found_timer = 0;
    91 char found_icu   = 0;
    92 char found_xcu   = 0;
    93 char found_dma   = 0;
    94 char found_mmc   = 0;
    95 
    96 /*
    97 ////////////////////////////////////////////////////////////////////////
    98 // These variables are used to generate the hard_config.h file.
    99 ////////////////////////////////////////////////////////////////////////
    100 
    101 
    102 unsigned int tim_channels     = 0; // number of user timers  (per cluster)
    103 unsigned int dma_channels     = 0; // number of DMA channels (per cluster)
    104 
    105 unsigned int tty_channels     = 0; // number of TTY channels
    106 unsigned int ioc_channels     = 0; // number of HBA channels
    107 unsigned int nic_channels     = 0; // number of NIC channels
    108 unsigned int cma_channels     = 0; // number of CMA channels
    109 unsigned int pic_channels     = 0; // number of PIC channels
    110 
    111 unsigned int use_iob          = 0; // using IOB component
    112 unsigned int use_pic          = 0; // using PIC component
    113 unsigned int use_xcu          = 0; // using XCU (not ICU)
    114 unsigned int use_fbf          = 0; // using Frame Buffer
    115 
    116 // These variables define the IOC peripheral subtype
    117 
    118 unsigned int use_hba          = 0; // using SoClib AHCI controller
    119 unsigned int use_bdv          = 0; // using SoCLIB block device controller
    120 unsigned int use_spi          = 0; // using SDCard-SPI
    121 
    122 ////////////////////////////////////////////////////////////////
    123 // These variables are used to generate the giet_vseg.ld file
    124 ////////////////////////////////////////////////////////////////
    125 
    126 unsigned int periph_vbase_array[PERIPH_TYPE_MAX_VALUE]
    127          = { [0 ... (PERIPH_TYPE_MAX_VALUE - 1)] = 0xFFFFFFFF };
    128 */
    12975
    13076
     
    967913
    968914
    969 
    970 ////////////////////////////////////////
    971 void cpPortNode(xmlTextReaderPtr reader)
    972 {
    973     char * str;
    974     unsigned int ok;
    975 
    976     if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) return;
    977 
    978     if (cp_port_index >= MAX_CP_PORTS)
    979     {
    980         printf("[XML ERROR] The number of ports (for coprocs) is larger than %d\n",
    981                  MAX_CP_PORTS);
    982         exit(1);
    983     }
    984 
    985 #if XML_PARSER_DEBUG
    986 printf("\n  port %d\n", cp_port_index);
    987 #endif
    988 
    989     cp_port[cp_port_index] = (mapping_cp_port_t *) malloc(sizeof(mapping_cp_port_t));
    990 
    991     ///////// get direction attribute
    992     str = getStringValue(reader, "direction", &ok);
    993     if (ok)
    994     {
    995 #if XML_PARSER_DEBUG
    996 printf("      direction = %s\n", str);
    997 #endif
    998         if (strcmp(str, "TO_COPROC")   ==  0)
    999         {
    1000             cp_port[cp_port_index]->direction = PORT_TO_COPROC;
    1001         }
    1002         else if (strcmp(str, "FROM_COPROC") ==  0)
    1003         {
    1004             cp_port[cp_port_index]->direction = PORT_FROM_COPROC;
    1005         }
    1006         else
    1007         {
    1008             printf("[XML ERROR] illegal <direction> for cp_port %d in cluster %d\n",
    1009                     cp_port_index, cluster_index);
    1010             exit(1);
    1011         }
    1012     } 
    1013     else
    1014     {
    1015         printf("[XML ERROR] missing <direction> for cp_port %d in cluster %d\n",
    1016                 cp_port_index, cluster_index);
    1017         exit(1);
    1018     }
    1019 
    1020     cp_port_index++;
    1021     cp_port_loc_index++;
    1022 } // end cpPortNode()
    1023 
    1024915////////////////////////////////////////
    1025916void periphNode(xmlTextReaderPtr reader)
     
    1059950    }
    1060951
    1061     ///////// get arg attribute (optionnal : 0 if missing)
    1062     value = getIntValue(reader, "arg", &ok);
    1063     if (ok)
    1064     {
    1065 #if XML_PARSER_DEBUG
    1066 printf("      arg         = %d\n", value);
    1067 #endif
    1068         periph[periph_index]->arg = value;
    1069     }
    1070     else
    1071     {
    1072         periph[periph_index]->arg = 1;
     952    ///////// get arg0 attribute (optionnal : undefined if missing)
     953    value = getIntValue(reader, "arg0", &ok);
     954    if (ok)
     955    {
     956#if XML_PARSER_DEBUG
     957printf("      arg0        = %d\n", value);
     958#endif
     959        periph[periph_index]->arg0 = value;
     960    }
     961
     962    ///////// get arg1 attribute (optionnal : undefined if missing)
     963    value = getIntValue(reader, "arg1", &ok);
     964    if (ok)
     965    {
     966#if XML_PARSER_DEBUG
     967printf("      arg1        = %d\n", value);
     968#endif
     969        periph[periph_index]->arg1 = value;
     970    }
     971
     972    ///////// get arg2 attribute (optionnal : undefined if missing)
     973    value = getIntValue(reader, "arg2", &ok);
     974    if (ok)
     975    {
     976#if XML_PARSER_DEBUG
     977printf("      arg2        = %d\n", value);
     978#endif
     979        periph[periph_index]->arg2 = value;
     980    }
     981
     982    ///////// get arg3 attribute (optionnal : undefined if missing)
     983    value = getIntValue(reader, "arg3", &ok);
     984    if (ok)
     985    {
     986#if XML_PARSER_DEBUG
     987printf("      arg3        = %d\n", value);
     988#endif
     989        periph[periph_index]->arg3 = value;
    1073990    }
    1074991
     
    11081025#endif
    11091026        if      (strcmp(str, "CMA" ) == 0) periph[periph_index]->type = PERIPH_TYPE_CMA;
     1027        else if (strcmp(str, "DMA" ) == 0) periph[periph_index]->type = PERIPH_TYPE_DMA;
    11101028        else if (strcmp(str, "FBF" ) == 0) periph[periph_index]->type = PERIPH_TYPE_FBF;
    11111029        else if (strcmp(str, "IOB" ) == 0) periph[periph_index]->type = PERIPH_TYPE_IOB;
    11121030        else if (strcmp(str, "IOC" ) == 0) periph[periph_index]->type = PERIPH_TYPE_IOC;
     1031        else if (strcmp(str, "MMC" ) == 0) periph[periph_index]->type = PERIPH_TYPE_MMC;
     1032        else if (strcmp(str, "MWR" ) == 0) periph[periph_index]->type = PERIPH_TYPE_MWR;
    11131033        else if (strcmp(str, "NIC" ) == 0) periph[periph_index]->type = PERIPH_TYPE_NIC;
    11141034        else if (strcmp(str, "ROM" ) == 0) periph[periph_index]->type = PERIPH_TYPE_ROM;
    11151035        else if (strcmp(str, "SIM" ) == 0) periph[periph_index]->type = PERIPH_TYPE_SIM;
     1036        else if (strcmp(str, "SIM" ) == 0) periph[periph_index]->type = PERIPH_TYPE_TIM;
    11161037        else if (strcmp(str, "TTY" ) == 0) periph[periph_index]->type = PERIPH_TYPE_TTY;
     1038        else if (strcmp(str, "XCU" ) == 0) periph[periph_index]->type = PERIPH_TYPE_XCU;
    11171039        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;
    11211040        else if (strcmp(str, "DROM") == 0) periph[periph_index]->type = PERIPH_TYPE_DROM;
    11221041        else
     
    11381057#endif
    11391058            if      (strcmp(subtype, "BDV") == 0)
    1140             periph[periph_index]->subtype = PERIPH_SUBTYPE_BDV;
     1059            periph[periph_index]->subtype = IOC_SUBTYPE_BDV;
    11411060            else if (strcmp(subtype, "HBA") == 0)
    1142             periph[periph_index]->subtype = PERIPH_SUBTYPE_HBA;
     1061            periph[periph_index]->subtype = IOC_SUBTYPE_HBA;
    11431062            else if (strcmp(subtype, "SPI") == 0)
    1144             periph[periph_index]->subtype = PERIPH_SUBTYPE_SPI;
     1063            periph[periph_index]->subtype = IOC_SUBTYPE_SPI;
    11451064        }
    11461065        else
    11471066        {
    11481067            printf("[XML ERROR] illegal subtype for IOC peripheral\n");
     1068            exit(1);
     1069        }
     1070    }
     1071    else
     1072    {
     1073        periph[periph_index]->subtype = 0XFFFFFFFF;
     1074    }
     1075
     1076    ////////// get subtype if MWR
     1077    if (periph[periph_index]->type == PERIPH_TYPE_MWR )
     1078    {
     1079        char* subtype = getStringValue(reader, "subtype", &ok);
     1080        if (ok)
     1081        {
     1082#if XML_PARSER_DEBUG
     1083printf("      subtype     = %s\n", str);
     1084#endif
     1085            if      (strcmp(subtype, "GCD") == 0)
     1086            periph[periph_index]->subtype = MWR_SUBTYPE_GCD;
     1087            else if (strcmp(subtype, "DCT") == 0)
     1088            periph[periph_index]->subtype = MWR_SUBTYPE_DCT;
     1089        }
     1090        else
     1091        {
     1092            printf("[XML ERROR] illegal subtype for MWR peripheral\n");
    11491093            exit(1);
    11501094        }
     
    12031147} // end periphNode
    12041148
    1205 ////////////////////////////////////////
    1206 void coprocNode(xmlTextReaderPtr reader)
    1207 {
    1208     char * str;
    1209     unsigned int ok;
    1210 
    1211     cp_port_loc_index = 0;
    1212 
    1213     if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) return;
    1214 
    1215     if (coproc_index >= MAX_COPROCS)
    1216     {
    1217         printf("[XML ERROR] The number of coprocs is larger than %d\n", MAX_COPROCS);
    1218         exit(1);
    1219     }
    1220 
    1221 #if XML_PARSER_DEBUG
    1222 printf("\n  coproc %d\n", coproc_index);
    1223 #endif
    1224 
    1225     coproc[coproc_index] = (mapping_coproc_t *) malloc(sizeof(mapping_coproc_t));
    1226 
    1227     /////////// get name attribute
    1228     str = getStringValue(reader, "name", &ok);
    1229     if (ok)
    1230     {
    1231 #if XML_PARSER_DEBUG
    1232 printf("      name = %s\n", str);
    1233 #endif
    1234         strncpy(coproc[coproc_index]->name, str, 31);
    1235     }
    1236     else
    1237     {
    1238         printf("[XML ERROR] illegal or missing <name> for coproc %d in cluster %d\n",
    1239                 coproc_index, cluster_index);
    1240         exit(1);
    1241     }
    1242 
    1243     /////////// get psegname attribute
    1244     str = getStringValue(reader, "psegname", &ok);
    1245     if (ok == 0)
    1246     {
    1247         printf("[XML ERROR] illegal or missing <psegname> for coproc %d in cluster %d\n",
    1248                 coproc_index, cluster_index);
    1249         exit(1);
    1250     }
    1251 
    1252     /////////// set psegid attribute
    1253     int index = getPsegId( cluster[cluster_index]->x, cluster[cluster_index]->y, str);
    1254     if (index >= 0)
    1255     {
    1256 #if XML_PARSER_DEBUG
    1257 printf("      clusterid = %d\n", cluster_index);
    1258 printf("      psegname  = %s\n", str);
    1259 printf("      psegid    = %d\n", index);
    1260 #endif
    1261         coproc[coproc_index]->psegid = index;
    1262         assert(pseg[index]->type == PSEG_TYPE_PERI &&
    1263         "coproc psegname attribute must refer to a pseg of type PERI" );
    1264     }
    1265     else
    1266     {
    1267         printf("[XML ERROR] pseg not found for coproc %d / clusterid = %d / psegname = %s\n",
    1268                 coproc_index, cluster_index, str );
    1269         exit(1);
    1270     } 
    1271 
    1272     ////////// set port_offset
    1273     coproc[coproc_index]->port_offset = cp_port_index;
    1274 
    1275 #if XML_PARSER_DEBUG
    1276 printf("      port_offset = %d\n", cp_port_index);
    1277 #endif
    1278 
    1279     int status = xmlTextReaderRead(reader);
    1280     while (status == 1)
    1281     {
    1282         const char * tag = (const char *) xmlTextReaderConstName(reader);
    1283 
    1284         if (strcmp(tag, "port") == 0 )
    1285         {
    1286             cpPortNode(reader);
    1287         }
    1288         else if (strcmp(tag, "#text")    == 0 ) { }
    1289         else if (strcmp(tag, "#comment") == 0 ) { }
    1290         else if (strcmp(tag, "coproc") == 0 )
    1291         {
    1292             coproc[coproc_index]->ports = cp_port_loc_index;
    1293             cluster[cluster_index]->coprocs++;
    1294             coproc_loc_index++;
    1295             coproc_index++;
    1296             return;
    1297         }
    1298         else
    1299         {
    1300             printf("[XML ERROR] Unknown tag %s", tag);
    1301             exit(1);
    1302         }
    1303         status = xmlTextReaderRead(reader);
    1304     }
    1305 } // end coprocNode()
    1306 
    1307 
    13081149//////////////////////////////////////
    13091150void procNode(xmlTextReaderPtr reader)
     
    14551296    coproc_loc_index = 0;
    14561297    periph_loc_index = 0;
    1457 
    1458     // for replicated periph
    1459     found_timer = 0;
    1460     found_icu   = 0;
    1461     found_xcu   = 0;
    1462     found_dma   = 0;
    1463     found_mmc   = 0;
    14641298
    14651299    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT)  return;
     
    15781412            header->irqs = irq_index;
    15791413            header->coprocs = coproc_index;
    1580             header->cp_ports = cp_port_index;
    15811414            header->periphs = periph_index;
    15821415            return;
     
    18381671    header->irqs      = 0;
    18391672    header->coprocs   = 0;
    1840     header->cp_ports  = 0;
    18411673    header->periphs   = 0;
    18421674
     
    19651797    //building coprocs array
    19661798    BuildTable(fdout, "coproc", coproc_index, sizeof(mapping_coproc_t), (char **) coproc);
    1967     //building cp_ports array
    1968     BuildTable(fdout, "cp_port", cp_port_index, sizeof(mapping_cp_port_t),(char **) cp_port);
    19691799    //building periphs array
    19701800    BuildTable(fdout, "periph", periph_index, sizeof(mapping_periph_t), (char **) periph);
Note: See TracChangeset for help on using the changeset viewer.