Exemplo n.º 1
0
 protected ImageValidator(SdkTbtBase controller, byte[] image, Dictionary <Sections, FwInfo.SectionDetails> controllerSections, Dictionary <Sections, FwInfo.SectionDetails> fileSections, HwInfo hwInfo)
 {
     _controller         = controller;
     _image              = image;
     _controllerSections = controllerSections;
     _fileSections       = fileSections;
     HwInfo              = hwInfo;
 }
Exemplo n.º 2
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);
             }
         }
     }
 }
Exemplo n.º 3
0
 internal DeviceImageValidator(SdkTbtBase controller, byte[] image, Dictionary <Sections, FwInfo.SectionDetails> controllerSections, Dictionary <Sections, FwInfo.SectionDetails> fileSections, HwInfo hwInfo)
     : base(controller, image, controllerSections, fileSections, hwInfo)
 {
 }