]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/ibl.git/blob - src/util/romparse/tiboot_c6455.h
1ea935be0ea2441b128e2e806865abee3ceb3ea1
[keystone-rtos/ibl.git] / src / util / romparse / tiboot_c6455.h
1 #ifndef __TIBOOT_H__
2 #define __TIBOOT_H__
3 /******************************************************************************
4  * FILE PURPOSE: Define Structures, MACROs and etc for TI Shared ROM Boot
5  ******************************************************************************
6  * FILE NAME:   tiboot.h
7  *
8  * DESCRIPTION: Define structures, macros and etc for the TI Shared ROM boot
9  *              process.
10  *
11  * TABS: NONE
12  *
13  * $Id: $
14  *
15  * REVISION HISTORY:
16  *
17  * $Log: $
18  *
19  * (C) Copyright 2004 TELOGY Networks, Inc. 
20  ******************************************************************************/
21 #include "types.h"
23 /*******************************************************************************
24  * Utility Macro definitions
25  ******************************************************************************/
26 #define HEX_DIGIT(digit)        ((digit) + '0')
27 #define BOOT_BIT_TO_MASK(bit)   (1 << (bit))
29 /*******************************************************************************
30  * Data Definition: Error Handling relatBOOT_ENTRY_POINT_ADDRed definition:
31  *******************************************************************************
32  * Description: Define Handling related macros, constants
33  *
34  ******************************************************************************/
35 /* Define Module IDs */
36 #define BOOT_MODULE_ID_MAIN         0
37 #define BOOT_MODULE_ID_BTBL         1
38 #define BOOT_MODULE_ID_BETH         2
39 #define BOOT_MODULE_ID_I2C          3
40 #define BOOT_MODULE_ID_CHIP         4
41 #define BOOT_MODULE_ID_HW           5
43 /* Boot error codes */
44 enum {
45   BOOT_NOERR                = 0,
46   BOOT_ERROR                = 1,    /* General error */
47   BOOT_INVALID_BOOT_MODE    = 2,    
48   BOOT_INVALID_I2C_DEV_ADDR = 3,
49   BOOT_INVALID_CHECKSUM     = 4,    /* Invalid checksum of the boot parameters */
50   BOOT_INVALID_PARAMS_SIZE  = 5,    /* the size of boot parameters is too big */
51   BOOT_RX_ETH_QUEUE_FULL    = 6,    /* ethmain.c, hw_rxPacket */
52   BOOT_CACHE_INIT_FAIL      = 7,    /* rmain.c, cache init failed */
53   BOOT_CACHE_DISABLE_FAIL   = 8,    /* rmain.c, cache disable failed */
54   BOOT_INVALID_CPPI_SIZE    = 9,    /* ethmain.c, invalid compile sizes */
55   BOOT_INVALID_CORE_ID      = 10,   /* Invalid core ID in cold boot */
56   BOOT_INVALID_MAC_ADDR     = 11,   /* Invalid MAC address (all 0's) */
57   BOOT_ETH_TX_SCRATCH       = 12,   /* tx scratch size invalid */
58   BOOT_ETH_TX_PACKET        = 13,   /* tx packet formation failure */
59   BOOT_ETH_MAC_INIT         = 14    /* ethmain.c - mac init failed */
60 };
62 /* Error tracking prototypes (functions in rmain.c)*/
63 void bootException (UINT16 errorCode);
64 void bootError (UINT16 errorCode);
66 /* Error code = (module ID *  100) + module specific error */
67 #define BOOT_ERROR_CODE(id, code)     ((UINT16)((id<<8) + code))
68 #define BOOT_EXCEPTION(error_code)     bootException(error_code)
69 #define BOOT_ERROR(error_code)         bootError(error_code) 
71 /*******************************************************************************
72  * Begin Boot Parameter definitions
73  ******************************************************************************/
75 /*******************************************************************************
76  * Boot Parameter Common 
77  ******************************************************************************/
78 typedef struct boot_params_common_s{
79    UINT16 length;       /* size of the entire boot parameters in bytes */
80    UINT16 checksum;     /* non-zero: 1's complement checksum of the boot 
81                          *           parameters
82                          * zero: checksum is not applicable
83                          */
84    UINT16 boot_mode;
85    /* 
86     * Specify the boot mode
87     * bit 02-00: Standard Boot Mode
88     * bit 15-03: Extended Boot Mode
89     */
90     
91 } BOOT_PARAMS_COMMON_T;
93 typedef struct boot_params_ethernet_s{
95     /* common portion of the Boot parameters */
96     UINT16 length;
97     UINT16 checksum;
98     UINT16 boot_mode;
99      
100     /* Etherent specific portion of the Boot Parameters */
101     UINT16 options;
102     /*
103      * Ethernet Specific Options
104      * Bit 0: GE:                                      
105      *        0 - 10/100 Mb                            
106      *        1 - 1 Gb                                 
107      * Bit 2: HD:                                      
108      *        0 - Full Duplex                          
109      *        1 - Half Duplex                          
110      * Bit 3: SKIP TX                                           
111      *        0 - Send the Ethernet Ready Frame 
112      *        1 - Skip sending the Ethernet Ready Frame                                              
113      * Bit 4: SKIP INIT                                           
114      *        0 - Initialize the Ethernet MAC peripheral 
115      *        1 - Skip initializing the Ethernet MAC peripheral 
116      * Bit 5: FC
117      *        0 - Disable Flow Control
118      *        1 - Enable Flow Control                                               
119      * Other bits:  Reserved 
120      */ 
121      #define BOOT_PARAMS_ETH_OPTIONS_GE         0x0001
122      #define BOOT_PARAMS_ETH_OPTIONS_HD         0x0004
123      #define BOOT_PARAMS_ETH_OPTIONS_SKIP_TX    0x0008
124      #define BOOT_PARAMS_ETH_OPTIONS_SKIP_INIT  0x0010
125      #define BOOT_PARAMS_ETH_OPTIONS_FC         0x0020
126      
127      /* 
128       * he device MAC address to be used for Boot:
129       * All zero mac address indicates that the device E-fuse address should
130       *  be used.
131       */ 
132      UINT16 mac_addr_h;
133      UINT16 mac_addr_m;
134      UINT16 mac_addr_l;
135      
136      /* 
137       * The multicast or broadcast MAC address which should be accepted as
138       * a destination MAC address for boot table frames
139       */
140      UINT16 mmac_addr_h;
141      UINT16 mmac_addr_m;
142      UINT16 mmac_addr_l;
143         
144      UINT16 src_port;     /* Source UDP port number to be used during boot process */
145                           /* 0: allow any SRC UDP port */
146      UINT16 dest_port;    /* Destination UDP port number to be used during boot process */
147      
148      /* The Device ID to be included in the boot ready announcement frame */
149      UINT16 device_id_12;   
150      UINT16 device_id_34;   
151      #define BOOT_PARAMS_DEVICE_ID_HIGH_MASK     0xFF00
152      #define BOOT_PARAMS_DEVICE_ID_HIGH_SHIFT    8
153      #define BOOT_PARAMS_DEVICE_ID_LOW_MASK      0x00FF
154      #define BOOT_PARAMS_DEVICE_ID_LOW_SHIFT     0
155      #define BOOT_PARAMS_GET_DEVICE_ID_13(device_id)    \
156                (((device_id) & BOOT_PARAMS_DEVICE_ID_HIGH_MASK) > BOOT_PARAMS_DEVICE_ID_HIGH_SHIFT)
157      #define BOOT_PARAMS_GET_DEVICE_ID_24(device_id)    \
158                (((device_id) & BOOT_PARAMS_DEVICE_ID_LOW_MASK) > BOOT_PARAMS_DEVICE_ID_LOW_SHIFT)
159  
160      /* 
161       * The destination MAC address used for the boot ready announce frame
162       */
163      UINT16 hmac_addr_h;
164      UINT16 hmac_addr_m;
165      UINT16 hmac_addr_l;
166 }   BOOT_PARAMS_ETHERNET_T;
168 typedef struct boot_params_i2c_s{
170     /* common portion of the Boot parameters */
171     UINT16 length;
172     UINT16 checksum;
173     UINT16 boot_mode;
174     
175     /* I2C specific portion of the Boot Parameters */
176     UINT16 options;
177     /*
178      * I2C Specific Options
179      * Bit 01-00: BT:                                      
180      *            00 - Boot Parameter Mode                            
181      *            01 - Boot Table Mode                     
182      *            10 - Boot Config mode
183      *            11 - Slave receive boot config
184      * Bit 04-02: EETYPE: EEPROM type             
185      * Other bits:  Reserved 
186      */ 
187      #define BOOT_PARAMS_I2C_OPTIONS_BP             0x0000
188      #define BOOT_PARAMS_I2C_OPTIONS_BT             0x0001
189      #define BOOT_PARAMS_I2C_OPTIONS_BC             0x0002
190      #define BOOT_PARAMS_I2C_OPTIONS_SLVOPT         0x0003
191      
192      #define BOOT_PARAMS_I2C_OPTIONS_MASK           0x0003
193      #define BOOT_PARAMS_I2C_OPTIONS_SHIFT          0
194      
195      #define BOOT_PARAMS_I2C_OPTIONS_EETYPE_MASK    0x001C
196      #define BOOT_PARAMS_I2C_OPTIONS_EETYPE_SHIFT   2 
197      
198      #define BOOT_PARAMS_I2C_IS_BOOTTBL_MODE(options) \
199              (((options) & BOOT_PARAMS_I2C_OPTIONS_MASK) == BOOT_PARAMS_I2C_OPTIONS_BT)
200              
201      #define BOOT_PARAMS_I2C_IS_BOOTCONFIG_MODE(options) \
202              (((options) & BOOT_PARAMS_I2C_OPTIONS_MASK) == BOOT_PARAMS_I2C_OPTIONS_BC)
203              
204      #define BOOT_PARAMS_I2C_IS_SLAVE_RCV_OPTIONS_MODE(options) \
205              (((options) & BOOT_PARAMS_I2C_OPTIONS_MASK) == BOOT_PARAMS_I2C_OPTIONS_SLVOPT)
206              
207      #define BOOT_PARAMS_I2C_SET_BOOTTBL_MODE(options, mode)               \
208              (options) = ((options) & ~BOOT_PARAMS_I2C_OPTIONS_MASK) |     \
209                          (((mode)   &  BOOT_PARAMS_I2C_OPTIONS_MASK) <<    \
210                                        BOOT_PARAMS_I2C_OPTIONS_SHIFT)
211              
212              
213      #define BOOT_PARAMS_I2C_GET_EETYPE(options)    \
214              (((options) & BOOT_PARAMS_I2C_OPTIONS_EETYPE_MASK) >> BOOT_PARAMS_I2C_OPTIONS_EETYPE_SHIFT)
215      #define BOOT_PARAMS_I2C_SET_EETYPE(options, ee_type)         \
216              (options) = (((options) & ~BOOT_PARAMS_I2C_OPTIONS_EETYPE_MASK) |  \
217                          (((ee_type) << BOOT_PARAMS_I2C_OPTIONS_EETYPE_SHIFT) & BOOT_PARAMS_I2C_OPTIONS_EETYPE_MASK))          
218         
219      /* The device address to be used for Boot */
220      UINT16 dev_addr;           /* 16-bit device address (low) */
221      UINT16 dev_addr_ext;       /* 16-bit extended device address (high) 
222                                  * set to zero if not used
223                                  * Note: some I2C device requires 32-bit 
224                                  * address
225                                  */ 
226      UINT16 multi_i2c_id;      /* Multi device master write boot ID */
227      UINT16 my_i2c_id;         /* This parts I2C address            */
228      
229      UINT16 core_freq_mhz;     /* Core frequency, MHz               */
230      UINT16 i2c_clk_freq_khz;  /* Desired I2C clock frequency, kHz  */
231      
232      UINT16 next_dev_addr;      /* Used only for the boot config mode.         */
233      UINT16 next_dev_addr_ext;  /* Copied into dev_addr* after config complete */
234      
235      UINT16 address_delay;      /* Rough number of cycles delay between address write
236                                  * and read to the i2c eeprom */
237      
238      
239 } BOOT_PARAMS_I2C_T;   
241 /*
242  * UNION of boot parameter structures in all modes
243  * Note: We need to make sure that the structures genertaed by the C-compiler
244  *       match with the boot parameter table data format i.e. a set of 16-bit
245  *       data array.
246  */ 
247 #define BOOT_PARAMS_SIZE_IN_BYTES       256            
248 typedef union {
249    BOOT_PARAMS_COMMON_T    common;  
250    BOOT_PARAMS_ETHERNET_T  eth;
251    BOOT_PARAMS_I2C_T       i2c;
252    UINT16                  parameter[BOOT_PARAMS_SIZE_IN_BYTES/2]; 
253 } BOOT_PARAMS_T;
256 /*******************************************************************************
257  * Definition: The time stamp and version number are placed into the stats. 
258  *             This will be two characters packed per 16bits . The length
259  *             value must be 32 bit divisible
260  *******************************************************************************/
261 #define BOOT_VERSION_LEN_UINT16    32 
262 typedef struct BOOT_VERSION_S {
264   UINT16 vstring[BOOT_VERSION_LEN_UINT16];
265   
266 } BOOT_VERSION_T;
267 extern BOOT_VERSION_T bootVersion;
268   
270 /*******************************************************************************
271  * Definition: Runs time stats that are not initialized on cold boot entry
272  *   !!!!!! boot.s assumes that the nonInit stats are at the top of the structure
273  *   !!!!!! and that stage is the first element
274  *******************************************************************************/
275 typedef struct BOOT_STATS_NONINIT_S {
276   UINT16  stage;            /* Record the SharedROM code execution stage */
277   #define BOOT_STAGE_ASM_START_UP               1
278   #define BOOT_STAGE_INIT_CACHE                 2
279   #define BOOT_STAGE_CHCHE_INITED               3
280   #define BOOT_STAGE_ENTER_WARMBOOT             4
281   #define BOOT_STAGE_INIT_CPGMAC                5
282   #define BOOT_STAGE_SEND_ERA_FRAME             6
283   #define BOOT_STAGE_ETH_MAIN_LOOP              7
284   #define BOOT_STAGE_I2C_BOOTTBL_LOOP           8
285   #define BOOT_STAGE_I2C_BOOTPARAM_LOOP         9
286   #define BOOT_STAGE_DISABLE_CACHE             10
287   #define BOOT_STAGE_CHCHE_DISABLED            11
288   #define BOOT_STAGE_EXIT                      12
289   #define BOOT_STAGE_ERROR_LOOP                13  
290   #define BOOT_STAGE_I2C_BOOTCONFIG_LOOP       14
291   #define BOOT_STAGE_I2C_SLV_RCV_OPTIONS_LOOP  15
292   UINT16  coldBootEntries;
293   
294 } BOOT_STATS_NONINIT_T;
296 /*******************************************************************************
297  * Definition: Run time statistics and error counts. These stats are 
298  *             initialized on cold boot entry.
299  ******************************************************************************/
300 typedef struct BOOT_STATS_MAIN_S {
301   UINT16  errorCode;        /* (module ID <<8 ) + module specific error */
302   
303   /* I2C operation related statistics */
304   UINT16  numI2Cpkts;       /* number of I2C boot table packets processed */
305   UINT16  numI2CchksumError;/* number of I2C checksum errors */
306   UINT16  numI2CotherError; /* number of I2C section with invalid length and etc */
307   UINT16  numI2Cretrys;     /* number of I2C retrys due to read access errors */
308   UINT16  numI2cWrites;     /* number of I2C master writes to passive devices */
309   UINT16  numI2cWriteError; /* number of I2C master write errors              */
310   
311   UINT16  warmBootEntry;    /* Count of entries into warm boot routine   */
312 } BOOT_STATS_MAIN_T;
314 /*****************************************************************************
315  * Definition: I2C stats, Boot table and Ethernrt stats initialized 
316  *             on cold boot entry
317  *****************************************************************************/
318 typedef struct I2C_STATS_tag
320     UINT16      num_trans;
321     UINT16      num_trys;
322     UINT16      num_try_ok;
323     UINT16      num_try_lost_arb;
324     UINT16      num_try_idle_to;
325     UINT16      num_try_no_ack;
326     UINT16      num_try_other_err;
327     UINT32      extra_idle_waits;
328     UINT32      extra_clock_waits;
329     UINT32      tx_bytes;
330     UINT32      rx_bytes;
331     UINT32      data_re_reads;
332 } I2C_STATS_T;
334 typedef struct BTBL_STATS_tag
336   UINT16  num_sections;     /* number of boot table sections received */
337   UINT16  num_pdma_copies;  /* number of PDMA copies performed */
338 } BTBL_STATS_T;
340 typedef struct ETH_STATS_tag
342   /* MAC packets related statistics */
343   UINT16  uniMacPkts;       /* Count of packets received with valid unicast mac 
344                                address   */
345   UINT16  multiMacPkts;     /* Count of packets received with valid multicast or
346                                broadcast mac address   */
347   UINT16  invalidMacPkts;   /* Count of packets received with invalid mac 
348                                address   */
349   UINT16  invalidLLCPkts;   /* Count of 802.3 packets with wrong LLC/SNAP header */
350   UINT16  nonIpPkts;        /* Count of non-IP packets received with valid 
351                                MAC address   */
352                                
353   /* IP packets related statistics */                             
354   UINT16  nonIP4Pkts;       /* Count of non-IP4 packets        */
355   UINT16  ipfragments;      /* Count of IP fragments received      */
356   UINT16  ipTruncatedError; /* Count of truncated IP frame */
357   UINT16  nonUDPPkts;       /* Count of IP packets with non-UDP paylaod  */
358   
359   /* UDP packets related statistics */
360   UINT16  udpSizeError;     /* Count of UDP packet with invalid (odd) size */
361   UINT16  udpPortError;     /* Count of UDP packets with invalid port number */
362   UINT16  udpChksumError;   /* Count of UDP packets with checksum error */
363   
364   /* Boot table packets related statistics */
365   UINT16  nonBtblPkts;      /* Count of UDP packets with invalid boot table paylaod */
366   UINT16  outSeqPkts;       /* Count of out of sequence boot table packets received       
367                                i.e. packets with unexpected seq_num      */
368   UINT16  expSeqNum;        /* Expected Sequence Number */
369   UINT16  lastSeqNum;       /* Last sequence number received */                             
371   /* Driver errors */
372   UINT16  sizeZeroPackets;  /* Count of packets arriving with 0 size */
373 } ETH_STATS_T;
375 typedef struct PCI_EEAI_STATS_tag
377   UINT16  pciI2cReads;         /* Count of block reads of i2c eeprom */
378   UINT16  pciI2cRetries;       /* Count of i2c read retries          */
379   UINT16  pciChkSumErr;        /* Count of block check sum errors    */
380   UINT16  pciEeaiFail;         /* Count of aborted pci attempts      */
381 } PCI_EEAI_STATS_T;
383 /* Rapid I/O stats */
384 typedef struct RAPIDIO_STATS_tag
386   UINT16 rapidIoFailReady;     /* If set rapid I/O peripheral failed to report ready */
387 } RAPIDIO_STATS_T;
389 /*******************************************************************************
390  * Definition: The statistics
391  *
392  *   !!!!!! boot.s assumes that the nonInit stats are at the top of the structure!
393  *******************************************************************************/
394 typedef struct BOOT_STATS_S {
396  BOOT_STATS_NONINIT_T  nonInit;
397  BOOT_STATS_MAIN_T     main;
398  ETH_STATS_T           eth;
399  I2C_STATS_T           i2c;
400  BTBL_STATS_T          btbl;
401  PCI_EEAI_STATS_T      pci_eeai;
402  RAPIDIO_STATS_T       rapidIo;
403 } BOOT_STATS_T;
405 extern BOOT_STATS_T bootStats;
407 /*******************************************************************************
408  * Definition: The magic start address, known to all modules
409  *******************************************************************************/
410 extern volatile UINT32 *p_boot_entry_addr;
412 #endif  /* __TIBOOT_H__ */
414 /* nothing past this point */