blob: c1d6b3ee524174b640a5a1436f723e3ea31eef86 [file] [log] [blame]
Nolen Johnson802fd002019-08-07 23:56:48 -04001#ifndef __LOKI_H_
2#define __LOKI_H_
3
4#define VERSION "2.1"
5
6#define BOOT_MAGIC_SIZE 8
7#define BOOT_NAME_SIZE 16
8#define BOOT_ARGS_SIZE 512
9
10#define BOOT_PARTITION "/dev/block/platform/msm_sdcc.1/by-name/boot"
11#define RECOVERY_PARTITION "/dev/block/platform/msm_sdcc.1/by-name/recovery"
12#define ABOOT_PARTITION "/dev/block/platform/msm_sdcc.1/by-name/aboot"
13
14#define PATTERN1 "\xf0\xb5\x8f\xb0\x06\x46\xf0\xf7"
15#define PATTERN2 "\xf0\xb5\x8f\xb0\x07\x46\xf0\xf7"
16#define PATTERN3 "\x2d\xe9\xf0\x41\x86\xb0\xf1\xf7"
17#define PATTERN4 "\x2d\xe9\xf0\x4f\xad\xf5\xc6\x6d"
18#define PATTERN5 "\x2d\xe9\xf0\x4f\xad\xf5\x21\x7d"
19#define PATTERN6 "\x2d\xe9\xf0\x4f\xf3\xb0\x05\x46"
20
21#define ABOOT_BASE_SAMSUNG 0x88dfffd8
22#define ABOOT_BASE_LG 0x88efffd8
23#define ABOOT_BASE_G2 0xf7fffd8
24#define ABOOT_BASE_VIPER 0x40100000
25
26struct boot_img_hdr {
27 unsigned char magic[BOOT_MAGIC_SIZE];
28 unsigned kernel_size; /* size in bytes */
29 unsigned kernel_addr; /* physical load addr */
30 unsigned ramdisk_size; /* size in bytes */
31 unsigned ramdisk_addr; /* physical load addr */
32 unsigned second_size; /* size in bytes */
33 unsigned second_addr; /* physical load addr */
34 unsigned tags_addr; /* physical addr for kernel tags */
35 unsigned page_size; /* flash page size we assume */
36 unsigned dt_size; /* device_tree in bytes */
37 unsigned unused; /* future expansion: should be 0 */
38 unsigned char name[BOOT_NAME_SIZE]; /* asciiz product name */
39 unsigned char cmdline[BOOT_ARGS_SIZE];
40 unsigned id[8]; /* timestamp / checksum / sha1 / etc */
41};
42
43struct loki_hdr {
44 unsigned char magic[4]; /* 0x494b4f4c */
45 unsigned int recovery; /* 0 = boot.img, 1 = recovery.img */
46 char build[128]; /* Build number */
47
48 unsigned int orig_kernel_size;
49 unsigned int orig_ramdisk_size;
50 unsigned int ramdisk_addr;
51};
52
53int loki_patch(const char* partition_label, const char* aboot_image, const char* in_image, const char* out_image);
54int loki_flash(const char* partition_label, const char* loki_image);
55int loki_find(const char* aboot_image);
56int loki_unlok(const char* in_image, const char* out_image);
57
58#define PATCH "\xfe\xb5" \
59 "\x0d\x4d" \
60 "\xd5\xf8" \
61 "\x88\x04" \
62 "\xab\x68" \
63 "\x98\x42" \
64 "\x12\xd0" \
65 "\xd5\xf8" \
66 "\x90\x64" \
67 "\x0a\x4c" \
68 "\xd5\xf8" \
69 "\x8c\x74" \
70 "\x07\xf5\x80\x57" \
71 "\x0f\xce" \
72 "\x0f\xc4" \
73 "\x10\x3f" \
74 "\xfb\xdc" \
75 "\xd5\xf8" \
76 "\x88\x04" \
77 "\x04\x49" \
78 "\xd5\xf8" \
79 "\x8c\x24" \
80 "\xa8\x60" \
81 "\x69\x61" \
82 "\x2a\x61" \
83 "\x00\x20" \
84 "\xfe\xbd" \
85 "\xff\xff\xff\xff" \
86 "\xee\xee\xee\xee"
87
88#endif //__LOKI_H_