summaryrefslogtreecommitdiffstats
path: root/src/occ/incl/common_types.h
blob: 6e1b791a9191b58f00fa856975883a77ad571ef1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
/******************************************************************************
// @file common_types.h
// @brief File containing OCC common defines 
*/
/******************************************************************************
 *
 *       @page ChangeLogs Change Logs
 *       @section  _common_types_h common_types.h
 *       @verbatim
 *
 *   Flag    Def/Fea    Userid    Date        Description
 *   ------- ---------- --------  ----------  ----------------------------------
 *                      TEAM      06/16/2010  Port
 *   @pb000             pbavari   07/07/2011  Added image_header structure and
 *                                            image macro
 *   @pb004             pbavari   09/14/2011  Added ssx_app_cfg.h for init sec
 *                                            defines
 *   @03                tapiar    10/03/2011  removed typedef from BOOLEAN type
 *   @04                dwoodham  12/12/2011  added aplt_id field to image_header
 *   @rc003             rickylie  02/03/2012  Verify & Clean Up OCC Headers & Comments
 *   @ai007             ailutsar  12/10/2012  Change OCC Image Header to reserve 64 bytes 
 *                                            for SRAM Repair instead of 16
 *   @th027  865085     thallet   12/21/2012  SRAM 'hack' to allow previous "16" HW scripts to work.
 *   @ai009  865968     ailutsar  01/09/2013  OCC Error log and trace parser web tool enhancement
 *
 *  @endverbatim
 *
 *///*************************************************************************/
 
#ifndef _COMMON_TYPES_H
#define _COMMON_TYPES_H

//*************************************************************************
// Includes
//*************************************************************************
#include <stdint.h>

#ifdef USE_SSX_APP_CFG_H
#include <ssx_app_cfg.h>
#endif

//*************************************************************************
// Externs
//*************************************************************************

//*************************************************************************
// Macros
//*************************************************************************

//*************************************************************************
// Defines/Enums
//*************************************************************************
typedef uint32_t      UINT32;
typedef int32_t       INT32;
typedef uint8_t       UCHAR;
typedef uint8_t       UINT8;
typedef int8_t        INT8;
typedef uint16_t      UINT16;
typedef int16_t       INT16;
typedef char          CHAR;
typedef unsigned int  UINT;
typedef unsigned long ULONG;
typedef int           INT;
typedef void          VOID;
// @ai009c
// Skip this typedef in x86 environment
#ifndef OCC_X86_PARSER  
typedef uint8_t       bool;
#endif
//@pb000d - moved typedef uint32_t size_t to common.h due to type conflict



/* Definition of FALSE and TRUE */
#if !defined(FALSE) && !defined(TRUE)
typedef enum
{
    FALSE = 0,
    TRUE
} BOOLEAN;
#endif

#ifndef NULL
#define NULL                 (VOID *) 0
#endif

//@pb000a - start
#define MAIN_APP_ID         "Main App Image\0"

#define SRAM_REPAIR_RESERVE_SZ  64  // @ai007c
#define IMAGE_ID_STR_SZ         16
#define RESERVED_SZ             14  // @04c
#define TRAP_INST               0x7FE00004
#define ID_NUM_INVALID          0xFFFF  // @04a sim. to OCC_APLT_INVALID

// @04a Magic number set for applet headers    // @ai007c Change data length
#define APLT_MAGIC_NUMBER {0x1A,0x2B,0x3C,0x4D, 0x5E,0x6F,0x7A,0x8B, 0x9C,0xAD,0xAE,0x9F, 0x8A,0x7B,0x6C,0x5D, 0x4E,0x3F,0x2A,0x1B,\
                           0x1A,0x2B,0x3C,0x4D, 0x5E,0x6F,0x7A,0x8B, 0x9C,0xAD,0xAE,0x9F, 0x8A,0x7B,0x6C,0x5D, 0x4E,0x3F,0x2A,0x1B,\
                           0x1A,0x2B,0x3C,0x4D, 0x5E,0x6F,0x7A,0x8B, 0x9C,0xAD,0xAE,0x9F, 0x8A,0x7B,0x6C,0x5D, 0x4E,0x3F,0x2A,0x1B, 0x12,0x34,0xAB,0xCD}
#define SRAM_HEADER_HACK   0x48000042  // @th027
#ifndef __ASSEMBLER__

