aboutsummaryrefslogtreecommitdiffstats
path: root/src/include/ipxe/cpio.h
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2021-05-17 14:57:48 +0100
committerMichael Brown <mcb30@ipxe.org>2021-05-21 15:19:38 +0100
commitbfca3db41e9af78e56e7a9b7f30121df83b6af0a (patch)
tree4f75eef31776bcc8d2918b9b2e92e90560859794 /src/include/ipxe/cpio.h
parentfc8bd4ba1a65db9d9091705f30fec19ded75530c (diff)
downloadipxe-bfca3db41e9af78e56e7a9b7f30121df83b6af0a.tar.gz
[cpio] Split out bzImage initrd CPIO header construction
iPXE will construct CPIO headers for images that have a non-empty command line, thereby allowing raw images (without CPIO headers) to be injected into a dynamically constructed initrd. This feature is currently implemented within the BIOS-only bzImage format support. Split out the CPIO header construction logic to allow for reuse in other contexts such as in a UEFI build. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe/cpio.h')
-rw-r--r--src/include/ipxe/cpio.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/include/ipxe/cpio.h b/src/include/ipxe/cpio.h
index 0637c531d..9c5e22d5a 100644
--- a/src/include/ipxe/cpio.h
+++ b/src/include/ipxe/cpio.h
@@ -9,6 +9,8 @@
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
+#include <ipxe/image.h>
+
/** A CPIO archive header
*
* All field are hexadecimal ASCII numbers padded with '0' on the
@@ -48,6 +50,25 @@ struct cpio_header {
/** CPIO magic */
#define CPIO_MAGIC "070701"
+/** CPIO header length alignment */
+#define CPIO_ALIGN 4
+
+/** Alignment for CPIO archives within an initrd */
+#define INITRD_ALIGN 4096
+
+/**
+ * Get CPIO image name
+ *
+ * @v image Image
+ * @ret name Image name (not NUL terminated)
+ */
+static inline __attribute__ (( always_inline )) const char *
+cpio_name ( struct image *image ) {
+ return image->cmdline;
+}
+
extern void cpio_set_field ( char *field, unsigned long value );
+extern size_t cpio_name_len ( struct image *image );
+extern size_t cpio_header ( struct image *image, struct cpio_header *cpio );
#endif /* _IPXE_CPIO_H */