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