From patchwork Wed Oct 7 01:33:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Gmeiner X-Patchwork-Id: 1377988 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=XHKSTnzJ; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C5v0B5kjyz9sSG for ; Wed, 7 Oct 2020 23:34:02 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 08B4E8233B; Wed, 7 Oct 2020 14:33:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="XHKSTnzJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 27B238233D; Wed, 7 Oct 2020 14:33:50 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A18E4806C5 for ; Wed, 7 Oct 2020 14:33:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=christian.gmeiner@gmail.com Received: by mail-wm1-x341.google.com with SMTP id d81so2131912wmc.1 for ; Wed, 07 Oct 2020 05:33:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=I0QuAdz8oLmaJUMzkkPcrkzqmGhQCwbVXWHakEvh3wY=; b=XHKSTnzJ02B8z0zgla221K3FGpZIkB9vdwTjTD/RTCXD+Qf4Gl1XhWo/6p7B8GmQcS fyiB3lA9ilTKAYaGgagvpH/wjtCv+RfOT05/PpNyKbvGWGGQERI3BoMrpnPplR1lIFZL SIO3VFPPLzeRhwbjbKiyQBPXhiNshLe8tCsGg6XvMQy/8uyuG9Ve1qFIWa5++xPJfY1k uCzvVBgordEhrCRLkH61a4nyOvziED/RaASFYskRhGIiQHmwbRJFxj4Ggs6uLJ5N/QKV z+EoLYDlMrEtouIZf/Zj527BtJOAR6tQdHGRF7XLqGpUyuB++ZeEaSc+4fvawwyz7/vr Pk0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=I0QuAdz8oLmaJUMzkkPcrkzqmGhQCwbVXWHakEvh3wY=; b=OaMtlEm6PvZnXd2HAhT2+Qwel7ELeTuocEbpdvnow1lgsWKMW3N4Ox2Pxtot6RERCN An1JdinDij57DqNL4iEtkcEaCS1oFk/Fi+8h42SaEnGiRr7NoQivMpEJp55hXTU4tgAU Qo0EF1q3R2vT3ESFtzQnfx4ojE7xlv/+OsFrVGFQ3M0X512Pnnb/1ZjGPc4xyKypbiB3 /Q4qjq0MLKJ16aeHgs4qerBSARawtAni/Nwl7PgKxtxlRblUyUbiBDhKGwGjb9pS5/4f hYbGVfJWJlBZAf4DtoqkXr5+KW+5SuoMo1bjCAprjGHrYKbcxelmXNUzOGkXkY/ISaZp HhLA== X-Gm-Message-State: AOAM530suslAG3IavUPnoioSWL+J3TrQp9bVyfDxt7pxVEt2biF46xSi TaMo9be7m8heN7jed0gEcxLVfu8sk1IsYQXI X-Google-Smtp-Source: ABdhPJw7IA0+rrVOsp/9DRM3jHwx4lPpSSzEqJLh0XAoCOC6JUyuF/F1008dhDrxRF5/3Bhkh4Aqvw== X-Received: by 2002:a1c:81ce:: with SMTP id c197mr3024098wmd.111.1602074026912; Wed, 07 Oct 2020 05:33:46 -0700 (PDT) Received: from chgm-pc-linux.bachmann.at ([185.67.228.2]) by smtp.gmail.com with ESMTPSA id q4sm2654570wru.65.2020.10.07.05.33.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Oct 2020 05:33:46 -0700 (PDT) From: Christian Gmeiner To: u-boot@lists.denx.de Cc: bmeng.cn@gmail.com, Christian Gmeiner Subject: [PATCH v2 2/2] coreboot: make use of smbios parser Date: Wed, 7 Oct 2020 14:33:35 +0200 Message-Id: <20201007123335.86983-2-christian.gmeiner@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201007123335.86983-1-christian.gmeiner@gmail.com> References: <20201007123335.86983-1-christian.gmeiner@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean If u-boot gets used as coreboot payload it might be nice to get vendor, model and bios version from smbios. I am not sure about the output of all the read information. With qemu target for coreboot this could look this: CBFS: Found @ offset 14f40 size 3b188 Checking segment from ROM address 0xffc15178 Checking segment from ROM address 0xffc15194 Loading segment from ROM address 0xffc15178 code (compression=1) New segment dstaddr 0x01110000 memsize 0x889ef srcaddr 0xffc151b0 filesize 0x3b150 Loading Segment: addr: 0x01110000 memsz: 0x00000000000889ef filesz: 0x000000000003b150 using LZMA Loading segment from ROM address 0xffc15194 Entry Point 0x01110000 BS: BS_PAYLOAD_LOAD run times (exec / console): 77 / 1 ms Jumping to boot code at 0x01110000(0x07fa7000) U-Boot 2020.10-00536-g5dcf7cc590-dirty (Oct 07 2020 - 14:21:51 +0200) CPU: x86_64, vendor AMD, device 663h DRAM: 127.1 MiB MMC: Video: No video mode configured in coreboot! Video: No video mode configured in coreboot! Vendor: QEMU Model: Standard PC (i440FX + PIIX, 1996) Bios Version: 4.12-3152-g326a499f6f-dirty Net: e1000: 52:54:00:12:34:56 eth0: e1000#0 No working controllers found Finalizing coreboot Hit any key to stop autoboot: 0 Signed-off-by: Christian Gmeiner Reviewed-by: Bin Meng --- board/coreboot/coreboot/coreboot.c | 45 ++++++++++++++++++++++++++++++ configs/coreboot_defconfig | 1 + 2 files changed, 46 insertions(+) diff --git a/board/coreboot/coreboot/coreboot.c b/board/coreboot/coreboot/coreboot.c index b791b82ef4..afb457212a 100644 --- a/board/coreboot/coreboot/coreboot.c +++ b/board/coreboot/coreboot/coreboot.c @@ -4,7 +4,9 @@ */ #include +#include #include +#include int board_early_init_r(void) { @@ -16,3 +18,46 @@ int board_early_init_r(void) return 0; } + +#ifdef CONFIG_SMBIOS_PARSER +int show_board_info(void) +{ + const struct smbios_entry *smbios = smbios_entry(lib_sysinfo.smbios_start, lib_sysinfo.smbios_size); + + if (!smbios) + goto fallback; + + const struct smbios_header *bios = smbios_header(smbios, SMBIOS_BIOS_INFORMATION); + const struct smbios_header *system = smbios_header(smbios, SMBIOS_SYSTEM_INFORMATION); + const struct smbios_type0 *t0 = (struct smbios_type0 *)bios; + const struct smbios_type1 *t1 = (struct smbios_type1 *)system; + + if (!t0 || !t1) + goto fallback; + + const char *bios_ver = smbios_string(bios, t0->bios_ver); + const char *model = smbios_string(system, t1->product_name); + const char *manufacturer = smbios_string(system, t1->manufacturer); + + if (!model || !manufacturer || !bios_ver) + goto fallback; + + printf("Vendor: %s\n", manufacturer); + printf("Model: %s\n", model); + printf("Bios Version: %s\n", bios_ver); + + return 0; + +fallback: +#ifdef CONFIG_OF_CONTROL + DECLARE_GLOBAL_DATA_PTR; + + model = fdt_getprop(gd->fdt_blob, 0, "model", NULL); + + if (model) + printf("Model: %s\n", model); +#endif + + return checkboard(); +} +#endif diff --git a/configs/coreboot_defconfig b/configs/coreboot_defconfig index 3249b2fb2f..501a20e790 100644 --- a/configs/coreboot_defconfig +++ b/configs/coreboot_defconfig @@ -43,3 +43,4 @@ CONFIG_SOUND=y CONFIG_SOUND_I8254=y CONFIG_CONSOLE_SCROLL_LINES=5 # CONFIG_GZIP is not set +CONFIG_SMBIOS_PARSER=y