sdk-hwV1.3/lichee/brandy-2.0/spl-pub/sboot/main/sboot_head.c

95 lines
3.4 KiB
C
Raw Normal View History

2024-05-07 10:09:20 +00:00
/*
* (C) Copyright 2007-2013
* Allwinner Technology Co., Ltd. <www.allwinnertech.com>
* Jerry Wang <wangflord@allwinnertech.com>
* wangwei <wangwei@allwinnertech.com>
*/
#include <common.h>
#include <private_boot0.h>
#include <private_toc.h>
#include <commit_info.h>
#ifdef CFG_ARCH_RISCV
#define BROM_FILE_HEAD_SIZE (sizeof(sboot_file_head_t) & 0x00FFFFF)
#define BROM_FILE_HEAD_BIT_10_1 ((BROM_FILE_HEAD_SIZE & 0x7FE) >> 1)
#define BROM_FILE_HEAD_BIT_11 ((BROM_FILE_HEAD_SIZE & 0x800) >> 11)
#define BROM_FILE_HEAD_BIT_19_12 ((BROM_FILE_HEAD_SIZE & 0xFF000) >> 12)
#define BROM_FILE_HEAD_BIT_20 ((BROM_FILE_HEAD_SIZE & 0x100000) >> 20)
#define BROM_FILE_HEAD_SIZE_OFFSET ((BROM_FILE_HEAD_BIT_20 << 31) | \
(BROM_FILE_HEAD_BIT_10_1 << 21) | \
(BROM_FILE_HEAD_BIT_11 << 20) | \
(BROM_FILE_HEAD_BIT_19_12 << 12))
#define JUMP_INSTRUCTION (BROM_FILE_HEAD_SIZE_OFFSET | 0x6f)
#else
#define BROM_FILE_HEAD_SIZE_OFFSET (((sizeof(sboot_file_head_t) + sizeof(int) - 1) / sizeof(int) - 2))
#define JUMP_INSTRUCTION (BROM_FILE_HEAD_SIZE_OFFSET | 0xEA000000)
#endif
const sboot_file_head_t sboot_head = {
/* head */
{
JUMP_INSTRUCTION,
TOC0_MAGIC,
STAMP_VALUE,
ALIGN_SIZE,
sizeof(sboot_file_head_t),
{
0, 0, 0, 0
},
0,
CFG_SBOOT_RUN_ADDR,
0,
{
0, 0, '2', '.', '0', '.', '0', 0
},
},
/* hash */
{CI_INFO},
#ifdef CFG_SUNXI_SELECT_DRAM_PARA
.extd_head.magic = DRAM_EXT_MAGIC,
#endif
};
/*******************************************************************************
*
* Boot_file_head中的jump_instruction字段
*
* jump_instruction字段存放的是一条跳转指令( B BACK_OF_Boot_file_head )
*Boot_file_head后面第一条指令
*
* ARM指令中的B指令编码如下
* +--------+---------+------------------------------+
* | 31--28 | 27--24 | 23--0 |
* +--------+---------+------------------------------+
* | cond | 1 0 1 0 | signed_immed_24 |
* +--------+---------+------------------------------+
* ARM Architecture Reference Manual
* Syntax :
* B{<cond>} <target_address>
* <cond> Is the condition under which the instruction is executed. If the
* <cond> is ommitted, the AL(always,its code is 0b1110 )is used.
* <target_address>
* Specified the address to branch to. The branch target address is
* calculated by:
* 1. Sign-extending the 24-bit signed(wro's complement)immediate
* to 32 bits.
* 2. Shifting the result left two bits.
* 3. Adding to the contents of the PC, which contains the address
* of the branch instruction plus 8.
*
* 80b1110101024Boot_file_head的大小动
*
* ( sizeof( boot_file_head_t ) + sizeof( int ) - 1 ) / sizeof( int )
*
* - 2 PC预取的指令条数
* & 0x00FFFFFF signed-immed-24
* | 0xEA000000 B指令
*
*******************************************************************************/