Documentation ¶
Index ¶
Constants ¶
const SetupHeaderMagic = 0x53726448 // "HdrS"
SetupHeaderMagic is the required value of the SetupHeader.Header field.
const ZeropageSize = 0x1000
ZeropageSize is the size of the zeropage in bytes (4K).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BootE820Entry ¶
type BootE820Entry struct { Addr uint64 // __u64 addr Size uint64 // __u64 size Type uint32 // __u32 type }
bootE820Entry represents the E820 memory region entry of the boot protocol ABI. It corresponds to struct boot_e820_entry. But since struct boot_e820_entry is packed, they don't have exactly the same layout.
type BootParams ¶
type BootParams struct { E820Entries uint8 // __u8 e820_entries; /* 0x1e8 */ Hdr SetupHeader // struct setup_header hdr; /* setup header */ /* 0x1f1 */ E820Table [128]BootE820Entry // struct boot_e820_entry e820_table[E820_MAX_ENTRIES_ZEROPAGE]; /* 0x2d0 */ // contains filtered or unexported fields }
BootParams is the so-called "zeropage". It corresponds to struct boot_params. Since struct boot_params is packed, BootParams doesn't have exactly the same layout. Instead, it implements BinaryUnmarshaler and BinaryMarshaler.
func (*BootParams) MarshalBinary ¶
func (bp *BootParams) MarshalBinary() (data []byte, err error)
MarshalBinary marshals the params into the layout of struct boot_params.
func (*BootParams) UnmarshalBinary ¶
func (bp *BootParams) UnmarshalBinary(data []byte) error
UnmarshalBinary unmarshals a packed struct boot_params into the params. It returns io.ErrUnexpectedEOF if the given data is too short.
type Loader ¶
type Loader struct { // Kernel is a bzImage. Kernel []byte // Initrd, if set, is a compressed cpio of the initial ramdisk. Initrd []byte // Cmdline is the kernel command line. Cmdline string }
Loader prepares the VM to boot a 64-bit Linux kernel in long mode.
type SetupHeader ¶
type SetupHeader struct { SetupSects uint8 // __u8 setup_sects RootFlags uint16 // __u16 root_flags Syssize uint32 // __u32 syssize RamSize uint16 // __u16 ram_size VidMode uint16 // __u16 vid_mode RootDev uint16 // __u16 root_dev BootFlag uint16 // __u16 boot_flag Jump uint16 // __u16 jump Header uint32 // __u32 header Version uint16 // __u16 version RealmodeSwtch uint32 // __u32 realmode_swtch StartSysSeg uint16 // __u16 start_sys_seg KernelVersion uint16 // __u16 kernel_version TypeOfLoader uint8 // __u8 type_of_loader Loadflags uint8 // __u8 loadflags SetupMoveSize uint16 // __u16 setup_move_size Code32Start uint32 // __u32 code32_start RamdiskImage uint32 // __u32 ramdisk_image RamdiskSize uint32 // __u32 ramdisk_size BootsectKludge uint32 // __u32 bootsect_kludge HeapEndPtr uint16 // __u16 heap_end_ptr ExtLoaderVer uint8 // __u8 ext_loader_ver ExtLoaderType uint8 // __u8 ext_loader_type CmdLinePtr uint32 // __u32 cmd_line_ptr InitrdAddrMax uint32 // __u32 initrd_addr_max KernelAlignment uint32 // __u32 kernel_alignment RelocatableKernel uint8 // __u8 relocatable_kernel MinAlignment uint8 // __u8 min_alignment Xloadflags uint16 // __u16 xloadflags CmdlineSize uint32 // __u32 cmdline_size HardwareSubarch uint32 // __u32 hardware_subarch HardwareSubarchData uint64 // __u64 hardware_subarch_data PayloadOffset uint32 // __u32 payload_offset PayloadLength uint32 // __u32 payload_length SetupData uint64 // __u64 setup_data PrefAddress uint64 // __u64 pref_address InitSize uint32 // __u32 init_size HandoverOffset uint32 // __u32 handover_offset KernelInfoOffset uint32 // __u32 kernel_info_offset }
SetupHeader is the part of the zeropage that explains how to boot the kernel. A boot loader usually copies the SetupHeader from of the kernel image's BootParams, customizes it, and copies it to the zeropage in memory. SetupHeader corresponds to struct setup_header, but they don't have exactly the same layout because the C struct is packed.