xref: /qemu/hw/core/uboot_image.h (revision c227f0995e1722a1abccc28cadf0664266bd8043)
11c7b3754Spbrook /*
21c7b3754Spbrook  * (C) Copyright 2000-2005
31c7b3754Spbrook  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
41c7b3754Spbrook  *
51c7b3754Spbrook  * See file CREDITS for list of people who contributed to this
61c7b3754Spbrook  * project.
71c7b3754Spbrook  *
81c7b3754Spbrook  * This program is free software; you can redistribute it and/or
91c7b3754Spbrook  * modify it under the terms of the GNU General Public License as
101c7b3754Spbrook  * published by the Free Software Foundation; either version 2 of
111c7b3754Spbrook  * the License, or (at your option) any later version.
121c7b3754Spbrook  *
131c7b3754Spbrook  * This program is distributed in the hope that it will be useful,
141c7b3754Spbrook  * but WITHOUT ANY WARRANTY; without even the implied warranty of
151c7b3754Spbrook  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
161c7b3754Spbrook  * GNU General Public License for more details.
171c7b3754Spbrook  *
18fad6cb1aSaurel32  * You should have received a copy of the GNU General Public License along
198167ee88SBlue Swirl  * with this program; if not, see <http://www.gnu.org/licenses/>.
201c7b3754Spbrook  *
211c7b3754Spbrook  ********************************************************************
221c7b3754Spbrook  * NOTE: This header file defines an interface to U-Boot. Including
231c7b3754Spbrook  * this (unmodified) header file in another file is considered normal
241c7b3754Spbrook  * use of U-Boot, and does *not* fall under the heading of "derived
251c7b3754Spbrook  * work".
261c7b3754Spbrook  ********************************************************************
271c7b3754Spbrook  */
281c7b3754Spbrook 
291c7b3754Spbrook #ifndef __UBOOT_IMAGE_H__
301c7b3754Spbrook #define __UBOOT_IMAGE_H__
311c7b3754Spbrook 
321c7b3754Spbrook /*
331c7b3754Spbrook  * Operating System Codes
341c7b3754Spbrook  */
351c7b3754Spbrook #define IH_OS_INVALID		0	/* Invalid OS	*/
361c7b3754Spbrook #define IH_OS_OPENBSD		1	/* OpenBSD	*/
371c7b3754Spbrook #define IH_OS_NETBSD		2	/* NetBSD	*/
381c7b3754Spbrook #define IH_OS_FREEBSD		3	/* FreeBSD	*/
391c7b3754Spbrook #define IH_OS_4_4BSD		4	/* 4.4BSD	*/
401c7b3754Spbrook #define IH_OS_LINUX		5	/* Linux	*/
411c7b3754Spbrook #define IH_OS_SVR4		6	/* SVR4		*/
421c7b3754Spbrook #define IH_OS_ESIX		7	/* Esix		*/
431c7b3754Spbrook #define IH_OS_SOLARIS		8	/* Solaris	*/
441c7b3754Spbrook #define IH_OS_IRIX		9	/* Irix		*/
451c7b3754Spbrook #define IH_OS_SCO		10	/* SCO		*/
461c7b3754Spbrook #define IH_OS_DELL		11	/* Dell		*/
471c7b3754Spbrook #define IH_OS_NCR		12	/* NCR		*/
481c7b3754Spbrook #define IH_OS_LYNXOS		13	/* LynxOS	*/
491c7b3754Spbrook #define IH_OS_VXWORKS		14	/* VxWorks	*/
501c7b3754Spbrook #define IH_OS_PSOS		15	/* pSOS		*/
511c7b3754Spbrook #define IH_OS_QNX		16	/* QNX		*/
521c7b3754Spbrook #define IH_OS_U_BOOT		17	/* Firmware	*/
531c7b3754Spbrook #define IH_OS_RTEMS		18	/* RTEMS	*/
541c7b3754Spbrook #define IH_OS_ARTOS		19	/* ARTOS	*/
551c7b3754Spbrook #define IH_OS_UNITY		20	/* Unity OS	*/
561c7b3754Spbrook 
571c7b3754Spbrook /*
581c7b3754Spbrook  * CPU Architecture Codes (supported by Linux)
591c7b3754Spbrook  */
601c7b3754Spbrook #define IH_CPU_INVALID		0	/* Invalid CPU	*/
611c7b3754Spbrook #define IH_CPU_ALPHA		1	/* Alpha	*/
621c7b3754Spbrook #define IH_CPU_ARM		2	/* ARM		*/
631c7b3754Spbrook #define IH_CPU_I386		3	/* Intel x86	*/
641c7b3754Spbrook #define IH_CPU_IA64		4	/* IA64		*/
651c7b3754Spbrook #define IH_CPU_MIPS		5	/* MIPS		*/
661c7b3754Spbrook #define IH_CPU_MIPS64		6	/* MIPS	 64 Bit */
671c7b3754Spbrook #define IH_CPU_PPC		7	/* PowerPC	*/
681c7b3754Spbrook #define IH_CPU_S390		8	/* IBM S390	*/
691c7b3754Spbrook #define IH_CPU_SH		9	/* SuperH	*/
701c7b3754Spbrook #define IH_CPU_SPARC		10	/* Sparc	*/
711c7b3754Spbrook #define IH_CPU_SPARC64		11	/* Sparc 64 Bit */
721c7b3754Spbrook #define IH_CPU_M68K		12	/* M68K		*/
731c7b3754Spbrook #define IH_CPU_NIOS		13	/* Nios-32	*/
741c7b3754Spbrook #define IH_CPU_MICROBLAZE	14	/* MicroBlaze   */
751c7b3754Spbrook #define IH_CPU_NIOS2		15	/* Nios-II	*/
761c7b3754Spbrook #define IH_CPU_BLACKFIN		16	/* Blackfin	*/
771c7b3754Spbrook #define IH_CPU_AVR32		17	/* AVR32	*/
781c7b3754Spbrook 
791c7b3754Spbrook /*
801c7b3754Spbrook  * Image Types
811c7b3754Spbrook  *
821c7b3754Spbrook  * "Standalone Programs" are directly runnable in the environment
831c7b3754Spbrook  *	provided by U-Boot; it is expected that (if they behave
841c7b3754Spbrook  *	well) you can continue to work in U-Boot after return from
851c7b3754Spbrook  *	the Standalone Program.
861c7b3754Spbrook  * "OS Kernel Images" are usually images of some Embedded OS which
871c7b3754Spbrook  *	will take over control completely. Usually these programs
881c7b3754Spbrook  *	will install their own set of exception handlers, device
891c7b3754Spbrook  *	drivers, set up the MMU, etc. - this means, that you cannot
901c7b3754Spbrook  *	expect to re-enter U-Boot except by resetting the CPU.
911c7b3754Spbrook  * "RAMDisk Images" are more or less just data blocks, and their
921c7b3754Spbrook  *	parameters (address, size) are passed to an OS kernel that is
931c7b3754Spbrook  *	being started.
941c7b3754Spbrook  * "Multi-File Images" contain several images, typically an OS
951c7b3754Spbrook  *	(Linux) kernel image and one or more data images like
961c7b3754Spbrook  *	RAMDisks. This construct is useful for instance when you want
971c7b3754Spbrook  *	to boot over the network using BOOTP etc., where the boot
981c7b3754Spbrook  *	server provides just a single image file, but you want to get
991c7b3754Spbrook  *	for instance an OS kernel and a RAMDisk image.
1001c7b3754Spbrook  *
1011c7b3754Spbrook  *	"Multi-File Images" start with a list of image sizes, each
1021c7b3754Spbrook  *	image size (in bytes) specified by an "uint32_t" in network
1031c7b3754Spbrook  *	byte order. This list is terminated by an "(uint32_t)0".
1041c7b3754Spbrook  *	Immediately after the terminating 0 follow the images, one by
1051c7b3754Spbrook  *	one, all aligned on "uint32_t" boundaries (size rounded up to
1061c7b3754Spbrook  *	a multiple of 4 bytes - except for the last file).
1071c7b3754Spbrook  *
1081c7b3754Spbrook  * "Firmware Images" are binary images containing firmware (like
1091c7b3754Spbrook  *	U-Boot or FPGA images) which usually will be programmed to
1101c7b3754Spbrook  *	flash memory.
1111c7b3754Spbrook  *
1121c7b3754Spbrook  * "Script files" are command sequences that will be executed by
1131c7b3754Spbrook  *	U-Boot's command interpreter; this feature is especially
1141c7b3754Spbrook  *	useful when you configure U-Boot to use a real shell (hush)
1151c7b3754Spbrook  *	as command interpreter (=> Shell Scripts).
1161c7b3754Spbrook  */
1171c7b3754Spbrook 
1181c7b3754Spbrook #define IH_TYPE_INVALID		0	/* Invalid Image		*/
1191c7b3754Spbrook #define IH_TYPE_STANDALONE	1	/* Standalone Program		*/
1201c7b3754Spbrook #define IH_TYPE_KERNEL		2	/* OS Kernel Image		*/
1211c7b3754Spbrook #define IH_TYPE_RAMDISK		3	/* RAMDisk Image		*/
1221c7b3754Spbrook #define IH_TYPE_MULTI		4	/* Multi-File Image		*/
1231c7b3754Spbrook #define IH_TYPE_FIRMWARE	5	/* Firmware Image		*/
1241c7b3754Spbrook #define IH_TYPE_SCRIPT		6	/* Script file			*/
1251c7b3754Spbrook #define IH_TYPE_FILESYSTEM	7	/* Filesystem Image (any type)	*/
1261c7b3754Spbrook #define IH_TYPE_FLATDT		8	/* Binary Flat Device Tree Blob	*/
1271c7b3754Spbrook 
1281c7b3754Spbrook /*
1291c7b3754Spbrook  * Compression Types
1301c7b3754Spbrook  */
1311c7b3754Spbrook #define IH_COMP_NONE		0	/*  No	 Compression Used	*/
1321c7b3754Spbrook #define IH_COMP_GZIP		1	/* gzip	 Compression Used	*/
1331c7b3754Spbrook #define IH_COMP_BZIP2		2	/* bzip2 Compression Used	*/
1341c7b3754Spbrook 
1351c7b3754Spbrook #define IH_MAGIC	0x27051956	/* Image Magic Number		*/
1361c7b3754Spbrook #define IH_NMLEN		32	/* Image Name Length		*/
1371c7b3754Spbrook 
1381c7b3754Spbrook /*
1391c7b3754Spbrook  * all data in network byte order (aka natural aka bigendian)
1401c7b3754Spbrook  */
1411c7b3754Spbrook 
1421c7b3754Spbrook typedef struct uboot_image_header {
1431c7b3754Spbrook 	uint32_t	ih_magic;	/* Image Header Magic Number	*/
1441c7b3754Spbrook 	uint32_t	ih_hcrc;	/* Image Header CRC Checksum	*/
1451c7b3754Spbrook 	uint32_t	ih_time;	/* Image Creation Timestamp	*/
1461c7b3754Spbrook 	uint32_t	ih_size;	/* Image Data Size		*/
1471c7b3754Spbrook 	uint32_t	ih_load;	/* Data	 Load  Address		*/
1481c7b3754Spbrook 	uint32_t	ih_ep;		/* Entry Point Address		*/
1491c7b3754Spbrook 	uint32_t	ih_dcrc;	/* Image Data CRC Checksum	*/
1501c7b3754Spbrook 	uint8_t		ih_os;		/* Operating System		*/
1511c7b3754Spbrook 	uint8_t		ih_arch;	/* CPU architecture		*/
1521c7b3754Spbrook 	uint8_t		ih_type;	/* Image Type			*/
1531c7b3754Spbrook 	uint8_t		ih_comp;	/* Compression Type		*/
1541c7b3754Spbrook 	uint8_t		ih_name[IH_NMLEN];	/* Image Name		*/
155*c227f099SAnthony Liguori } uboot_image_header_t;
1561c7b3754Spbrook 
1571c7b3754Spbrook 
1581c7b3754Spbrook #endif	/* __IMAGE_H__ */
159