multiboot

package
v7.0.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2020 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Overview

Package multiboot implements bootloading multiboot kernels as defined by https://www.gnu.org/software/grub/manual/multiboot/multiboot.html.

Package multiboot crafts kexec segments that can be used with the kexec_load system call.

Index

Constants

View Source
const (
	MUTIBOOT_INVALID_TYPE  mutibootType = 0
	MUTIBOOT_MEMRANGE_TYPE mutibootType = 1
	MUTIBOOT_MODULE_TYPE   mutibootType = 2
	MUTIBOOT_VBE_TYPE      mutibootType = 3
	MUTIBOOT_EFI_TYPE      mutibootType = 4
	MUTIBOOT_LOADESX_TYPE  mutibootType = 5
)
View Source
const (
	// 64-bit ARM EFI. (Why would we have to tell the next kernel that it's
	// an aarch64 EFI? Shouldn't it know?)
	MUTIBOOT_EFI_ARCH64 mutibootEfiFlags = 1 << 0

	// EFI Secure Boot in progress.
	MUTIBOOT_EFI_SECURE_BOOT mutibootEfiFlags = 1 << 1

	// UEFI memory map is valid rather than mutiboot memory map.
	MUTIBOOT_EFI_MMAP mutibootEfiFlags = 1 << 2
)
View Source
const (
	// Kernel runs in EL1, not EL2.
	MUTIBOOT_ARCH_FLAG_ARM64_EL1 mutibootHeaderFlag = 1 << 0
	// Must pass video info to OS.
	MUTIBOOT_FLAG_VIDEO mutibootHeaderFlag = 1 << 2

	// rts_vaddr field is valid.
	MUTIBOOT_FLAG_EFI_RTS_OLD mutibootHeaderFlag = 1 << 17
	// rts vaddr and size fields valid.
	MUTIBOOT_FLAG_EFI_RTS_NEW mutibootHeaderFlag = 1 << 18
	// LoadESX version field valid.
	MUTIBOOT_FLAG_LOADESX_VERSION mutibootHeaderFlag = 1 << 19
	// Video min fields valid.
	MUTIBOOT_FLAG_VIDEO_MIN mutibootHeaderFlag = 1 << 20
)
View Source
const (
	MUTIBOOT_VIDEO_GRAPHIC = 0
	MUTIBOOT_VIDEO_TEXT    = 1
)
View Source
const DebugPrefix = "MULTIBOOT_DEBUG_INFO:"

DebugPrefix is a prefix that some messages are printed with for tests to parse.

Variables

View Source
var (
	// ErrHeaderNotFound indicates that a multiboot header magic was not
	// found in the given binary.
	ErrHeaderNotFound = errors.New("multiboot header not found")

	// ErrFlagsNotSupported indicates that a valid multiboot header
	// contained flags this package does not support (yet).
	ErrFlagsNotSupported = errors.New("multiboot header flags not supported	yet")
)

Functions

func Load

func Load(debug bool, kernel io.ReaderAt, cmdline string, modules []Module, ibft *ibft.IBFT) error

Load parses and loads a multiboot `kernel` using kexec_load.

debug turns on debug logging.

Load can set up an arbitrary number of modules, and takes care of the multiboot info structure, including the memory map.

After Load is called, kexec.Reboot() is ready to be called any time to stop Linux and execute the loaded kernel.

func Probe

func Probe(kernel io.ReaderAt) error

Probe checks if `kernel` is multiboot v1 or mutiboot kernel.

Types

type Description

type Description struct {
	Status string `json:"status"`

	Flags      uint32 `json:"flags"`
	MemLower   uint32 `json:"mem_lower"`
	MemUpper   uint32 `json:"mem_upper"`
	MmapAddr   uint32 `json:"mmap_addr"`
	MmapLength uint32 `json:"mmap_length"`

	Cmdline    string `json:"cmdline"`
	Bootloader string `json:"bootloader"`

	Mmap    []MemoryMap  `json:"mmap"`
	Modules []ModuleDesc `json:"modules"`
}

Description stores representation of multiboot information passed to a final kernel used for for debugging and testing.

type MemoryMap

type MemoryMap struct {
	// Size is the size of the associated structure in bytes.
	Size uint32
	// BaseAddr is the starting address.
	BaseAddr uint64
	// Length is the size of the memory region in bytes.
	Length uint64
	// Type is the variety of address range represented.
	Type uint32
}

MemoryMap represents a reserved range of memory passed via the multiboot Info header.

func (MemoryMap) MarshalJSON

func (m MemoryMap) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (MemoryMap) String

func (m MemoryMap) String() string

String returns a readable representation of a MemoryMap entry.

func (*MemoryMap) UnmarshalJSON

func (m *MemoryMap) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler

type Module

type Module struct {
	Module  io.ReaderAt
	Cmdline string
}

Module describe a module by a ReaderAt and a `Cmdline`

func (Module) Name

func (m Module) Name() string

Name returns the first field of the cmdline, if there is one.

type ModuleDesc

type ModuleDesc struct {
	Start   uint32 `json:"start"`
	End     uint32 `json:"end"`
	Cmdline string `json:"cmdline"`
	SHA256  string `json:"sha256"`
}

ModuleDesc is a debug representation of loaded module.

type Modules

type Modules []Module

Modules is a range of module with a Closer interface

func LazyOpenModules

func LazyOpenModules(cmds []string) Modules

LazyOpenModules assigns modules to be opened as files.

Each module is a path followed by optional command-line arguments, e.g. []string{"./module arg1 arg2", "./module2 arg3 arg4"}.

func OpenModules

func OpenModules(cmds []string) (Modules, error)

OpenModules open modules as files and fill a range of `Module` struct

Each module is a path followed by optional command-line arguments, e.g. []string{"./module arg1 arg2", "./module2 arg3 arg4"}.

func (Modules) Close

func (m Modules) Close() error

Close closes all Modules ReaderAt implementing the io.Closer interface

Directories

Path Synopsis
internal
trampoline
Package trampoline sets machine to a specific state defined by multiboot v1 spec and jumps to the intended kernel.
Package trampoline sets machine to a specific state defined by multiboot v1 spec and jumps to the intended kernel.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL