github.com/u-root/u-root@v7.0.1-0.20200915234505-ad7babab0a8e+incompatible/pkg/boot/multiboot.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 "fmt" 9 "io" 10 "strings" 11 12 "github.com/u-root/u-root/pkg/boot/ibft" 13 "github.com/u-root/u-root/pkg/boot/multiboot" 14 ) 15 16 // MultibootImage is a multiboot-formated OSImage, such as ESXi, Xen, Akaros, 17 // tboot. 18 type MultibootImage struct { 19 Name string 20 21 Kernel io.ReaderAt 22 Cmdline string 23 Modules []multiboot.Module 24 IBFT *ibft.IBFT 25 } 26 27 var _ OSImage = &MultibootImage{} 28 29 // Label returns either Name or a short description. 30 func (mi *MultibootImage) Label() string { 31 if len(mi.Name) > 0 { 32 return mi.Name 33 } 34 return fmt.Sprintf("Multiboot(kernel=%s cmdline=%s iBFT=%s)", stringer(mi.Kernel), mi.Cmdline, mi.IBFT) 35 } 36 37 // Load implements OSImage.Load. 38 func (mi *MultibootImage) Load(verbose bool) error { 39 return multiboot.Load(verbose, mi.Kernel, mi.Cmdline, mi.Modules, mi.IBFT) 40 } 41 42 // String implements fmt.Stringer. 43 func (mi *MultibootImage) String() string { 44 modules := make([]string, len(mi.Modules)) 45 for i, mod := range mi.Modules { 46 modules[i] = mod.Cmdline 47 } 48 return fmt.Sprintf("MultibootImage(\n Name: %s\n Kernel: %s\n Cmdline: %s\n iBFT: %s\n Modules: %s\n)", 49 mi.Name, stringer(mi.Kernel), mi.Cmdline, mi.IBFT, strings.Join(modules, ", ")) 50 }