forked from hugelgupf/u-root
/
boot.go
36 lines (29 loc) · 990 Bytes
/
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
// 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
import (
"log"
"github.com/u-root/u-root/pkg/cpio"
)
// OSImage represents a bootable OS package.
type OSImage interface {
// ExecutionInfo prints information about the OS image. A user should
// be able to use the kexec command line tool to execute the OSImage
// given the printed information.
ExecutionInfo(log *log.Logger)
// Execute kexec's the OS image: it loads the OS image into memory and
// jumps to the kernel's entry point.
Execute() error
// Pack writes the OS image to the modules directory of sw and the
// package type to package_type of sw.
Pack(sw cpio.RecordWriter) error
}
var (
osimageMap = map[string]func(*cpio.Archive) (OSImage, error){
"linux": func(a *cpio.Archive) (OSImage, error) {
return NewLinuxImageFromArchive(a)
},
"multiboot": newMultibootImage,
}
)