1/* 2 * This program is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU General Public License as 4 * published by the Free Software Foundation; either version 2 of 5 * the License, or (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software 14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 15 * MA 02111-1307 USA 16 */ 17/* 18 * (C) Copyright 2000 19 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 20 * 21 * See file CREDITS for list of people who contributed to this 22 * project. 23 * 24 * This program is free software; you can redistribute it and/or 25 * modify it under the terms of the GNU General Public License as 26 * published by the Free Software Foundation; either version 2 of 27 * the License, or (at your option) any later version. 28 * 29 * This program is distributed in the hope that it will be useful, 30 * but WITHOUT ANY WARRANTY; without even the implied warranty of 31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 32 * GNU General Public License for more details. 33 * 34 * You should have received a copy of the GNU General Public License 35 * along with this program; if not, write to the Free Software 36 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 37 * MA 02111-1307 USA 38 */ 39 40#ifndef __IMAGE_H__ 41#define __IMAGE_H__ 42 43/* 44 * Operating System Codes 45 */ 46#define IH_OS_INVALID 0 /* Invalid OS */ 47#define IH_OS_OPENBSD 1 /* OpenBSD */ 48#define IH_OS_NETBSD 2 /* NetBSD */ 49#define IH_OS_FREEBSD 3 /* FreeBSD */ 50#define IH_OS_4_4BSD 4 /* 4.4BSD */ 51#define IH_OS_LINUX 5 /* Linux */ 52#define IH_OS_SVR4 6 /* SVR4 */ 53#define IH_OS_ESIX 7 /* Esix */ 54#define IH_OS_SOLARIS 8 /* Solaris */ 55#define IH_OS_IRIX 9 /* Irix */ 56#define IH_OS_SCO 10 /* SCO */ 57#define IH_OS_DELL 11 /* Dell */ 58#define IH_OS_NCR 12 /* NCR */ 59#define IH_OS_LYNXOS 13 /* LynxOS */ 60#define IH_OS_VXWORKS 14 /* VxWorks */ 61#define IH_OS_PSOS 15 /* pSOS */ 62#define IH_OS_QNX 16 /* QNX */ 63#define IH_OS_U_BOOT 17 /* Firmware */ 64#define IH_OS_RTEMS 18 /* RTEMS */ 65#define IH_OS_ARTOS 19 /* ARTOS */ 66#define IH_OS_UNITY 20 /* Unity OS */ 67 68/* 69 * CPU Architecture Codes (supported by Linux) 70 */ 71#define IH_CPU_INVALID 0 /* Invalid CPU */ 72#define IH_CPU_ALPHA 1 /* Alpha */ 73#define IH_CPU_ARM 2 /* ARM */ 74#define IH_CPU_I386 3 /* Intel x86 */ 75#define IH_CPU_IA64 4 /* IA64 */ 76#define IH_CPU_MIPS 5 /* MIPS */ 77#define IH_CPU_MIPS64 6 /* MIPS 64 Bit */ 78#define IH_CPU_PPC 7 /* PowerPC */ 79#define IH_CPU_S390 8 /* IBM S390 */ 80#define IH_CPU_SH 9 /* SuperH */ 81#define IH_CPU_SPARC 10 /* Sparc */ 82#define IH_CPU_SPARC64 11 /* Sparc 64 Bit */ 83#define IH_CPU_M68K 12 /* M68K */ 84#define IH_CPU_NIOS 13 /* Nios-32 */ 85#define IH_CPU_MICROBLAZE 14 /* MicroBlaze */ 86#define IH_CPU_NIOS2 15 /* Nios-II */ 87 88/* 89 * Image Types 90 * 91 * "Standalone Programs" are directly runnable in the environment 92 * provided by U-Boot; it is expected that (if they behave 93 * well) you can continue to work in U-Boot after return from 94 * the Standalone Program. 95 * "OS Kernel Images" are usually images of some Embedded OS which 96 * will take over control completely. Usually these programs 97 * will install their own set of exception handlers, device 98 * drivers, set up the MMU, etc. - this means, that you cannot 99 * expect to re-enter U-Boot except by resetting the CPU. 100 * "RAMDisk Images" are more or less just data blocks, and their 101 * parameters (address, size) are passed to an OS kernel that is 102 * being started. 103 * "Multi-File Images" contain several images, typically an OS 104 * (Linux) kernel image and one or more data images like 105 * RAMDisks. This construct is useful for instance when you want 106 * to boot over the network using BOOTP etc., where the boot 107 * server provides just a single image file, but you want to get 108 * for instance an OS kernel and a RAMDisk image. 109 * 110 * "Multi-File Images" start with a list of image sizes, each 111 * image size (in bytes) specified by an "uint32_t" in network 112 * byte order. This list is terminated by an "(uint32_t)0". 113 * Immediately after the terminating 0 follow the images, one by 114 * one, all aligned on "uint32_t" boundaries (size rounded up to 115 * a multiple of 4 bytes - except for the last file). 116 * 117 * "Firmware Images" are binary images containing firmware (like 118 * U-Boot or FPGA images) which usually will be programmed to 119 * flash memory. 120 * 121 * "Script files" are command sequences that will be executed by 122 * U-Boot's command interpreter; this feature is especially 123 * useful when you configure U-Boot to use a real shell (hush) 124 * as command interpreter (=> Shell Scripts). 125 */ 126 127#define IH_TYPE_INVALID 0 /* Invalid Image */ 128#define IH_TYPE_STANDALONE 1 /* Standalone Program */ 129#define IH_TYPE_KERNEL 2 /* OS Kernel Image */ 130#define IH_TYPE_RAMDISK 3 /* RAMDisk Image */ 131#define IH_TYPE_MULTI 4 /* Multi-File Image */ 132#define IH_TYPE_FIRMWARE 5 /* Firmware Image */ 133#define IH_TYPE_SCRIPT 6 /* Script file */ 134#define IH_TYPE_FILESYSTEM 7 /* Filesystem Image (any type) */ 135 136/* 137 * Compression Types 138 */ 139#define IH_COMP_NONE 0 /* No Compression Used */ 140#define IH_COMP_GZIP 1 /* gzip Compression Used */ 141#define IH_COMP_BZIP2 2 /* bzip2 Compression Used */ 142#define IH_COMP_LZMA 3 /* lzma Compression Used */ 143 144#define IH_MAGIC 0x27051956 /* Image Magic Number */ 145#define IH_NMLEN 32 /* Image Name Length */ 146 147/* 148 * all data in network byte order (aka natural aka bigendian) 149 */ 150 151#define MAX_STRING 12 152#define MAX_VER 4 153 154/* If hw[i].kernel == ROOTFS_OFFSET_MAGIC, 155 * rootfilesystem offset (uImage header size + kernel size) 156 * can be calculated by following equation: 157 * (hw[i].minor << 16) | (hw[i+1].major << 8) | (hw[i+1].minor) 158 */ 159#define ROOTFS_OFFSET_MAGIC 0xA9 /* Occupy two version_t */ 160 161typedef struct { 162 uint8_t major; 163 uint8_t minor; 164} version_t; 165 166typedef struct { 167 version_t kernel; 168 version_t fs; 169 char productid[MAX_STRING]; 170 version_t hw[MAX_VER*2]; 171} TAIL; 172 173typedef struct image_header { 174 uint32_t ih_magic; /* Image Header Magic Number */ 175 uint32_t ih_hcrc; /* Image Header CRC Checksum */ 176 uint32_t ih_time; /* Image Creation Timestamp */ 177 uint32_t ih_size; /* Image Data Size */ 178 uint32_t ih_load; /* Data Load Address */ 179 uint32_t ih_ep; /* Entry Point Address */ 180 uint32_t ih_dcrc; /* Image Data CRC Checksum */ 181 uint8_t ih_os; /* Operating System */ 182 uint8_t ih_arch; /* CPU architecture */ 183 uint8_t ih_type; /* Image Type */ 184 uint8_t ih_comp; /* Compression Type */ 185 union { 186 uint8_t ih_name[IH_NMLEN]; /* Image Name */ 187 TAIL tail; /* ASUS firmware infomation */ 188 } u; 189} image_header_t; 190 191 192#endif /* __IMAGE_H__ */ 193