TianoCore EDK2 master
Loading...
Searching...
No Matches
ScmiPerformanceProtocol.c
Go to the documentation of this file.
1
15
17#include "ScmiPrivate.h"
18
35 OUT UINT32 *Version
36 )
37{
38 return ScmiGetProtocolVersion (ScmiProtocolIdPerformance, Version);
39}
40
56 )
57{
58 EFI_STATUS Status;
59 UINT32 *ReturnValues;
60
62 ScmiProtocolIdPerformance,
63 &ReturnValues
64 );
65 if (EFI_ERROR (Status)) {
66 return Status;
67 }
68
69 CopyMem (
70 Attributes,
71 ReturnValues,
73 );
74
75 return EFI_SUCCESS;
76}
77
93 IN UINT32 DomainId,
95 )
96{
97 EFI_STATUS Status;
98 UINT32 *MessageParams;
99 UINT32 *ReturnValues;
100 UINT32 PayloadLength;
101 SCMI_COMMAND Cmd;
102
103 Status = ScmiCommandGetPayload (&MessageParams);
104 if (EFI_ERROR (Status)) {
105 return Status;
106 }
107
108 *MessageParams = DomainId;
109
110 Cmd.ProtocolId = ScmiProtocolIdPerformance;
111 Cmd.MessageId = ScmiMessageIdPerformanceDomainAttributes;
112
113 PayloadLength = sizeof (DomainId);
114
115 Status = ScmiCommandExecute (
116 &Cmd,
117 &PayloadLength,
118 &ReturnValues
119 );
120 if (EFI_ERROR (Status)) {
121 return Status;
122 }
123
124 CopyMem (
125 DomainAttributes,
126 ReturnValues,
128 );
129
130 return EFI_SUCCESS;
131}
132
150STATIC
154 IN UINT32 DomainId,
155 OUT UINT32 *NumLevels,
156 IN OUT UINT32 *LevelArraySize,
157 OUT SCMI_PERFORMANCE_LEVEL *LevelArray
158 )
159{
160 EFI_STATUS Status;
161 UINT32 PayloadLength;
162 SCMI_COMMAND Cmd;
163 UINT32 *MessageParams;
164 UINT32 LevelIndex;
165 UINT32 RequiredSize;
166 UINT32 LevelNo;
167 UINT32 ReturnNumLevels;
168 UINT32 ReturnRemainNumLevels;
169
170 PERF_DESCRIBE_LEVELS *Levels;
171
172 Status = ScmiCommandGetPayload (&MessageParams);
173 if (EFI_ERROR (Status)) {
174 return Status;
175 }
176
177 LevelIndex = 0;
178 RequiredSize = 0;
179
180 *MessageParams++ = DomainId;
181
182 Cmd.ProtocolId = ScmiProtocolIdPerformance;
183 Cmd.MessageId = ScmiMessageIdPerformanceDescribeLevels;
184
185 do {
186 *MessageParams = LevelIndex;
187
188 // Note, PayloadLength is an IN/OUT parameter.
189 PayloadLength = sizeof (DomainId) + sizeof (LevelIndex);
190
191 Status = ScmiCommandExecute (
192 &Cmd,
193 &PayloadLength,
194 (UINT32 **)&Levels
195 );
196 if (EFI_ERROR (Status)) {
197 return Status;
198 }
199
200 ReturnNumLevels = NUM_PERF_LEVELS (Levels->NumLevels);
201 ReturnRemainNumLevels = NUM_REMAIN_PERF_LEVELS (Levels->NumLevels);
202
203 if (RequiredSize == 0) {
204 *NumLevels = ReturnNumLevels + ReturnRemainNumLevels;
205
206 RequiredSize = (*NumLevels) * sizeof (SCMI_PERFORMANCE_LEVEL);
207 if (RequiredSize > (*LevelArraySize)) {
208 // Update LevelArraySize with required size.
209 *LevelArraySize = RequiredSize;
210 return EFI_BUFFER_TOO_SMALL;
211 }
212 }
213
214 for (LevelNo = 0; LevelNo < ReturnNumLevels; LevelNo++) {
215 CopyMem (
216 &LevelArray[LevelIndex++],
217 &Levels->PerfLevel[LevelNo],
219 );
220 }
221 } while (ReturnRemainNumLevels != 0);
222
223 *LevelArraySize = RequiredSize;
224
225 return EFI_SUCCESS;
226}
227
241 IN UINT32 DomainId,
243 )
244{
245 EFI_STATUS Status;
246 UINT32 PayloadLength;
247 SCMI_COMMAND Cmd;
248 UINT32 *MessageParams;
249
250 Status = ScmiCommandGetPayload (&MessageParams);
251 if (EFI_ERROR (Status)) {
252 return Status;
253 }
254
255 *MessageParams++ = DomainId;
256 *MessageParams++ = Limits->RangeMax;
257 *MessageParams = Limits->RangeMin;
258
259 Cmd.ProtocolId = ScmiProtocolIdPerformance;
260 Cmd.MessageId = ScmiMessageIdPerformanceLimitsSet;
261
262 PayloadLength = sizeof (DomainId) + sizeof (SCMI_PERFORMANCE_LIMITS);
263
264 Status = ScmiCommandExecute (
265 &Cmd,
266 &PayloadLength,
267 NULL
268 );
269
270 return Status;
271}
272
287 UINT32 DomainId,
289 )
290{
291 EFI_STATUS Status;
292 UINT32 PayloadLength;
293 SCMI_COMMAND Cmd;
294 UINT32 *MessageParams;
295
296 SCMI_PERFORMANCE_LIMITS *ReturnValues;
297
298 Status = ScmiCommandGetPayload (&MessageParams);
299 if (EFI_ERROR (Status)) {
300 return Status;
301 }
302
303 *MessageParams = DomainId;
304
305 Cmd.ProtocolId = ScmiProtocolIdPerformance;
306 Cmd.MessageId = ScmiMessageIdPerformanceLimitsGet;
307
308 PayloadLength = sizeof (DomainId);
309
310 Status = ScmiCommandExecute (
311 &Cmd,
312 &PayloadLength,
313 (UINT32 **)&ReturnValues
314 );
315 if (EFI_ERROR (Status)) {
316 return Status;
317 }
318
319 Limits->RangeMax = ReturnValues->RangeMax;
320 Limits->RangeMin = ReturnValues->RangeMin;
321
322 return EFI_SUCCESS;
323}
324
338 IN UINT32 DomainId,
339 IN UINT32 Level
340 )
341{
342 EFI_STATUS Status;
343 UINT32 PayloadLength;
344 SCMI_COMMAND Cmd;
345 UINT32 *MessageParams;
346
347 Status = ScmiCommandGetPayload (&MessageParams);
348 if (EFI_ERROR (Status)) {
349 return Status;
350 }
351
352 *MessageParams++ = DomainId;
353 *MessageParams = Level;
354
355 Cmd.ProtocolId = ScmiProtocolIdPerformance;
356 Cmd.MessageId = ScmiMessageIdPerformanceLevelSet;
357
358 PayloadLength = sizeof (DomainId) + sizeof (Level);
359
360 Status = ScmiCommandExecute (
361 &Cmd,
362 &PayloadLength,
363 NULL
364 );
365
366 return Status;
367}
368
383 IN UINT32 DomainId,
384 OUT UINT32 *Level
385 )
386{
387 EFI_STATUS Status;
388 UINT32 PayloadLength;
389 SCMI_COMMAND Cmd;
390 UINT32 *ReturnValues;
391 UINT32 *MessageParams;
392
393 Status = ScmiCommandGetPayload (&MessageParams);
394 if (EFI_ERROR (Status)) {
395 return Status;
396 }
397
398 *MessageParams = DomainId;
399
400 Cmd.ProtocolId = ScmiProtocolIdPerformance;
401 Cmd.MessageId = ScmiMessageIdPerformanceLevelGet;
402
403 PayloadLength = sizeof (DomainId);
404
405 Status = ScmiCommandExecute (
406 &Cmd,
407 &PayloadLength,
408 &ReturnValues
409 );
410 if (EFI_ERROR (Status)) {
411 return Status;
412 }
413
414 *Level = *ReturnValues;
415
416 return EFI_SUCCESS;
417}
418
441 IN UINT32 DomainId,
444 )
445{
446 EFI_STATUS Status;
447 SCMI_COMMAND Cmd;
448 UINT32 PayloadLength;
449 UINT32 *ReturnValues;
450 UINT32 *MessageParams;
451
452 if ((This == NULL) ||
453 (FastChannel == NULL))
454 {
455 return EFI_INVALID_PARAMETER;
456 }
457
458 Status = ScmiCommandGetPayload (&MessageParams);
459 if (EFI_ERROR (Status)) {
460 return Status;
461 }
462
463 *MessageParams++ = DomainId;
464 *MessageParams = MessageId;
465
466 Cmd.ProtocolId = ScmiProtocolIdPerformance;
467 Cmd.MessageId = ScmiMessageIdPerformanceDescribeFastchannel;
468 PayloadLength = sizeof (DomainId) + sizeof (MessageId);
469
470 Status = ScmiCommandExecute (
471 &Cmd,
472 &PayloadLength,
473 &ReturnValues
474 );
475 if (EFI_ERROR (Status)) {
476 return Status;
477 }
478
479 CopyMem (
480 FastChannel,
481 ReturnValues,
483 );
484
485 return Status;
486}
487
488// Instance of the SCMI performance management protocol.
489STATIC CONST SCMI_PERFORMANCE_PROTOCOL PerformanceProtocol = {
499};
500
510 IN EFI_HANDLE *Handle
511 )
512{
513 return gBS->InstallMultipleProtocolInterfaces (
514 Handle,
515 &gArmScmiPerformanceProtocolGuid,
516 &PerformanceProtocol,
517 NULL
518 );
519}
SCMI_MESSAGE_ID_PERFORMANCE
SCMI Message Ids for the Performance Protocol.
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define STATIC
Definition: Base.h:264
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
EFI_STATUS ScmiGetProtocolVersion(IN SCMI_PROTOCOL_ID ProtocolId, OUT UINT32 *Version)
Definition: Scmi.c:190
EFI_STATUS ScmiCommandExecute(IN SCMI_COMMAND *Command, IN OUT UINT32 *PayloadLength, OUT UINT32 **ReturnValues OPTIONAL)
Definition: Scmi.c:76
EFI_STATUS ScmiCommandGetPayload(OUT UINT32 **Payload)
Definition: Scmi.c:31
EFI_STATUS ScmiGetProtocolAttributes(IN SCMI_PROTOCOL_ID ProtocolId, OUT UINT32 **ReturnValues)
Definition: Scmi.c:222
EFI_STATUS PerformanceLevelGet(IN SCMI_PERFORMANCE_PROTOCOL *This, IN UINT32 DomainId, OUT UINT32 *Level)
EFI_STATUS DescribeFastchannel(IN SCMI_PERFORMANCE_PROTOCOL *This, IN UINT32 DomainId, IN SCMI_MESSAGE_ID_PERFORMANCE MessageId, OUT SCMI_PERFORMANCE_FASTCHANNEL *FastChannel)
EFI_STATUS PerformanceLimitsGet(SCMI_PERFORMANCE_PROTOCOL *This, UINT32 DomainId, SCMI_PERFORMANCE_LIMITS *Limits)
STATIC EFI_STATUS PerformanceGetAttributes(IN SCMI_PERFORMANCE_PROTOCOL *This, OUT SCMI_PERFORMANCE_PROTOCOL_ATTRIBUTES *Attributes)
STATIC EFI_STATUS PerformanceDomainAttributes(IN SCMI_PERFORMANCE_PROTOCOL *This, IN UINT32 DomainId, OUT SCMI_PERFORMANCE_DOMAIN_ATTRIBUTES *DomainAttributes)
STATIC EFI_STATUS PerformanceDescribeLevels(IN SCMI_PERFORMANCE_PROTOCOL *This, IN UINT32 DomainId, OUT UINT32 *NumLevels, IN OUT UINT32 *LevelArraySize, OUT SCMI_PERFORMANCE_LEVEL *LevelArray)
EFI_STATUS ScmiPerformanceProtocolInit(IN EFI_HANDLE *Handle)
EFI_STATUS PerformanceLimitsSet(IN SCMI_PERFORMANCE_PROTOCOL *This, IN UINT32 DomainId, IN SCMI_PERFORMANCE_LIMITS *Limits)
STATIC EFI_STATUS PerformanceGetVersion(IN SCMI_PERFORMANCE_PROTOCOL *This, OUT UINT32 *Version)
EFI_STATUS PerformanceLevelSet(IN SCMI_PERFORMANCE_PROTOCOL *This, IN UINT32 DomainId, IN UINT32 Level)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
Performance protocol describe fastchannel.