mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-12-18 09:53:04 +00:00
payload: Add a custom header with a payload size field for initramfs'
This add supports for concatenated (compressed) cpio archives and relies on the kernel to decompress the initramfs. Signed-off-by: Janne Grunau <j@jannau.net>
This commit is contained in:
parent
8bf08b0ff1
commit
a2b4a7479a
1 changed files with 9 additions and 0 deletions
|
@ -24,6 +24,9 @@ static const u8 kernel_magic[] = {'A', 'R', 'M', 0x64}; // at 0x38
|
|||
static const u8 cpio_magic[] = {'0', '7', '0', '7', '0'}; // '1' or '2' next
|
||||
static const u8 img4_magic[] = {0x16, 0x04, 'I', 'M', 'G', '4'}; // IA5String 'IMG4'
|
||||
static const u8 sig_magic[] = {'m', '1', 'n', '1', '_', 's', 'i', 'g'};
|
||||
static const u8 initramfs_magic[] = {
|
||||
'm', '1', 'n', '1', '_', 'i', 'n',
|
||||
'i', 't', 'r', 'a', 'm', 'f', 's'}; // followed by size as little endian uint32_t
|
||||
static const u8 empty[] = {0, 0, 0, 0};
|
||||
|
||||
static char expect_compatible[256];
|
||||
|
@ -218,6 +221,12 @@ static void *load_one_payload(void *start, size_t size)
|
|||
|
||||
printf("Found a m1n1 signature at %p, skipping 0x%x bytes\n", p, size);
|
||||
return p + size;
|
||||
} else if (!memcmp(p, initramfs_magic, sizeof(initramfs_magic))) {
|
||||
u32 size;
|
||||
memcpy(&size, p + sizeof(initramfs_magic), 4);
|
||||
printf("Found a m1n1 initramfs payload at %p, 0x%x bytes\n", p, size);
|
||||
p += sizeof(initramfs_magic) + 4;
|
||||
return load_cpio(p, size);
|
||||
} else if (check_var(&p)) {
|
||||
return p;
|
||||
} else if (!memcmp(p, empty, sizeof empty) ||
|
||||
|
|
Loading…
Reference in a new issue