public static Image CreateFromXml(XmlNode node, int id, string name, ArrayList secInfo) { PermanentImage image = new PermanentImage(id, name, secInfo); return(image); }
public static Firmware CreateFromXml(XmlNode fwNode) { Firmware firmware = new Firmware(); XmlNode cur_node = null; UInt32 extDataMemStart = 0, extDataMemEnd = 0; UInt32 srcItcmStart = 0, srcItcmEnd = 0, dstItcmStart = 0; UInt32 srcDtcmStart = 0, srcDtcmEnd = 0, dstDtcmStart = 0; string extrFilePath = null; UInt32 extrFileAddr = 0; // Parse firmware information in ConfigXml string version = fwNode.SelectSingleNode(ConfigXml.ATTR_VERSION).InnerText.Trim(); string coreName = fwNode.SelectSingleNode(ConfigXml.ATTR_CORENAME).InnerText.Trim(); string toolsPath = fwNode.SelectSingleNode(ConfigXml.ATTR_TOOLSPATH).InnerText.Trim(); string compatiable = fwNode.SelectSingleNode(ConfigXml.ATTR_COMPATIBLE).InnerText.Trim(); string exeFilePath = fwNode.SelectSingleNode(ConfigXml.ATTR_EXEFILE).InnerText.Trim(); UInt32 maxCodeSize = (UInt32)Convert.ToInt32(fwNode.SelectSingleNode(ConfigXml.ATTR_MAX_CSIZE).InnerText.Trim(), 16); UInt32 maxDataSize = (UInt32)Convert.ToInt32(fwNode.SelectSingleNode(ConfigXml.ATTR_MAX_DSIZE).InnerText.Trim(), 16); cur_node = fwNode.SelectSingleNode(ConfigXml.ATTR_EXTRFILE); if (cur_node != null) { extrFilePath = cur_node.InnerText.Trim(); } cur_node = fwNode.SelectSingleNode(ConfigXml.ATTR_EXTRADDR); if (cur_node != null) { extrFileAddr = (UInt32)Convert.ToInt32(cur_node.InnerText.Trim(), 16); } /* itcm */ cur_node = fwNode.SelectSingleNode(ConfigXml.ATTR_SRC_ITCM_START); if (cur_node != null) { srcItcmStart = (UInt32)Convert.ToInt32(cur_node.InnerText.Trim(), 16); } cur_node = fwNode.SelectSingleNode(ConfigXml.ATTR_SRC_ITCM_END); if (cur_node != null) { srcItcmEnd = (UInt32)Convert.ToInt32(cur_node.InnerText.Trim(), 16); } cur_node = fwNode.SelectSingleNode(ConfigXml.ATTR_DST_ITCM_START); if (cur_node != null) { dstItcmStart = (UInt32)Convert.ToInt32(cur_node.InnerText.Trim(), 16); } /* dtcm */ cur_node = fwNode.SelectSingleNode(ConfigXml.ATTR_SRC_DTCM_START); if (cur_node != null) { srcDtcmStart = (UInt32)Convert.ToInt32(cur_node.InnerText.Trim(), 16); } cur_node = fwNode.SelectSingleNode(ConfigXml.ATTR_SRC_DTCM_END); if (cur_node != null) { srcDtcmEnd = (UInt32)Convert.ToInt32(cur_node.InnerText.Trim(), 16); } cur_node = fwNode.SelectSingleNode(ConfigXml.ATTR_DST_DTCM_START); if (cur_node != null) { dstDtcmStart = (UInt32)Convert.ToInt32(cur_node.InnerText.Trim(), 16); } /* extern data */ cur_node = fwNode.SelectSingleNode(ConfigXml.ATTR_EXTDMEM_START); if (cur_node != null) { extDataMemStart = (UInt32)Convert.ToInt32(cur_node.InnerText.Trim(), 16); } cur_node = fwNode.SelectSingleNode(ConfigXml.ATTR_EXTDMEM_END); if (cur_node != null) { extDataMemEnd = (UInt32)Convert.ToInt32(cur_node.InnerText.Trim(), 16); } #if OVERLAYS UInt32 codeLoadableStart = (UInt32)Convert.ToInt32(fwNode.SelectSingleNode(ConfigXml.ATTR_LOADABLE_CSTART).InnerText.Trim(), 16); UInt32 codeLoadableSize = (UInt32)Convert.ToInt32(fwNode.SelectSingleNode(ConfigXml.ATTR_LOADABLE_CSIZE).InnerText.Trim(), 16); UInt32 dataLoadableStart = (UInt32)Convert.ToInt32(fwNode.SelectSingleNode(ConfigXml.ATTR_LOADABLE_DSTART).InnerText.Trim(), 16); UInt32 dataLoadableSize = (UInt32)Convert.ToInt32(fwNode.SelectSingleNode(ConfigXml.ATTR_LOADABLE_DSIZE).InnerText.Trim(), 16); UInt32 externalCodeStart = (UInt32)Convert.ToInt32(fwNode.SelectSingleNode(ConfigXml.ATTR_EXTCMEM_START).InnerText.Trim(), 16); UInt32 externalCodeEnd = (UInt32)Convert.ToInt32(fwNode.SelectSingleNode(ConfigXml.ATTR_EXTCMEM_END).InnerText.Trim(), 16); UInt32 externalDataStart = (UInt32)Convert.ToInt32(fwNode.SelectSingleNode(ConfigXml.ATTR_EXTDMEM_START).InnerText.Trim(), 16); UInt32 externalDataEnd = (UInt32)Convert.ToInt32(fwNode.SelectSingleNode(ConfigXml.ATTR_EXTDMEM_END).InnerText.Trim(), 16); #endif firmware.SetVersion(version); firmware.SetCoreName(coreName); firmware.SetToolsPath(toolsPath); firmware.SetCompatible(compatiable); firmware.SetMaxCodeSize(maxCodeSize); firmware.SetMaxDataSize(maxDataSize); firmware.SetExecutableFile(new ExecutableFile(exeFilePath, coreName, toolsPath, extrFilePath, extrFileAddr)); firmware.SetExternalFile(extrFilePath); firmware.GetExecutableFile().SetTcmAddr(srcItcmStart, srcItcmEnd, dstItcmStart, srcDtcmStart, srcDtcmEnd, dstDtcmStart, extDataMemStart, extDataMemEnd); ArrayList secInfo = firmware.GetExecutableFile().Parser(); #if OVERLAYS firmware.SetCodeLoadableStart(codeLoadableStart); firmware.SetCodeLoadableSize(codeLoadableSize); firmware.SetDataLoadableStart(dataLoadableStart); firmware.SetDataLoadableSize(dataLoadableSize); #endif XmlNodeList nodeList = fwNode.SelectNodes(ConfigXml.NODE_IMAGE); if (nodeList.Count < 1) { Console.WriteLine("At least one image in firmware node"); return(null); } foreach (XmlNode node in nodeList) { Image image = null; int id = int.Parse(node.SelectSingleNode(ConfigXml.ATTR_ID).InnerText.Trim()); string name = node.SelectSingleNode(ConfigXml.ATTR_NAME).InnerText.Trim(); string type = node.SelectSingleNode(ConfigXml.ATTR_TYPE).InnerText.Trim(); #if OVERLAYS if (type.Equals(ImageType.LOADABLE_STRING)) { image = LoadableImage.CreateFromXml(node, id, name); image.SetInternalCodeRange(codeLoadableStart, codeLoadableStart + codeLoadableSize); image.SetInternalDataRange(dataLoadableStart, dataLoadableStart + dataLoadableSize); } else if (type.Equals(ImageType.PERMANENT_STRING)) { image = PermanentImage.CreateFromXml(node, id, name); image.SetInternalCodeRange(0, maxCodeSize); image.SetInternalDataRange(0, maxDataSize); image.SetExternalCodeRange(externalCodeStart, externalCodeEnd); image.SetExternalDataRange(externalDataStart, externalDataEnd); } #else image = PermanentImage.CreateFromXml(node, id, name, secInfo); image.SetInternalCodeRange(0, maxCodeSize); image.SetInternalDataRange(0, maxDataSize); #endif firmware.AddImage(image); } return(firmware); }