[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 38/55] hw/smbios: support for type 8 (port connector)
From: |
Michael S. Tsirkin |
Subject: |
[PULL 38/55] hw/smbios: support for type 8 (port connector) |
Date: |
Mon, 10 Oct 2022 13:31:27 -0400 |
From: Hal Martin <hal.martin@gmail.com>
PATCH v1: add support for SMBIOS type 8 to qemu
PATCH v2: incorporate patch v1 feedback and add smbios type=8 to qemu-options
internal_reference: internal reference designator
external_reference: external reference designator
connector_type: hex value for port connector type (see SMBIOS 7.9.2)
port_type: hex value for port type (see SMBIOS 7.9.3)
After studying various vendor implementationsi (Dell, Lenovo, MSI),
the value of internal connector type was hard-coded to 0x0 (None).
Example usage:
-smbios
type=8,internal_reference=JUSB1,external_reference=USB1,connector_type=0x12,port_type=0x10
\
-smbios type=8,internal_reference=JAUD1,external_reference="Audio
Jack",connector_type=0x1f,port_type=0x1d \
-smbios
type=8,internal_reference=LAN,external_reference=Ethernet,connector_type=0x0b,port_type=0x1f
\
-smbios
type=8,internal_reference=PS2,external_reference=Mouse,connector_type=0x0f,port_type=0x0e
\
-smbios
type=8,internal_reference=PS2,external_reference=Keyboard,connector_type=0x0f,port_type=0x0d
Signed-off-by: Hal Martin <hal.martin@gmail.com>
Message-Id: <20220812135153.17859-1-hal.martin@gmail.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/firmware/smbios.h | 10 ++++++
hw/smbios/smbios.c | 63 ++++++++++++++++++++++++++++++++++++
qemu-options.hx | 2 ++
3 files changed, 75 insertions(+)
diff --git a/include/hw/firmware/smbios.h b/include/hw/firmware/smbios.h
index 4b7ad77a44..e7d386f7c8 100644
--- a/include/hw/firmware/smbios.h
+++ b/include/hw/firmware/smbios.h
@@ -189,6 +189,16 @@ struct smbios_type_4 {
uint16_t processor_family2;
} QEMU_PACKED;
+/* SMBIOS type 8 - Port Connector Information */
+struct smbios_type_8 {
+ struct smbios_structure_header header;
+ uint8_t internal_reference_str;
+ uint8_t internal_connector_type;
+ uint8_t external_reference_str;
+ uint8_t external_connector_type;
+ uint8_t port_type;
+} QEMU_PACKED;
+
/* SMBIOS type 11 - OEM strings */
struct smbios_type_11 {
struct smbios_structure_header header;
diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index 4c9f664830..51437ca09f 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -111,6 +111,13 @@ static struct {
.processor_id = 0,
};
+struct type8_instance {
+ const char *internal_reference, *external_reference;
+ uint8_t connector_type, port_type;
+ QTAILQ_ENTRY(type8_instance) next;
+};
+static QTAILQ_HEAD(, type8_instance) type8 = QTAILQ_HEAD_INITIALIZER(type8);
+
static struct {
size_t nvalues;
char **values;
@@ -337,6 +344,29 @@ static const QemuOptDesc qemu_smbios_type4_opts[] = {
{ /* end of list */ }
};
+static const QemuOptDesc qemu_smbios_type8_opts[] = {
+ {
+ .name = "internal_reference",
+ .type = QEMU_OPT_STRING,
+ .help = "internal reference designator",
+ },
+ {
+ .name = "external_reference",
+ .type = QEMU_OPT_STRING,
+ .help = "external reference designator",
+ },
+ {
+ .name = "connector_type",
+ .type = QEMU_OPT_NUMBER,
+ .help = "connector type",
+ },
+ {
+ .name = "port_type",
+ .type = QEMU_OPT_NUMBER,
+ .help = "port type",
+ },
+};
+
static const QemuOptDesc qemu_smbios_type11_opts[] = {
{
.name = "value",
@@ -718,6 +748,26 @@ static void smbios_build_type_4_table(MachineState *ms,
unsigned instance)
smbios_type4_count++;
}
+static void smbios_build_type_8_table(void)
+{
+ unsigned instance = 0;
+ struct type8_instance *t8;
+
+ QTAILQ_FOREACH(t8, &type8, next) {
+ SMBIOS_BUILD_TABLE_PRE(8, T0_BASE + instance, true);
+
+ SMBIOS_TABLE_SET_STR(8, internal_reference_str,
t8->internal_reference);
+ SMBIOS_TABLE_SET_STR(8, external_reference_str,
t8->external_reference);
+ /* most vendors seem to set this to None */
+ t->internal_connector_type = 0x0;
+ t->external_connector_type = t8->connector_type;
+ t->port_type = t8->port_type;
+
+ SMBIOS_BUILD_TABLE_POST;
+ instance++;
+ }
+}
+
static void smbios_build_type_11_table(void)
{
char count_str[128];
@@ -1030,6 +1080,7 @@ void smbios_get_tables(MachineState *ms,
smbios_build_type_4_table(ms, i);
}
+ smbios_build_type_8_table();
smbios_build_type_11_table();
#define MAX_DIMM_SZ (16 * GiB)
@@ -1348,6 +1399,18 @@ void smbios_entry_add(QemuOpts *opts, Error **errp)
UINT16_MAX);
}
return;
+ case 8:
+ if (!qemu_opts_validate(opts, qemu_smbios_type8_opts, errp)) {
+ return;
+ }
+ struct type8_instance *t;
+ t = g_new0(struct type8_instance, 1);
+ save_opt(&t->internal_reference, opts, "internal_reference");
+ save_opt(&t->external_reference, opts, "external_reference");
+ t->connector_type = qemu_opt_get_number(opts, "connector_type", 0);
+ t->port_type = qemu_opt_get_number(opts, "port_type", 0);
+ QTAILQ_INSERT_TAIL(&type8, t, next);
+ return;
case 11:
if (!qemu_opts_validate(opts, qemu_smbios_type11_opts, errp)) {
return;
diff --git a/qemu-options.hx b/qemu-options.hx
index 95b998a13b..c0bb74655c 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -2572,6 +2572,8 @@ DEF("smbios", HAS_ARG, QEMU_OPTION_smbios,
" [,asset=str][,part=str][,max-speed=%d][,current-speed=%d]\n"
" [,processor-id=%d]\n"
" specify SMBIOS type 4 fields\n"
+ "-smbios
type=8[,external_reference=str][,internal_reference=str][,connector_type=%d][,port_type=%d]\n"
+ " specify SMBIOS type 8 fields\n"
"-smbios type=11[,value=str][,path=filename]\n"
" specify SMBIOS type 11 fields\n"
"-smbios
type=17[,loc_pfx=str][,bank=str][,manufacturer=str][,serial=str]\n"
--
MST
- Re: [PULL 29/55] Revert "intel_iommu: Fix irqchip / X2APIC configuration checks", (continued)
[PULL 31/55] qmp: add QMP command x-query-virtio-status, Michael S. Tsirkin, 2022/10/10
[PULL 30/55] qmp: add QMP command x-query-virtio, Michael S. Tsirkin, 2022/10/10
[PULL 33/55] qmp: add QMP commands for virtio/vhost queue-status, Michael S. Tsirkin, 2022/10/10
[PULL 32/55] qmp: decode feature & status bits in virtio-status, Michael S. Tsirkin, 2022/10/10
[PULL 34/55] qmp: add QMP command x-query-virtio-queue-element, Michael S. Tsirkin, 2022/10/10
[PULL 35/55] hmp: add virtio commands, Michael S. Tsirkin, 2022/10/10
[PULL 36/55] pci: Remove unused pci_get_*_by_mask() functions, Michael S. Tsirkin, 2022/10/10
[PULL 37/55] pci: Sanity check mask argument to pci_set_*_by_mask(), Michael S. Tsirkin, 2022/10/10
[PULL 38/55] hw/smbios: support for type 8 (port connector),
Michael S. Tsirkin <=
[PULL 39/55] tests: acpi: whitelist pc/q35 DSDT due to HPET AML move, Michael S. Tsirkin, 2022/10/10
[PULL 40/55] acpi: x86: deduplicate HPET AML building, Michael S. Tsirkin, 2022/10/10
[PULL 41/55] tests: acpi: update expected blobs after HPET move, Michael S. Tsirkin, 2022/10/10
[PULL 43/55] acpi: x86: refactor PDSM method to reduce nesting, Michael S. Tsirkin, 2022/10/10
[PULL 42/55] tests: acpi: whitelist pc/q35 DSDT due to HPET AML move, Michael S. Tsirkin, 2022/10/10
[PULL 44/55] x86: acpi: _DSM: use Package to pass parameters, Michael S. Tsirkin, 2022/10/10
[PULL 45/55] tests: acpi: update expected blobs, Michael S. Tsirkin, 2022/10/10
[PULL 46/55] tests: acpi: whitelist pc/q35 DSDT before switching _DSM to use ASUN, Michael S. Tsirkin, 2022/10/10
[PULL 47/55] x86: acpi: cleanup PCI device _DSM duplication, Michael S. Tsirkin, 2022/10/10
[PULL 48/55] tests: acpi: update expected blobs, Michael S. Tsirkin, 2022/10/10