From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) by mx.groups.io with SMTP id smtpd.web09.199.1630643453831292851 for ; Thu, 02 Sep 2021 21:30:54 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=WMQDzNb/; spf=pass (domain: gmail.com, ip: 209.85.160.179, mailfrom: benjamin.doron00@gmail.com) Received: by mail-qt1-f179.google.com with SMTP id g11so3592481qtk.5 for ; Thu, 02 Sep 2021 21:30:53 -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=4FcwtmCEL36/guo60nq8CTrx9CdeD8f+H3aH44AygBU=; b=WMQDzNb/GTCcppWA+t1ka9oXUxLrnSoyvMNEdGw8EVbXEvfQL7Md3iuwV2vcpUF/Ha pDNO4uneNbl20kxbzaGCTuObEWGBv+0ADuA3+r/ms6Oum/m/4KVQKapoITJNkrlPrag3 PfPARh52/WzbtgEpr7OmulNIZhH/qNCoNvyOQgEByx/clQloBFL1mppLhN7Zl+8dRrYt s8MWLwb6x94A6ptMRHRtshKPQU9ysuSir24STY3no83XjXdy27RZwqoJjcGn0nhdLYCS pbJ7CUen4A9v+4o1K3PR3ue4nZEbHNRor53/+ByQe1rJKzpz8WPKY0S6OEQ5BojSGk+J 3tQg== 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=4FcwtmCEL36/guo60nq8CTrx9CdeD8f+H3aH44AygBU=; b=jzUl1l7jaCndxKv1eUFKBbrnWgR1glNf4AXlzns00qvTkeCns89LmlvodDO6gqcmN4 LOTZ9J/WcP438XRiyLt11BTjkKihEtxbybWg3WT5IEa+uq9VsD1Uv1J3GBhd8Nizgs5v 15wu6tREbpGT69OvWqW8bWN1couazQvpfke1fUVGzqDsXztf02Zc3QqwG2/oQJro0rcH 2x4ue99b4HQX0KXnGiOY3HetSV/NNJ0e0/XYd/e+8b26zsU/E1WkpmY5VBj1ygeQcEAk KcfA6JTLfIcC2xW06UoOqLW/OJoyMbr7vOoSZmDoWpxOttjWxgLCRoWl6mwG8J4Wo+f9 wy2g== X-Gm-Message-State: AOAM533lsbuxKx0aPp+fZpmIxUoztFfegjjQJxR1KtaaZm/RDRE1Kt4t zW69YM9KiD0wb6VMfxhI7s4jR28Zba4= X-Google-Smtp-Source: ABdhPJyyJ0rScLvV2jpSGytty3aRO29PFxMgkzlFnterZFhoqHOLHMDewJEaEMW/fluuJfp6S+yCLw== X-Received: by 2002:ac8:7285:: with SMTP id v5mr1959067qto.300.1630643452684; Thu, 02 Sep 2021 21:30:52 -0700 (PDT) Return-Path: Received: from benjamind-benjamindomain.. ([2607:f2c0:e98c:24:56bd:6598:f34d:ffdf]) by smtp.gmail.com with ESMTPSA id i16sm2411418qtw.15.2021.09.02.21.30.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 21:30:52 -0700 (PDT) From: "Benjamin Doron" To: devel@edk2.groups.io Cc: Chasel Chiu , Nate DeSimone Subject: [edk2-platforms][PATCH v1 1/2] KabylakeOpenBoardPkg/AspireVn7Dash572G/BoardEcLib: Check for NULL Date: Fri, 3 Sep 2021 00:30:19 -0400 Message-Id: <20210903043020.20233-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..55c0e1495ced 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 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..98507eab34f1 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 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 + * Protocols/PPI reversing:=0D + * - Only read and write are used.=0D + * - EcQuery, ACPI "CMDB" processing and command 58 are unused.=0D + * - Equivalent KbcPeim is 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 Command success=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