uuu
uuu (Universal Update Utility), mfgtools 3.0
Toggle main menu visibility
Loading...
Searching...
No Matches
sdp.h
Go to the documentation of this file.
1
/*
2
* Copyright 2018 NXP.
3
*
4
* Redistribution and use in source and binary forms, with or without modification,
5
* are permitted provided that the following conditions are met:
6
*
7
* Redistributions of source code must retain the above copyright notice, this
8
* list of conditions and the following disclaimer.
9
*
10
* Redistributions in binary form must reproduce the above copyright notice, this
11
* list of conditions and the following disclaimer in the documentation and/or
12
* other materials provided with the distribution.
13
*
14
* Neither the name of the NXP Semiconductor nor the names of its
15
* contributors may be used to endorse or promote products derived from this
16
* software without specific prior written permission.
17
*
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
* POSSIBILITY OF SUCH DAMAGE.
29
*
30
*/
31
32
#pragma once
33
34
#include "
cmd.h
"
35
36
#include <climits>
37
38
class
FileBuffer
;
39
class
HIDReport
;
40
41
#pragma pack (1)
42
struct
SDPCmd
{
43
uint16_t
m_cmd
;
44
uint32_t
m_addr
;
45
uint8_t
m_format
;
46
uint32_t
m_count
;
47
uint32_t
m_data
;
48
uint8_t
m_rsvd
;
49
};
50
51
struct
IvtHeader
52
{
53
uint32_t
IvtBarker
;
54
uint32_t
ImageStartAddr
;
55
uint32_t
Reserved
;
56
uint32_t
DCDAddress
;
57
uint32_t
BootData
;
58
uint32_t
SelfAddr
;
59
uint32_t
Reserved2
[2];
60
};
61
62
struct
BootData
63
{
64
uint32_t
ImageStartAddr
;
65
uint32_t
ImageSize
;
66
uint32_t
PluginFlag
;
67
};
68
69
#pragma pack ()
70
71
#define ROM_KERNEL_CMD_RD_MEM 0x0101
72
#define ROM_KERNEL_CMD_WR_MEM 0x0202
73
#define ROM_KERNEL_CMD_WR_FILE 0x0404
74
#define ROM_KERNEL_CMD_ERROR_STATUS 0x0505
75
#define RAM_KERNEL_CMD_HEADER 0x0606
76
//#define ROM_KERNEL_CMD_RE_ENUM 0x0909
77
#define ROM_KERNEL_CMD_DCD_WRITE 0x0A0A
78
#define ROM_KERNEL_CMD_JUMP_ADDR 0x0B0B
79
#define ROM_KERNEL_CMD_SKIP_DCD_HEADER 0x0C0C
80
81
#define MAX_DCD_WRITE_REG_CNT 85
82
#define ROM_WRITE_ACK 0x128A8A12
83
#define ROM_STATUS_ACK 0x88888888
84
#define ROM_OK_ACK 0x900DD009
85
86
#define IVT_BARKER_HEADER 0x402000D1
87
#define IVT_BARKER2_HEADER 0x412000D1
88
89
#define HAB_TAG_DCD 0xd2
90
91
class
SDPCmdBase
:
public
CmdBase
92
{
93
public
:
94
95
enum
HAB_t
96
{
97
HabUnknown
= -1,
98
HabEnabled
= 0x12343412,
99
HabDisabled
= 0x56787856
100
};
101
102
SDPCmdBase
(
const
char
*p) :
CmdBase
(p) {
init_cmd
(); }
103
104
protected
:
105
int
check_ack
(
HIDReport
*report, uint32_t ack);
106
HAB_t
get_hab_type
(
HIDReport
*report);
107
int
get_status
(
HIDReport
*p, uint32_t &status, uint8_t report_id);
108
int
init_cmd
();
109
IvtHeader
*
search_ivt_header
(std::shared_ptr<DataBuffer> data,
size_t
&off,
size_t
limit=ULLONG_MAX);
110
111
std::string
m_filename
;
112
SDPCmd
m_spdcmd
;
113
uint64_t
m_scan_limited
= UINT64_MAX;
114
115
private
:
116
int
send_cmd
(
HIDReport
*p);
117
118
std::vector<uint8_t>
m_input
;
119
};
120
121
class
SDPBootlogCmd
:
public
SDPCmdBase
122
{
123
public
:
124
SDPBootlogCmd
(
const
char
*p);
125
int
run
(
CmdCtx
*)
override
;
126
};
127
128
class
SDPDcdCmd
:
public
SDPCmdBase
129
{
130
public
:
131
SDPDcdCmd
(
const
char
*p);
132
int
run
(
CmdCtx
*)
override
;
133
134
private
:
135
uint32_t
m_dcd_addr
;
136
};
137
138
class
SDPReadMemCmd
:
public
SDPCmdBase
139
{
140
public
:
141
SDPReadMemCmd
(
const
char
*p);
142
int
run
(
CmdCtx
*)
override
;
143
144
private
:
145
uint32_t
m_mem_addr
;
146
uint8_t
m_mem_format
;
147
};
148
149
class
SDPWriteMemCmd
:
public
SDPCmdBase
150
{
151
public
:
152
SDPWriteMemCmd
(
const
char
*p);
153
int
run
(
CmdCtx
*p)
override
;
154
155
private
:
156
uint32_t
m_mem_addr
;
157
uint8_t
m_mem_format
;
158
uint32_t
m_mem_value
;
159
};
160
161
class
SDPWriteCmd
:
public
SDPCmdBase
162
{
163
public
:
164
SDPWriteCmd
(
const
char
*p);
165
166
int
run
(
CmdCtx
*p)
override
;
167
int
run
(
CmdCtx
*p,
void
*buff,
size_t
size, uint32_t addr,
bool
validate =
true
);
168
169
private
:
170
uint32_t
m_download_addr
;
171
int32_t
m_Ivt
;
172
int
m_PlugIn
;
173
uint32_t
m_max_download_pre_cmd
;
174
uint32_t
m_offset
;
175
bool
m_bIvtReserve
;
176
bool
m_bskipspl
=
false
;
177
bool
m_bskipfhdr
=
false
;
178
bool
m_bscanterm
=
false
;
179
bool
m_barebox_bl33
=
false
;
180
};
181
182
class
SDPJumpCmd
:
public
SDPCmdBase
183
{
184
public
:
185
SDPJumpCmd
(
const
char
*p);
186
int
run
(
CmdCtx
*p)
override
;
187
188
private
:
189
bool
m_clear_dcd
=
false
;
190
int32_t
m_Ivt
= -1;
191
uint32_t
m_jump_addr
= 0;
192
bool
m_PlugIn
=
false
;
193
};
194
195
class
SDPSkipDCDCmd
:
public
SDPCmdBase
196
{
197
public
:
198
SDPSkipDCDCmd
(
const
char
*p);
199
int
run
(
CmdCtx
*p)
override
;
200
};
201
202
class
SDPStatusCmd
:
public
SDPCmdBase
203
{
204
public
:
205
SDPStatusCmd
(
const
char
*p);
206
int
run
(
CmdCtx
*p)
override
;
207
};
208
209
class
SDPBootCmd
:
public
SDPCmdBase
210
{
211
public
:
212
SDPBootCmd
(
const
char
*p);
213
int
run
(
CmdCtx
*p)
override
;
214
215
private
:
216
bool
is_barebox_img
(
void
);
217
int
load_barebox
(
CmdCtx
*ctx);
218
219
bool
m_clear_dcd
=
false
;
220
uint32_t
m_dcd_addr
= 0;
221
bool
m_nojump
=
false
;
222
bool
m_barebox
=
false
;
223
};
CmdBase::CmdBase
CmdBase()=default
CmdCtx
Definition
cmd.h:45
FileBuffer
Definition
buffer.h:164
HIDReport
Definition
hidreport.h:40
SDPBootCmd::m_nojump
bool m_nojump
Definition
sdp.h:221
SDPBootCmd::SDPBootCmd
SDPBootCmd(const char *p)
Definition
sdp.cpp:235
SDPBootCmd::is_barebox_img
bool is_barebox_img(void)
Definition
sdp.cpp:248
SDPBootCmd::m_clear_dcd
bool m_clear_dcd
Definition
sdp.h:219
SDPBootCmd::load_barebox
int load_barebox(CmdCtx *ctx)
Definition
sdp.cpp:265
SDPBootCmd::m_dcd_addr
uint32_t m_dcd_addr
Definition
sdp.h:220
SDPBootCmd::run
int run(CmdCtx *p) override
Definition
sdp.cpp:303
SDPBootCmd::m_barebox
bool m_barebox
Definition
sdp.h:222
SDPBootlogCmd::run
int run(CmdCtx *) override
Definition
sdp.cpp:834
SDPBootlogCmd::SDPBootlogCmd
SDPBootlogCmd(const char *p)
Definition
sdp.cpp:829
SDPCmdBase::check_ack
int check_ack(HIDReport *report, uint32_t ack)
Definition
sdp.cpp:46
SDPCmdBase::get_hab_type
HAB_t get_hab_type(HIDReport *report)
Definition
sdp.cpp:63
SDPCmdBase::m_input
std::vector< uint8_t > m_input
Definition
sdp.h:118
SDPCmdBase::SDPCmdBase
SDPCmdBase(const char *p)
Definition
sdp.h:102
SDPCmdBase::get_status
int get_status(HIDReport *p, uint32_t &status, uint8_t report_id)
Definition
sdp.cpp:79
SDPCmdBase::m_spdcmd
SDPCmd m_spdcmd
Definition
sdp.h:112
SDPCmdBase::search_ivt_header
IvtHeader * search_ivt_header(std::shared_ptr< DataBuffer > data, size_t &off, size_t limit=ULLONG_MAX)
Definition
sdp.cpp:104
SDPCmdBase::HAB_t
HAB_t
Definition
sdp.h:96
SDPCmdBase::HabUnknown
@ HabUnknown
Definition
sdp.h:97
SDPCmdBase::HabEnabled
@ HabEnabled
Definition
sdp.h:98
SDPCmdBase::HabDisabled
@ HabDisabled
Definition
sdp.h:99
SDPCmdBase::m_scan_limited
uint64_t m_scan_limited
Definition
sdp.h:113
SDPCmdBase::send_cmd
int send_cmd(HIDReport *p)
Definition
sdp.cpp:128
SDPCmdBase::init_cmd
int init_cmd()
Definition
sdp.cpp:97
SDPCmdBase::m_filename
std::string m_filename
Definition
sdp.h:111
SDPDcdCmd::run
int run(CmdCtx *) override
Definition
sdp.cpp:141
SDPDcdCmd::m_dcd_addr
uint32_t m_dcd_addr
Definition
sdp.h:135
SDPDcdCmd::SDPDcdCmd
SDPDcdCmd(const char *p)
Definition
sdp.cpp:133
SDPJumpCmd::m_clear_dcd
bool m_clear_dcd
Definition
sdp.h:189
SDPJumpCmd::m_jump_addr
uint32_t m_jump_addr
Definition
sdp.h:191
SDPJumpCmd::m_PlugIn
bool m_PlugIn
Definition
sdp.h:192
SDPJumpCmd::SDPJumpCmd
SDPJumpCmd(const char *p)
Definition
sdp.cpp:724
SDPJumpCmd::m_Ivt
int32_t m_Ivt
Definition
sdp.h:190
SDPJumpCmd::run
int run(CmdCtx *p) override
Definition
sdp.cpp:735
SDPReadMemCmd::m_mem_addr
uint32_t m_mem_addr
Definition
sdp.h:145
SDPReadMemCmd::m_mem_format
uint8_t m_mem_format
Definition
sdp.h:146
SDPReadMemCmd::run
int run(CmdCtx *) override
Definition
sdp.cpp:611
SDPReadMemCmd::SDPReadMemCmd
SDPReadMemCmd(const char *p)
Definition
sdp.cpp:602
SDPSkipDCDCmd::run
int run(CmdCtx *p) override
Definition
sdp.cpp:219
SDPSkipDCDCmd::SDPSkipDCDCmd
SDPSkipDCDCmd(const char *p)
Definition
sdp.cpp:214
SDPStatusCmd::run
int run(CmdCtx *p) override
Definition
sdp.cpp:380
SDPStatusCmd::SDPStatusCmd
SDPStatusCmd(const char *p)
Definition
sdp.cpp:374
SDPWriteCmd::m_download_addr
uint32_t m_download_addr
Definition
sdp.h:170
SDPWriteCmd::m_offset
uint32_t m_offset
Definition
sdp.h:174
SDPWriteCmd::run
int run(CmdCtx *p) override
Definition
sdp.cpp:424
SDPWriteCmd::m_bIvtReserve
bool m_bIvtReserve
Definition
sdp.h:175
SDPWriteCmd::SDPWriteCmd
SDPWriteCmd(const char *p)
Definition
sdp.cpp:400
SDPWriteCmd::m_bskipfhdr
bool m_bskipfhdr
Definition
sdp.h:177
SDPWriteCmd::m_barebox_bl33
bool m_barebox_bl33
Definition
sdp.h:179
SDPWriteCmd::m_Ivt
int32_t m_Ivt
Definition
sdp.h:171
SDPWriteCmd::m_PlugIn
int m_PlugIn
Definition
sdp.h:172
SDPWriteCmd::m_bskipspl
bool m_bskipspl
Definition
sdp.h:176
SDPWriteCmd::m_bscanterm
bool m_bscanterm
Definition
sdp.h:178
SDPWriteCmd::m_max_download_pre_cmd
uint32_t m_max_download_pre_cmd
Definition
sdp.h:173
SDPWriteMemCmd::SDPWriteMemCmd
SDPWriteMemCmd(const char *p)
Definition
sdp.cpp:667
SDPWriteMemCmd::m_mem_value
uint32_t m_mem_value
Definition
sdp.h:158
SDPWriteMemCmd::m_mem_format
uint8_t m_mem_format
Definition
sdp.h:157
SDPWriteMemCmd::run
int run(CmdCtx *p) override
Definition
sdp.cpp:677
SDPWriteMemCmd::m_mem_addr
uint32_t m_mem_addr
Definition
sdp.h:156
cmd.h
BootData
Definition
sdp.h:63
BootData::ImageStartAddr
uint32_t ImageStartAddr
Definition
sdp.h:64
BootData::PluginFlag
uint32_t PluginFlag
Definition
sdp.h:66
BootData::ImageSize
uint32_t ImageSize
Definition
sdp.h:65
IvtHeader
Definition
sdp.h:52
IvtHeader::ImageStartAddr
uint32_t ImageStartAddr
Definition
sdp.h:54
IvtHeader::IvtBarker
uint32_t IvtBarker
Definition
sdp.h:53
IvtHeader::Reserved
uint32_t Reserved
Definition
sdp.h:55
IvtHeader::SelfAddr
uint32_t SelfAddr
Definition
sdp.h:58
IvtHeader::DCDAddress
uint32_t DCDAddress
Definition
sdp.h:56
IvtHeader::Reserved2
uint32_t Reserved2[2]
Definition
sdp.h:59
IvtHeader::BootData
uint32_t BootData
Definition
sdp.h:57
SDPCmd
Definition
sdp.h:42
SDPCmd::m_format
uint8_t m_format
Definition
sdp.h:45
SDPCmd::m_cmd
uint16_t m_cmd
Definition
sdp.h:43
SDPCmd::m_count
uint32_t m_count
Definition
sdp.h:46
SDPCmd::m_rsvd
uint8_t m_rsvd
Definition
sdp.h:48
SDPCmd::m_data
uint32_t m_data
Definition
sdp.h:47
SDPCmd::m_addr
uint32_t m_addr
Definition
sdp.h:44
libuuu
sdp.h
Generated by
1.18.0