forked from pcercuei/UBIBoot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathubi.h
71 lines (59 loc) · 1.33 KB
/
ubi.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
#ifndef UBI_H
#define UBI_H
#include <stdint.h>
#include <sys/queue.h>
#include <arpa/inet.h>
#define UBI_EC_HDR_MAGIC __bswap32(0x55424923)
#define UBI_VID_HDR_MAGIC __bswap32(0x55424921)
#define UBI_VOL_TABLE_ID 0x7fffefff
/* The maximum volume name length */
#define UBI_VOL_NAME_MAX 127
struct ubi_ec_hdr {
uint32_t magic;
uint8_t version;
uint8_t padding[3];
uint64_t ec;
uint32_t vid_hdr_offset;
uint32_t data_offset;
uint32_t image_seq;
uint8_t padding2[32];
uint32_t hdr_crc;
} __attribute__ ((packed));
struct ubi_vid_hdr {
uint32_t magic;
uint8_t version;
uint8_t vol_type;
uint8_t copy_flag;
uint8_t compat;
uint32_t vol_id;
uint32_t lnum;
uint32_t leb_ver;
uint32_t data_size;
uint32_t used_ebs;
uint32_t data_pad;
uint32_t data_crc;
uint8_t padding1[4];
uint64_t sqnum;
uint8_t padding2[12];
uint32_t hdr_crc;
} __attribute__ ((packed));
struct ubi_vol_tbl_record {
uint32_t reserved_pebs;
uint32_t alignment;
uint32_t data_pad;
uint8_t vol_type;
uint8_t padding1;
uint16_t name_len;
uint8_t name[UBI_VOL_NAME_MAX + 1];
uint8_t padding2[24];
uint32_t crc;
} __attribute__ ((packed));
struct EraseBlock {
uint32_t peb;
uint32_t leb;
uint64_t sqnum;
uint32_t vol_id;
SLIST_ENTRY(EraseBlock) next;
};
int ubi_load_kernel(unsigned char *ld_addr, void **exec_addr, uint32_t vol_id);
#endif /* UBI_H */