github.com/hugelgupf/u-root@v0.0.0-20191023214958-4807c632154c/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 TableTypeBIOSInformation TableType = 0 18 TableTypeSystemInformation TableType = 1 19 TableTypeBaseboardInformation TableType = 2 20 TableTypeChassisInformation TableType = 3 21 TableTypeProcessorInformation TableType = 4 22 TableTypeCacheInformation TableType = 7 23 TableTypeMemoryDevice TableType = 17 24 TableTypeIPMIDeviceInformation 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 TableTypeBIOSInformation: 33 return "BIOS Information" 34 case TableTypeSystemInformation: 35 return "System Information" 36 case TableTypeBaseboardInformation: 37 return "Base Board Information" 38 case TableTypeChassisInformation: 39 return "Chassis Information" 40 case TableTypeProcessorInformation: 41 return "Processor Information" 42 case TableTypeCacheInformation: 43 return "Cache Information" 44 case TableTypeMemoryDevice: 45 return "Memory Device" 46 case TableTypeIPMIDeviceInformation: 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 TableTypeBIOSInformation: // 0 66 return NewBIOSInformation(t) 67 case TableTypeSystemInformation: // 1 68 return NewSystemInformation(t) 69 case TableTypeBaseboardInformation: // 2 70 return NewBaseboardInformation(t) 71 case TableTypeChassisInformation: // 3 72 return NewChassisInformation(t) 73 case TableTypeProcessorInformation: // 4 74 return NewProcessorInformation(t) 75 case TableTypeCacheInformation: // 7 76 return NewCacheInformation(t) 77 case TableTypeMemoryDevice: // 17 78 return NewMemoryDevice(t) 79 case TableTypeIPMIDeviceInformation: // 38 80 return NewIPMIDeviceInformation(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 }