diff --git a/dmi.c b/dmi.c
new file mode 100644
index 0000000..ca75461
--- /dev/null
+++ b/dmi.c
@@ -0,0 +1,168 @@
+/*
+ * This file is part of the flashrom project.
+ *
+ * Copyright (C) 2009,2010 Michael Karcher
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "flash.h"
+
+enum dmi_strings {
+	DMI_SYS_MANUFACTURER,
+	DMI_SYS_PRODUCT,
+	DMI_SYS_VERSION,
+	DMI_BB_MANUFACTURER,
+	DMI_BB_PRODUCT,
+	DMI_BB_VERSION,
+	DMI_ID_INVALID /* This must always be the last entry */
+};
+
+/* The short_id for baseboard starts with "m" as in mainboard to leave
+   "b" available for BIOS */
+struct {
+	const char *dmidecode_name;
+	char short_id[3];
+} dmi_properties[DMI_ID_INVALID] = {
+	{"system-manufacturer", "sm"},
+	{"system-product-name", "sp"},
+	{"system-version", "sv"},
+	{"baseboard-manufacturer", "mm"},
+	{"baseboard-product-name", "mp"},
+	{"baseboard-version", "mv"}
+};
+
+#define DMI_COMMAND_LEN_MAX 260
+const char *dmidecode_command = "dmidecode";
+
+int has_dmi_support = 0;
+char *dmistrings[DMI_ID_INVALID];
+
+/* strings longer than 4096 in DMI are just insane */
+#define DMI_MAX_ANSWER_LEN 4096
+
+void dmi_init(void)
+{
+	FILE *dmidecode_pipe;
+	int i;
+	char *answerbuf = malloc(DMI_MAX_ANSWER_LEN);
+	if(!answerbuf)
+	{
+		fprintf(stderr, "DMI: couldn't alloc answer buffer\n");
+		return;
+	}
+	for (i = 0; i < DMI_ID_INVALID; i++)
+	{
+		char commandline[DMI_COMMAND_LEN_MAX+40];
+		snprintf(commandline, sizeof(commandline),
+		         "%s -s %s", dmidecode_command,
+		         dmi_properties[i].dmidecode_name);
+		dmidecode_pipe = popen(commandline, "r");
+		if (!dmidecode_pipe)
+		{
+			printf_debug("DMI pipe open error\n");
+			goto out_free;
+		}
+		fgets(answerbuf, DMI_MAX_ANSWER_LEN, dmidecode_pipe);
+		if (ferror(dmidecode_pipe))
+		{
+			printf_debug("DMI pipe read error\n");
+			pclose(dmidecode_pipe);
+			goto out_free;
+		}
+		/* Toss all output above DMI_MAX_ANSWER_LEN away to prevent
+		   deadlock on pclose. */
+		while (!feof(dmidecode_pipe))
+			getc(dmidecode_pipe);
+		if (pclose(dmidecode_pipe) != 0)
+		{
+			printf_debug("DMI pipe close error\n");
+			goto out_free;
+		}
+
+		/* chomp trailing newline */
+		if (answerbuf[0] != 0 &&
+		    answerbuf[strlen(answerbuf) - 1] == '\n')
+			answerbuf[strlen(answerbuf) - 1] = 0;
+		printf_debug("DMI string %d: \"%s\"\n", i, answerbuf);
+		dmistrings[i] = strdup(answerbuf);
+	}
+	has_dmi_support = 1;
+out_free:
+	free(answerbuf);
+}
+
+/**
+ * Does an substring/prefix/postfix/whole-string match.
+ *
+ * The pattern is matched as-is. The only metacharacters supported are '^'
+ * at the beginning and '$' at the end. So you can look for "^prefix",
+ * "suffix$", "substring" or "^complete string$".
+ *
+ * @param value The string to check.
+ * @param pattern The pattern.
+ * @return Nonzero if pattern matches.
+ */
+static int dmi_compare(const char *value, const char *pattern)
+{
+	int anchored = 0;
+	int patternlen;
+	printf_debug("matching %s against %s\n", value, pattern);
+	/* The empty string is part of all strings */
+	if (pattern[0] == 0)
+		return 1;
+
+	if (pattern[0] == '^') {
+		anchored = 1;
+		pattern++;
+	}
+
+	patternlen = strlen(pattern);
+	if (pattern[patternlen - 1] == '$') {
+		int valuelen = strlen(value);
+		patternlen--;
+		if(patternlen > valuelen)
+			return 0;
+
+		/* full string match: require same length */
+		if(anchored && (valuelen != patternlen))
+			return 0;
+
+		/* start character to make ends match */
+		value += valuelen - patternlen;
+		anchored = 1;
+	}
+
+	if (anchored)
+		return strncmp(value, pattern, patternlen) == 0;
+	else
+		return strstr(value, pattern) != NULL;
+}
+
+int dmi_match(const char *pattern)
+{
+	int i;
+	if (!has_dmi_support)
+		return 0;
+
+	for (i = 0;i < DMI_ID_INVALID; i++)
+		return dmi_compare(dmistrings[i], pattern);
+
+	return 0;
+}
