forked from Xilinx/bootgen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootimage.h
executable file
·172 lines (160 loc) · 5.66 KB
/
bootimage.h
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/******************************************************************************
* Copyright 2015-2020 Xilinx, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
#ifndef _BOOTIMAGE_H_
#define _BOOTIMAGE_H_
/*
-------------------------------------------------------------------------------
*********************************************** H E A D E R F I L E S ***
-------------------------------------------------------------------------------
*/
#include <list>
#include <string>
#include "bootgenenum.h"
#include "encryption.h"
#include <iostream>
#include "binary.h"
#include "checksum.h"
#include "bootgenexception.h"
#include "logger.h"
#include "authkeys.h"
#include "partitionheadertable.h"
#include "bifoptions.h"
/* Forward class declarations */
class Options;
class BifOptions;
class PartitionBifOptions;
class BootHeader;
class ImageHeaderTable;
class PartitionHeaderTable;
class BootImage;
class Partition;
class ImageHeader;
class ElfFormat;
class Elf32ProgramHeader;
class BitFile;
class ByteFile;
class ChecksumContext;
class MD5ChecksumContext;
class Key;
class ChecksumTable;
/*
-------------------------------------------------------------------------------
********************************************************* C L A S S E S ***
-------------------------------------------------------------------------------
*/
/******************************************************************************/
class BIF_File
{
public:
BIF_File(std::string& filename0) : biffilename(filename0) {}
void Process(Options& options);
private:
std::string biffilename;
void Output(Options& options, uint8_t index);
std::vector<BifOptions*> bifOptionList;
std::vector<BootImage*> bootImages;
};
/******************************************************************************/
class BootImage
{
public:
BootImage(Options& options, uint8_t index);
~BootImage();
virtual void Add(BifOptions* bifoptions) { };
virtual void DetermineEncryptionDefaults() {};
virtual void ParseBootImage(PartitionBifOptions * it) = 0;
virtual void ConfigureProcessingStages(ImageHeader* image, PartitionBifOptions* partitionbifoptions) = 0;
virtual void OutputOptionalEfuseHash();
virtual void BuildAndLink(Binary* cache);
void OutputPartitionFiles(Options& options, Binary& cache);
void PrintPartitionInformation(void);
void SetLegacyEncryptionFlag(bool flag);
void GenerateAuthenticationKeys(void);
void GenerateGreyKey(void);
void SetOutputSplitModeFormat(SplitMode::Type splitMode, File::Type fmt);
void ValidateOutputModes(File::Type split, OutputMode::Type outMode);
bool IsBootloaderFound();
virtual void OutputOptionalSecureDebugImage() {};
void SetAssumeEncryptionFlag (bool);
void SetCore (Core::Type);
void SetPmuFwSize (uint32_t);
void SetFsblFwSize (uint32_t);
void SetTotalPmuFwSize (uint32_t);
void SetTotalFsblFwSize (uint32_t);
void SetFsblSourceAddr (Binary::Address_t);
void SetOutputBitstreamModeFormat (File::Type);
void SetCoreFromDestCpu (DestinationCPU::Type type, A53ExecState::Type procType);
void SetDestCpuFromCore(Core::Type coreType, DestinationCPU::Type cpuType);
std::vector<std::string> encryptionKeyFileVec;
std::vector<std::string>& GetEncryptionKeyFileVec();
void InsertEncryptionKeyFile(std::string filename);
std::vector<std::pair<KeySource::Type, uint32_t*>> aesKeyandKeySrc;
Core::Type GetCore(void);
uint32_t GetPmuFwSize (void);
uint32_t GetFsblFwSize (void);
uint32_t GetTotalPmuFwSize (void);
uint32_t GetTotalFsblFwSize (void);
Binary::Address_t GetFsblSourceAddr (void);
AuthHash::Type GetAuthHashAlgo(void);
std::string Name;
BootHeader* bootHeader;
std::list<Section*> headers;
Section* encryptedHeaders;
ImageHeaderTable* imageHeaderTable;
std::list<ImageHeader*> imageList;
std::list<SubSysImageHeader*> subSysImageList;
PartitionHeaderTable* partitionHeaderTable;
std::list<PartitionHeader*> partitionHeaderList;
Section* nullPartHeaderSection;
ChecksumTable* checksumTable;
AuthenticationCertificate* headerAC;
AuthenticationContext* currentAuthCtx;
AuthenticationContext* metaHdrAuthCtx;
EncryptionContext* currentEncryptCtx;
MD5ChecksumContext* currentChecksumCtx;
Hash* hash;
Options& options;
BifOptions* bifOptions;
KeyGenerationStruct* keygen;
PartitionOutput* partitionOutput;
bool headerSignature_Loaded;
bool XipMode;
uint32_t totalHeadersSize;
uint32_t partCount;
Binary* cache;
bool createSubSystemPdis;
bool convertAieElfToCdo;
std::string fsblFilename;
std::string bitFilename;
//private:
bool assumeEncryption;
uint32_t* deviceKey;
uint32_t* firstIv;
uint32_t* firstOptKey;
Core::Type core;
AuthHash::Type authHash;
uint32_t pmuFwSize;
uint32_t fsblFwSize;
uint32_t totalPmuFwSize;
uint32_t totalFsblFwSize;
Binary::Address_t sourceAddr;
bool legacyEncryptionEnabled;
bool bootloaderFound;
bool bootloaderEncrypt;
KeySource::Type bootloaderKeySource;
bool bootloaderAuthenticate;
};
#endif