// Structure for the common image header
struct image_header
{
    // >@04c Overload sram_repair_reserved for magic applet number (thanks, Tim H.!)
    //       Note: unit64_t's don't compile when used w/IMAGE_HEADER macro.
    union
    {
        struct
        {
            // @ai007c
            uint32_t magic_1;  // 0x1A2B3C4D
            uint32_t magic_2;  // 0x5E6F7A8B
            uint32_t magic_3;  // 0x9CADAE9F
            uint32_t magic_4;  // 0x8A7B6C5D
            uint32_t magic_5;  // 0x4E3F2A1B
            uint32_t magic_6;  // 0x1A2B3C4D
            uint32_t magic_7;  // 0x5E6F7A8B
            uint32_t magic_8;  // 0x9CADAE9F
            uint32_t magic_9;  // 0x8A7B6C5D
            uint32_t magic_a;  // 0x4E3F2A1B
            uint32_t magic_b;  // 0x1A2B3C4D
            uint32_t magic_c;  // 0x5E6F7A8B
            uint32_t magic_d;  // 0x9CADAE9F
            uint32_t magic_e;  // 0x8A7B6C5D
            uint32_t magic_f;  // 0x4E3F2A1B
            uint32_t magic_10;  // 0x1234ABCD
        };
        uint8_t sram_repair_reserved[SRAM_REPAIR_RESERVE_SZ]; //reserved for HW use
    };
    // <@04c
    uint32_t ep_branch_inst; // entry point branch instruction for bootloader
    uint32_t halt_inst; // halt instruction
    uint32_t image_size; // image size including header
    uint32_t start_addr; // image start address including header
    uint32_t readonly_size; // readonly image size
    uint32_t boot_writeable_addr; // boot writeable address
    uint32_t boot_writeable_size; // boot writeable size
    uint32_t zero_data_addr; // zero data address
    uint32_t zero_data_size; // zero data size
    uint32_t ep_addr; // entry point to the image
    uint32_t checksum; // checksum of the image including header
    uint32_t version; // image version
    char image_id_str[IMAGE_ID_STR_SZ]; // image id string
    uint16_t aplt_id;  // @04a type: enum OCC_APLT
    uint8_t reserved[RESERVED_SZ]; // reserved for future use
} __attribute__ ((__packed__));

typedef struct image_header imageHdr_t;

extern uint32_t __READ_ONLY_DATA_LEN__;
extern uint32_t __WRITEABLE_DATA_ADDR__;
extern uint32_t __WRITEABLE_DATA_LEN__;
extern uint32_t __START_ADDR__;


// Macro for creating common image header
// NOTE: ep_branch_inst is defaulted to trap instruction. Script to fix
// header will change it to branch to address in ep_addr field.
// >@04c Init field sram_repair_reserved.  Add field IdNum == aplt_id.
// >@ai007 Update magic number
#define IMAGE_HEADER(nameStr, epAddr, IdStr, IdNum)   \
const volatile imageHdr_t nameStr  __attribute__((section("imageHeader")))= \
{ \
    /* sram_repair_reserved values should match APLT_MAGIC_NUMBER for an applet; 0 otherwise */ \
    { \
        { \
            .magic_1 = (IdNum == ID_NUM_INVALID)?0:0x1A2B3C4D, \
            .magic_2 = (IdNum == ID_NUM_INVALID)?0:0x5E6F7A8B, \
            .magic_3 = (IdNum == ID_NUM_INVALID)?0:0x9CADAE9F, \
            .magic_4 = (IdNum == ID_NUM_INVALID)?0:0x8A7B6C5D, \
            .magic_5 = (IdNum == ID_NUM_INVALID)? SRAM_HEADER_HACK:0x4E3F2A1B, \
            .magic_6 = (IdNum == ID_NUM_INVALID)?0:0x1A2B3C4D, \
            .magic_7 = (IdNum == ID_NUM_INVALID)?0:0x5E6F7A8B, \
            .magic_8 = (IdNum == ID_NUM_INVALID)?0:0x9CADAE9F, \
            .magic_9 = (IdNum == ID_NUM_INVALID)?0:0x8A7B6C5D, \
            .magic_a = (IdNum == ID_NUM_INVALID)?0:0x4E3F2A1B, \
            .magic_b = (IdNum == ID_NUM_INVALID)?0:0x1A2B3C4D, \
            .magic_c = (IdNum == ID_NUM_INVALID)?0:0x5E6F7A8B, \
            .magic_d = (IdNum == ID_NUM_INVALID)?0:0x9CADAE9F, \
            .magic_e = (IdNum == ID_NUM_INVALID)?0:0x8A7B6C5D, \
            .magic_f = (IdNum == ID_NUM_INVALID)?0:0x4E3F2A1B, \
            .magic_10 = (IdNum == ID_NUM_INVALID)?0:0x1234ABCD, \
        } \
    }, \
    TRAP_INST,   /* ep_branch_Inst */ \
    TRAP_INST,   /* halt_inst */ \
    0,   /* image_size (filled in later by imageHdrScript) */ \
    (uint32_t)&__START_ADDR__,   /* start_addr */ \
    (uint32_t)&__READ_ONLY_DATA_LEN__,  /* readonly_size */ \
    (uint32_t)&__WRITEABLE_DATA_ADDR__,  /* boot_writeable_addr */ \
    (uint32_t)&__WRITEABLE_DATA_LEN__,  /* boot_writeable_size */ \
    0,  /* zero_data_addr (currently unused) */ \
    0,  /* zero data_size (currently unused) */ \
    (uint32_t)&epAddr,  /* ep_addr */ \
    0,  /* checksum (calculated later by imsageHdrScript) */ \
    0,  /* version (filled in later by imageHdrScript) */ \
    IdStr,  /* image_id_str */ \
    (uint16_t)IdNum,  /* @04a aplt_id */ \
    {0} /* reserved */ \
};
// <@ai007
// <@04c

#endif  /* __ASSEMBLER__ */
//@pb000a - end

//*************************************************************************
// Structures
//*************************************************************************

//*************************************************************************
// Globals
//*************************************************************************

//*************************************************************************
// Function Prototypes
//*************************************************************************

//*************************************************************************
// Functions
//*************************************************************************

#endif //_COMMON_TYPES_H
OpenPOWER on IntegriCloud