Support Nook Green Loader

This commit is contained in:
topjohnwu 2018-01-30 05:56:59 +08:00
parent f48e6c93b8
commit 28350e3ad9
3 changed files with 10 additions and 0 deletions

View File

@ -122,6 +122,11 @@ int parse_img(const char *image, boot_img *boot) {
fprintf(stderr, "PXA_BOOT_HDR\n");
boot->hdr = malloc(sizeof(pxa_boot_img_hdr));
memcpy(boot->hdr, head, sizeof(pxa_boot_img_hdr));
} else if (memcmp(((boot_img_hdr*) head)->cmdline, NOOK_MAGIC, 12) == 0) {
boot->flags |= NOOK_FLAG;
fprintf(stderr, "NOOK_GREEN_LOADER\n");
head += NOOK_PRE_HEADER_SZ - 1;
continue;
} else {
boot->hdr = malloc(sizeof(boot_img_hdr));
memcpy(boot->hdr, head, sizeof(boot_img_hdr));
@ -285,6 +290,8 @@ void repack(const char* orig_image, const char* out_image) {
} else if (boot.flags & BLOB_FLAG) {
// Skip blob header
write_zero(fd, sizeof(blob_hdr));
} else if (boot.flags & NOOK_FLAG) {
restore_buf(fd, boot.map_addr, NOOK_PRE_HEADER_SZ);
}
// Skip a page for header

View File

@ -130,6 +130,7 @@ typedef struct blob_hdr {
#define LG_BUMP_FLAG 0x0040
#define SHA256_FLAG 0x0080
#define BLOB_FLAG 0x0100
#define NOOK_FLAG 0x0200
typedef struct boot_img {
// Memory map of the whole image

View File

@ -38,6 +38,8 @@ typedef enum {
#define DHTB_MAGIC "\x44\x48\x54\x42\x01\x00\x00\x00"
#define SEANDROID_MAGIC "SEANDROIDENFORCE"
#define TEGRABLOB_MAGIC "-SIGNED-BY-SIGNBLOB-"
#define NOOK_MAGIC "Green Loader"
#define NOOK_PRE_HEADER_SZ 1048575
#define SUP_LIST ((char *[]) { "gzip", "xz", "lzma", "bzip2", "lz4", "lz4_legacy", NULL })
#define SUP_EXT_LIST ((char *[]) { "gz", "xz", "lzma", "bz2", "lz4", "lz4", NULL })