github.com/mvdan/u-root-coreutils@v0.0.0-20230122170626-c2eef2898555/pkg/acpi/tables_linux.go (about)

     1  // Copyright 2019 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  //go:build linux
     6  // +build linux
     7  
     8  package acpi
     9  
    10  import (
    11  	"path/filepath"
    12  )
    13  
    14  var (
    15  	// DefaultMethod is the name of the default method used to get tables.
    16  	DefaultMethod = "files"
    17  	// Methods is the map of all methods implemented for Linux.
    18  	Methods = map[string]TableMethod{
    19  		"files": RawTablesFromSys,
    20  		"ebda":  RawTablesFromMem,
    21  	}
    22  )
    23  
    24  // MethodNames returns the list of supported MethodNames.
    25  func MethodNames() []string {
    26  	var s []string
    27  	for name := range Methods {
    28  		s = append(s, name)
    29  	}
    30  	return s
    31  }
    32  
    33  // RawTablesFromSys returns an array of Raw tables, for all ACPI tables
    34  // available in /sys.
    35  func RawTablesFromSys() ([]Table, error) {
    36  	n, err := filepath.Glob("/sys/firmware/acpi/tables/[A-Z]*")
    37  	if err != nil {
    38  		return nil, err
    39  	}
    40  
    41  	var tabs []Table
    42  	for _, t := range n {
    43  		r, err := RawFromName(t)
    44  		if err != nil {
    45  			return nil, err
    46  		}
    47  		tabs = append(tabs, r...)
    48  	}
    49  	return tabs, nil
    50  }