Esempio n. 1
0
 public override void ValidateImage(string path)
 {
     if (!File.Exists(path))
     {
         throw new TbtException(TbtStatus.SDK_FILE_NOT_FOUND);
     }
     using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
     {
         byte[]     image      = new BinaryReader(fileStream).ReadBytes((int)fileStream.Length);
         HostFwInfo hostFwInfo = new HostFwInfo(new FileFwInfoSource(image));
         if (IsInSafeMode)
         {
             HwInfo hwInfo = FwInfoSource.HwConfiguration(DeviceId);
             if (hwInfo.Generation != hostFwInfo.Info.Generation)
             {
                 throw new TbtException(TbtStatus.SDK_HW_GENERATION_MISMATCH);
             }
             if (hwInfo.Type != hostFwInfo.Info.Type)
             {
                 throw new TbtException(TbtStatus.SDK_PORT_COUNT_MISMATCH);
             }
             if (!Utilities.GetImageIsHost(path))
             {
                 throw new TbtException(TbtStatus.SDK_IMAGE_FOR_DEVICE_ERROR);
             }
         }
         else
         {
             HostFwInfo hostFwInfo2 = new HostFwInfo(new ControllerFwInfoSource(this));
             HostFwInfo hostFwInfo3 = new HostFwInfo(new FileFwInfoSource(image));
             if (hostFwInfo2.Info.Generation != hostFwInfo3.Info.Generation)
             {
                 throw new TbtException(TbtStatus.SDK_HW_GENERATION_MISMATCH);
             }
             if (hostFwInfo2.Info.Type != hostFwInfo3.Info.Type)
             {
                 throw new TbtException(TbtStatus.SDK_PORT_COUNT_MISMATCH);
             }
             new HostImageValidator(this, image, hostFwInfo2.GetSectionInfo(), hostFwInfo3.GetSectionInfo(), hostFwInfo2.Info).Validate();
             if (OsNativePciEnumeration != hostFwInfo3.OsNativePciEnumeration)
             {
                 throw new TbtException(TbtStatus.SDK_NATIVE_MODE_MISMATCH);
             }
         }
     }
 }
Esempio n. 2
0
 protected FwInfo(FwInfoSource source)
 {
     Source = source;
 }
Esempio n. 3
0
 public HostFwInfo(FwInfoSource source)
     : base(source)
 {
 }
Esempio n. 4
0
        private static HwInfo GetHwConfiguration(string controllerId)
        {
            int startIndex = controllerId.IndexOf("DEV_") + "DEV_".Length;

            return(FwInfoSource.HwConfiguration(ushort.Parse(controllerId.Substring(startIndex, 4), NumberStyles.AllowHexSpecifier)));
        }