github.com/linuxboot/fiano@v1.2.0/pkg/cbfs/optionrom.go (about)

     1  // Copyright 2022 the LinuxBoot 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 cbfs
     6  
     7  import (
     8  	"io"
     9  	"log"
    10  )
    11  
    12  func init() {
    13  	if err := RegisterFileReader(&SegReader{Type: TypeOptionRom, Name: "option rom", New: NewOptionROM}); err != nil {
    14  		log.Fatal(err)
    15  	}
    16  }
    17  
    18  func NewOptionROM(f *File) (ReadWriter, error) {
    19  	rec := &OptionROMRecord{File: *f}
    20  	return rec, nil
    21  }
    22  
    23  func (r *OptionROMRecord) Read(in io.ReadSeeker) error {
    24  	return nil
    25  }
    26  
    27  func (r *OptionROMRecord) String() string {
    28  	return recString(r.File.Name, r.RecordStart, r.Type.String(), r.Size, r.File.Compression().String())
    29  }
    30  
    31  func (r *OptionROMRecord) Write(w io.Writer) error {
    32  	return Write(w, r.FData)
    33  }
    34  
    35  func (r *OptionROMRecord) GetFile() *File {
    36  	return &r.File
    37  }