git: 6d67af5f8e66 - main - Revert "ipmi_smbios: Deduplicate smbios entry point discovery logic"
Allan Jude
allanjude at FreeBSD.org
Tue Feb 23 22:49:31 UTC 2021
The branch main has been updated by allanjude:
URL: https://cgit.FreeBSD.org/src/commit/?id=6d67af5f8e66218ab0b3d927837fe00903c2feac
commit 6d67af5f8e66218ab0b3d927837fe00903c2feac
Author: Allan Jude <allanjude at FreeBSD.org>
AuthorDate: 2021-02-23 22:48:42 +0000
Commit: Allan Jude <allanjude at FreeBSD.org>
CommitDate: 2021-02-23 22:49:13 +0000
Revert "ipmi_smbios: Deduplicate smbios entry point discovery logic"
This depends on another commit that has not landed yet, and broke the build
This reverts commit ba6e37e47f41484fc61cc034619267b82ddd056c.
---
sys/dev/ipmi/ipmi_isa.c | 1 -
sys/dev/ipmi/ipmi_pci.c | 1 -
sys/dev/ipmi/ipmi_smbios.c | 46 ++++++++++++++++++++++++++++++----------------
sys/dev/ipmi/ipmi_smbus.c | 1 -
sys/dev/smbios/smbios.c | 21 ---------------------
sys/dev/smbios/smbios.h | 2 --
6 files changed, 30 insertions(+), 42 deletions(-)
diff --git a/sys/dev/ipmi/ipmi_isa.c b/sys/dev/ipmi/ipmi_isa.c
index 2831b53e4586..cdff305b07ec 100644
--- a/sys/dev/ipmi/ipmi_isa.c
+++ b/sys/dev/ipmi/ipmi_isa.c
@@ -286,4 +286,3 @@ static driver_t ipmi_isa_driver = {
};
DRIVER_MODULE(ipmi_isa, isa, ipmi_isa_driver, ipmi_devclass, 0, 0);
-MODULE_DEPEND(ipmi_isa, smbios, 1, 1, 1);
diff --git a/sys/dev/ipmi/ipmi_pci.c b/sys/dev/ipmi/ipmi_pci.c
index 1697a4c31c2a..d4598f9db873 100644
--- a/sys/dev/ipmi/ipmi_pci.c
+++ b/sys/dev/ipmi/ipmi_pci.c
@@ -179,7 +179,6 @@ static driver_t ipmi_pci_driver = {
};
DRIVER_MODULE(ipmi_pci, pci, ipmi_pci_driver, ipmi_devclass, 0, 0);
-MODULE_DEPEND(ipmi_pci, smbios, 1, 1, 1);
/* Native IPMI on PCI driver. */
diff --git a/sys/dev/ipmi/ipmi_smbios.c b/sys/dev/ipmi/ipmi_smbios.c
index 735f404eec5f..308a3b076ef7 100644
--- a/sys/dev/ipmi/ipmi_smbios.c
+++ b/sys/dev/ipmi/ipmi_smbios.c
@@ -88,7 +88,7 @@ MTX_SYSINIT(ipmi_info, &ipmi_info_mtx, "ipmi info", MTX_DEF);
static void ipmi_smbios_probe(struct ipmi_get_info *);
static int smbios_cksum(struct smbios_eps *);
-static void smbios_walk_table(uint8_t *, vm_size_t, smbios_callback_t,
+static void smbios_walk_table(uint8_t *, int, smbios_callback_t,
void *);
static void smbios_ipmi_info(struct smbios_structure_header *, void *);
@@ -147,12 +147,11 @@ smbios_ipmi_info(struct smbios_structure_header *h, void *arg)
}
static void
-smbios_walk_table(uint8_t *table, vm_size_t size, smbios_callback_t cb, void *arg)
+smbios_walk_table(uint8_t *p, int entries, smbios_callback_t cb, void *arg)
{
struct smbios_structure_header *s;
- uint8_t *p;
- for (p = table; p < table + size;) {
+ while (entries--) {
s = (struct smbios_structure_header *)p;
cb(s, arg);
@@ -161,11 +160,8 @@ smbios_walk_table(uint8_t *table, vm_size_t size, smbios_callback_t cb, void *ar
* formatted area of this structure.
*/
p += s->length;
- while (!(p[0] == 0 && p[1] == 0)) {
+ while (!(p[0] == 0 && p[1] == 0))
p++;
- if (p >= table + size)
- return;
- }
/*
* Skip over the double-nul to the start of the next
@@ -183,23 +179,41 @@ smbios_walk_table(uint8_t *table, vm_size_t size, smbios_callback_t cb, void *ar
static void
ipmi_smbios_probe(struct ipmi_get_info *info)
{
+ struct smbios_eps *header;
void *table;
- vm_paddr_t table_paddr;
- vm_size_t table_size;
- int err;
+ u_int32_t addr;
bzero(info, sizeof(struct ipmi_get_info));
- err = smbios_get_structure_table(&table_paddr, &table_size);
- if (err != 0)
+ /* Find the SMBIOS table header. */
+ addr = bios_sigsearch(SMBIOS_START, SMBIOS_SIG, SMBIOS_LEN,
+ SMBIOS_STEP, SMBIOS_OFF);
+ if (addr == 0)
return;
- table = pmap_mapbios(table_paddr, table_size);
+ /*
+ * Map the header. We first map a fixed size to get the actual
+ * length and then map it a second time with the actual length so
+ * we can verify the checksum.
+ */
+ header = pmap_mapbios(addr, sizeof(struct smbios_eps));
+ table = pmap_mapbios(addr, header->length);
+ pmap_unmapbios((vm_offset_t)header, sizeof(struct smbios_eps));
+ header = table;
+ if (smbios_cksum(header) != 0) {
+ pmap_unmapbios((vm_offset_t)header, header->length);
+ return;
+ }
- smbios_walk_table(table, table_size, smbios_ipmi_info, info);
+ /* Now map the actual table and walk it looking for an IPMI entry. */
+ table = pmap_mapbios(header->structure_table_address,
+ header->structure_table_length);
+ smbios_walk_table(table, header->number_structures, smbios_ipmi_info,
+ info);
/* Unmap everything. */
- pmap_unmapbios((vm_offset_t)table, table_size);
+ pmap_unmapbios((vm_offset_t)table, header->structure_table_length);
+ pmap_unmapbios((vm_offset_t)header, header->length);
}
/*
diff --git a/sys/dev/ipmi/ipmi_smbus.c b/sys/dev/ipmi/ipmi_smbus.c
index bc7377e5aee8..212248f0217e 100644
--- a/sys/dev/ipmi/ipmi_smbus.c
+++ b/sys/dev/ipmi/ipmi_smbus.c
@@ -131,4 +131,3 @@ static driver_t ipmi_smbus_driver = {
DRIVER_MODULE(ipmi_smbus, smbus, ipmi_smbus_driver, ipmi_devclass, 0, 0);
MODULE_DEPEND(ipmi_smbus, smbus, SMBUS_MINVER, SMBUS_PREFVER, SMBUS_MAXVER);
-MODULE_DEPEND(ipmi_smbus, smbios, 1, 1, 1);
diff --git a/sys/dev/smbios/smbios.c b/sys/dev/smbios/smbios.c
index 00c7e2c98d2a..10589ed8d49d 100644
--- a/sys/dev/smbios/smbios.c
+++ b/sys/dev/smbios/smbios.c
@@ -51,8 +51,6 @@ __FBSDID("$FreeBSD$");
#endif
#include <dev/smbios/smbios.h>
-static struct smbios_softc *smbios;
-
/*
* System Management BIOS Reference Specification, v2.4 Final
* http://www.dmtf.org/standards/published_documents/DSP0134.pdf
@@ -181,7 +179,6 @@ smbios_attach (device_t dev)
bcd2bin(sc->eps->BCD_revision & 0x0f));
printf("\n");
- smbios = sc;
return (0);
bad:
if (sc->res)
@@ -194,7 +191,6 @@ smbios_detach (device_t dev)
{
struct smbios_softc *sc;
- smbios = NULL;
sc = device_get_softc(dev);
if (sc->res)
@@ -203,23 +199,6 @@ smbios_detach (device_t dev)
return (0);
}
-int
-smbios_get_structure_table(vm_paddr_t *table, vm_size_t *size)
-{
-
- if (smbios == NULL)
- return (ENXIO);
- if (smbios->eps_64bit) {
- *table = smbios->eps3->structure_table_address;
- *size = smbios->eps3->structure_table_max_size;
- } else {
- *table = smbios->eps->structure_table_address;
- *size = smbios->eps->structure_table_length;
- }
- return (0);
-}
-
-
static int
smbios_modevent (mod, what, arg)
module_t mod;
diff --git a/sys/dev/smbios/smbios.h b/sys/dev/smbios/smbios.h
index 554b882f1da4..6503cdb73c4c 100644
--- a/sys/dev/smbios/smbios.h
+++ b/sys/dev/smbios/smbios.h
@@ -32,8 +32,6 @@
#ifndef _SMBIOS_H_
#define _SMBIOS_H_
-int smbios_get_structure_table(vm_paddr_t *table, vm_size_t *size);
-
/*
* System Management BIOS
*/
More information about the dev-commits-src-all
mailing list