/
tables_linux.go
50 lines (43 loc) · 1.05 KB
/
tables_linux.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2019 the u-root Authors. All rights reserved
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build linux
// +build linux
package acpi
import (
"path/filepath"
)
var (
// DefaultMethod is the name of the default method used to get tables.
DefaultMethod = "files"
// Methods is the map of all methods implemented for Linux.
Methods = map[string]TableMethod{
"files": RawTablesFromSys,
"ebda": RawTablesFromMem,
}
)
// MethodNames returns the list of supported MethodNames.
func MethodNames() []string {
var s []string
for name := range Methods {
s = append(s, name)
}
return s
}
// RawTablesFromSys returns an array of Raw tables, for all ACPI tables
// available in /sys.
func RawTablesFromSys() ([]Table, error) {
n, err := filepath.Glob("/sys/firmware/acpi/tables/[A-Z]*")
if err != nil {
return nil, err
}
var tabs []Table
for _, t := range n {
r, err := RawFromName(t)
if err != nil {
return nil, err
}
tabs = append(tabs, r...)
}
return tabs, nil
}