From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) by mx.groups.io with SMTP id smtpd.web12.519.1630646401977443793 for ; Thu, 02 Sep 2021 22:20:02 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XysbZ9/S; spf=pass (domain: gmail.com, ip: 209.85.219.51, mailfrom: benjamin.doron00@gmail.com) Received: by mail-qv1-f51.google.com with SMTP id a5so2571808qvq.0 for ; Thu, 02 Sep 2021 22:20:01 -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:mime-version :content-transfer-encoding; bh=cEjk4kNWFkF5IGZj51JSCPZARVzDDworekyukV0pgbc=; b=XysbZ9/SJqEYMUmHSsB8DIzcyt5Z1VazlTdn2CThpxcXYpUc/hnOaZmV+oL0iI0M/T V2q7idvey2DWErRxV8rp53tSYhK+RFTOs6ow0sn2+BGinoN6Z8yYAGn+2T7Q0hby2Rte yY+Pp5uj11M3fnYGwDQQVjzeJkHX6XUrhCiYXqdwaguTpeY34kEn7b6Q5wF7DOlNLHDe tNlwTHQ1CfQKqPz7zxcKViKAgPK4sp7y2weKG0wKtSY5YtPCDWCLDVyQa0hXbNzpcf2S v9M2YePc7ZYOrdznqQ94T4v5gmhDjQ9eFL3YpnF4aC7jNQaLURSgH4O9VOqwbg5JPkTy R30Q== 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:mime-version :content-transfer-encoding; bh=cEjk4kNWFkF5IGZj51JSCPZARVzDDworekyukV0pgbc=; b=Kqg5aXpqfwIen+vWJTIqqpY3LIjpHrxEncENy1RKdNpv3o+MGrhxo/1eXSIc4XygRN OFXgXgJQPpsxdj1SQpCoehiXCSj2sLEJA/pI+4B8KW34TKhaYv9PMChhCLHYr4k5P8tY Gtcf/NBohEu3VRvjV7i7/z+3hqjj/lU3QRb6AJ05+VoGFks7uax4/hps85DQz7H/PFG2 rHTDpy6PNgV/XVqo2eX5dES+sLhlmaHjcieerCHNghqmlKQj3Q56An7pFyQ7m0QGMlmz HmqtTE1Mfm9zwk1J/hheeJ+uuaTzXG48emU52dR1yXbgaj8RVKZ/5axffYXGIlv3Dycv ZcWg== X-Gm-Message-State: AOAM532SK+K0PiaW/SQtLwkIeiDJVteO8dXdexuY4MR3JZ1gYs+AanSw iYzzik7g94bXZpf9QzrDe+jTNpi51VQ= X-Google-Smtp-Source: ABdhPJxFnkJ35j/NC7Ury7LcnEFK/1QCvz95N/a58fTaI1OssJUb4wVqICtkmU5IAlMBzcptawoXlQ== X-Received: by 2002:a05:6214:28b:: with SMTP id l11mr1884429qvv.18.1630646400945; Thu, 02 Sep 2021 22:20:00 -0700 (PDT) Return-Path: Received: from benjamind-benjamindomain.. ([2607:f2c0:e98c:24:56bd:6598:f34d:ffdf]) by smtp.gmail.com with ESMTPSA id 90sm2528742qte.89.2021.09.02.22.20.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 22:20:00 -0700 (PDT) From: "Benjamin Doron" To: devel@edk2.groups.io Cc: Chasel Chiu , Nate DeSimone Subject: [edk2-platforms][PATCH v2 1/2] KabylakeOpenBoardPkg/AspireVn7Dash572G/BoardEcLib: Check for NULL Date: Fri, 3 Sep 2021 01:19:29 -0400 Message-Id: <20210903051930.21649-1-benjamin.doron00@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Check that Data pointer is not NULL. Also update some notes on this library. 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..0cc20325b9d1 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 Command success=0D + @retval EFI_DEVICE_ERROR Data is NULL=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