]>
Commit | Line | Data |
---|---|---|
4f2494cf GP |
1 | /** @file\r |
2 | \r | |
3 | Copyright (c) 2017-2018, Arm Limited. All rights reserved.\r | |
4 | \r | |
5 | This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | System Control and Management Interface V1.0\r | |
14 | http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/\r | |
15 | DEN0056A_System_Control_and_Management_Interface.pdf\r | |
16 | **/\r | |
17 | \r | |
18 | #include <Base.h>\r | |
19 | #include <Library/DebugLib.h>\r | |
20 | #include <Library/MemoryAllocationLib.h>\r | |
21 | #include <Library/UefiBootServicesTableLib.h>\r | |
22 | #include <Protocol/ArmScmiBaseProtocol.h>\r | |
23 | #include <Protocol/ArmScmiClockProtocol.h>\r | |
24 | #include <Protocol/ArmScmiPerformanceProtocol.h>\r | |
25 | \r | |
26 | #include "ArmScmiBaseProtocolPrivate.h"\r | |
27 | #include "ArmScmiClockProtocolPrivate.h"\r | |
28 | #include "ArmScmiPerformanceProtocolPrivate.h"\r | |
29 | #include "ScmiDxe.h"\r | |
30 | #include "ScmiPrivate.h"\r | |
31 | \r | |
32 | STATIC CONST SCMI_PROTOCOL_INIT_TABLE ProtocolInitFxns[MAX_PROTOCOLS] = {\r | |
33 | { ScmiBaseProtocolInit },\r | |
34 | { NULL },\r | |
35 | { NULL },\r | |
36 | { ScmiPerformanceProtocolInit },\r | |
37 | { ScmiClockProtocolInit },\r | |
38 | { NULL }\r | |
39 | };\r | |
40 | \r | |
41 | /** ARM SCMI driver entry point function.\r | |
42 | \r | |
43 | This function installs the SCMI Base protocol and a list of other\r | |
44 | protocols is queried using the Base protocol. If protocol is supported,\r | |
45 | driver will call each protocol init function to install the protocol on\r | |
46 | the ImageHandle.\r | |
47 | \r | |
48 | @param[in] ImageHandle Handle to this EFI Image which will be used to\r | |
49 | install Base, Clock and Performance protocols.\r | |
50 | @param[in] SystemTable A pointer to boot time system table.\r | |
51 | \r | |
52 | @retval EFI_SUCCESS Driver initalized successfully.\r | |
53 | @retval EFI_UNSUPPORTED If SCMI base protocol version is not supported.\r | |
54 | @retval !(EFI_SUCCESS) Other errors.\r | |
55 | **/\r | |
56 | EFI_STATUS\r | |
57 | EFIAPI\r | |
58 | ArmScmiDxeEntryPoint (\r | |
59 | IN EFI_HANDLE ImageHandle,\r | |
60 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
61 | )\r | |
62 | {\r | |
63 | EFI_STATUS Status;\r | |
64 | SCMI_BASE_PROTOCOL *BaseProtocol;\r | |
65 | UINT32 Version;\r | |
66 | UINT32 Index;\r | |
67 | UINT32 NumProtocols;\r | |
68 | UINT32 ProtocolNo;\r | |
69 | UINT8 SupportedList[MAX_PROTOCOLS];\r | |
70 | UINT32 SupportedListSize = sizeof (SupportedList);\r | |
71 | \r | |
72 | ProtocolNo = SCMI_PROTOCOL_ID_BASE & PROTOCOL_ID_MASK;\r | |
73 | \r | |
74 | // Every SCMI implementation must implement the base protocol.\r | |
75 | Status = ProtocolInitFxns[ProtocolNo].Init (&ImageHandle);\r | |
76 | if (EFI_ERROR (Status)) {\r | |
77 | ASSERT (FALSE);\r | |
78 | return Status;\r | |
79 | }\r | |
80 | \r | |
81 | Status = gBS->LocateProtocol (\r | |
82 | &gArmScmiBaseProtocolGuid,\r | |
83 | NULL,\r | |
84 | (VOID**)&BaseProtocol\r | |
85 | );\r | |
86 | if (EFI_ERROR (Status)) {\r | |
87 | ASSERT (FALSE);\r | |
88 | return Status;\r | |
89 | }\r | |
90 | \r | |
91 | // Get SCMI Base protocol version.\r | |
92 | Status = BaseProtocol->GetVersion (BaseProtocol, &Version);\r | |
93 | if (EFI_ERROR (Status)) {\r | |
94 | ASSERT (FALSE);\r | |
95 | return Status;\r | |
96 | }\r | |
97 | \r | |
98 | if (Version != BASE_PROTOCOL_VERSION) {\r | |
99 | ASSERT (FALSE);\r | |
100 | return EFI_UNSUPPORTED;\r | |
101 | }\r | |
102 | \r | |
103 | // Apart from Base protocol, SCMI may implement various other protocols,\r | |
104 | // query total protocols implemented by the SCP firmware.\r | |
105 | NumProtocols = 0;\r | |
106 | Status = BaseProtocol->GetTotalProtocols (BaseProtocol, &NumProtocols);\r | |
107 | if (EFI_ERROR (Status)) {\r | |
108 | ASSERT (FALSE);\r | |
109 | return Status;\r | |
110 | }\r | |
111 | \r | |
112 | ASSERT (NumProtocols != 0);\r | |
113 | \r | |
114 | // Get the list of protocols supported by SCP firmware on the platform.\r | |
115 | Status = BaseProtocol->DiscoverListProtocols (\r | |
116 | BaseProtocol,\r | |
117 | &SupportedListSize,\r | |
118 | SupportedList\r | |
119 | );\r | |
120 | if (EFI_ERROR (Status)) {\r | |
121 | ASSERT (FALSE);\r | |
122 | return Status;\r | |
123 | }\r | |
124 | \r | |
125 | // Install supported protocol on ImageHandle.\r | |
126 | for (Index = 0; Index < NumProtocols; Index++) {\r | |
127 | ProtocolNo = SupportedList[Index] & PROTOCOL_ID_MASK;\r | |
128 | if (ProtocolInitFxns[ProtocolNo].Init != NULL) {\r | |
129 | Status = ProtocolInitFxns[ProtocolNo].Init (&ImageHandle);\r | |
130 | if (EFI_ERROR (Status)) {\r | |
131 | ASSERT (FALSE);\r | |
132 | return Status;\r | |
133 | }\r | |
134 | }\r | |
135 | }\r | |
136 | \r | |
137 | return EFI_SUCCESS;\r | |
138 | }\r |