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