コード例 #1
0
 public static UImageResult TryLoad(string fileName, out UImage uImage)
 {
     uImage = null;
     if (new FileInfo(fileName).Length < 64)
     {
         return(UImageResult.NotUImage);
     }
     byte[] headerForCrc;
     using (var reader = new BinaryReader(File.OpenRead(fileName)))
     {
         headerForCrc = reader.ReadBytes(64);
         // we need to zero crc part
         for (var i = 4; i < 8; i++)
         {
             headerForCrc[i] = 0;
         }
     }
     using (var reader = new BinaryReader(File.OpenRead(fileName)))
     {
         var magic = reader.ReadUInt32BigEndian();
         if (magic != Magic)
         {
             return(UImageResult.NotUImage);
         }
         var crc = reader.ReadUInt32BigEndian();
         if (crc != GzipCrc32(headerForCrc))
         {
             return(UImageResult.BadChecksum);
         }
         reader.ReadBytes(22);
         var imageType = (ImageType)reader.ReadByte();
         if (!Enum.IsDefined(typeof(ImageType), imageType))
         {
             return(UImageResult.NotSupportedImageType);
         }
         // TODO: check CRC of the header
         uImage = new UImage(fileName);
         return(UImageResult.OK);
     }
 }
コード例 #2
0
ファイル: UImageReader.cs プロジェクト: xxy1991/cozy
		public static UImageResult TryLoad(string fileName, out UImage uImage)
		{
			uImage = null;
			if(new FileInfo(fileName).Length < 64)
			{
				return UImageResult.NotUImage;
			}
			byte[] headerForCrc;
			using(var reader = new BinaryReader(File.OpenRead(fileName)))
			{
				headerForCrc = reader.ReadBytes(64);
				// we need to zero crc part
				for(var i = 4; i < 8; i++)
				{
					headerForCrc[i] = 0;
				}
			}
			using(var reader = new BinaryReader(File.OpenRead(fileName)))
			{
				var magic = reader.ReadUInt32BigEndian();
				if(magic != Magic)
				{
					return UImageResult.NotUImage;
				}
				var crc = reader.ReadUInt32BigEndian();
				if(crc != GzipCrc32(headerForCrc))
				{
					return UImageResult.BadChecksum;
				}
				reader.ReadBytes(22);
				var imageType = (ImageType)reader.ReadByte();
				if(!Enum.IsDefined(typeof(ImageType), imageType))
				{
					return UImageResult.NotSupportedImageType;
				}
				// TODO: check CRC of the header
				uImage = new UImage(fileName);
				return UImageResult.OK;
			}
		}
コード例 #3
0
ファイル: CortexM.cs プロジェクト: emul8/emul8
 void IControllableCPU.InitFromUImage(UImage uImage)
 {
     // do nothing
 }
コード例 #4
0
ファイル: TranslationCPU.cs プロジェクト: rte-se/emul8
 public virtual void InitFromUImage(UImage uImage)
 {
     this.Log(LogLevel.Info, "Setting PC value to 0x{0:X}.", uImage.EntryPoint);
     SetPCFromEntryPoint(uImage.EntryPoint);
 }
コード例 #5
0
ファイル: PowerPc.cs プロジェクト: rte-se/emul8
 public override void InitFromUImage(UImage uImage)
 {
     this.Log(LogLevel.Warning, "PowerPC VLE mode not implemented for uImage loading.");
     base.InitFromUImage(uImage);
 }