1/*  *********************************************************************
2    *  Broadcom Common Firmware Environment (CFE)
3    *
4    *  Definitions for U-Boot loader			File: uboot.h
5    *
6    *  Boot image for the U-Boot loader (Universal Bootloader).
7    *
8    *********************************************************************
9    *
10    *  Copyright 2004
11    *  Broadcom Corporation. All rights reserved.
12    *
13    *  This software is furnished under license and may be used and
14    *  copied only in accordance with the following terms and
15    *  conditions.  Subject to these conditions, you may download,
16    *  copy, install, use, modify and distribute modified or unmodified
17    *  copies of this software in source and/or binary form.  No title
18    *  or ownership is transferred hereby.
19    *
20    *  1) Any source code used, modified or distributed must reproduce
21    *     and retain this copyright notice and list of conditions
22    *     as they appear in the source file.
23    *
24    *  2) No right is granted to use any trade name, trademark, or
25    *     logo of Broadcom Corporation.  The "Broadcom Corporation"
26    *     name may not be used to endorse or promote products derived
27    *     from this software without the prior written permission of
28    *     Broadcom Corporation.
29    *
30    *  3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
31    *     IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
32    *     WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
33    *     PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
34    *     SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
35    *     PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
36    *     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37    *     (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
38    *     GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
39    *     BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
40    *     OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
41    *     TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
42    *     THE POSSIBILITY OF SUCH DAMAGE.
43    ********************************************************************* */
44
45/*
46 * Operating System Codes
47 */
48#define IH_OS_INVALID		0	/* Invalid OS	*/
49#define IH_OS_OPENBSD		1	/* OpenBSD	*/
50#define IH_OS_NETBSD		2	/* NetBSD	*/
51#define IH_OS_FREEBSD		3	/* FreeBSD	*/
52#define IH_OS_4_4BSD		4	/* 4.4BSD	*/
53#define IH_OS_LINUX		5	/* Linux	*/
54#define IH_OS_SVR4		6	/* SVR4		*/
55#define IH_OS_ESIX		7	/* Esix		*/
56#define IH_OS_SOLARIS		8	/* Solaris	*/
57#define IH_OS_IRIX		9	/* Irix		*/
58#define IH_OS_SCO		10	/* SCO		*/
59#define IH_OS_DELL		11	/* Dell		*/
60#define IH_OS_NCR		12	/* NCR		*/
61#define IH_OS_LYNXOS		13	/* LynxOS	*/
62#define IH_OS_VXWORKS		14	/* VxWorks	*/
63#define IH_OS_PSOS		15	/* pSOS		*/
64#define IH_OS_QNX		16	/* QNX		*/
65#define IH_OS_PPCBOOT		17	/* Firmware	*/
66
67/*
68 * CPU Architecture Codes (supported by Linux)
69 */
70#define IH_CPU_INVALID		0	/* Invalid CPU	*/
71#define IH_CPU_ALPHA		1	/* Alpha	*/
72#define IH_CPU_ARM		2	/* ARM		*/
73#define IH_CPU_I386		3	/* Intel x86	*/
74#define IH_CPU_IA64		4	/* IA64		*/
75#define IH_CPU_MIPS		5	/* MIPS		*/
76#define IH_CPU_MIPS64		6	/* MIPS	 64 Bit */
77#define IH_CPU_PPC		7	/* PowerPC	*/
78#define IH_CPU_S390		8	/* IBM S390	*/
79#define IH_CPU_SH		9	/* SuperH	*/
80#define IH_CPU_SPARC		10	/* Sparc	*/
81#define IH_CPU_SPARC64		11	/* Sparc 64 Bit */
82
83/*
84 * Image Types
85 *
86 * "Standalone Programs" are directly runnable in the environment
87 *	provided by PPCBoot; it is expected that (if they behave
88 *	well) you can continue to work in PPCBoot after return from
89 *	the Standalone Program.
90 * "OS Kernel Images" are usually images of some Embedded OS which
91 *	will take over control completely. Usually these programs
92 *	will install their own set of exception handlers, device
93 *	drivers, set up the MMU, etc. - this means, that you cannot
94 *	expect to re-enter PPCBoot except by resetting the CPU.
95 * "RAMDisk Images" are more or less just data blocks, and their
96 *	parameters (address, size) are passed to an OS kernel that is
97 *	being started.
98 * "Multi-File Images" contain several images, typically an OS
99 *	(Linux) kernel image and one or more data images like
100 *	RAMDisks. This construct is useful for instance when you want
101 *	to boot over the network using BOOTP etc., where the boot
102 *	server provides just a single image file, but you want to get
103 *	for instance an OS kernel and a RAMDisk image.
104 *
105 *	"Multi-File Images" start with a list of image sizes, each
106 *	image size (in bytes) specified by an "uint32_t" in network
107 *	byte order. This list is terminated by an "(uint32_t)0".
108 *	Immediately after the terminating 0 follow the images, one by
109 *	one, all aligned on "uint32_t" boundaries (size rounded up to
110 *	a multiple of 4 bytes).
111 *
112 * "Firmware Images" are binary images containing firmware (like
113 *	PPCBoot or FPGA images) which usually will be programmed to
114 *	flash memory.
115 *
116 * "Script files" are command sequences that will be executed by
117 *	PPCBoot's command interpreter; this feature is especially
118 *	useful when you configure PPCBoot to use a real shell (hush)
119 *	as command interpreter.
120 */
121
122#define IH_TYPE_INVALID		0	/* Invalid Image		*/
123#define IH_TYPE_STANDALONE	1	/* Standalone Program		*/
124#define IH_TYPE_KERNEL		2	/* OS Kernel Image		*/
125#define IH_TYPE_RAMDISK		3	/* RAMDisk Image		*/
126#define IH_TYPE_MULTI		4	/* Multi-File Image		*/
127#define IH_TYPE_FIRMWARE	5	/* Firmware Image		*/
128#define IH_TYPE_SCRIPT		6	/* Script file			*/
129
130/*
131 * Compression Types
132 */
133#define IH_COMP_NONE		0	/*  No	 Compression Used	*/
134#define IH_COMP_GZIP		1	/* gzip	 Compression Used	*/
135#define IH_COMP_BZIP2		2	/* bzip2 Compression Used	*/
136
137#define IH_MAGIC	0x27051956	/* Image Magic Number		*/
138#define IH_NMLEN		32	/* Image Name Length		*/
139
140#ifdef __CYGWIN__
141typedef unsigned long uint32_t;
142typedef unsigned char uint8_t;
143#endif /* __CYGWIN__ */
144
145/*
146 * all data in network byte order (aka natural aka bigendian)
147 */
148
149typedef struct image_header {
150	uint32_t	ih_magic;	/* Image Header Magic Number	*/
151	uint32_t	ih_hcrc;	/* Image Header CRC Checksum	*/
152	uint32_t	ih_time;	/* Image Creation Timestamp	*/
153	uint32_t	ih_size;	/* Image Data Size		*/
154	uint32_t	ih_load;	/* Data	 Load  Address		*/
155	uint32_t	ih_ep;		/* Entry Point Address		*/
156	uint32_t	ih_dcrc;	/* Image Data CRC Checksum	*/
157	uint8_t		ih_os;		/* Operating System		*/
158	uint8_t		ih_arch;	/* CPU architecture		*/
159	uint8_t		ih_type;	/* Image Type			*/
160	uint8_t		ih_comp;	/* Compression Type		*/
161	uint8_t		ih_name[IH_NMLEN];	/* Image Name		*/
162} image_header_t;
163
164