From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by mx.groups.io with SMTP id smtpd.web10.439.1596212374340309222 for ; Fri, 31 Jul 2020 09:19:34 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=FgJ0Ag8B; spf=pass (domain: nuviainc.com, ip: 209.85.128.67, mailfrom: tomas@nuviainc.com) Received: by mail-wm1-f67.google.com with SMTP id c80so8990243wme.0 for ; Fri, 31 Jul 2020 09:19:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=K7ukcYhoQsNx7V2pqWjxK4h1HEX8uzxw17AcEAho8pI=; b=FgJ0Ag8BQFf+OZKYIDbGZ8+fFbP4YnxazLXur+TOkFAcnNgNMbTzqxxyx/o3BmXHOW /VS7Q/UYiGwddUk4uoJMCbHDuqQ+DJIvujDnXAdlUgJtA+FGpBUskwTFG53rwPAKYCGg iQB4pNFDVuN2/HIvWU5TNuUPnEH/nlj0c8fScBCskCwM8RM8D8toBuS1tE5G+DHVJT1e +nkuZyxNh+DV6LYbEof6hhthSbEBzCbUl6HMuiSSjDzbvOlXus9A2O7+YoDsduwn4Du7 tOz25TrsyI5Ize3yxoehbXXOXrRvxNKeU2L5hXDCG3xlrzuIo9kCPqAh8XPbJPA6MR3D 5q+w== 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=K7ukcYhoQsNx7V2pqWjxK4h1HEX8uzxw17AcEAho8pI=; b=afAdv66OquF+CG56aiB7DqLwxVVzJfWmlaf15sSWMM+fdgv8VkFdgAH1ogBoUwNdkw VtgwwUjA7QqSo0PK65ll/9Qm1b0qnCu2J1ndjFtVTyKhCljiAAJGNeBMMzboNIEo5Jzv wTl34nzB40DygjyEldhbDWussIza7DSI8zq1Q2Dfjwm7R+l/kAJcOMZHFmcJHpXhydeG ah21mWsfyCf3UgZtmEwbKIwyhkkGyJfASjjgGJzt7+4NBHAHOFh3MZJVOS+AzifVx7o6 s9GjiERVmFzXEJaquZstsQXMv44wWwtgIs4DgRcAC72YM1Dfbg3cqdvRv2b793rqABF6 PkoQ== X-Gm-Message-State: AOAM532t/ZZtf6fFtPJmoLlF0YoCjRJScuAxMALldEopBukGAPwVpBjQ YuRHi94+OMuc78Umnu3I/lx9d20lDMLUQzwMfH43RUx4uQXVf9QDO8JRsIkqV4DJP8yB8Q8/XxX nQVTeTljegeEu38Zq/iwnqefGhDuyuu/y4v2WQbp6PJubORDQqitXK38C1QZoU9sm37s= X-Google-Smtp-Source: ABdhPJzjs/3t6mh3qmsIrpGGQnCEg0/lGVG4XHIp5BIdx46je/Y46TJYAMwXFMdZwfbmoazs16lG5Q== X-Received: by 2002:a1c:9e84:: with SMTP id h126mr4266410wme.61.1596212372496; Fri, 31 Jul 2020 09:19:32 -0700 (PDT) Return-Path: Received: from localhost.localdomain (cpc159317-cmbg20-2-0-cust162.5-4.cable.virginm.net. [81.111.29.163]) by smtp.gmail.com with ESMTPSA id v11sm14149739wrr.10.2020.07.31.09.19.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:19:31 -0700 (PDT) From: "Tomas Pilar (tpilar)" To: devel@edk2.groups.io Cc: Sami Mujawar , Alexei Fedorov Subject: [PATCH 4/8] DynamicTablesPkg: Update ConfigurationManagerProtocol Date: Fri, 31 Jul 2020 17:19:22 +0100 Message-Id: <20200731161926.341330-5-tomas@nuviainc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200731161926.341330-1-tomas@nuviainc.com> References: <20200731161926.341330-1-tomas@nuviainc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The Configuration Manager Protocol is updated to include a FreeObject function that must be used by the callers to GetObject to clean up any dynamic allocations and other resources reserved by the Configuration Manager in the process of fulfilling the request in GetObject. A NULL inline static FreeObject function is provided for the ease of transition for v1.0 managers. Cc: Sami Mujawar Cc: Alexei Fedorov Signed-off-by: Tomas Pilar --- .../Protocol/ConfigurationManagerProtocol.h | 83 ++++++++++++++++++- 1 file changed, 80 insertions(+), 3 deletions(-) diff --git a/DynamicTablesPkg/Include/Protocol/ConfigurationManagerProtocol.h b/DynamicTablesPkg/Include/Protocol/ConfigurationManagerProtocol.h index 7de1be3b23..72bf3c79bc 100644 --- a/DynamicTablesPkg/Include/Protocol/ConfigurationManagerProtocol.h +++ b/DynamicTablesPkg/Include/Protocol/ConfigurationManagerProtocol.h @@ -25,7 +25,7 @@ /** This macro defines the Configuration Manager Protocol Revision. */ -#define EDKII_CONFIGURATION_MANAGER_PROTOCOL_REVISION CREATE_REVISION (1, 0) +#define EDKII_CONFIGURATION_MANAGER_PROTOCOL_REVISION CREATE_REVISION (1, 1) #pragma pack(1) @@ -35,10 +35,18 @@ typedef struct ConfigurationManagerProtocol EDKII_CONFIGURATION_MANAGER_PROTOCOL; typedef struct PlatformRepositoryInfo EDKII_PLATFORM_REPOSITORY_INFO; -/** The GetObject function defines the interface implemented by the +/** The GetObject function defines the interface of the Configuration Manager Protocol for returning the Configuration Manager Objects. + If Token is CM_NULL_TOKEN, the function provides in its output all + the objects of the given CmObjectId. If the Token is not CM_NULL_TOKEN, + the function provides only those object that match both the CmObjectId + and Token. + + The memory in CmObject.Data may be static or dynamic. The caller of this + function must call FreeObject on the CmObject populated by this function. + @param [in] This Pointer to the Configuration Manager Protocol. @param [in] CmObjectId The Configuration Manager Object ID. @param [in] Token An optional token identifying the object. If @@ -62,10 +70,24 @@ EFI_STATUS IN OUT CM_OBJ_DESCRIPTOR * CONST CmObject ); -/** The SetObject function defines the interface implemented by the +/** The SetObject function defines the interface of the Configuration Manager Protocol for updating the Configuration Manager Objects. + If Token is CM_NULL_TOKEN, and CmObject is not NULL, then the objects + in the configuration manager that match the CmObjectId and do not + have an associated cross reference Token are replaced by the contents of + CmObject. + + If Token is not CM_NULL_TOKEN and CmObject is not NULL, then the objects + that match both CmObjectId and Token in the configuration manager are + replaced with the contents of CmObject. + + If CmObject is NULL, then objects that match the CmObjectId and Token + are removed from the configuration manager. If Token is also CM_NULL_TOKEN, + then all objects of given CmObjectId are removed, regardless of their + cross-reference Token. + @param [in] This Pointer to the Configuration Manager Protocol. @param [in] CmObjectId The Configuration Manager Object ID. @param [in] Token An optional token identifying the object. If @@ -90,6 +112,29 @@ EFI_STATUS IN CM_OBJ_DESCRIPTOR * CONST CmObject ); +/** The FreeObject function defines the interface of the + Configuration Manager Protocol for correctly freeing resources + that have been reserved by calls to the GetObject interface. + + The caller of GetObject must use this function to dispose of CmObject + populated by the GetObject call when the CmObject is no longer needed. + + If an implementation of the Configuration Manager Protocol does not + use dynamically allocated memory, this function should simply return + EFI_SUCCESS. + + @param [in] This Pointer to the Configuration Manager Protocol + @param [in] CmObject Pointer to the CmObject that has been populated + by the GetObject function and is to be destroyed. + @retval EFI_SUCCESS The CmObject was successfully destroyed +**/ +typedef +EFI_STATUS +(EFIAPI * EDKII_CONFIGURATION_MANAGER_FREE_OBJECT) ( + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST This, + IN CM_OBJ_DESCRIPTOR * CmObject + ); + /** The EDKII_CONFIGURATION_MANAGER_PROTOCOL structure describes the Configuration Manager Protocol interface. */ @@ -111,12 +156,44 @@ typedef struct ConfigurationManagerProtocol { provisioned by the Configuration Manager. */ EDKII_PLATFORM_REPOSITORY_INFO * PlatRepoInfo; + + /** The interface used to destroy CmObject instances + populated by calls to GetObject + */ + EDKII_CONFIGURATION_MANAGER_FREE_OBJECT FreeObject; } EDKII_CONFIGURATION_MANAGER_PROTOCOL; /** The Configuration Manager Protocol GUID. */ extern EFI_GUID gEdkiiConfigurationManagerProtocolGuid; +/** Inline NULL implementation of FreeObject for backward compatibility + of configuration managers that do not require to deallocate any + memory following a call to GetObject. + + @param[in] This Pointer to Configuration Manager Protocol instance + @param[in] CmObject Pointer to CmObject populated by GetObject + + @retval EFI_SUCCESS Successfully handled CmObject. + @retval EFI_INVALID_PARAMETER CmObject is NULL. + @retval EFI_INVALID_PARAMETER This is NULL. + @retval EFI_INVALID_PARAMETER CmObject is not valid. +**/ +static +inline +EFI_STATUS +EFIAPI EdkiiCfgMgrFreeObjectNull ( + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST This, + IN CM_OBJ_DESCRIPTOR * CmObject + ) +{ + if (!This || !CmObject) { + return EFI_INVALID_PARAMETER; + } + + return EFI_SUCCESS; +} + #pragma pack() #endif // CONFIGURATION_MANAGER_PROTOCOL_H_ -- 2.25.1