github.com/mvdan/u-root-coreutils@v0.0.0-20230122170626-c2eef2898555/cmds/exp/dumpebda/main.go (about)

     1  // Copyright 2021 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  // dumpebda reads and prints the Extended BIOS Data Area.
     6  package main
     7  
     8  import (
     9  	"encoding/hex"
    10  	"fmt"
    11  	"log"
    12  	"os"
    13  
    14  	"github.com/mvdan/u-root-coreutils/pkg/boot/ebda"
    15  )
    16  
    17  func main() {
    18  	f, err := os.OpenFile("/dev/mem", os.O_RDWR, 0)
    19  	if err != nil {
    20  		log.Fatal(err)
    21  	}
    22  	defer f.Close()
    23  
    24  	e, err := ebda.ReadEBDA(f)
    25  	if err != nil {
    26  		log.Fatal(err)
    27  	}
    28  	log.Printf("EBDA starts at %#X, length %#X bytes", e.BaseOffset, e.Length)
    29  	fmt.Println(hex.Dump(e.Data))
    30  }