iPXE
lkrn.h
Go to the documentation of this file.
1 #ifndef _IPXE_LKRN_H
2 #define _IPXE_LKRN_H
3 
4 /** @file
5  *
6  * Linux kernel images
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <stdint.h>
13 
14 /** Kernel image header */
15 struct lkrn_header {
16  /** Executable code */
18  /** Image load offset */
20  /** Image size */
22  /** Flags */
24  /** Reserved */
26  /** Magic */
28  /** Reserved */
30 } __attribute__ (( packed ));
31 
32 /** Kernel magic value */
33 #define LKRN_MAGIC( a, b, c, d ) \
34  ( ( (a) << 0 ) | ( (b) << 8 ) | ( (c) << 16 ) | ( (d) << 24 ) )
35 
36 /** Kernel magic value for AArch64 */
37 #define LKRN_MAGIC_AARCH64 LKRN_MAGIC ( 'A', 'R', 'M', 0x64 )
38 
39 /** Kernel magic value for RISC-V */
40 #define LKRN_MAGIC_RISCV LKRN_MAGIC ( 'R', 'S', 'C', 0x05 )
41 
42 /** Kernel image context */
43 struct lkrn_context {
44  /** Load offset */
45  size_t offset;
46  /** File size */
47  size_t filesz;
48  /** Memory size */
49  size_t memsz;
50 
51  /** Start of RAM */
53  /** Entry point */
55  /** Initial ramdisk (if any) */
57  /** Device tree */
59 };
60 
61 /** Compressed kernel image header */
62 struct zimg_header {
63  /** Reserved */
65  /** Magic */
67  /** Offset to payload */
69  /** Length of payload */
71  /** Reserved */
73  /** Compression type */
75 } __attribute__ (( packed ));
76 
77 /** Compressed kernel image magic value */
78 #define ZIMG_MAGIC LKRN_MAGIC ( 'z', 'i', 'm', 'g' )
79 
80 /** Compressed kernel image context */
81 struct zimg_context {
82  /** Offset to compressed data */
83  size_t offset;
84  /** Length of compressed data */
85  size_t len;
86  /** Compression type */
87  union {
88  /** Raw type */
90  /** Printable string */
91  char string[5];
92  } type;
93 };
94 
95 #include <bits/lkrn.h>
96 
97 /**
98  * Jump to kernel entry point
99  *
100  * @v entry Kernel entry point
101  * @v fdt Device tree
102  */
103 void lkrn_jump ( physaddr_t entry, physaddr_t fdt );
104 
105 #endif /* _IPXE_LKRN_H */
size_t offset
Offset to compressed data.
Definition: lkrn.h:83
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
uint32_t offset
Offset to payload.
Definition: lkrn.h:68
uint8_t reserved_a[4]
Reserved.
Definition: lkrn.h:64
size_t offset
Load offset.
Definition: lkrn.h:45
physaddr_t entry
Entry point.
Definition: lkrn.h:54
Kernel image context.
Definition: lkrn.h:43
uint64_t flags
Flags.
Definition: lkrn.h:23
unsigned long long uint64_t
Definition: stdint.h:13
uint64_t image_size
Image size.
Definition: lkrn.h:21
Compressed kernel image context.
Definition: lkrn.h:81
uint8_t reserved_a[24]
Reserved.
Definition: lkrn.h:25
uint32_t magic
Magic.
Definition: lkrn.h:66
Compressed kernel image header.
Definition: lkrn.h:62
uint32_t code[2]
Executable code.
Definition: lkrn.h:17
uint32_t type
Compression type.
Definition: lkrn.h:74
uint8_t reserved_b[4]
Reserved.
Definition: lkrn.h:29
physaddr_t fdt
Device tree.
Definition: lkrn.h:58
Dummy architecture-specific Linux kernel image invocation.
void lkrn_jump(physaddr_t entry, physaddr_t fdt)
Jump to kernel entry point.
union zimg_context::@637 type
Compression type.
uint8_t reserved_b[8]
Reserved.
Definition: lkrn.h:72
size_t memsz
Memory size.
Definition: lkrn.h:49
uint64_t text_offset
Image load offset.
Definition: lkrn.h:19
unsigned char uint8_t
Definition: stdint.h:10
uint32_t len
Length of payload.
Definition: lkrn.h:70
uint32_t magic
Magic.
Definition: lkrn.h:27
physaddr_t initrd
Initial ramdisk (if any)
Definition: lkrn.h:56
size_t len
Length of compressed data.
Definition: lkrn.h:85
unsigned int uint32_t
Definition: stdint.h:12
Kernel image header.
Definition: lkrn.h:15
unsigned long physaddr_t
Definition: stdint.h:20
physaddr_t ram
Start of RAM.
Definition: lkrn.h:52
A device tree.
Definition: fdt.h:88
struct lkrn_context __attribute__
size_t filesz
File size.
Definition: lkrn.h:47
uint32_t raw
Raw type.
Definition: lkrn.h:89