blob: a09739c47d9a689b8e70af2a2f60d010c14142e4 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/*
2 * (C) Copyright 2016 ZXIC Inc.
3 *
4 */
5
6#ifndef __IMAGE_H__
7#define __IMAGE_H__
8
9#define IH_NMLEN 32 /* Image Name Length */
10#define IH_MAGIC 0x27051956 /* Image Magic Number */
11
12
13#define CFG_PARTITION_MAGIC 0x31594876 /* ͬ²½ U-BOOT */
14
15
16
17/*
18 +--------------+
19 | magic | uint32_t
20 +--------------+
21 | version | uint32_t
22 +--------------+
23 | entry nums | uint32_t
24 +--------------+
25 | crc | uint32_t
26 +==============+
27 | name[1] |
28 +--------------+
29 | offset |
30 +--------------+
31 | size |
32 +==============+
33 | |
34 +==============+
35 | |
36 +==============+
37
38*/
39#define MAX_ENTRYS 30
40
41typedef struct partition_entry {
42 unsigned char part_name[16];
43 unsigned char part_type[16];
44 unsigned int part_offset;
45 unsigned int part_size;
46}partition_entry_t;
47
48typedef struct partition_table {
49 unsigned int magic;
50 unsigned char platform_name[16];
51 unsigned int version; /* ·ÖÇø°æ±¾ */
52 unsigned int entrys; /* ×ܵķÖÇø¸öÊý */
53 unsigned int crc;
54 partition_entry_t table[MAX_ENTRYS];
55}partition_table_t;
56
57#ifdef CONFIG_ZX297520V3E_MDL_AB
58/*
59flags partition
60
61*/
62/*˫ϵͳÀàÐÍ*/
63#define FLAGS_BOOT_FOTA_OFFSET (0X0UL)
64//#define FLAGS_BOOT_FOTA_SIZE (0X80000UL)
65//#define FLAGS_BOOT_ENV_OFFSET (FLAGS_BOOT_FOTA_OFFSET + FLAGS_BOOT_FOTA_SIZE)
66//#define FLAGS_BOOT_ENV_SIZE (0X80000UL)
67//#define FLAGS_BACKUP_OFFSET (FLAGS_BOOT_ENV_OFFSET + FLAGS_BOOT_ENV_SIZE)
68
69#define FLAGS_MAGIC (0X464C4147UL)
70
71#define DUALSYSTEM_STATUS_BOOTABLE (0XB0AB) /*¿ÉÆô¶¯*/
72#define DUALSYSTEM_STATUS_SUCCESSFUL (0X5CCF) /*Äܳɹ¦Æô¶¯*/
73#define DUALSYSTEM_STATUS_UNBOOTABLE (0XBABE) /*²»¿ÉÆô¶¯*/
74
75typedef struct
76{
77 int status; /*bootable/successful/unbootable*/
78 int try_cnt;
79}T_DualSystem_Status;
80
81typedef enum
82{
83 DUAL_SYSTEM = 0X875A, /*µÚÒ»¸öϵͳ*/
84 DUAL_SYSTEM2 = 0X986B, /*µÚ¶þ¸öϵͳ*/
85}T_BOOT_TARGET;
86
87/*˫ϵͳÀàÐÍ*/
88typedef enum
89{
90 DUALSYSTEM_RECOVERY = 0X7575, /*normal-recovery˫ϵͳ*/
91 DUALSYSTEM_AA = 0XAAAA, /*AA˫ϵͳ*/
92 DUALSYSTEM_AB = 0XABAB /*AB˫ϵͳ*/
93}T_BOOT_DUALSYSTEM_TYPE;
94
95typedef struct
96{
97 uint32_t magic; /*Êý¾ÝÓÐЧÐÔħÊõ×Ö*/
98 T_BOOT_TARGET boot_to; /*µ±Ç°Æô¶¯ÏµÍ³±êÖ¾*/
99 uint32_t fota_status; /*fota״̬*/
100 T_DualSystem_Status system; /*µÚÒ»¸öϵͳ״̬*/
101 T_DualSystem_Status system2; /*µÚ¶þ¸öϵͳ״̬*/
102}T_BOOT_FOTA_FLAG;
103
104typedef struct
105{
106 unsigned int magic; /*Êý¾ÝÓÐЧÐÔħÊõ×Ö*/
107 T_BOOT_DUALSYSTEM_TYPE dualsys_type; /*˫ϵͳÀàÐÍ*/
108 char system_boot_env[128];
109 char system2_boot_env[128];
110}T_BOOT_ENV;
111
112typedef struct
113{
114 T_BOOT_FOTA_FLAG boot_flag;
115 T_BOOT_ENV boot_env;
116}T_FOTA_FLAG_INFO;
117#endif
118
119/*
120 * Legacy format image header, sizeof(image_header_t) = 64
121 * all data in network byte order (aka natural aka bigendian).
122 */
123typedef struct image_header {
124 uint32_t ih_magic; /* Image Header Magic Number */
125 uint32_t ih_hcrc; /* Image Header CRC Checksum */
126 uint32_t ih_time; /* Image Creation Timestamp */
127 uint32_t ih_size; /* Image Data Size */
128 uint32_t ih_load; /* Data Load Address */
129 uint32_t ih_ep; /* Entry Point Address used ************* */
130 uint32_t ih_dcrc; /* Image Data CRC Checksum */
131 uint8_t ih_os; /* Operating System */
132 uint8_t ih_arch; /* CPU architecture */
133 uint8_t ih_type; /* Image Type */
134 uint8_t ih_comp; /* Compression Type */
135 uint8_t ih_name[IH_NMLEN]; /* Image Name */
136} image_header_t;
137
138typedef struct
139{
140 u32 uiPubKeyRsaE[32];
141 u32 uiPubKeyRsaN[32];
142 u32 uiHashY[32];
143} sImageHeader;
144
145
146extern int read_uboot_image(uint8_t *name, uint32_t *uboot_entry_point);
147extern int nand_read_m0(uint32_t *m0_entry_point);
148
149
150#endif /* __IMAGE_H__ */