Created
December 8, 2018 09:11
-
-
Save geekman/fb800469d905eb9b94d334cb801e4403 to your computer and use it in GitHub Desktop.
010 editor template for U-Boot images that i hacked up
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// quick 010 Editor template for u-boot images | |
// darell tan 2018.12.08 | |
// | |
enum <uchar> IH_TYPES { | |
TYPE_INVALID, | |
TYPE_STANDALONE, | |
TYPE_KERNEL, | |
TYPE_RAMDISK, | |
TYPE_MULTI, | |
TYPE_FIRMWARE, | |
TYPE_SCRIPT, | |
TYPE_FILESYSTEM, | |
TYPE_FLATDT, | |
TYPE_KWBIMAGE, | |
TYPE_IMXIMAGE, | |
}; | |
enum <uchar> IH_ARCHS { | |
ARCH_INVALID, | |
ARCH_ALPHA, | |
ARCH_ARM, | |
ARCH_I386, | |
ARCH_IA64, | |
ARCH_MIPS, | |
ARCH_MIPS64, | |
ARCH_PPC, | |
ARCH_S390, | |
ARCH_SH, | |
ARCH_SPARC, | |
ARCH_SPARC64, | |
ARCH_M68K, | |
ARCH_NIOS, | |
ARCH_MICROBLAZE, | |
ARCH_NIOS2, | |
ARCH_BLACKFIN, | |
ARCH_AVR32, | |
ARCH_ST200, | |
}; | |
enum <uchar> IH_OSES { | |
OS_INVALID, | |
OS_OPENBSD, | |
OS_NETBSD, | |
OS_FREEBSD, | |
OS_4_4BSD, | |
OS_LINUX, | |
OS_SVR4, | |
OS_ESIX, | |
OS_SOLARIS, | |
OS_IRIX, | |
OS_SCO, | |
OS_DELL, | |
OS_NCR, | |
OS_LYNXOS, | |
OS_VXWORKS, | |
OS_PSOS, | |
OS_QNX, | |
OS_U_BOOT, | |
OS_RTEMS, | |
OS_ARTOS, | |
OS_UNITY, | |
OS_INTEGRITY, | |
}; | |
enum <uchar> IH_COMPS { | |
COMP_NONE, | |
COMP_GZIP, | |
COMP_BZIP2, | |
COMP_LZMA, | |
COMP_LZO, | |
}; | |
typedef struct image_header { | |
uint32 ih_magic <format=hex>; /* Image Header Magic Number */ | |
uint32 ih_hcrc <format=hex>; /* Image Header CRC Checksum */ | |
uint32 ih_time <format=hex>; /* Image Creation Timestamp */ | |
uint32 ih_size; /* Image Data Size */ | |
uint32 ih_load <format=hex>; /* Data Load Address */ | |
uint32 ih_ep <format=hex>; /* Entry Point Address */ | |
uint32 ih_dcrc <format=hex>; /* Image Data CRC Checksum */ | |
enum IH_OSES ih_os; /* Operating System */ | |
enum IH_ARCHS ih_arch; /* CPU architecture */ | |
enum IH_TYPES ih_type; /* Image Type */ | |
enum IH_COMPS ih_comp; /* Compression Type */ | |
char ih_name[32]; /* Image Name */ | |
byte img_data[ih_size]; | |
} image_header_t; | |
// XXX are the images of a fixed endian format? | |
#define IH_MAGIC 0x27051956 | |
if (ReadUInt() != IH_MAGIC) { | |
// try flipping endian and try again | |
if (IsBigEndian()) LittleEndian(); | |
else BigEndian(); | |
if (ReadUInt() != IH_MAGIC) { | |
Warning("can't find header magic"); | |
return -1; | |
} | |
} | |
local int64 pos = -1; | |
while (!FEof() && FTell() > pos) { | |
pos = FTell(); | |
image_header_t img; | |
// seek back into the prev image data | |
//FSeek(sizeof(img) - img.ih_size); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment