File: acpi_device.go

package info (click to toggle)
golang-github-foxboron-go-uefi 0.0~git20250207.69fb7db-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,140 kB
  • sloc: makefile: 29; sh: 14
file content (43 lines) | stat: -rw-r--r-- 880 bytes parent folder | download
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
package device

import (
	"encoding/binary"
	"io"
	"log"
)

// Subtypes of ACPI Device
// Section 10.3.3 - ACPI Device Path
const (
	_ DevicePathSubType = iota
	ACPIDevice
	ExpandedACPIDevice
)

type ACPIDevicePath struct {
	EFIDevicePath
	HID [4]byte
	UID [4]byte
}

func (a ACPIDevicePath) Format() string {
	return "No format"
}

func ParseACPIDevicePath(f io.Reader, efi *EFIDevicePath) EFIDevicePaths {
	switch efi.SubType {
	case ACPIDevice:
		a := ACPIDevicePath{EFIDevicePath: *efi}
		for _, i := range []interface{}{&a.HID, &a.UID} {
			if err := binary.Read(f, binary.LittleEndian, i); err != nil {
				log.Fatalf("Can't prase ACPI Device Path: %s", err)
			}
		}
		return a
	case ExpandedACPIDevice:
		log.Fatalf("Not implemented ACPIDevicePath type: %x\n", efi.SubType)
	default:
		log.Printf("Not implemented ACPIDevicePath type: %x\n", efi.SubType)
	}
	return nil
}