src/boot/image.bend checks
raw source on the hub · import 0x2740e30df705f4fb9b9db637023eca00/src/boot/image.bend as MImage
3 imports
import Base import ../lib/u64.bend as U import ../lib/bytes.bend as B
Types
type ImageInfo source · line 15 · raw
Data
ImageInfo@text_offset:0x2740e30df705f4fb9b9db637023eca00/src/lib/u64.U64 -> @image_size:0x2740e30df705f4fb9b9db637023eca00/src/lib/u64.U64 -> @flags:0x2740e30df705f4fb9b9db637023eca00/src/lib/u64.U64 -> ImageInfo
type Layout source · line 19 · raw
Data
Where everything goes in guest RAM.
Layout@kernel:0x2740e30df705f4fb9b9db637023eca00/src/lib/u64.U64 -> @kernel_end:0x2740e30df705f4fb9b9db637023eca00/src/lib/u64.U64 -> @dtb:0x2740e30df705f4fb9b9db637023eca00/src/lib/u64.U64 -> @initrd:0x2740e30df705f4fb9b9db637023eca00/src/lib/u64.U64 -> @initrd_end:0x2740e30df705f4fb9b9db637023eca00/src/lib/u64.U64 -> Layout
Definitions
def Image.magic source · line 22 · raw
U32
def Image.old_text_offset source · line 25 · raw
0x2740e30df705f4fb9b9db637023eca00/src/lib/u64.U64
def Image.mib2 source · line 28 · raw
U32
def Image.field source · line 32 · raw
@bs:List<&2, U32> -> @off:Nat -> 0x2740e30df705f4fb9b9db637023eca00/src/lib/u64.U64
The le64 field at byte off of the header.
def Image.text_offset source · line 36 · raw
@old:Bool -> @given:0x2740e30df705f4fb9b9db637023eca00/src/lib/u64.U64 -> 0x2740e30df705f4fb9b9db637023eca00/src/lib/u64.U64
A pre-3.17 kernel (image_size 0) loads at text_offset 0x8_0000.
def Image.when source · line 43 · raw
@-A:Data -> @ok:Bool -> @x:A -> Maybe<&2, A>
def Image.parse.fields source · line 51 · raw
@+bs:List<&2, U32> -> Maybe<&2, ImageInfo>
The fields of a header of at least 64 bytes.
def Image.parse.go source · line 58 · raw
@long:Bool -> @bs:List<&2, U32> -> Maybe<&2, ImageInfo>
def Image.parse source · line 67 · raw
@header:List<&2, U32> -> Maybe<&2, ImageInfo>
Parses the header; None if shorter than 64 bytes, the magic is wrong or the kernel is big-endian.
def Image.add source · line 72 · raw
@+a:0x2740e30df705f4fb9b9db637023eca00/src/lib/u64.U64 -> @b:0x2740e30df705f4fb9b9db637023eca00/src/lib/u64.U64 -> Maybe<&2, 0x2740e30df705f4fb9b9db637023eca00/src/lib/u64.U64>
a + b, or None when the sum wraps past 2^64.
def Image.align source · line 77 · raw
@k:Nat -> @+a:0x2740e30df705f4fb9b9db637023eca00/src/lib/u64.U64 -> Maybe<&2, 0x2740e30df705f4fb9b9db637023eca00/src/lib/u64.U64>
a rounded up to a multiple of 2^k, or None when that wraps past 2^64.
def Image.max source · line 81 · raw
@+a:0x2740e30df705f4fb9b9db637023eca00/src/lib/u64.U64 -> @+b:0x2740e30df705f4fb9b9db637023eca00/src/lib/u64.U64 -> 0x2740e30df705f4fb9b9db637023eca00/src/lib/u64.U64
def Image.layout source · line 95 · raw
@ram_base:0x2740e30df705f4fb9b9db637023eca00/src/lib/u64.U64 -> @ram_size:0x2740e30df705f4fb9b9db637023eca00/src/lib/u64.U64 -> @info:ImageInfo -> @kernel_len:U32 -> @dtb_len:U32 -> @initrd_len:U32 -> Maybe<&2, Layout>
Places the kernel, the DTB and the initrd in RAM [ram_base, ram_base+ram_size): - kernel at ram_base + text_offset (ram_base is 2 MiB aligned), spanning max(image_size, kernel_len) bytes; - the DTB at the first 2 MiB boundary at or after the kernel's end (it must be 8-byte aligned and within one 2 MiB region; dtb_len <= 2 MiB); - the initrd at the first 4 KiB boundary at or after the end of the DTB's 2 MiB region (initrd_len 0 gives initrd == initrd_end, still placed there). None if anything would end past the end of RAM.
Each region ends at or before the start of the next one, so the initrd's end bounds them all. Also None when dtb_len > 2 MiB or an address wraps past 2^64.
def Image.is_gzip source · line 114 · raw
@+head:List<&2, U32> -> Bool
A gzip stream (RFC 1952: 1f 8b), from a file's first bytes: a compressed kernel (Ubuntu's vmlinuz) the host inflates into RAM. A file of 2 bytes or fewer is not one.