#include "ScmiDxe.h"\r
#include "ScmiPrivate.h"\r
\r
-STATIC CONST SCMI_PROTOCOL_INIT_TABLE ProtocolInitFxns[MAX_PROTOCOLS] = {\r
- { ScmiBaseProtocolInit },\r
- { NULL },\r
- { NULL },\r
- { ScmiPerformanceProtocolInit },\r
- { ScmiClockProtocolInit },\r
- { NULL }\r
+STATIC CONST SCMI_PROTOCOL_ENTRY Protocols[] = {\r
+ { SCMI_PROTOCOL_ID_BASE, ScmiBaseProtocolInit },\r
+ { SCMI_PROTOCOL_ID_PERFORMANCE, ScmiPerformanceProtocolInit },\r
+ { SCMI_PROTOCOL_ID_CLOCK, ScmiClockProtocolInit }\r
};\r
\r
/** ARM SCMI driver entry point function.\r
UINT32 Version;\r
UINT32 Index;\r
UINT32 NumProtocols;\r
- UINT32 ProtocolNo;\r
+ UINT32 ProtocolIndex;\r
UINT8 SupportedList[MAX_PROTOCOLS];\r
UINT32 SupportedListSize = sizeof (SupportedList);\r
\r
- ProtocolNo = SCMI_PROTOCOL_ID_BASE & PROTOCOL_ID_MASK;\r
-\r
// Every SCMI implementation must implement the base protocol.\r
- Status = ProtocolInitFxns[ProtocolNo].Init (&ImageHandle);\r
+ ASSERT (Protocols[0].Id == SCMI_PROTOCOL_ID_BASE);\r
+\r
+ Status = ScmiBaseProtocolInit (&ImageHandle);\r
if (EFI_ERROR (Status)) {\r
ASSERT (FALSE);\r
return Status;\r
}\r
\r
// Install supported protocol on ImageHandle.\r
- for (Index = 0; Index < NumProtocols; Index++) {\r
- ProtocolNo = SupportedList[Index] & PROTOCOL_ID_MASK;\r
- if (ProtocolInitFxns[ProtocolNo].Init != NULL) {\r
- Status = ProtocolInitFxns[ProtocolNo].Init (&ImageHandle);\r
- if (EFI_ERROR (Status)) {\r
- ASSERT (FALSE);\r
- return Status;\r
+ for (ProtocolIndex = 1; ProtocolIndex < ARRAY_SIZE (Protocols);\r
+ ProtocolIndex++) {\r
+ for (Index = 0; Index < NumProtocols; Index++) {\r
+ if (Protocols[ProtocolIndex].Id == SupportedList[Index]) {\r
+ Status = Protocols[ProtocolIndex].InitFn (&ImageHandle);\r
+ if (EFI_ERROR (Status)) {\r
+ ASSERT_EFI_ERROR (Status);\r
+ return Status;\r
+ }\r
+ break;\r
}\r
}\r
}\r
#ifndef SCMI_DXE_H_\r
#define SCMI_DXE_H_\r
\r
+#include "ScmiPrivate.h"\r
+\r
#define MAX_PROTOCOLS 6\r
-#define PROTOCOL_ID_MASK 0xF\r
#define MAX_VENDOR_LEN SCMI_MAX_STR_LEN\r
\r
/** Pointer to protocol initialization function.\r
);\r
\r
typedef struct {\r
- SCMI_PROTOCOL_INIT_FXN Init;\r
-} SCMI_PROTOCOL_INIT_TABLE;\r
+ SCMI_PROTOCOL_ID Id; // Protocol Id.\r
+ SCMI_PROTOCOL_INIT_FXN InitFn; // Protocol init function.\r
+} SCMI_PROTOCOL_ENTRY;\r
\r
#endif /* SCMI_DXE_H_ */\r