mirror of https://github.com/acidanthera/audk.git
ArmPkg/ArmScmiDxe: Dynamically allocate buffer for protocol ids
Dynamically allocate the buffer to receive the SCMI protocol list. This makes MAX_PROTOCOLS redundant, so it is removed. It also fixes one minor code alignment issue and removes an unused macro PROTOCOL_MASK. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Girish Pathak <girish.pathak@arm.com> Tested-by: Sudeep Holla <sudeep.holla@arm.com> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
This commit is contained in:
parent
889cf68c3c
commit
3b03b5e990
|
@ -22,11 +22,6 @@
|
||||||
|
|
||||||
#include "ScmiPrivate.h"
|
#include "ScmiPrivate.h"
|
||||||
|
|
||||||
// SCMI Specification 1.0
|
|
||||||
#define MAX_PROTOCOLS 6
|
|
||||||
|
|
||||||
#define PROTOCOL_MASK 0xF
|
|
||||||
|
|
||||||
// Arbitrary timeout value 20ms.
|
// Arbitrary timeout value 20ms.
|
||||||
#define RESPONSE_TIMEOUT 20000
|
#define RESPONSE_TIMEOUT 20000
|
||||||
|
|
||||||
|
|
|
@ -63,8 +63,8 @@ ArmScmiDxeEntryPoint (
|
||||||
UINT32 Index;
|
UINT32 Index;
|
||||||
UINT32 NumProtocols;
|
UINT32 NumProtocols;
|
||||||
UINT32 ProtocolIndex;
|
UINT32 ProtocolIndex;
|
||||||
UINT8 SupportedList[MAX_PROTOCOLS];
|
UINT8 *SupportedList;
|
||||||
UINT32 SupportedListSize = sizeof (SupportedList);
|
UINT32 SupportedListSize;
|
||||||
|
|
||||||
// Every SCMI implementation must implement the base protocol.
|
// Every SCMI implementation must implement the base protocol.
|
||||||
ASSERT (Protocols[0].Id == SCMI_PROTOCOL_ID_BASE);
|
ASSERT (Protocols[0].Id == SCMI_PROTOCOL_ID_BASE);
|
||||||
|
@ -108,13 +108,26 @@ ArmScmiDxeEntryPoint (
|
||||||
|
|
||||||
ASSERT (NumProtocols != 0);
|
ASSERT (NumProtocols != 0);
|
||||||
|
|
||||||
|
SupportedListSize = (NumProtocols * sizeof (*SupportedList));
|
||||||
|
|
||||||
|
Status = gBS->AllocatePool (
|
||||||
|
EfiBootServicesData,
|
||||||
|
SupportedListSize,
|
||||||
|
(VOID**)&SupportedList
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
ASSERT (FALSE);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the list of protocols supported by SCP firmware on the platform.
|
// Get the list of protocols supported by SCP firmware on the platform.
|
||||||
Status = BaseProtocol->DiscoverListProtocols (
|
Status = BaseProtocol->DiscoverListProtocols (
|
||||||
BaseProtocol,
|
BaseProtocol,
|
||||||
&SupportedListSize,
|
&SupportedListSize,
|
||||||
SupportedList
|
SupportedList
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
|
gBS->FreePool (SupportedList);
|
||||||
ASSERT (FALSE);
|
ASSERT (FALSE);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
@ -134,5 +147,7 @@ ArmScmiDxeEntryPoint (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gBS->FreePool (SupportedList);
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
#include "ScmiPrivate.h"
|
#include "ScmiPrivate.h"
|
||||||
|
|
||||||
#define MAX_PROTOCOLS 6
|
|
||||||
#define MAX_VENDOR_LEN SCMI_MAX_STR_LEN
|
#define MAX_VENDOR_LEN SCMI_MAX_STR_LEN
|
||||||
|
|
||||||
/** Pointer to protocol initialization function.
|
/** Pointer to protocol initialization function.
|
||||||
|
|
Loading…
Reference in New Issue