From: Alexander Graf Date: Tue, 16 Aug 2016 10:55:24 +0200 Subject: [U-Boot] [PATCH v3 5/8] smbios: Generate type 4 on non-x86 systems In-Reply-To: <1471337727-225297-1-git-send-email-agraf@suse.de> References: <1471337727-225297-1-git-send-email-agraf@suse.de> Message-ID: <1471337727-225297-6-git-send-email-agraf@suse.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de The type 4 table generation code is very x86 centric today. Refactor things out a bit to allow the tables to get generated for other architectures as well. Signed-off-by: Alexander Graf --- include/smbios.h | 3 +++ lib/smbios.c | 37 +++++++++++++++++++++++++++---------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/include/smbios.h b/include/smbios.h index 5962d4c..3cbc687 100644 --- a/include/smbios.h +++ b/include/smbios.h @@ -139,6 +139,9 @@ struct __packed smbios_type3 { #define SMBIOS_PROCESSOR_STATUS_ENABLED 1 #define SMBIOS_PROCESSOR_UPGRADE_NONE 6 +#define SMBIOS_PROCESSOR_FAMILY_OTHER 1 +#define SMBIOS_PROCESSOR_FAMILY_UNKNOWN 2 + struct __packed smbios_type4 { u8 type; u8 length; diff --git a/lib/smbios.c b/lib/smbios.c index 8dfd486..11cacec 100644 --- a/lib/smbios.c +++ b/lib/smbios.c @@ -10,7 +10,9 @@ #include #include #include +#ifdef CONFIG_X86 #include +#endif DECLARE_GLOBAL_DATA_PTR; @@ -152,26 +154,41 @@ static int smbios_write_type3(uintptr_t *current, int handle) return len; } -static int smbios_write_type4(uintptr_t *current, int handle) +static void smbios_write_type4_arch(struct smbios_type4 *t) { - struct smbios_type4 *t = (struct smbios_type4 *)*current; - int len = sizeof(struct smbios_type4); - const char *vendor; - char *name; + u16 processor_family = SMBIOS_PROCESSOR_FAMILY_UNKNOWN; + const char *vendor = "Unknown"; + char *name = "Unknown"; + +#ifdef CONFIG_X86 char processor_name[CPU_MAX_NAME_LEN]; struct cpuid_result res; - memset(t, 0, sizeof(struct smbios_type4)); - fill_smbios_header(t, SMBIOS_PROCESSOR_INFORMATION, len, handle); - t->processor_type = SMBIOS_PROCESSOR_TYPE_CENTRAL; - t->processor_family = gd->arch.x86; + processor_family = gd->arch.x86; vendor = cpu_vendor_name(gd->arch.x86_vendor); - t->processor_manufacturer = smbios_add_string(t->eos, vendor); res = cpuid(1); t->processor_id[0] = res.eax; t->processor_id[1] = res.edx; name = cpu_get_name(processor_name); +#elif defined(CONFIG_ARM) + processor_family = SMBIOS_PROCESSOR_FAMILY_OTHER; + vendor = "ARM"; +#endif + + t->processor_family = processor_family; + t->processor_manufacturer = smbios_add_string(t->eos, vendor); t->processor_version = smbios_add_string(t->eos, name); +} + +static int smbios_write_type4(uintptr_t *current, int handle) +{ + struct smbios_type4 *t = (struct smbios_type4 *)*current; + int len = sizeof(struct smbios_type4); + + memset(t, 0, sizeof(struct smbios_type4)); + fill_smbios_header(t, SMBIOS_PROCESSOR_INFORMATION, len, handle); + t->processor_type = SMBIOS_PROCESSOR_TYPE_CENTRAL; + smbios_write_type4_arch(t); t->status = SMBIOS_PROCESSOR_STATUS_ENABLED; t->processor_upgrade = SMBIOS_PROCESSOR_UPGRADE_NONE; t->l1_cache_handle = 0xffff; -- 1.8.5.6