ronnie
2022-10-14 1504bb53e29d3d46222c0b3ea994fc494b48e153
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
/*
 * (C) Copyright 2007-2013
 * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
 * Jerry Wang <wangflord@allwinnertech.com>
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */
 
#ifndef  __private_uboot_h__
#define  __private_uboot_h__
 
#include "spare_head.h"
 
#define UBOOT_VERSION           "4.0.0"
#define UBOOT_PLATFORM        "2.0.0"
/******************************************************************************/
/*               the control information stored in file head                  */
/******************************************************************************/
struct spare_boot_ctrl_head
{
   unsigned int  jump_instruction;   /* one intruction jumping to real code */
   unsigned char magic[MAGIC_SIZE];  /* ="u-boot" */
   unsigned int  check_sum;          /* generated by PC */
   unsigned int  align_size;          /* align size in byte */
   unsigned int  length;             /* the size of all file */
   unsigned int  uboot_length;       /* the size of uboot */
   unsigned char version[8];         /* uboot version */
   unsigned char platform[8];        /* platform information */
   int           reserved[1];        /*stamp space, 16bytes align */
};
 
/******************************************************************************/
/*                          the data stored in file head                      */
/******************************************************************************/
struct spare_boot_data_head
{
   unsigned int                dram_para[32];
   int                         run_clock;              /* Mhz */
   int                         run_core_vol;           /* mV */
   int                         uart_port;              /* UART ctrl num */
   normal_gpio_cfg             uart_gpio[2];           /* UART GPIO info */
   int                         twi_port;               /* TWI ctrl num */
   normal_gpio_cfg             twi_gpio[2];            /* TWI GPIO info */
   int                         work_mode;              /* boot,usb-burn, card-burn */
   int                         storage_type;           /* 0:nand 1:sdcard 2:spinor */
   normal_gpio_cfg             nand_gpio[32];          /* nand GPIO info */
   char                        nand_spare_data[256];    /* nand info */
   normal_gpio_cfg             sdcard_gpio[32];        /* sdcard GPIO info */
   char                        sdcard_spare_data[256];    /* sdcard info */
   unsigned char               secureos_exist;
   unsigned char               monitor_exist;
   unsigned char               func_mask;              /* see enum UBOOT_FUNC_MASK_EN */
   unsigned char               res[1];
   unsigned int                uboot_start_sector_in_mmc;  /*use in OTA update */
   int                         dtb_offset;                 /*device tree in uboot */
   int                         boot_package_size;          /*boot package size, boot0 pass this value */
   unsigned int                dram_scan_size;             /*dram real size */
   int                         reserved[1];                /*reseved,256bytes align */
   /*expend boot_ext[0](int[4]) in uboot 2014*/
   uint16_t                    pmu_type;
   uint16_t                    uart_input;
   uint16_t                    key_input;
   uint8_t                     secure_mode; /*update by update_uboot*/
   uint8_t                     debug_mode;  /*update by update_uboot*/
   int                         reserved2[2];
};
 
struct spare_boot_ext_head
{
   int data[4];
};
 
typedef struct spare_boot_head_t
{
   struct spare_boot_ctrl_head    boot_head;
   struct spare_boot_data_head    boot_data;
   struct spare_boot_ext_head     boot_ext[15];
   char   hash[64];
}uboot_head_t;
 
struct spare_monitor_head
{
   unsigned int  jump_instruction;   /* one intruction jumping to real code */
   unsigned char magic[MAGIC_SIZE];  /* ="u-boot" */
   unsigned int  scp_base;           /* generated by PC */
   unsigned int  nboot_base;         /* align size in byte */
   unsigned int  nos_base;           /* the size of all file */
   unsigned int  secureos_base;      /* the size of uboot */
   unsigned char version[8];         /* uboot version */
   unsigned char platform[8];        /* platform information */
   int           reserved[1];         /*stamp space, 16bytes align */
};
 
struct display_params {
   char resolution[32];
   char margin[32];
   char vendorid[64];
 
   int format;      /* RGB / YUV444 / YUV422 / YUV420     */
   int depth;       /* Color depth: 8 / 10 / 12 / 16      */
   int eotf;    /* Electro-Optical Transfer Functions */
   int color_space; /* BT.601 / BT.709 / BT.2020          */
 
   /*
    * make sure sizeof(struct display_params) == 256
    * reserved size = 256 -128 - 4*4 = 112
    */
   char reserved[112];
};
 
/*size is 128*/
typedef struct spare_parameter_ctrl_head_t {
   unsigned int crc;
   unsigned char magic[MAGIC_SIZE];
   unsigned int length;
   char reserved[112];
} __attribute__((packed)) spare_parameter_ctrl_head;
 
/*size is 4096-128*/
typedef struct spare_parameter_data_head_t {
   struct display_params display_param;
   char reserved[3712];
} __attribute__((packed)) spare_parameter_data_head;
 
/*size is 4096*/
typedef struct spare_parameter_head_t {
   spare_parameter_ctrl_head para_head;
   spare_parameter_data_head para_data;
} __attribute__((packed)) spare_parameter_head;
 
extern struct spare_boot_head_t uboot_spare_head;
extern unsigned long get_spare_head_size(void);
 
enum UBOOT_FUNC_MASK_EN {
   UBOOT_FUNC_MASK_BIT_BOOTLOGO = (1 << 0),
   UBOOT_FUNC_MASK_BIT_FORCE_ROTPK = (1 << 1),
   UBOOT_FUNC_MASK_ALL      = (0xFF)
};
#endif