gopkg.in/hugelgupf/u-root.v2@v2.0.0-20180831055005-3f8fdb0ce09d/pkg/boot/boot.go (about)

     1  // Copyright 2018 the u-root Authors. All rights reserved
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package boot
     6  
     7  import (
     8  	"log"
     9  
    10  	"github.com/u-root/u-root/pkg/cpio"
    11  )
    12  
    13  // OSImage represents a bootable OS package.
    14  type OSImage interface {
    15  	// ExecutionInfo prints information about the OS image. A user should
    16  	// be able to use the kexec command line tool to execute the OSImage
    17  	// given the printed information.
    18  	ExecutionInfo(log *log.Logger)
    19  
    20  	// Execute kexec's the OS image: it loads the OS image into memory and
    21  	// jumps to the kernel's entry point.
    22  	Execute() error
    23  
    24  	// Pack writes the OS image to the modules directory of sw and the
    25  	// package type to package_type of sw.
    26  	Pack(sw cpio.RecordWriter) error
    27  }
    28  
    29  var (
    30  	osimageMap = map[string]func(*cpio.Archive) (OSImage, error){
    31  		"linux": func(a *cpio.Archive) (OSImage, error) {
    32  			return NewLinuxImageFromArchive(a)
    33  		},
    34  		"multiboot": newMultibootImage,
    35  	}
    36  )