github.com/u-root/u-root@v7.0.1-0.20200915234505-ad7babab0a8e+incompatible/pkg/smbios/table_type.go (about) 1 // Copyright 2016-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 smbios 6 7 import ( 8 "fmt" 9 ) 10 11 // TableType specifies the DMI type of the table. 12 // Types are defined in DMTF DSP0134. 13 type TableType uint8 14 15 // Supported table types. 16 const ( 17 TableTypeBIOSInfo TableType = 0 18 TableTypeSystemInfo TableType = 1 19 TableTypeBaseboardInfo TableType = 2 20 TableTypeChassisInfo TableType = 3 21 TableTypeProcessorInfo TableType = 4 22 TableTypeCacheInfo TableType = 7 23 TableTypeMemoryDevice TableType = 17 24 TableTypeIPMIDeviceInfo TableType = 38 25 TableTypeTPMDevice TableType = 43 26 TableTypeInactive TableType = 126 27 TableTypeEndOfTable TableType = 127 28 ) 29 30 func (t TableType) String() string { 31 switch t { 32 case TableTypeBIOSInfo: 33 return "BIOS Information" 34 case TableTypeSystemInfo: 35 return "System Information" 36 case TableTypeBaseboardInfo: 37 return "Base Board Information" 38 case TableTypeChassisInfo: 39 return "Chassis Information" 40 case TableTypeProcessorInfo: 41 return "Processor Information" 42 case TableTypeCacheInfo: 43 return "Cache Information" 44 case TableTypeMemoryDevice: 45 return "Memory Device" 46 case TableTypeIPMIDeviceInfo: 47 return "IPMI Device Information" 48 case TableTypeTPMDevice: 49 return "TPM Device" 50 case TableTypeInactive: 51 return "Inactive" 52 case TableTypeEndOfTable: 53 return "End Of Table" 54 default: 55 if t >= 0x80 { 56 return "OEM-specific Type" 57 } 58 return "Unsupported" 59 } 60 } 61 62 // ParseTypedTable parses generic Table into a typed struct. 63 func ParseTypedTable(t *Table) (fmt.Stringer, error) { 64 switch t.Type { 65 case TableTypeBIOSInfo: // 0 66 return ParseBIOSInfo(t) 67 case TableTypeSystemInfo: // 1 68 return ParseSystemInfo(t) 69 case TableTypeBaseboardInfo: // 2 70 return ParseBaseboardInfo(t) 71 case TableTypeChassisInfo: // 3 72 return ParseChassisInfo(t) 73 case TableTypeProcessorInfo: // 4 74 return ParseProcessorInfo(t) 75 case TableTypeCacheInfo: // 7 76 return ParseCacheInfo(t) 77 case TableTypeMemoryDevice: // 17 78 return NewMemoryDevice(t) 79 case TableTypeIPMIDeviceInfo: // 38 80 return ParseIPMIDeviceInfo(t) 81 case TableTypeTPMDevice: // 43 82 return NewTPMDevice(t) 83 case TableTypeInactive: // 126 84 return NewInactiveTable(t) 85 case TableTypeEndOfTable: // 127 86 return NewEndOfTable(t) 87 } 88 return nil, ErrUnsupportedTableType 89 }