Changeset 522 for soft/giet_vm/giet_xml/xml_parser.c
- Timestamp:
- Mar 10, 2015, 3:17:57 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_xml/xml_parser.c
r511 r522 34 34 #define MAX_PROCS 1024 35 35 #define MAX_IRQS 8192 36 #define MAX_COPROCS 409637 #define MAX_CP_PORTS 819238 36 #define MAX_PERIPHS 8192 39 37 … … 52 50 mapping_proc_t * proc[MAX_PROCS]; // proc array 53 51 mapping_irq_t * irq[MAX_IRQS]; // irq array 54 mapping_coproc_t * coproc[MAX_COPROCS]; // coproc array55 mapping_cp_port_t * cp_port[MAX_CP_PORTS]; // coproc port array56 52 mapping_periph_t * periph[MAX_PERIPHS]; // peripheral array 57 53 … … 69 65 unsigned int irq_loc_index = 0; 70 66 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 77 67 unsigned int periph_index = 0; 78 68 unsigned int periph_loc_index = 0; … … 83 73 unsigned int task_index = 0; 84 74 unsigned int task_loc_index = 0; 85 86 87 //////////////////////////////88 // for replicated peripheral89 //////////////////////////////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 channels106 unsigned int ioc_channels = 0; // number of HBA channels107 unsigned int nic_channels = 0; // number of NIC channels108 unsigned int cma_channels = 0; // number of CMA channels109 unsigned int pic_channels = 0; // number of PIC channels110 111 unsigned int use_iob = 0; // using IOB component112 unsigned int use_pic = 0; // using PIC component113 unsigned int use_xcu = 0; // using XCU (not ICU)114 unsigned int use_fbf = 0; // using Frame Buffer115 116 // These variables define the IOC peripheral subtype117 118 unsigned int use_hba = 0; // using SoClib AHCI controller119 unsigned int use_bdv = 0; // using SoCLIB block device controller120 unsigned int use_spi = 0; // using SDCard-SPI121 122 ////////////////////////////////////////////////////////////////123 // These variables are used to generate the giet_vseg.ld file124 ////////////////////////////////////////////////////////////////125 126 unsigned int periph_vbase_array[PERIPH_TYPE_MAX_VALUE]127 = { [0 ... (PERIPH_TYPE_MAX_VALUE - 1)] = 0xFFFFFFFF };128 */129 75 130 76 … … 967 913 968 914 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_DEBUG986 printf("\n port %d\n", cp_port_index);987 #endif988 989 cp_port[cp_port_index] = (mapping_cp_port_t *) malloc(sizeof(mapping_cp_port_t));990 991 ///////// get direction attribute992 str = getStringValue(reader, "direction", &ok);993 if (ok)994 {995 #if XML_PARSER_DEBUG996 printf(" direction = %s\n", str);997 #endif998 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 else1007 {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 else1014 {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 1024 915 //////////////////////////////////////// 1025 916 void periphNode(xmlTextReaderPtr reader) … … 1059 950 } 1060 951 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 957 printf(" 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 967 printf(" 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 977 printf(" 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 987 printf(" arg3 = %d\n", value); 988 #endif 989 periph[periph_index]->arg3 = value; 1073 990 } 1074 991 … … 1108 1025 #endif 1109 1026 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; 1110 1028 else if (strcmp(str, "FBF" ) == 0) periph[periph_index]->type = PERIPH_TYPE_FBF; 1111 1029 else if (strcmp(str, "IOB" ) == 0) periph[periph_index]->type = PERIPH_TYPE_IOB; 1112 1030 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; 1113 1033 else if (strcmp(str, "NIC" ) == 0) periph[periph_index]->type = PERIPH_TYPE_NIC; 1114 1034 else if (strcmp(str, "ROM" ) == 0) periph[periph_index]->type = PERIPH_TYPE_ROM; 1115 1035 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; 1116 1037 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; 1117 1039 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 1040 else if (strcmp(str, "DROM") == 0) periph[periph_index]->type = PERIPH_TYPE_DROM; 1122 1041 else … … 1138 1057 #endif 1139 1058 if (strcmp(subtype, "BDV") == 0) 1140 periph[periph_index]->subtype = PERIPH_SUBTYPE_BDV;1059 periph[periph_index]->subtype = IOC_SUBTYPE_BDV; 1141 1060 else if (strcmp(subtype, "HBA") == 0) 1142 periph[periph_index]->subtype = PERIPH_SUBTYPE_HBA;1061 periph[periph_index]->subtype = IOC_SUBTYPE_HBA; 1143 1062 else if (strcmp(subtype, "SPI") == 0) 1144 periph[periph_index]->subtype = PERIPH_SUBTYPE_SPI;1063 periph[periph_index]->subtype = IOC_SUBTYPE_SPI; 1145 1064 } 1146 1065 else 1147 1066 { 1148 1067 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 1083 printf(" 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"); 1149 1093 exit(1); 1150 1094 } … … 1203 1147 } // end periphNode 1204 1148 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_DEBUG1222 printf("\n coproc %d\n", coproc_index);1223 #endif1224 1225 coproc[coproc_index] = (mapping_coproc_t *) malloc(sizeof(mapping_coproc_t));1226 1227 /////////// get name attribute1228 str = getStringValue(reader, "name", &ok);1229 if (ok)1230 {1231 #if XML_PARSER_DEBUG1232 printf(" name = %s\n", str);1233 #endif1234 strncpy(coproc[coproc_index]->name, str, 31);1235 }1236 else1237 {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 attribute1244 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 attribute1253 int index = getPsegId( cluster[cluster_index]->x, cluster[cluster_index]->y, str);1254 if (index >= 0)1255 {1256 #if XML_PARSER_DEBUG1257 printf(" clusterid = %d\n", cluster_index);1258 printf(" psegname = %s\n", str);1259 printf(" psegid = %d\n", index);1260 #endif1261 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 else1266 {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_offset1273 coproc[coproc_index]->port_offset = cp_port_index;1274 1275 #if XML_PARSER_DEBUG1276 printf(" port_offset = %d\n", cp_port_index);1277 #endif1278 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 else1299 {1300 printf("[XML ERROR] Unknown tag %s", tag);1301 exit(1);1302 }1303 status = xmlTextReaderRead(reader);1304 }1305 } // end coprocNode()1306 1307 1308 1149 ////////////////////////////////////// 1309 1150 void procNode(xmlTextReaderPtr reader) … … 1455 1296 coproc_loc_index = 0; 1456 1297 periph_loc_index = 0; 1457 1458 // for replicated periph1459 found_timer = 0;1460 found_icu = 0;1461 found_xcu = 0;1462 found_dma = 0;1463 found_mmc = 0;1464 1298 1465 1299 if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) return; … … 1578 1412 header->irqs = irq_index; 1579 1413 header->coprocs = coproc_index; 1580 header->cp_ports = cp_port_index;1581 1414 header->periphs = periph_index; 1582 1415 return; … … 1838 1671 header->irqs = 0; 1839 1672 header->coprocs = 0; 1840 header->cp_ports = 0;1841 1673 header->periphs = 0; 1842 1674 … … 1965 1797 //building coprocs array 1966 1798 BuildTable(fdout, "coproc", coproc_index, sizeof(mapping_coproc_t), (char **) coproc); 1967 //building cp_ports array1968 BuildTable(fdout, "cp_port", cp_port_index, sizeof(mapping_cp_port_t),(char **) cp_port);1969 1799 //building periphs array 1970 1800 BuildTable(fdout, "periph", periph_index, sizeof(mapping_periph_t), (char **) periph);
Note: See TracChangeset
for help on using the changeset viewer.