Debian Codegraph @

util/nvidia/cbootimage/src/cbootimage.h

raw symbols SCIP
1 /*
2 * Copyright (c) 2012-2015, NVIDIA CORPORATION. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * See file CREDITS for list of people who contributed to this
17 * project.
18 */
19
20 /*
21 * cbootimage.h - Definitions for the cbootimage code.
22 */
23
24 #ifndef INCLUDED_BUILDIMAGE_H
25 #define INCLUDED_BUILDIMAGE_H
26
27 #include <sys/types.h>
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <assert.h>
31 #include <errno.h>
32 #include <math.h>
33 #include <stdint.h>
34
35 #define NVBOOT_AES_BLOCK_SIZE_LOG2 4
36 #define MAX_BUFFER 200
37 #define MAX_STR_LEN 20
38 #define MAX_BOOTLOADER_SIZE (16 * 1024 * 1024)
39 #define NVBOOT_BOOTDATA_VERSION(a, b) ((((a)&0xffff) << 16) | ((b)&0xffff))
40 #define NVBOOT_BAD_BLOCK_TABLE_SIZE 4096
41 #define NV_MAX(a, b) (((a) > (b)) ? (a) : (b))
42 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
43
44 #define BOOTDATA_VERSION_T20 NVBOOT_BOOTDATA_VERSION(0x2, 0x1)
45 #define BOOTDATA_VERSION_T30 NVBOOT_BOOTDATA_VERSION(0x3, 0x1)
46 #define BOOTDATA_VERSION_T114 NVBOOT_BOOTDATA_VERSION(0x35, 0x1)
47 #define BOOTDATA_VERSION_T124 NVBOOT_BOOTDATA_VERSION(0x40, 0x1)
48 #define BOOTDATA_VERSION_T132 NVBOOT_BOOTDATA_VERSION(0x13, 0x1)
49 #define BOOTDATA_VERSION_T210 NVBOOT_BOOTDATA_VERSION(0x21, 0x1)
50
51 #define MAX_MTS_SIZE (4 * 1024 * 1024)
52
53 /* Minimum size to read to at least be able to validate a BCT, it must
54 * include the boot_data_version field with any BCT version while not
55 * being larger than the smallest possible BCT. The currently supported
56 * BCT are as follow:
57 *
58 * Chip Version offset Total size
59 * T20 32 4080
60 * T30 32 6128
61 * T114 1792 8192
62 * T124 1744 8192
63 * T132 1744 8704
64 * T210 1328 10240
65 */
66 #define NVBOOT_CONFIG_TABLE_SIZE_MIN 4080
67 #define NVBOOT_CONFIG_TABLE_SIZE_MAX (10 * 1024)
68
69 /*
70 * Enumerations
71 */
72
73 typedef enum
74 {
75 file_type_bl = 0,
76 file_type_bct,
77 file_type_mts,
78 file_type_bin,
79 } file_type;
80
81 /*
82 * The main context data structure of cbootimage tool
83 */
84 typedef struct build_image_context_rec
85 {
86 FILE *config_file;
87 char *output_image_filename;
88 char *input_image_filename;
89 FILE *raw_file;
90 uint32_t block_size;
91 uint32_t block_size_log2;
92 uint32_t page_size;
93 uint32_t page_size_log2;
94 uint32_t pages_per_blk;
95 uint32_t partition_size;
96 uint32_t redundancy;
97 uint32_t version;
98 uint32_t bct_copy;
99 /*
100 * Number of blocks at start of device to skip before the BCT.
101 * This may be used to reserve space for a partition table, for
102 * example, in order to write the resultant boot image to e.g. an
103 * SD card while using the remaining space for a user filesystem.
104 */
105 uint32_t pre_bct_pad_blocks;
106 /* Allocation data. */
107 struct blk_data_rec *memory; /* Representation of memory */
108 /* block number for the BCT block */
109 uint32_t next_bct_blk;
110
111 char *newbl_filename;
112 uint32_t newbl_load_addr;
113 uint32_t newbl_entry_point;
114 uint32_t newbl_attr;
115 uint8_t generate_bct;
116 uint8_t *bct;
117
118 char *mts_filename;
119 uint32_t mts_load_addr;
120 uint32_t mts_entry_point;
121 uint32_t mts_attr;
122
123 char *bct_filename;
124 uint32_t last_blk;
125 uint32_t bct_size; /* The BCT file size */
126 uint32_t boot_data_version; /* The boot data version of BCT */
127 uint8_t bct_init; /* The flag for the memory allocation of bct */
128 uint32_t odm_data; /* The odm data value */
129 uint8_t unique_chip_id[16]; /* The unique chip uid */
130 uint8_t secure_jtag_control; /* The flag for enabling jtag control */
131 uint32_t secure_debug_control; /* The flag for enabling jtag control */
132 uint8_t update_image; /* The flag for updating image */
133 } build_image_context;
134
135 /* Function prototypes */
136
137 int write_image_file(build_image_context *context);
138
139 /* Global data */
140 extern int enable_debug;
141
142 #endif /* #ifndef INCLUDED_BUILDIMAGE_H */