3 //==========================================================================
7 // RedBoot - structure of ARM flash file format
9 //==========================================================================
10 //####ECOSGPLCOPYRIGHTBEGIN####
11 // -------------------------------------------
12 // This file is part of eCos, the Embedded Configurable Operating System.
13 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
15 // eCos is free software; you can redistribute it and/or modify it under
16 // the terms of the GNU General Public License as published by the Free
17 // Software Foundation; either version 2 or (at your option) any later version.
19 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
20 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 // You should have received a copy of the GNU General Public License along
25 // with eCos; if not, write to the Free Software Foundation, Inc.,
26 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
28 // As a special exception, if other files instantiate templates or use macros
29 // or inline functions from this file, or you compile this file and link it
30 // with other works to produce a work based on this file, this file does not
31 // by itself cause the resulting work to be covered by the GNU General Public
32 // License. However the source code for this file must still be made available
33 // in accordance with section (3) of the GNU General Public License.
35 // This exception does not invalidate any other reasons why a work based on
36 // this file might be covered by the GNU General Public License.
38 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
39 // at http://sources.redhat.com/ecos/ecos-license/
40 // -------------------------------------------
41 //####ECOSGPLCOPYRIGHTEND####
42 //==========================================================================
43 //#####DESCRIPTIONBEGIN####
45 // Author(s): Philippe Robin
46 // Contributors: Philippe Robin, jskov
51 // This code is part of RedBoot (tm).
53 //####DESCRIPTIONEND####
55 //==========================================================================
57 #include <cyg/hal/hal_io.h>
59 /* type information :-
60 * 0xffff ffff - deleted (usual flash erased value)
61 * 0x0000 xxxx - Reserved for ARM usage:
62 * Bit 0 - ARM Executable Image
63 * Bit 1 - System Information Block
64 * Bit 2 - File System Block
65 * 0xyyyy 0000 - Available for customers (y != 0)
67 #define TYPE_DELETED 0xFFFFFFFF
68 #define TYPE_ARM_MASK 0x0000FFFF
69 #define TYPE_CUSTOM_MASK 0xFFFF0000
70 #define TYPE_ARM_EXEC 0x00000001
71 #define TYPE_ARM_SIB 0x00000002
72 #define TYPE_ARM_SYSBLOCK 0x00000004
74 /* This is the type we use for RedBoot blocks */
75 #define TYPE_REDHAT_REDBOOT 0x52420000
77 /* The ARM monitor may be using a different memory mapping than RedBoot */
78 #ifndef _ADDR_REDBOOT_TO_ARM
79 # define _ADDR_REDBOOT_TO_ARM(x)
84 #define UNKNOWN_FILE 0x00000000
85 #define MOT_S_RECORD 0x00000001
86 #define INTEL_HEX 0x00000002
87 #define ELF 0x00000004
88 #define DWARF 0x00000008
89 #define ARM_AOF 0x00000010
90 #define ARM_AIF 0x00000020
91 #define PLAIN_BINARY 0x00000040
92 #define ARM_AIF_BIN 0x00000080
93 #define MCS_TYPE 0x00000100
95 #define CONVERT_TYPE (MOT_S_RECORD | INTEL_HEX | MCS_TYPE | ELF)
97 #define SIB_OWNER_STRING_SIZE 32
98 #define MAX_SIB_SIZE 512
99 #define MAX_SIB_INDEX 64
101 #define SIB_HEADER_SIGNATURE 0xA00FFF9F /* This is an invalid instruction - MULGE pc,pc,pc */
102 #define FLASH_FOOTER_SIGNATURE 0xA0FFFF9F /* This is an invalid instruction - SMULALGES pc,pc,pc */
105 typedef struct SIBType {
106 cyg_uint32 signature;
108 char owner[SIB_OWNER_STRING_SIZE];
114 typedef struct SIBInfoType {
115 cyg_uint32 SIB_number; /* Unique number of SIB Block */
116 cyg_uint32 SIB_Extension; /* Base of SIB Flash Block */
117 char Label[16]; /* String space for ownership string */
118 cyg_uint32 checksum; /* SIB Image checksum */
121 typedef struct FooterType {
122 void *infoBase; /* Address of first word of ImageFooter */
123 char *blockBase; /* Start of area reserved by this footer */
124 cyg_uint32 signature; /* 'Magic' number proves it's a footer */
125 cyg_uint32 type; /* Area type: ARM Image, SIB, customer */
126 cyg_uint32 checksum; /* Just this structure */
129 typedef struct ImageInfoType {
130 cyg_uint32 bootFlags; /* Boot flags, compression etc. */
131 cyg_uint32 imageNumber; /* Unique number, selects for boot etc. */
132 char *loadAddress; /* Address program should be loaded to */
133 cyg_uint32 length; /* Actual size of image */
134 char *address; /* Image is executed from here */
135 char name[16]; /* Null terminated */
136 char *headerBase; /* Flash Address of any stripped header */
137 cyg_uint32 header_length; /* Length of header in memory */
138 cyg_uint32 headerType; /* AIF, RLF, s-record etc. */
139 cyg_uint32 checksum; /* Image checksum (inc. this struct) */