From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) by mx.groups.io with SMTP id smtpd.web08.624.1630647189574909982 for ; Thu, 02 Sep 2021 22:33:09 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=buHED8YR; spf=pass (domain: gmail.com, ip: 209.85.222.178, mailfrom: benjamin.doron00@gmail.com) Received: by mail-qk1-f178.google.com with SMTP id t190so4732085qke.7 for ; Thu, 02 Sep 2021 22:33:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TfKyQSkqI8GHecv87UpOqZz3dQ5Hnfu4ZoIhFrMZ5IQ=; b=buHED8YRcYtH38Y2V4nWfw/xP0xwcEcKZPz/cFT0trMCUFQAg04FeXiV1MzwbXcszQ cKPg50W+CpLSwhhuWzMyq2b/lw4R/oo5v7jcFjbYlEeTy3KGjCt7Dt7NT47IJk1BUCgw DEezljO7hZXHigkx4qBw/ztWpPclvN8+IECpv1JegslEe/5Ou+xJrz9rzKynNjdH92IR g5mTax7pb3KctOq5Jnx4cCHw6EXHoTbbo8PaYdNCt+MFvm0CClId1FznrvEgoRO7zZYz 8AjpAa6AfiAL6XXYo/+JGpHLHfIidGIb8yFU3g40+JXV+D8y6/wo54ZDIcT5HfDwX+fv el3g== 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=TfKyQSkqI8GHecv87UpOqZz3dQ5Hnfu4ZoIhFrMZ5IQ=; b=mlKesNipxdTNTSiQtvKlsNSrs99V1pm8HIF9lR3NoPNpx7JFSCIju3aBL1ufGCPTgG kLhXzsfX9zj8ZMryOYYw45INsLZ96b8UEiK7xRQUq3ltPZaSJZNyQfdxVdNp9MtPiV7h pyPZ1fI3aI+owRcNH7QyvRZ/p0N+CKTtiSf5T+qi9KJpG2dKuk6VHQ8zKT4+7jpljfLD smrogdRpCGNEE6RgYflQsH2oPS/apIjichOWW6BQs5ekQc1iihVbPc5CvkOSBcT3NFXz Zuj/U09Bt7SjLk3msTvbNw96MyNwBk079mD+LA4N2zZwl188EsKHOWqYlifbVxxwXPl5 wNRA== X-Gm-Message-State: AOAM5335gqS80TVWOThRg0hqXtb1nS1Hs0pGl4EpkJn1FlmYq2emDcIR 5ZHWptkc7eyfZoBiQZohC9ZNhLhHBfw= X-Google-Smtp-Source: ABdhPJyoCotXSJDEu1nvqRsOM0C3ME3gTlljYEC8JEoL0GtcV8psK90AojXJxEyYmNXdvoNZKLkrIw== X-Received: by 2002:a05:620a:1998:: with SMTP id bm24mr1770186qkb.444.1630647188531; Thu, 02 Sep 2021 22:33:08 -0700 (PDT) Return-Path: Received: from benjamind-benjamindomain.. ([2607:f2c0:e98c:24:56bd:6598:f34d:ffdf]) by smtp.gmail.com with ESMTPSA id y19sm2439020qtv.21.2021.09.02.22.33.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 22:33:08 -0700 (PDT) From: "Benjamin Doron" To: devel@edk2.groups.io Cc: Chasel Chiu , Nate DeSimone Subject: [edk2-platforms][PATCH v3 1/2] KabylakeOpenBoardPkg/AspireVn7Dash572G/BoardEcLib: Check for NULL Date: Fri, 3 Sep 2021 01:32:40 -0400 Message-Id: <20210903053241.22928-1-benjamin.doron00@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210903051930.21649-1-benjamin.doron00@gmail.com> References: <20210903051930.21649-1-benjamin.doron00@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Check that Data pointer is not NULL. Also update some notes on this library. The documented return values are updated. Cc: Chasel Chiu Cc: Nate DeSimone Signed-off-by: Benjamin Doron --- Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Include/Library/Boar= dEcLib.h | 11 +++---- Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardEcLib/E= cCommands.c | 31 +++++++++++++------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Include/= Library/BoardEcLib.h b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572= G/Include/Library/BoardEcLib.h index 2e7e0573900a..6b8d92ce056b 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Include/Library= /BoardEcLib.h +++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Include/Library= /BoardEcLib.h @@ -12,12 +12,13 @@ /**=0D Reads a byte of EC RAM.=0D =0D - @param[in] Address Address to read=0D - @param[out] Data Data received=0D + @param[in] Address Address to read=0D + @param[out] Data Data received=0D =0D - @retval EFI_SUCCESS Command success=0D - @retval EFI_DEVICE_ERROR Command error=0D - @retval EFI_TIMEOUT Command timeout=0D + @retval EFI_SUCCESS Command success=0D + @retval EFI_INVALID_PARAMETER Data is NULL=0D + @retval EFI_DEVICE_ERROR Command error=0D + @retval EFI_TIMEOUT Command timeout=0D **/=0D EFI_STATUS=0D EcCmd90Read (=0D diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/= BoardEcLib/EcCommands.c b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash= 572G/Library/BoardEcLib/EcCommands.c index 09b2b5ee9180..b779717f410e 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardEc= Lib/EcCommands.c +++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardEc= Lib/EcCommands.c @@ -12,18 +12,22 @@ #include =0D #include =0D =0D -/* TODO - Implement:=0D +/* Notes:=0D + * - ACPI "CMDB": Writing to this offset is equivalent to sending commands= .=0D + * The CMDx bytes contain the command parameters.=0D + *=0D + * TODO - Implement:=0D * - Commands: 0x58, 0xE1 and 0xE2=0D * - 0x51, 0x52: EC flash write?=0D * - ACPI CMDB: 0x63 and 0x64, 0xC7=0D * - 0x0B: Flash write (Boolean argument? Set in offset 0x0B?)=0D *=0D - * NB: Consider that if a vendor's UEFI driver consumes=0D - * unimplemented PPI/protocol, the driver is dead code.=0D + * Reversing vendor's protocols:=0D + * - Only read and write are used.=0D + * - Query, ACPI "CMDB" processing and command 58 are unused.=0D + * - Equivalent KbcPeim is an unused PPI.=0D *=0D - * NOTE: Check protocol use.=0D - * - Commands delivered across vendor's modules=0D - * - EC writes also control behaviour=0D + * NB: Also look for potential EC library=0D */=0D =0D #define EC_INDEX_IO_PORT 0x1200=0D @@ -34,12 +38,13 @@ /**=0D Reads a byte of EC RAM.=0D =0D - @param[in] Address Address to read=0D - @param[out] Data Data received=0D + @param[in] Address Address to read=0D + @param[out] Data Data received=0D =0D - @retval EFI_SUCCESS Command success=0D - @retval EFI_DEVICE_ERROR Command error=0D - @retval EFI_TIMEOUT Command timeout=0D + @retval EFI_SUCCESS Command success=0D + @retval EFI_INVALID_PARAMETER Data is NULL=0D + @retval EFI_DEVICE_ERROR Command error=0D + @retval EFI_TIMEOUT Command timeout=0D **/=0D EFI_STATUS=0D EcCmd90Read (=0D @@ -49,6 +54,10 @@ EcCmd90Read ( {=0D EFI_STATUS Status;=0D =0D + if (Data =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D Status =3D SendEcCommand (0x90);=0D if (EFI_ERROR (Status)) {=0D DEBUG((DEBUG_ERROR, "%a(): SendEcCommand(0x90) failed!\n", __FUNCTION_= _));=0D --=20 2.31.1