forked from u-root/u-root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
boot.go
45 lines (36 loc) · 1.13 KB
/
boot.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2018 the u-root Authors. All rights reserved
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package boot is the high-level interface for booting another operating
// system from Linux using kexec.
package boot
import (
"fmt"
"github.com/u-root/u-root/pkg/boot/kexec"
)
// OSImage represents a bootable OS package.
type OSImage interface {
fmt.Stringer
// Label is a name or short description for this OSImage.
//
// Label is intended for boot menus.
Label() string
// Rank the priority of the images for boot menus.
//
// The larger the number, the prior the image shows in the menu.
Rank() int
// Edit the kernel command line if possible. Must be called before
// Load.
Edit(func(cmdline string) string)
// Load loads the OS image into kernel memory, ready for execution.
//
// After Load is called, call boot.Execute() to stop Linux and boot the
// loaded OSImage.
Load(verbose bool) error
}
// Execute executes a previously loaded OSImage.
//
// This will only work if OSImage.Load was called on some OSImage.
func Execute() error {
return kexec.Reboot()
}