forked from forth32/qhuaweiflash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kerneledit.h
146 lines (113 loc) · 3.63 KB
/
kerneledit.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
#ifndef __KERNELEDIT_H
#define __KERNELEDIT_H
#include <stdint.h>
#include <QtWidgets>
// Описатели формата заголовка раздела с ядром
// Выдрано из mkbootimg от android-sdk
#define BOOT_MAGIC "ANDROID!"
#define BOOT_MAGIC_SIZE 8
#define BOOT_NAME_SIZE 16
#define BOOT_ARGS_SIZE 512
#define BOOT_EXTRA_ARGS_SIZE 1024
struct boot_img_hdr
{
uint8_t magic[BOOT_MAGIC_SIZE];
uint32_t kernel_size; /* size in bytes */
uint32_t kernel_addr; /* physical load addr */
uint32_t ramdisk_size; /* size in bytes */
uint32_t ramdisk_addr; /* physical load addr */
uint32_t second_size; /* size in bytes */
uint32_t second_addr; /* physical load addr */
uint32_t tags_addr; /* physical addr for kernel tags */
uint32_t page_size; /* flash page size we assume */
uint32_t dt_size; /* device tree in bytes */
uint32_t unused; /* future expansion: should be 0 */
uint8_t name[BOOT_NAME_SIZE]; /* asciiz product name */
uint8_t cmdline[BOOT_ARGS_SIZE];
uint32_t id[8]; /* timestamp / checksum / sha1 / etc */
/* Supplemental command line data; kept here to maintain
* binary compatibility with older versions of mkbootimg */
uint8_t extra_cmdline[BOOT_EXTRA_ARGS_SIZE];
} __attribute__((packed));
//***********************************************************
//* Класс главного окна редактора
//***********************************************************
class kerneledit : public QWidget {
Q_OBJECT
// указатель на структуру заголовка
struct boot_img_hdr* hdr;
QVBoxLayout* vlm;
QFormLayout* flm;
QGridLayout* lcomp;
QSpacerItem* rspacer;
QLabel* hdrlabel;
QLabel* parmlabel;
QLabel* pgslabel;
QLabel* tagslabel;
QLabel* dtlabel;
QLabel* pname;
QLineEdit* cmdline;
QLabel* comphdr1;
QLabel* comphdr2;
QLabel* comphdr3;
QLabel* kcomp;
QLabel* r1comp;
QLabel* r2comp;
QLabel* kaddr;
QLabel* r1addr;
QLabel* r2addr;
QPushButton* kext;
QPushButton* krepl;
QPushButton* r1ext;
QPushButton* r1repl;
QPushButton* r2ext;
QPushButton* r2repl;
void setup_adr(int type, uint32_t* adr, uint32_t* len, QString* filename);
void extractor(int type);
void replacer(int type);
// номер данного разела в таблице разделов
int pnum;
// локальная копия образа раздела
uint8_t* localdata;
uint32_t plen;// длина-128, без хуавеевского заголовка
public:
kerneledit(int xpnum, QWidget* parent);
~kerneledit();
public slots:
void kextract();
void r1extract();
void r2extract();
void kreplace();
void r1replace();
void r2replace();
};
/*
** +-----------------+
** | boot header | 1 page
** +-----------------+
** | kernel | n pages
** +-----------------+
** | ramdisk | m pages
** +-----------------+
** | second stage | o pages
** +-----------------+
** | device tree | p pages
** +-----------------+
**
** n = (kernel_size + page_size - 1) / page_size
** m = (ramdisk_size + page_size - 1) / page_size
** o = (second_size + page_size - 1) / page_size
** p = (dt_size + page_size - 1) / page_size
**
** 0. all entities are page_size aligned in flash
** 1. kernel and ramdisk are required (size != 0)
** 2. second is optional (second_size == 0 -> no second)
** 3. load each element (kernel, ramdisk, second) at
** the specified physical address (kernel_addr, etc)
** 4. prepare tags at tag_addr. kernel_args[] is
** appended to the kernel commandline in the tags.
** 5. r0 = 0, r1 = MACHINE_TYPE, r2 = tags_addr
** 6. if second_size != 0: jump to second_addr
** else: jump to kernel_addr
*/
#endif