boot.h 2.19 KB
#ifndef __BBBOOT_HDR__
#define __BBBOOT_HDR__

/* defines here are for IDE3 simulator commands */
#include <PR/bbsim.h>

/* virage2 checksum value */
#define VIRAGE2_CHECKSUM 0x00bbc0de

/* load the number of pages it takes to fill the bram */
#define LOAD_SK_PAGES \
          ((BOOT_RAM_HI_END-BOOT_RAM_HI_START)>>PI_FLASH_PAGE_ADDR_SHIFT)

/* return and error code definitions */
#define FLASH_SUCCESS                  0
#define ERROR_FLASH_CTRL_DOUBLE_BIT   -1
#define ERROR_FLASH_MODULE_REMOVED    -2

/* For "fatal" errors (double-bit ecc, bad hash, bad v2 checksum) */
#if defined(_LANGUAGE_C)
#define JUMP_HANDLER \
             TRACE(0xbaad); \
             asm(".set noreorder; li $8, 0xbfc00200; jr $8; nop; .set reorder")
#elif defined(_LANGUAGE_ASSEMBLY)
#define JUMP_HANDLER \
             TRACE_VAL(0xbaad); \
             li t0, 0xbfc00200; \
             jr t0; \
             nop
#endif /* _LANGUAGE_ */

/* HALT_SIM will shutdown the simulator by writing to
 * IDE3. Since we're using IDE3 to output trace info
 * it is OK to retain this code when not using the
 * simulator (real chip). The writes will still go out
 * but they will have no impact.
 */
#if defined(_LANGUAGE_C)
#define HALT_SIM    /* power down */ \
    IDE_WRITE(PI_IDE3_SIM_HALT,0); \
    while(1){}
#elif defined(_LANGUAGE_ASSEMBLY)
#define HALT_SIM \
    li  t0, PHYS_TO_K1(PI_IDE_CONFIG_REG); \
    lw  t1, 0(t0); \
    and t1, ~PI_IDE_CONFIG_RESET; \
    sw  t1, 0(t0); \
    sh  zero, PHYS_TO_K1(PI_IDE3_SIM_HALT); \
    lw  t0, PHYS_TO_K1(PI_IDE_FC_BASE_REG) 
#endif /* _LANGUAGE_ */

/* trace macros */

#define TRACE_OUTPUT_REG          PI_IDE3_BASE_REG

#if defined(_LANGUAGE_C)
#define TRACE(val) (IDE_WRITE(TRACE_OUTPUT_REG,(val)))
#endif

#if defined(_LANGUAGE_ASSEMBLY)
#define TRACE_ADDR PHYS_TO_K1(TRACE_OUTPUT_REG)
#define TRACE_VAL_REG t7
#define TRACE_VAL(val)              \
    li  TRACE_VAL_REG,(val);        \
    sh  TRACE_VAL_REG, TRACE_ADDR;  \
    lw  TRACE_VAL_REG, PHYS_TO_K1(PI_IDE_FC_BASE_REG)
#define TRACE_REG(_r) 	            \
    sh  _r, TRACE_ADDR;             \
    srl TRACE_VAL_REG, _r, 0x10  ;  \
    sh  TRACE_VAL_REG, TRACE_ADDR;  \
    lw  TRACE_VAL_REG, PHYS_TO_K1(PI_IDE_FC_BASE_REG)
#endif


#endif