]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/firmware/dmi_scan.c
icside: fix ->speedproc to return on unsupported modes (take 5)
[linux-2.6-omap-h63xx.git] / drivers / firmware / dmi_scan.c
index b9e3886d9e1618cc4b85345e81a8a2c23fb876ea..f7318b3b51f2a0860bf2f952896d60f746bd98a8 100644 (file)
@@ -84,6 +84,7 @@ static int __init dmi_checksum(u8 *buf)
 
 static char *dmi_ident[DMI_STRING_MAX];
 static LIST_HEAD(dmi_devices);
+int dmi_available;
 
 /*
  *     Save a DMI string
@@ -102,6 +103,51 @@ static void __init dmi_save_ident(struct dmi_header *dm, int slot, int string)
        dmi_ident[slot] = p;
 }
 
+static void __init dmi_save_uuid(struct dmi_header *dm, int slot, int index)
+{
+       u8 *d = (u8*) dm + index;
+       char *s;
+       int is_ff = 1, is_00 = 1, i;
+
+       if (dmi_ident[slot])
+               return;
+
+       for (i = 0; i < 16 && (is_ff || is_00); i++) {
+               if(d[i] != 0x00) is_ff = 0;
+               if(d[i] != 0xFF) is_00 = 0;
+       }
+
+       if (is_ff || is_00)
+               return;
+
+       s = dmi_alloc(16*2+4+1);
+       if (!s)
+               return;
+
+       sprintf(s,
+               "%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
+               d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7],
+               d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]);
+
+        dmi_ident[slot] = s;
+}
+
+static void __init dmi_save_type(struct dmi_header *dm, int slot, int index)
+{
+       u8 *d = (u8*) dm + index;
+       char *s;
+
+       if (dmi_ident[slot])
+               return;
+
+       s = dmi_alloc(4);
+       if (!s)
+               return;
+
+       sprintf(s, "%u", *d & 0x7F);
+       dmi_ident[slot] = s;
+}
+
 static void __init dmi_save_devices(struct dmi_header *dm)
 {
        int i, count = (dm->length - sizeof(struct dmi_header)) / 2;
@@ -123,6 +169,26 @@ static void __init dmi_save_devices(struct dmi_header *dm)
                dev->type = *d++ & 0x7f;
                dev->name = dmi_string(dm, *d);
                dev->device_data = NULL;
+               list_add(&dev->list, &dmi_devices);
+       }
+}
+
+static void __init dmi_save_oem_strings_devices(struct dmi_header *dm)
+{
+       int i, count = *(u8 *)(dm + 1);
+       struct dmi_device *dev;
+
+       for (i = 1; i <= count; i++) {
+               dev = dmi_alloc(sizeof(*dev));
+               if (!dev) {
+                       printk(KERN_ERR
+                          "dmi_save_oem_strings_devices: out of memory.\n");
+                       break;
+               }
+
+               dev->type = DMI_DEV_TYPE_OEM_STRING;
+               dev->name = dmi_string(dm, i);
+               dev->device_data = NULL;
 
                list_add(&dev->list, &dmi_devices);
        }
@@ -172,15 +238,28 @@ static void __init dmi_decode(struct dmi_header *dm)
                dmi_save_ident(dm, DMI_PRODUCT_NAME, 5);
                dmi_save_ident(dm, DMI_PRODUCT_VERSION, 6);
                dmi_save_ident(dm, DMI_PRODUCT_SERIAL, 7);
+               dmi_save_uuid(dm, DMI_PRODUCT_UUID, 8);
                break;
        case 2:         /* Base Board Information */
                dmi_save_ident(dm, DMI_BOARD_VENDOR, 4);
                dmi_save_ident(dm, DMI_BOARD_NAME, 5);
                dmi_save_ident(dm, DMI_BOARD_VERSION, 6);
+               dmi_save_ident(dm, DMI_BOARD_SERIAL, 7);
+               dmi_save_ident(dm, DMI_BOARD_ASSET_TAG, 8);
+               break;
+       case 3:         /* Chassis Information */
+               dmi_save_ident(dm, DMI_CHASSIS_VENDOR, 4);
+               dmi_save_type(dm, DMI_CHASSIS_TYPE, 5);
+               dmi_save_ident(dm, DMI_CHASSIS_VERSION, 6);
+               dmi_save_ident(dm, DMI_CHASSIS_SERIAL, 7);
+               dmi_save_ident(dm, DMI_CHASSIS_ASSET_TAG, 8);
                break;
        case 10:        /* Onboard Devices Information */
                dmi_save_devices(dm);
                break;
+       case 11:        /* OEM Strings */
+               dmi_save_oem_strings_devices(dm);
+               break;
        case 38:        /* IPMI Device Information */
                dmi_save_ipmi_device(dm);
        }
@@ -220,18 +299,20 @@ void __init dmi_scan_machine(void)
                if (efi.smbios == EFI_INVALID_TABLE_ADDR)
                        goto out;
 
-               /* This is called as a core_initcall() because it isn't
-                * needed during early boot.  This also means we can
-                * iounmap the space when we're done with it.
-               */
+               /* This is called as a core_initcall() because it isn't
+                * needed during early boot.  This also means we can
+                * iounmap the space when we're done with it.
+                */
                p = dmi_ioremap(efi.smbios, 32);
                if (p == NULL)
                        goto out;
 
                rc = dmi_present(p + 0x10); /* offset of _DMI_ string */
                dmi_iounmap(p, 32);
-               if (!rc)
+               if (!rc) {
+                       dmi_available = 1;
                        return;
+               }
        }
        else {
                /*
@@ -245,8 +326,10 @@ void __init dmi_scan_machine(void)
 
                for (q = p; q < p + 0x10000; q += 16) {
                        rc = dmi_present(q);
-                       if (!rc)
+                       if (!rc) {
+                               dmi_available = 1;
                                return;
+                       }
                }
        }
  out:  printk(KERN_INFO "DMI not present or invalid.\n");
@@ -303,6 +386,26 @@ char *dmi_get_system_info(int field)
 }
 EXPORT_SYMBOL(dmi_get_system_info);
 
+
+/**
+ *     dmi_name_in_vendors - Check if string is anywhere in the DMI vendor information.
+ *     @str:   Case sensitive Name
+ */
+int dmi_name_in_vendors(char *str)
+{
+       static int fields[] = { DMI_BIOS_VENDOR, DMI_BIOS_VERSION, DMI_SYS_VENDOR,
+                               DMI_PRODUCT_NAME, DMI_PRODUCT_VERSION, DMI_BOARD_VENDOR,
+                               DMI_BOARD_NAME, DMI_BOARD_VERSION, DMI_NONE };
+       int i;
+       for (i = 0; fields[i] != DMI_NONE; i++) {
+               int f = fields[i];
+               if (dmi_ident[f] && strstr(dmi_ident[f], str))
+                       return 1;
+       }
+       return 0;
+}
+EXPORT_SYMBOL(dmi_name_in_vendors);
+
 /**
  *     dmi_find_device - find onboard device by type/name
  *     @type: device type or %DMI_DEV_TYPE_ANY to match all device types
@@ -361,3 +464,4 @@ int dmi_get_year(int field)
 
        return year;
 }
+