github.com/system-transparency/u-root@v6.0.1-0.20190919065413-ed07a650de4c+incompatible/pkg/acpi/types.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 package acpi 6 7 // These types are used in emitting binary from a JSON. 8 // You can serialize from JSON into structs with these types, and then 9 // they can be used in a type switch to serialize out different ways. 10 // In one case, the sheap, they serialize into the head and the heap. 11 type ( 12 // These are serialized as: 13 sig string 14 oem string 15 tableid string 16 ipaddr string // 16 byte IP4 or IP6 addr 17 sockaddr string // IP addr as above and 2 byte port 18 flag string // with other flags in the struct as one u32 19 mac string // Ethernet MAC to get converted to six uint8's 20 bdf string // u32 pci bus/dev/function 21 sheap string // string placed into the heap, with u16 len and offset in header 22 u8 string // 1 byte unsigned 23 u16 string // 2 byte unsigned 24 u32 string // 4 byte unsigned 25 u64 string // 8 byte unsigned 26 ) 27 28 // Tabler is the interface to ACPI tables, be they 29 // held in memory as a byte slice, header and byte slice, 30 // or more complex struct. 31 type Tabler interface { 32 Sig() string 33 Len() uint32 34 Revision() uint8 35 CheckSum() uint8 36 OEMID() string 37 OEMTableID() string 38 OEMRevision() uint32 39 CreatorID() uint32 40 CreatorRevision() uint32 41 AllData() []byte 42 TableData() []byte 43 Marshal() ([]byte, error) 44 } 45 46 // Header is the standard header for all ACPI tables, except the 47 // ones that don't use it. (That's a joke. So is ACPI.) 48 // We use types that we hope are easy to read; they in turn 49 // make writing marshal code with type switches very convenient. 50 type Header struct { 51 Sig sig 52 Length uint32 53 Revision uint8 54 CheckSum uint8 55 OEMID oem 56 OEMTableID tableid 57 OEMRevision uint32 58 CreatorID uint32 59 CreatorRevision uint32 60 }