All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Ani Sinha" <ani@anisinha.ca>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Igor Mammedov" <imammedo@redhat.com>
Subject: [PULL v2 06/47] hw/smbios: code cleanup - use macro definitions for table header handles
Date: Mon, 7 Mar 2022 05:01:40 -0500	[thread overview]
Message-ID: <20220307100058.449628-7-mst@redhat.com> (raw)
In-Reply-To: <20220307100058.449628-1-mst@redhat.com>

From: Ani Sinha <ani@anisinha.ca>

This is a minor cleanup. Using macro definitions makes the code more
readable. It is at once clear which tables use which handle numbers in their
header. It also makes it easy to calculate the gaps between the numbers and
update them if needed.

Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Ani Sinha <ani@anisinha.ca>
Message-Id: <20220223143322.927136-6-ani@anisinha.ca>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/smbios/smbios.c | 38 ++++++++++++++++++++++++++------------
 1 file changed, 26 insertions(+), 12 deletions(-)

diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index 6013df1698..56b412ce35 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -549,9 +549,23 @@ bool smbios_skip_table(uint8_t type, bool required_table)
     return true;
 }
 
+#define T0_BASE 0x000
+#define T1_BASE 0x100
+#define T2_BASE 0x200
+#define T3_BASE 0x300
+#define T4_BASE 0x400
+#define T11_BASE 0xe00
+
+#define T16_BASE 0x1000
+#define T17_BASE 0x1100
+#define T19_BASE 0x1300
+#define T32_BASE 0x2000
+#define T41_BASE 0x2900
+#define T127_BASE 0x7F00
+
 static void smbios_build_type_0_table(void)
 {
-    SMBIOS_BUILD_TABLE_PRE(0, 0x000, false); /* optional, leave up to BIOS */
+    SMBIOS_BUILD_TABLE_PRE(0, T0_BASE, false); /* optional, leave up to BIOS */
 
     SMBIOS_TABLE_SET_STR(0, vendor_str, type0.vendor);
     SMBIOS_TABLE_SET_STR(0, bios_version_str, type0.version);
@@ -599,7 +613,7 @@ static void smbios_encode_uuid(struct smbios_uuid *uuid, QemuUUID *in)
 
 static void smbios_build_type_1_table(void)
 {
-    SMBIOS_BUILD_TABLE_PRE(1, 0x100, true); /* required */
+    SMBIOS_BUILD_TABLE_PRE(1, T1_BASE, true); /* required */
 
     SMBIOS_TABLE_SET_STR(1, manufacturer_str, type1.manufacturer);
     SMBIOS_TABLE_SET_STR(1, product_name_str, type1.product);
@@ -619,7 +633,7 @@ static void smbios_build_type_1_table(void)
 
 static void smbios_build_type_2_table(void)
 {
-    SMBIOS_BUILD_TABLE_PRE(2, 0x200, false); /* optional */
+    SMBIOS_BUILD_TABLE_PRE(2, T2_BASE, false); /* optional */
 
     SMBIOS_TABLE_SET_STR(2, manufacturer_str, type2.manufacturer);
     SMBIOS_TABLE_SET_STR(2, product_str, type2.product);
@@ -637,7 +651,7 @@ static void smbios_build_type_2_table(void)
 
 static void smbios_build_type_3_table(void)
 {
-    SMBIOS_BUILD_TABLE_PRE(3, 0x300, true); /* required */
+    SMBIOS_BUILD_TABLE_PRE(3, T3_BASE, true); /* required */
 
     SMBIOS_TABLE_SET_STR(3, manufacturer_str, type3.manufacturer);
     t->type = 0x01; /* Other */
@@ -662,7 +676,7 @@ static void smbios_build_type_4_table(MachineState *ms, unsigned instance)
 {
     char sock_str[128];
 
-    SMBIOS_BUILD_TABLE_PRE(4, 0x400 + instance, true); /* required */
+    SMBIOS_BUILD_TABLE_PRE(4, T4_BASE + 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);
@@ -702,7 +716,7 @@ static void smbios_build_type_11_table(void)
         return;
     }
 
-    SMBIOS_BUILD_TABLE_PRE(11, 0xe00, true); /* required */
+    SMBIOS_BUILD_TABLE_PRE(11, T11_BASE, true); /* required */
 
     snprintf(count_str, sizeof(count_str), "%zu", type11.nvalues);
     t->count = type11.nvalues;
@@ -722,7 +736,7 @@ static void smbios_build_type_16_table(unsigned dimm_cnt)
 {
     uint64_t size_kb;
 
-    SMBIOS_BUILD_TABLE_PRE(16, 0x1000, true); /* required */
+    SMBIOS_BUILD_TABLE_PRE(16, T16_BASE, true); /* required */
 
     t->location = 0x01; /* Other */
     t->use = 0x03; /* System memory */
@@ -749,7 +763,7 @@ static void smbios_build_type_17_table(unsigned instance, uint64_t size)
     char loc_str[128];
     uint64_t size_mb;
 
-    SMBIOS_BUILD_TABLE_PRE(17, 0x1100 + instance, true); /* required */
+    SMBIOS_BUILD_TABLE_PRE(17, T17_BASE + instance, true); /* required */
 
     t->physical_memory_array_handle = cpu_to_le16(0x1000); /* Type 16 above */
     t->memory_error_information_handle = cpu_to_le16(0xFFFE); /* Not provided */
@@ -790,7 +804,7 @@ static void smbios_build_type_19_table(unsigned instance,
 {
     uint64_t end, start_kb, end_kb;
 
-    SMBIOS_BUILD_TABLE_PRE(19, 0x1300 + instance, true); /* required */
+    SMBIOS_BUILD_TABLE_PRE(19, T19_BASE + instance, true); /* required */
 
     end = start + size - 1;
     assert(end > start);
@@ -814,7 +828,7 @@ static void smbios_build_type_19_table(unsigned instance,
 
 static void smbios_build_type_32_table(void)
 {
-    SMBIOS_BUILD_TABLE_PRE(32, 0x2000, true); /* required */
+    SMBIOS_BUILD_TABLE_PRE(32, T32_BASE, true); /* required */
 
     memset(t->reserved, 0, 6);
     t->boot_status = 0; /* No errors detected */
@@ -828,7 +842,7 @@ static void smbios_build_type_41_table(Error **errp)
     struct type41_instance *t41;
 
     QTAILQ_FOREACH(t41, &type41, next) {
-        SMBIOS_BUILD_TABLE_PRE(41, 0x2900 + instance, true);
+        SMBIOS_BUILD_TABLE_PRE(41, T41_BASE + instance, true);
 
         SMBIOS_TABLE_SET_STR(41, reference_designation_str, t41->designation);
         t->device_type = t41->kind;
@@ -871,7 +885,7 @@ static void smbios_build_type_41_table(Error **errp)
 
 static void smbios_build_type_127_table(void)
 {
-    SMBIOS_BUILD_TABLE_PRE(127, 0x7F00, true); /* required */
+    SMBIOS_BUILD_TABLE_PRE(127, T127_BASE, true); /* required */
     SMBIOS_BUILD_TABLE_POST;
 }
 
-- 
MST



  parent reply	other threads:[~2022-03-07 10:10 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-07 10:01 [PULL v2 00/47] virtio,pc,pci: features, cleanups, fixes Michael S. Tsirkin
2022-03-07 10:01 ` [PULL v2 01/47] qom: assert integer does not overflow Michael S. Tsirkin
2022-03-07 10:01 ` [PULL v2 02/47] ACPI ERST: specification for ERST support Michael S. Tsirkin
2022-03-07 10:01 ` [PULL v2 03/47] MAINTAINERS: no need to add my name explicitly as a reviewer for VIOT tables Michael S. Tsirkin
2022-03-07 10:01 ` [PULL v2 04/47] docs/acpi/erst: add device id for ACPI ERST device in pci-ids.txt Michael S. Tsirkin
2022-03-07 10:01 ` [PULL v2 05/47] hw/acpi/erst: clean up unused IS_UEFI_CPER_RECORD macro Michael S. Tsirkin
2022-03-07 10:01 ` Michael S. Tsirkin [this message]
2022-03-07 10:01 ` [PULL v2 07/47] hw/smbios: fix overlapping table handle numbers with large memory vms Michael S. Tsirkin
2022-03-07 10:01 ` [PULL v2 08/47] hw/smbios: add assertion to ensure handles of tables 19 and 32 do not collide Michael S. Tsirkin
2022-03-07 10:01 ` [PULL v2 09/47] vhost-user: remove VirtQ notifier restore Michael S. Tsirkin
2022-03-07 10:01 ` [PULL v2 10/47] vhost-user: fix VirtQ notifier cleanup Michael S. Tsirkin
2022-03-07 10:01 ` [PULL v2 11/47] virtio: fix the condition for iommu_platform not supported Michael S. Tsirkin
2022-03-07 10:01 ` [PULL v2 12/47] hw/vhost-user-i2c: Add support for VIRTIO_I2C_F_ZERO_LENGTH_REQUEST Michael S. Tsirkin
2022-03-07 10:02 ` [PULL v2 13/47] hw/virtio: vdpa: Fix leak of host-notifier memory-region Michael S. Tsirkin
2022-03-07 10:02 ` [PULL v2 14/47] vhost-vdpa: make notifiers _init()/_uninit() symmetric Michael S. Tsirkin
2022-03-07 10:02 ` [PULL v2 15/47] intel_iommu: support snoop control Michael S. Tsirkin
2022-03-07 10:02 ` [PULL v2 16/47] hw/i386: Improve bounds checking in OVMF table parsing Michael S. Tsirkin
2022-03-07 10:02 ` [PULL v2 17/47] hw/i386: Replace magic number with field length calculation Michael S. Tsirkin
2022-03-07 10:02 ` [PULL v2 18/47] virtio-iommu: Default to bypass during boot Michael S. Tsirkin
2022-03-07 10:02 ` [PULL v2 19/47] virtio-iommu: Support bypass domain Michael S. Tsirkin
2022-03-07 10:02 ` [PULL v2 20/47] tests/qtest/virtio-iommu-test: Check bypass config Michael S. Tsirkin
2022-03-07 10:02 ` [PULL v2 21/47] hw/i386/pc_piix: Mark the machine types from version 1.4 to 1.7 as deprecated Michael S. Tsirkin
2022-03-07 10:02 ` [PULL v2 22/47] hw/pci-bridge/pxb: Fix missing swizzle Michael S. Tsirkin
2022-03-07 10:02 ` [PULL v2 23/47] virtio-net: Unlimit tx queue size if peer is vdpa Michael S. Tsirkin
2022-03-07 10:02 ` [PULL v2 24/47] pcie: Add support for Single Root I/O Virtualization (SR/IOV) Michael S. Tsirkin
2022-03-07 10:02 ` [PULL v2 25/47] pcie: Add some SR/IOV API documentation in docs/pcie_sriov.txt Michael S. Tsirkin
2022-03-07 10:02 ` [PULL v2 26/47] pcie: Add a helper to the SR/IOV API Michael S. Tsirkin
2022-03-07 10:02 ` [PULL v2 27/47] pcie: Add 1.2 version token for the Power Management Capability Michael S. Tsirkin
2022-03-07 10:02 ` [PULL v2 28/47] pci-bridge/xio3130_upstream: Fix error handling Michael S. Tsirkin
2022-03-07 10:02 ` [PULL v2 29/47] pci-bridge/xio3130_downstream: " Michael S. Tsirkin
2022-03-07 10:02 ` [PULL v2 30/47] headers: Add pvpanic.h Michael S. Tsirkin
2022-03-07 10:02 ` [PULL v2 31/47] hw/misc/pvpanic: Use standard headers instead Michael S. Tsirkin
2022-03-07 10:02 ` [PULL v2 32/47] pci: show id info when pci BDF conflict Michael S. Tsirkin
2022-03-07 10:02 ` [PULL v2 33/47] pci: expose TYPE_XIO3130_DOWNSTREAM name Michael S. Tsirkin
2022-03-07 10:03 ` [PULL v2 34/47] acpi: pcihp: pcie: set power on cap on parent slot Michael S. Tsirkin
2022-03-07 10:03 ` [PULL v2 35/47] pc: add option to disable PS/2 mouse/keyboard Michael S. Tsirkin
2022-03-07 10:03 ` [PULL v2 36/47] vhost-vsock: detach the virqueue element in case of error Michael S. Tsirkin
2022-03-07 10:03 ` [PULL v2 37/47] x86: cleanup unused compat_apic_id_mode Michael S. Tsirkin
2022-03-07 10:03 ` [PULL v2 38/47] hw/smbios: Add table 4 parameter, "processor-id" Michael S. Tsirkin
2022-03-07 10:03 ` [PULL v2 39/47] pci: drop COMPAT_PROP_PCP for 2.0 machine types Michael S. Tsirkin
2022-03-07 10:03 ` [PULL v2 40/47] event_notifier: add event_notifier_get_wfd() Michael S. Tsirkin
2022-03-07 10:03 ` [PULL v2 41/47] vhost: use wfd on functions setting vring call fd Michael S. Tsirkin
2022-03-07 10:03 ` [PULL v2 42/47] configure, meson: allow enabling vhost-user on all POSIX systems Michael S. Tsirkin
2022-03-07 10:03 ` [PULL v2 43/47] docs: vhost-user: add subsection for non-Linux platforms Michael S. Tsirkin
2022-03-07 10:03 ` [PULL v2 44/47] tests/acpi: i386: allow FACP acpi table changes Michael S. Tsirkin
2022-03-07 10:03 ` [PULL v2 45/47] hw/acpi: add indication for i8042 in IA-PC boot flags of the FADT table Michael S. Tsirkin
2022-03-07 10:03 ` [PULL v2 46/47] tests/acpi: i386: update FACP table differences Michael S. Tsirkin
2022-03-07 10:03 ` [PULL v2 47/47] hw/acpi/microvm: turn on 8042 bit in FADT boot architecture flags if present Michael S. Tsirkin
2022-03-07 17:06 ` [PULL v2 00/47] virtio,pc,pci: features, cleanups, fixes Peter Maydell
2022-03-07 17:13   ` Peter Maydell
2022-03-07 22:52     ` Michael S. Tsirkin
2022-03-08  9:05       ` Peter Maydell
2022-03-08 11:01         ` Michael S. Tsirkin
2022-03-08 11:18           ` Peter Maydell
2022-03-08 11:23             ` Michael S. Tsirkin
2022-03-08 13:19             ` Philippe Mathieu-Daudé
2022-03-15 18:41               ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220307100058.449628-7-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=ani@anisinha.ca \
    --cc=f4bug@amsat.org \
    --cc=imammedo@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.