[U-Boot] [PATCH v3 5/8] smbios: Generate type 4 on non-x86 systems

Simon Glass sjg at chromium.org
Wed Aug 17 06:15:52 CEST 2016


HI Alex,

On 16 August 2016 at 02:55, Alexander Graf <agraf at suse.de> wrote:
> 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 <agraf at suse.de>
> ---
>  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 <smbios.h>
>  #include <tables_csum.h>
>  #include <version.h>
> +#ifdef CONFIG_X86
>  #include <asm/cpu.h>
> +#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

This should use the cpu uclass. As mentioned you may need to add a new
method, but it should be easy enough.

>         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
>

Regards,
Simon


More information about the U-Boot mailing list