Christian Walter has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/32910
Change subject: src/arch/x86: Add automatic type41 entry creation ......................................................................
src/arch/x86: Add automatic type41 entry creation
SMBIOS Type41 Emtries will be automatically created.
Change-Id: Idcb3532a5c05666d6613af4f303df85f4f1f6e97 Signed-off-by: Christian Walter christian.walter@9elements.com --- M src/arch/x86/smbios.c M src/include/device/pci_ids.h 2 files changed, 93 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/10/32910/1
diff --git a/src/arch/x86/smbios.c b/src/arch/x86/smbios.c index d389314..3d62614 100644 --- a/src/arch/x86/smbios.c +++ b/src/arch/x86/smbios.c @@ -30,6 +30,8 @@ #include <memory_info.h> #include <spd.h> #include <cbmem.h> +#include <device/pci_ids.h> +#include <device/pci_def.h> #if CONFIG(CHROMEOS) #include <vendorcode/google/chromeos/gnvs.h> #endif @@ -50,6 +52,67 @@ return -ret; }
+static const char *smbios_get_name_from_type(u8 device_type) +{ + switch (device_type) { + case SMBIOS_DEVICE_TYPE_VIDEO: + return "Video Controller"; + case SMBIOS_DEVICE_TYPE_ETHERNET: + case SMBIOS_DEVICE_TYPE_TOKEN_RING: + return "Ethernet Controller"; + case SMBIOS_DEVICE_TYPE_SOUND: + return "Sound Controller"; + case SMBIOS_DEVICE_TYPE_PATA: + case SMBIOS_DEVICE_TYPE_SAS: + case SMBIOS_DEVICE_TYPE_SATA: + case SMBIOS_DEVICE_TYPE_SCSI: + return "Memory Controller"; + default: + return "Unknown"; + } + + return "Unknown"; +} + +/* Get the device type from the dev struct */ +static u8 smbios_get_device_type_from_dev(struct device *dev) +{ + u16 pci_basesubclass = (dev->class >> 8) & 0xFFFF; + + switch (pci_basesubclass) { + case PCI_CLASS_NOT_DEFINED: + return SMBIOS_DEVICE_TYPE_OTHER; + case PCI_CLASS_DISPLAY_VGA: + case PCI_CLASS_DISPLAY_XGA: + case PCI_CLASS_DISPLAY_3D: + case PCI_CLASS_DISPLAY_OTHER: + return SMBIOS_DEVICE_TYPE_VIDEO; + case PCI_CLASS_STORAGE_SCSI: + return SMBIOS_DEVICE_TYPE_SCSI; + case PCI_CLASS_NETWORK_ETHERNET: + return SMBIOS_DEVICE_TYPE_ETHERNET; + case PCI_CLASS_NETWORK_TOKEN_RING: + return SMBIOS_DEVICE_TYPE_TOKEN_RING; + case PCI_CLASS_MULTIMEDIA_VIDEO: + case PCI_CLASS_MULTIMEDIA_AUDIO: + case PCI_CLASS_MULTIMEDIA_PHONE: + case PCI_CLASS_MULTIMEDIA_OTHER: + return SMBIOS_DEVICE_TYPE_SOUND; + case PCI_CLASS_STORAGE_ATA: + return SMBIOS_DEVICE_TYPE_PATA; + case PCI_CLASS_STORAGE_SATA: + return SMBIOS_DEVICE_TYPE_SATA; + case PCI_CLASS_STORAGE_SAS: + return SMBIOS_DEVICE_TYPE_SAS; + default: + return SMBIOS_DEVICE_TYPE_UNKNOWN; + break; + } + + return SMBIOS_DEVICE_TYPE_UNKNOWN; // safety first + +} +
int smbios_add_string(u8 *start, const char *str) { @@ -999,6 +1062,33 @@ return len; }
+/* Generate Type41 entries from devicetree */ +static int smbios_walk_device_tree_type41(struct device *dev, int *handle, + unsigned long *current) +{ + static u8 type41_instance_cnt = 0; + + if (dev->path.type != DEVICE_PATH_PCI) + return 0; + + u8 device_type = smbios_get_device_type_from_dev(dev); + + if (device_type == SMBIOS_DEVICE_TYPE_OTHER || + device_type == SMBIOS_DEVICE_TYPE_UNKNOWN) + return 0; + + const char *name = smbios_get_name_from_type(device_type); + + return smbios_write_type41(current, handle, + name, // name + type41_instance_cnt++, // instance + 0, // segment + dev->bus->secondary, //bus + PCI_SLOT(dev->path.pci.devfn), //device + PCI_FUNC(dev->path.pci.devfn), //func + device_type); +} + /* Generate Type9 entries from devicetree */ static int smbios_walk_device_tree_type9(struct device *dev, int *handle, unsigned long *current) @@ -1062,6 +1152,7 @@ len += dev->ops->get_smbios_data(dev, handle, current); } len += smbios_walk_device_tree_type9(dev, handle, current); + len += smbios_walk_device_tree_type41(dev, handle, current); } return len; } diff --git a/src/include/device/pci_ids.h b/src/include/device/pci_ids.h index 6453951..bd98e91 100644 --- a/src/include/device/pci_ids.h +++ b/src/include/device/pci_ids.h @@ -18,6 +18,7 @@ #define PCI_CLASS_STORAGE_FLOPPY 0x0102 #define PCI_CLASS_STORAGE_IPI 0x0103 #define PCI_CLASS_STORAGE_RAID 0x0104 +#define PCI_CLASS_STORAGE_ATA 0x0105 #define PCI_CLASS_STORAGE_SATA 0x0106 #define PCI_CLASS_STORAGE_OTHER 0x0180
@@ -3081,6 +3082,7 @@ #define PCI_DEVICE_ID_INTEL_KBL_ID_Y 0x590c #define PCI_DEVICE_ID_INTEL_KBL_ID_H 0x5910 #define PCI_DEVICE_ID_INTEL_KBL_U_R 0x5914 +#define PCI_DEVICE_ID_INTEL_KBL_ID_DT_2 0x5918 #define PCI_DEVICE_ID_INTEL_KBL_ID_DT 0x591f #define PCI_DEVICE_ID_INTEL_CNL_ID_U 0x5A04 #define PCI_DEVICE_ID_INTEL_CNL_ID_Y 0x5A02