Hello Ivan,
On 16 January 2015 at 17:56, Ivan Khoronzhuk ivan.khoronzhuk@linaro.org wrote:
There are situations when code needs to access SMBIOS entry table area. For example, to pass it via sysfs to userspace when it's not allowed to get SMBIOS info via /dev/mem.
Signed-off-by: Ivan Khoronzhuk ivan.khoronzhuk@linaro.org
drivers/firmware/dmi_scan.c | 43 +++++++++++++++++++++++++++++++++++++++++++ include/linux/dmi.h | 2 ++ 2 files changed, 45 insertions(+)
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index ade4b51..174cf0b 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c @@ -113,6 +113,7 @@ static void dmi_table(u8 *buf, int len, int num, } }
+static phys_addr_t smbios_base; static phys_addr_t dmi_base;
If the kernel has managed to determine where the SMBIOS structure table is, and records the address in dmi_base, why are we still interested in the other stuff? Couldn't we just make dmi_base and dmi_len globals?
static u16 dmi_len; static u16 dmi_num; @@ -583,6 +584,7 @@ void __init dmi_scan_machine(void) dmi_early_unmap(p, 32);
if (!dmi_smbios3_present(buf)) {
smbios_base = efi.smbios3; dmi_available = 1; goto out; }
@@ -601,6 +603,7 @@ void __init dmi_scan_machine(void) dmi_early_unmap(p, 32);
if (!dmi_present(buf)) {
smbios_base = efi.smbios; dmi_available = 1; goto out; }
@@ -620,6 +623,11 @@ void __init dmi_scan_machine(void) for (q = p; q < p + 0x10000; q += 16) { memcpy_fromio(buf + 16, q, 16); if (!dmi_smbios3_present(buf) || !dmi_present(buf)) {
smbios_base = q - p + 0xF0000;
if (!memcmp(buf, "_SM_", 4) ||
!memcmp(buf, "_SM3_", 5))
smbios_base -= 16;
dmi_available = 1; dmi_early_unmap(p, 0x10000); goto out;
@@ -943,3 +951,38 @@ void dmi_memdev_name(u16 handle, const char **bank, const char **device) } } EXPORT_SYMBOL_GPL(dmi_memdev_name);
+/**
- dmi_get_smbios_entry_area - copy SMBIOS entry point area to array.
- @entry - pointer on array to read area in, current max size is 32 bytes.
- returns -ENODATA if table is not available, otherwise returns actual
- size of SMBIOS entry point area.
- */
+int dmi_get_smbios_entry_area(char *table) +{
u8 *buf;
int size = 0;
if (!dmi_initialized || !smbios_base)
return -ENODATA;
buf = dmi_remap(smbios_base, 32);
if (memcmp(buf, "_SM3_", 5) == 0)
size = buf[6];
else if (memcmp(buf, "_SM_", 4) == 0)
size = buf[5];
else if (memcmp(buf, "_DMI_", 5) == 0)
size = 15;
memcpy(table, buf, size);
dmi_unmap(buf);
if (!size)
return -ENODATA;
return size;
+} +EXPORT_SYMBOL_GPL(dmi_get_smbios_entry_area); diff --git a/include/linux/dmi.h b/include/linux/dmi.h index f820f0a..f262d53 100644 --- a/include/linux/dmi.h +++ b/include/linux/dmi.h @@ -109,6 +109,7 @@ extern int dmi_walk(void (*decode)(const struct dmi_header *, void *), void *private_data); extern bool dmi_match(enum dmi_field f, const char *str); extern void dmi_memdev_name(u16 handle, const char **bank, const char **device); +extern int dmi_get_smbios_entry_area(char *table);
#else
@@ -140,6 +141,7 @@ static inline void dmi_memdev_name(u16 handle, const char **bank, const char **device) { } static inline const struct dmi_system_id * dmi_first_match(const struct dmi_system_id *list) { return NULL; } +static int dmi_get_smbios_entry_area(char *table) { return -ENODATA; }
#endif
-- 1.9.1
Linaro-uefi mailing list Linaro-uefi@lists.linaro.org http://lists.linaro.org/mailman/listinfo/linaro-uefi