[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [v2 PATCH 09/13] SMBIOS: Build full type 4 tables
From: |
Gabriel L. Somlo |
Subject: |
[Qemu-devel] [v2 PATCH 09/13] SMBIOS: Build full type 4 tables |
Date: |
Tue, 11 Mar 2014 11:16:25 -0400 |
From: "Gabriel L. Somlo" <address@hidden>
Build full smbios type 4 (processor information) tables, and make
them available to the bios via fw_cfg.
Signed-off-by: Gabriel Somlo <address@hidden>
---
hw/i386/pc.c | 3 ++
hw/i386/smbios.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++
include/hw/i386/smbios.h | 1 +
3 files changed, 101 insertions(+)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index e715a33..9c4623e 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1011,6 +1011,9 @@ void pc_cpus_init(const char *cpu_model, DeviceState
*icc_bridge)
sysbus_mmio_map_overlap(SYS_BUS_DEVICE(icc_bridge), 0,
APIC_DEFAULT_ADDRESS, 0x1000);
}
+
+ /* tell smbios about cpuid version and features */
+ smbios_set_cpuid(cpu->env.cpuid_version, cpu->env.features[FEAT_1_EDX]);
}
/* pci-info ROM file. Little endian format */
diff --git a/hw/i386/smbios.c b/hw/i386/smbios.c
index c1c0513..e36d48c 100644
--- a/hw/i386/smbios.c
+++ b/hw/i386/smbios.c
@@ -42,6 +42,7 @@ static size_t smbios_entries_len;
static int smbios_type4_count = 0;
static bool smbios_immutable;
static bool smbios_have_defaults;
+static uint32_t smbios_cpuid_version, smbios_cpuid_features; /* for type 4 */
static DECLARE_BITMAP(have_binfile_bitmap, SMBIOS_MAX_TYPE+1);
static DECLARE_BITMAP(have_fields_bitmap, SMBIOS_MAX_TYPE+1);
@@ -65,6 +66,10 @@ static struct {
const char *manufacturer, *version, *serial, *asset;
} type3;
+static struct {
+ const char *sock_pfx, *manufacturer, *version, *serial, *asset, *part;
+} type4;
+
static QemuOptsList qemu_smbios_opts = {
.name = "smbios",
.head = QTAILQ_HEAD_INITIALIZER(qemu_smbios_opts.head),
@@ -206,6 +211,39 @@ static const QemuOptDesc qemu_smbios_type3_opts[] = {
{ /* end of list */ }
};
+static const QemuOptDesc qemu_smbios_type4_opts[] = {
+ {
+ .name = "type",
+ .type = QEMU_OPT_NUMBER,
+ .help = "SMBIOS element type",
+ },{
+ .name = "sock_pfx",
+ .type = QEMU_OPT_STRING,
+ .help = "socket designation string prefix",
+ },{
+ .name = "manufacturer",
+ .type = QEMU_OPT_STRING,
+ .help = "manufacturer name",
+ },{
+ .name = "version",
+ .type = QEMU_OPT_STRING,
+ .help = "version number",
+ },{
+ .name = "serial",
+ .type = QEMU_OPT_STRING,
+ .help = "serial number",
+ },{
+ .name = "asset",
+ .type = QEMU_OPT_STRING,
+ .help = "asset tag number",
+ },{
+ .name = "part",
+ .type = QEMU_OPT_STRING,
+ .help = "part number",
+ },
+ { /* end of list */ }
+};
+
static void smbios_register_config(void)
{
qemu_add_opts(&qemu_smbios_opts);
@@ -400,11 +438,48 @@ static void smbios_build_type_3_table(void)
SMBIOS_BUILD_TABLE_POST;
}
+static void smbios_build_type_4_table(unsigned instance)
+{
+ char sock_str[128];
+
+ SMBIOS_BUILD_TABLE_PRE(4, 0x400 + instance, true); /* required */
+
+ snprintf(sock_str, sizeof(sock_str), "%s%2x", type4.sock_pfx, instance);
+ SMBIOS_TABLE_SET_STR(4, socket_designation_str, sock_str);
+ t->processor_type = 0x03; /* CPU */
+ t->processor_family = 0x01; /* Other */
+ SMBIOS_TABLE_SET_STR(4, processor_manufacturer_str, type4.manufacturer);
+ t->processor_id[0] = smbios_cpuid_version;
+ t->processor_id[1] = smbios_cpuid_features;
+ SMBIOS_TABLE_SET_STR(4, processor_version_str, type4.version);
+ t->voltage = 0;
+ t->external_clock = 0;
+ t->max_speed = 2000; /* hardcoded in SeaBIOS (use 0/Unknown instead ?) */
+ t->current_speed = 2000; /* hardcoded in SeaBIOS (use 0/Unknown ?) */
+ t->status = 0x41; /* Socket populated, CPU enabled */
+ t->processor_upgrade = 0x01; /* Other */
+ t->l1_cache_handle = 0xFFFF; /* N/A */
+ t->l2_cache_handle = 0xFFFF; /* N/A */
+ t->l3_cache_handle = 0xFFFF; /* N/A */
+ SMBIOS_TABLE_SET_STR(4, serial_number_str, type4.serial);
+ SMBIOS_TABLE_SET_STR(4, asset_tag_number_str, type4.asset);
+ SMBIOS_TABLE_SET_STR(4, part_number_str, type4.part);
+
+ SMBIOS_BUILD_TABLE_POST;
+ smbios_type4_count++;
+}
+
#define SMBIOS_SET_DEFAULT(field, value) \
if (!field) { \
field = value; \
}
+void smbios_set_cpuid(uint32_t version, uint32_t features)
+{
+ smbios_cpuid_version = version;
+ smbios_cpuid_features = features;
+}
+
void smbios_set_defaults(const char *manufacturer,
const char *product, const char *version)
{
@@ -420,15 +495,24 @@ void smbios_set_defaults(const char *manufacturer,
SMBIOS_SET_DEFAULT(type2.version, version);
SMBIOS_SET_DEFAULT(type3.manufacturer, manufacturer);
SMBIOS_SET_DEFAULT(type3.version, version);
+ SMBIOS_SET_DEFAULT(type4.sock_pfx, "CPU");
+ SMBIOS_SET_DEFAULT(type4.manufacturer, manufacturer);
+ SMBIOS_SET_DEFAULT(type4.version, version);
}
uint8_t *smbios_get_table(size_t *length)
{
+ unsigned i;
+
if (!smbios_immutable) {
smbios_build_type_0_table();
smbios_build_type_1_table();
smbios_build_type_2_table();
smbios_build_type_3_table();
+ for (i = 0; i < smp_cpus; i++) {
+ /* count CPUs starting with 1, to minimize diff vs. SeaBIOS */
+ smbios_build_type_4_table(i + 1);
+ }
smbios_validate_table();
smbios_immutable = true;
}
@@ -586,6 +670,19 @@ void smbios_entry_add(QemuOpts *opts)
save_opt(&type3.serial, opts, "serial");
save_opt(&type3.asset, opts, "asset");
return;
+ case 4:
+ qemu_opts_validate(opts, qemu_smbios_type4_opts, &local_err);
+ if (local_err) {
+ error_report("%s", error_get_pretty(local_err));
+ exit(1);
+ }
+ save_opt(&type4.sock_pfx, opts, "sock_pfx");
+ save_opt(&type4.manufacturer, opts, "manufacturer");
+ save_opt(&type4.version, opts, "version");
+ save_opt(&type4.serial, opts, "serial");
+ save_opt(&type4.asset, opts, "asset");
+ save_opt(&type4.part, opts, "part");
+ return;
default:
error_report("Don't know how to build fields for SMBIOS type %ld",
type);
diff --git a/include/hw/i386/smbios.h b/include/hw/i386/smbios.h
index d0fb908..bc05a5f 100644
--- a/include/hw/i386/smbios.h
+++ b/include/hw/i386/smbios.h
@@ -18,6 +18,7 @@
#define SMBIOS_MAX_TYPE 127
void smbios_entry_add(QemuOpts *opts);
+void smbios_set_cpuid(uint32_t version, uint32_t features);
void smbios_set_defaults(const char *manufacturer,
const char *product, const char *version);
uint8_t *smbios_get_table(size_t *length);
--
1.8.1.4
- Re: [Qemu-devel] SMBIOS (Set of 10 patches), (continued)
- Re: [Qemu-devel] SMBIOS (Set of 10 patches), Kevin O'Connor, 2014/03/11
- [Qemu-devel] [v2 PATCH 00/13] SMBIOS: build full tables in QEMU, Gabriel L. Somlo, 2014/03/11
- [Qemu-devel] [v2 PATCH 01/13] SMBIOS: Update all table definitions to smbios spec v2.3, Gabriel L. Somlo, 2014/03/11
- [Qemu-devel] [v2 PATCH 02/13] SMBIOS: Rename smbios_set_type1_defaults() for more general use, Gabriel L. Somlo, 2014/03/11
- [Qemu-devel] [v2 PATCH 03/13] SMBIOS: Use macro to set smbios defaults, Gabriel L. Somlo, 2014/03/11
- [Qemu-devel] [v2 PATCH 04/13] SMBIOS: Use bitmaps to check for smbios table collisions, Gabriel L. Somlo, 2014/03/11
- [Qemu-devel] [v2 PATCH 05/13] SMBIOS: Add code to build full smbios tables; build type 2 table, Gabriel L. Somlo, 2014/03/11
- [Qemu-devel] [v3 PATCH 05/13] SMBIOS: Add code to build full smbios tables; build type 2 table, Gabriel L. Somlo, 2014/03/11
- [Qemu-devel] [v2 PATCH 06/13] SMBIOS: Build full tables for types 0 and 1, Gabriel L. Somlo, 2014/03/11
- [Qemu-devel] [v2 PATCH 09/13] SMBIOS: Build full type 4 tables,
Gabriel L. Somlo <=
- [Qemu-devel] [v2 PATCH 08/13] SMBIOS: Build full type 3 table, Gabriel L. Somlo, 2014/03/11
- [Qemu-devel] [v2 PATCH 10/13] SMBIOS: Build full smbios v2.3 compliant type 16 and 17 tables, Gabriel L. Somlo, 2014/03/11
- [Qemu-devel] [v2 PATCH 07/13] SMBIOS: Remove unused code for passing individual fields to bios, Gabriel L. Somlo, 2014/03/11
- [Qemu-devel] [v2 PATCH 12/13] SMBIOS: Build full type 20 tables, Gabriel L. Somlo, 2014/03/11
- [Qemu-devel] [v2 PATCH 13/13] SMBIOS: Build full tables for type 32 and 127, Gabriel L. Somlo, 2014/03/11
- [Qemu-devel] [v2 PATCH 11/13] SMBIOS: Build full type 19 tables, Gabriel L. Somlo, 2014/03/11
- Re: [Qemu-devel] [v2 PATCH 11/13] SMBIOS: Build full type 19 tables, Gerd Hoffmann, 2014/03/12
- Re: [Qemu-devel] [v2 PATCH 11/13] SMBIOS: Build full type 19 tables, Gabriel L. Somlo, 2014/03/12
- Re: [Qemu-devel] [v2 PATCH 11/13] SMBIOS: Build full type 19 tables, Gerd Hoffmann, 2014/03/12
- Re: [Qemu-devel] [v2 PATCH 11/13] SMBIOS: Build full type 19 tables, Gabriel L. Somlo, 2014/03/12