コード例 #1
0
        public static Firmware CreateFromXml(XmlNode fwNode)
        {
            Firmware firmware = new Firmware();

            // Parse firmware information in ConfigXml
            string version           = fwNode.SelectSingleNode(ConfigXml.ATTR_VERSION).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);
            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);

            firmware.SetVersion(version);
            firmware.SetCompatible(compatiable);
            firmware.SetExecutableFile(new ExecutableFile(exeFilePath));
            firmware.SetMaxCodeSize(maxCodeSize);
            firmware.SetMaxDataSize(maxDataSize);
            firmware.SetCodeLoadableStart(codeLoadableStart);
            firmware.SetCodeLoadableSize(codeLoadableSize);
            firmware.SetDataLoadableStart(dataLoadableStart);
            firmware.SetDataLoadableSize(dataLoadableSize);

            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 (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);
                }

                firmware.AddImage(image);
            }

            return(firmware);
        }
コード例 #2
0
        public static Image CreateFromXml(XmlNode node, int id, string name)
        {
            PermanentImage image = new PermanentImage(id, name);

            return(image);
        }