Exemple #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);
     }
 }
Exemple #2
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;
			}
		}
Exemple #3
0
 void IControllableCPU.InitFromUImage(UImage uImage)
 {
     // do nothing
 }
Exemple #4
0
 public virtual void InitFromUImage(UImage uImage)
 {
     this.Log(LogLevel.Info, "Setting PC value to 0x{0:X}.", uImage.EntryPoint);
     SetPCFromEntryPoint(uImage.EntryPoint);
 }
Exemple #5
0
 public override void InitFromUImage(UImage uImage)
 {
     this.Log(LogLevel.Warning, "PowerPC VLE mode not implemented for uImage loading.");
     base.InitFromUImage(uImage);
 }