blob: b118c74ceb7998b69edf7adc65760843e132b8b8 [file] [log] [blame]
--- dmidecode.c.orig 2011-05-25 21:35:54.000000000 -0700
+++ dmidecode.c 2011-05-25 22:19:11.000000000 -0700
@@ -4204,6 +4204,43 @@
return 1;
}
+
+/*
+ * Probe for EFI interface
+ */
+#define DEBUGFS_NO_SMBIOS (-1)
+static int address_from_debugfs(size_t *address)
+{
+ FILE *efi_smbios_base;
+ const char *filename;
+ char linebuf[64];
+ int ret;
+
+ *address = 0; /* Prevent compiler warning */
+
+ /* ChromeOS contains /sys/kernel/debug/efi_smbios_base */
+ if ((efi_smbios_base = fopen(filename = "/sys/kernel/debug/efi_smbios_base", "r")) == NULL)
+ {
+ /* Try another interface */
+ return DEBUGFS_NO_SMBIOS;
+ }
+ ret = DEBUGFS_NO_SMBIOS;
+ if ((fgets(linebuf, sizeof(linebuf) - 1, efi_smbios_base)) != NULL)
+ {
+ *address = strtoul(linebuf, NULL, 0);
+ if (!(opt.flags & FLAG_QUIET))
+ printf("# SMBIOS entry point at 0x%08lx\n",
+ (unsigned long)*address);
+ ret = 0;
+ }
+ if (fclose(efi_smbios_base) != 0)
+ perror(filename);
+
+ if (ret == DEBUGFS_NO_SMBIOS)
+ fprintf(stderr, "%s: SMBIOS entry point missing\n", filename);
+ return ret;
+}
+
/*
* Probe for EFI interface
*/
@@ -4257,6 +4294,7 @@
int found = 0;
size_t fp;
int efi;
+ int debugfs;
u8 *buf;
if (sizeof(u8) != 1 || sizeof(u16) != 2 || sizeof(u32) != 4 || '\0' != 0)
@@ -4315,6 +4353,11 @@
goto done;
}
+ /* Try debugfs: /sys/kernel/debug/efi_smbios_base */
+ debugfs = address_from_debugfs(&fp);
+ if (debugfs == 0)
+ goto address_check;
+
/* First try EFI (ia64, Intel-based Mac) */
efi = address_from_efi(&fp);
switch (efi)
@@ -4326,6 +4369,7 @@
goto exit_free;
}
+address_check:
if ((buf = mem_chunk(fp, 0x20, opt.devmem)) == NULL)
{
ret = 1;