SMBIOS: Correct length calculation for empty string table

If all strings in SMBIOS table are empty, smbios_string_table_len
function should return 2, cause every table must end with "\0\0".

Also replace "eos" field type in smbios structures
from char to u8.

Change-Id: Ia3178b0030aa71e1ff11a3fd3d102942f0027eb1
Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Reviewed-on: https://review.coreboot.org/20840
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
diff --git a/src/arch/x86/smbios.c b/src/arch/x86/smbios.c
index 72fb0df..89951a1 100644
--- a/src/arch/x86/smbios.c
+++ b/src/arch/x86/smbios.c
@@ -42,10 +42,10 @@
 }
 
 
-int smbios_add_string(char *start, const char *str)
+int smbios_add_string(u8 *start, const char *str)
 {
 	int i = 1;
-	char *p = start;
+	char *p = (char *)start;
 
 	/*
 	 * Return 0 as required for empty strings.
@@ -71,9 +71,9 @@
 	}
 }
 
-int smbios_string_table_len(char *start)
+int smbios_string_table_len(u8 *start)
 {
-	char *p = start;
+	char *p = (char *)start;
 	int i, len = 0;
 
 	while (*p) {
@@ -81,10 +81,14 @@
 		p += i;
 		len += i;
 	}
+
+	if (!len)
+		return 2;
+
 	return len + 1;
 }
 
-static int smbios_cpu_vendor(char *start)
+static int smbios_cpu_vendor(u8 *start)
 {
 	if (cpu_have_cpuid()) {
 		u32 tmp[4];
@@ -99,7 +103,7 @@
 	}
 }
 
-static int smbios_processor_name(char *start)
+static int smbios_processor_name(u8 *start)
 {
 	u32 tmp[13];
 	const char *str = "Unknown Processor Name";
diff --git a/src/drivers/intel/wifi/wifi.c b/src/drivers/intel/wifi/wifi.c
index d1d5684..77918e4 100644
--- a/src/drivers/intel/wifi/wifi.c
+++ b/src/drivers/intel/wifi/wifi.c
@@ -40,7 +40,7 @@
 		u8 length;
 		u16 handle;
 		u8 str;
-		char eos[2];
+		u8 eos[2];
 	} __packed;
 
 	struct smbios_type_intel_wifi *t =
diff --git a/src/include/smbios.h b/src/include/smbios.h
index dec0300..fddcce8 100644
--- a/src/include/smbios.h
+++ b/src/include/smbios.h
@@ -22,8 +22,8 @@
 #include <compiler.h>
 
 unsigned long smbios_write_tables(unsigned long start);
-int smbios_add_string(char *start, const char *str);
-int smbios_string_table_len(char *start);
+int smbios_add_string(u8 *start, const char *str);
+int smbios_string_table_len(u8 *start);
 
 /* Used by mainboard to add an on-board device */
 int smbios_write_type41(unsigned long *current, int *handle,
@@ -249,7 +249,7 @@
 	u8 system_bios_minor_release;
 	u8 ec_major_release;
 	u8 ec_minor_release;
-	char eos[2];
+	u8 eos[2];
 } __packed;
 
 struct smbios_type1 {
@@ -264,7 +264,7 @@
 	u8 wakeup_type;
 	u8 sku;
 	u8 family;
-	char eos[2];
+	u8 eos[2];
 } __packed;
 
 struct smbios_type2 {
@@ -275,7 +275,7 @@
 	u8 product_name;
 	u8 version;
 	u8 serial_number;
-	char eos[2];
+	u8 eos[2];
 } __packed;
 
 enum {
@@ -336,7 +336,7 @@
 	u8 element_count;
 	u8 element_record_length;
 	u8 sku_number;
-	char eos[2];
+	u8 eos[2];
 } __packed;
 
 struct smbios_type4 {
@@ -366,7 +366,7 @@
 	u8 thread_count;
 	u16 processor_characteristics;
 	u16 processor_family2;
-	char eos[2];
+	u8 eos[2];
 } __packed;
 
 struct smbios_type11 {
@@ -374,7 +374,7 @@
 	u8 length;
 	u16 handle;
 	u8 count;
-	char eos[2];
+	u8 eos[2];
 } __packed;
 
 struct smbios_type15 {
@@ -391,7 +391,7 @@
 	u8 header_format;
 	u8 log_type_descriptors;
 	u8 log_type_descriptor_length;
-	char eos[2];
+	u8 eos[2];
 } __packed;
 
 enum {
@@ -418,7 +418,7 @@
 	u16 memory_error_information_handle;
 	u16 number_of_memory_devices;
 	u64 extended_maximum_capacity;
-	char eos[2];
+	u8 eos[2];
 } __packed;
 
 struct smbios_type17 {
@@ -447,7 +447,7 @@
 	u16 minimum_voltage;
 	u16 maximum_voltage;
 	u16 configured_voltage;
-	char eos[2];
+	u8 eos[2];
 } __packed;
 
 struct smbios_type32 {
@@ -497,7 +497,7 @@
 	u8 bus_number;
 	u8 function_number: 3;
 	u8 device_number: 5;
-	char eos[2];
+	u8 eos[2];
 } __packed;
 
 struct smbios_type127 {