From patchwork Tue Jun 25 23:17:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Park, Aiden" X-Patchwork-Id: 1122388 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45YMWj4Jkhz9s4Y for ; Wed, 26 Jun 2019 09:17:36 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id C18B5C21C3F; Tue, 25 Jun 2019 23:17:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 263C8C21C3F; Tue, 25 Jun 2019 23:17:31 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 80A03C21C4A; Tue, 25 Jun 2019 23:17:29 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lists.denx.de (Postfix) with ESMTPS id 90FECC21C29 for ; Tue, 25 Jun 2019 23:17:28 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jun 2019 16:17:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,417,1557212400"; d="scan'208";a="188454589" Received: from orsmsx109.amr.corp.intel.com ([10.22.240.7]) by fmsmga002.fm.intel.com with ESMTP; 25 Jun 2019 16:17:19 -0700 Received: from orsmsx163.amr.corp.intel.com (10.22.240.88) by ORSMSX109.amr.corp.intel.com (10.22.240.7) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 25 Jun 2019 16:17:18 -0700 Received: from orsmsx116.amr.corp.intel.com ([169.254.7.97]) by ORSMSX163.amr.corp.intel.com ([169.254.9.84]) with mapi id 14.03.0439.000; Tue, 25 Jun 2019 16:17:18 -0700 From: "Park, Aiden" To: U-Boot Mailing List , Simon Glass , Bin Meng Thread-Topic: [PATCH v2 2/8] x86: slimbootloader: Add a function to access HOB Thread-Index: AdUrq/Y0hroP7/ULQVCnNnxTcg/98Q== Date: Tue, 25 Jun 2019 23:17:17 +0000 Message-ID: Accept-Language: ko-KR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYzcwZjk2OTEtMDYyOS00N2JkLThkMDUtMmQ4ZTFjMjQ5NTFkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiOHFjeWJlejRVZzdSejdYZDhGaWFmdE9HbVVjd1wvWEVoN2hzN1lCbWE3ZlhXS3ZJeUlCUDJUU1kyUEpQUjA1YzIifQ== x-ctpclassification: CTP_NT x-originating-ip: [10.22.254.138] MIME-Version: 1.0 Subject: [U-Boot] [PATCH v2 2/8] x86: slimbootloader: Add a function to access HOB X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" - Added a function to get a GUID HOB data pointer from hob_list Signed-off-by: Aiden Park --- arch/x86/cpu/slimbootloader/Makefile | 2 +- arch/x86/cpu/slimbootloader/hob.c | 97 +++++++++++++++++++ .../asm/arch-slimbootloader/slimbootloader.h | 14 +++ 3 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 arch/x86/cpu/slimbootloader/hob.c diff --git a/arch/x86/cpu/slimbootloader/Makefile b/arch/x86/cpu/slimbootloader/Makefile index 627a721e8c..620fc8a139 100644 --- a/arch/x86/cpu/slimbootloader/Makefile +++ b/arch/x86/cpu/slimbootloader/Makefile @@ -2,4 +2,4 @@ # # Copyright (C) 2019 Intel Corporation -obj-y += car.o slimbootloader.o +obj-y += car.o slimbootloader.o hob.o diff --git a/arch/x86/cpu/slimbootloader/hob.c b/arch/x86/cpu/slimbootloader/hob.c new file mode 100644 index 0000000000..dff86b696e --- /dev/null +++ b/arch/x86/cpu/slimbootloader/hob.c @@ -0,0 +1,97 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2019 Intel Corporation + */ + +#include +#include + +/* + * This compares two guids and returns its result(0 or others). + * + * @guid1: A pointer to a 128 bit guid + * @guid2: A pointer to a 128 bit guid + * + * @return: 0 if guid1 and guid2 are identical. Otherwise it returns none 0. + */ +static int compare_guid(const struct efi_guid *guid1, + const struct efi_guid *guid2) +{ + return memcmp(guid1, guid2, sizeof(struct efi_guid)); +} + +/** + * This returns a hob header pointer which has a specific type from the given + * hob list. + * + * @type: A specific hob type + * @hob_list: A pointer to a hob list + * + * @return: A hob header pointer if the specified type is found. + * Otherwise, this returns NULL. + */ +static const struct hob_header *get_next_hob_from_hdr(uint type, + const void *hob_list) +{ + const struct hob_header *hdr; + + hdr = hob_list; + + /* Parse the HOB list until end of list or matching type is found */ + while (!end_of_hob(hdr)) { + if (hdr->type == type) + return hdr; + + hdr = get_next_hob(hdr); + } + + return NULL; +} + +/** + * This returns a hob header pointer which has a specific guid from the given + * hob list. + * + * @guid: A pointer to a 128 bit guid + * @hob_list: A pointer to a hob list + * + * @return: A hob header pointer if the specified guid hob entry is found. + * Otherwise, this returns NULL. + */ +static const struct hob_header *get_next_guid_hob(const struct efi_guid *guid, + const void *hob_list) +{ + const struct hob_header *hdr; + struct hob_guid *guid_hob; + + hdr = hob_list; + while ((hdr = get_next_hob_from_hdr(HOB_TYPE_GUID_EXT, hdr))) { + guid_hob = (struct hob_guid *)hdr; + if (!compare_guid(guid, &guid_hob->name)) + break; + hdr = get_next_hob(hdr); + } + + return hdr; +} + +/** + * This returns a pointer to hob data buffer if the given guid hob is found. + * + * @guid: A pointer to a 128 bit guid + * @hob_list: A pointer to a hob list + * + * @return: A pointer to hob data buffer if the specified guid hob entry is + * found. Otherwise, this returns NULL. + */ +void *get_next_guid_hob_data(const struct efi_guid *guid, + const void *hob_list) +{ + const struct hob_header *guid_hob; + + guid_hob = get_next_guid_hob(guid, hob_list); + if (!guid_hob) + return NULL; + + return get_guid_hob_data(guid_hob); +} diff --git a/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h b/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h index 7309a83724..bd1f4ee374 100644 --- a/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h +++ b/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h @@ -7,5 +7,19 @@ #define __SLIMBOOTLOADER_ARCH_H__ #include +#include +#include + +/** + * This returns a pointer to hob data buffer if the given guid hob is found. + * + * @guid: A pointer to a 128 bit guid + * @hob_list: A pointer to a hob list + * + * @return: A pointer to hob data buffer if the specified guid hob entry is + * found. Otherwise, this returns NULL. + */ +void *get_next_guid_hob_data(const struct efi_guid *guid, + const void *hob_list); #endif