microsoft/mu_feature_ffa

Public

mirrored from https://github.com/microsoft/mu_feature_ffaAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
update

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

FfaFeaturePkg/Library/NotificationServiceLib/NotificationServiceLib.c

536lines · modeblame

97eb3c34Raymond-MS1 years ago1/** @file
2Implementation for the Notification Service
3
4Copyright (c), Microsoft Corporation.
5SPDX-License-Identifier: BSD-2-Clause-Patent
6
7**/
8
9#include <Uefi.h>
10#include <Library/DebugLib.h>
11#include <Library/BaseMemoryLib.h>
12#include <Library/NotificationServiceLib.h>
0585e78fRaymond-MS1 years ago13#include <Guid/NotificationServiceFfa.h>
97eb3c34Raymond-MS1 years ago14
15/* Notification Service Defines */
16#define NOTIFICATION_MAX_SERVICES (16)
1cf65721Raymond-MS1 years ago17#define NOTIFICATION_MAX_MAPPINGS (64)
18#define NOTIFICATION_NOT_FOUND (-1)
19
20#define MESSAGE_INFO_DIR_RESP (0x100)
21#define MESSAGE_INFO_ID_MASK (0x03)
22
23#define RETURN_STATUS_MASK (0xFF)
24
25#define MAPPING_MIN (0x01)
26#define MAPPING_MAX (0x07)
27
28#define PER_VCPU_BIT_POS (0)
97eb3c34Raymond-MS1 years ago29
30/* Notification Service Structures */
31typedef struct {
1cf65721Raymond-MS1 years ago32UINT32 Cookie; // SW defined value
33UINT16 Id; // Global bitmask value
34BOOLEAN PerVcpu; // Notification flag
35UINT16 SourceId;
97eb3c34Raymond-MS1 years ago36BOOLEAN InUse;
1cf65721Raymond-MS1 years ago37} NotifInfo;
97eb3c34Raymond-MS1 years ago38
1cf65721Raymond-MS1 years ago39typedef struct {
97eb3c34Raymond-MS1 years ago40UINT8 ServiceUuid[16];
1cf65721Raymond-MS1 years ago41NotifInfo ServiceInfo[NOTIFICATION_MAX_MAPPINGS];
97eb3c34Raymond-MS1 years ago42BOOLEAN InUse;
43} NotifService;
44
45/* Notification Service Variables */
1cf65721Raymond-MS1 years ago46STATIC UINT64 GlobalBitmask;
47STATIC NotifService NotificationServices[NOTIFICATION_MAX_SERVICES];
97eb3c34Raymond-MS1 years ago48
49/**
1cf65721Raymond-MS1 years ago50Checks if the cookie passed in matches one stored within the service structure
97eb3c34Raymond-MS1 years ago51
1cf65721Raymond-MS1 years ago52@param Cookie The cookie value to search for
53@param Service The service to search for the given ID
97eb3c34Raymond-MS1 years ago54
1cf65721Raymond-MS1 years ago55@return The index of the cookie if found, otherwise -1 (NOTIFICATION_NOT_FOUND)
97eb3c34Raymond-MS1 years ago56
57**/
58STATIC
59INT8
1cf65721Raymond-MS1 years ago60IsMatchingCookie (
61UINT32 Cookie,
97eb3c34Raymond-MS1 years ago62NotifService *Service
63)
64{
03d3c59akuqin121 years ago65UINT8 Index;
a56f62ecRaymond-MS1 years ago66
97eb3c34Raymond-MS1 years ago67/* Validate the incoming function parameters */
68if (Service == NULL) {
1cf65721Raymond-MS1 years ago69return NOTIFICATION_NOT_FOUND;
97eb3c34Raymond-MS1 years ago70}
71
1cf65721Raymond-MS1 years ago72for (Index = 0; Index < NOTIFICATION_MAX_MAPPINGS; Index++) {
73if (Service->ServiceInfo[Index].InUse && (Service->ServiceInfo[Index].Cookie == Cookie)) {
a56f62ecRaymond-MS1 years ago74return Index;
97eb3c34Raymond-MS1 years ago75}
76}
77
1cf65721Raymond-MS1 years ago78return NOTIFICATION_NOT_FOUND;
97eb3c34Raymond-MS1 years ago79}
80
81/**
82Adds or removes service bit information to the local notification services struct array
83
1cf65721Raymond-MS1 years ago84@param Unregister Whether or not we are adding or removing bit information
85@param Request The incoming message containing the bit information
86@param Service The service we are updating bit information for
97eb3c34Raymond-MS1 years ago87
88@retval NOTIFICATION_STATUS_SUCCESS Success
89@retval NOTIFICATION_STATUS_INVALID_PARAMETER Invalid parameter
90
91**/
92STATIC
93NotificationStatus
1cf65721Raymond-MS1 years ago94UpdateServiceInfo (
95BOOLEAN Unregister,
97eb3c34Raymond-MS1 years ago96DIRECT_MSG_ARGS_EX *Request,
97NotifService *Service
98)
99{
1cf65721Raymond-MS1 years ago100NotificationStatus ReturnVal;
101INT8 FoundIndex;
102UINT8 ReqNumMappings;
103NotificationMapping *ReqMappings;
104UINT8 ReqMappingIndex;
105UINT16 MappingId;
106UINT32 Cookie;
107UINT8 PerVcpu;
108UINT8 EmptyIndex;
109BOOLEAN EmptyFound;
110NotifService TempService;
111UINT64 TempBitmask;
a56f62ecRaymond-MS1 years ago112
97eb3c34Raymond-MS1 years ago113/* Validate the incoming function parameters */
114if ((Request == NULL) || (Service == NULL)) {
115return NOTIFICATION_STATUS_INVALID_PARAMETER;
116}
117
1cf65721Raymond-MS1 years ago118/* Number of cookie/ID pairs = x10. Cookie/ID pairs = x11 (i.e. Arg6/Arg7) */
119ReqNumMappings = Request->Arg6;
120ReqMappings = (NotificationMapping *)&Request->Arg7;
97eb3c34Raymond-MS1 years ago121
1cf65721Raymond-MS1 years ago122/* You must be adding/removing at least one bit and no more than a transaction supports */
123if ((ReqNumMappings < MAPPING_MIN) || (ReqNumMappings > MAPPING_MAX)) {
124DEBUG ((DEBUG_ERROR, "Invalid Number of Mappings: %x\n", ReqNumMappings));
a56f62ecRaymond-MS1 years ago125return NOTIFICATION_STATUS_INVALID_PARAMETER;
126}
97eb3c34Raymond-MS1 years ago127
a56f62ecRaymond-MS1 years ago128/* Copy the current service structure and global bitmask to the temporaries */
03d3c59akuqin121 years ago129CopyMem (&TempService, Service, sizeof (NotifService));
a56f62ecRaymond-MS1 years ago130TempBitmask = GlobalBitmask;
131
132/* Need to go through all of the setup bits and update the structure */
1cf65721Raymond-MS1 years ago133ReturnVal = NOTIFICATION_STATUS_SUCCESS;
134for (ReqMappingIndex = 0; ReqMappingIndex < ReqNumMappings; ReqMappingIndex++) {
135MappingId = ReqMappings[ReqMappingIndex].Bits.Id;
136Cookie = ReqMappings[ReqMappingIndex].Bits.Cookie;
137PerVcpu = ReqMappings[ReqMappingIndex].Bits.PerVcpu;
138FoundIndex = IsMatchingCookie (Cookie, &TempService);
139
140/* Check if we are doing an unregister */
141if (Unregister) {
142/* If we can not find the cookie to unregister, it is an error */
143if (FoundIndex == NOTIFICATION_NOT_FOUND) {
144DEBUG ((DEBUG_ERROR, "Invalid Unregister - Cookie: %x Not Registered\n", Cookie));
145ReturnVal = NOTIFICATION_STATUS_INVALID_PARAMETER;
146break;
147/* If the IDs do not match, it is an error */
148} else if (TempService.ServiceInfo[FoundIndex].Id != MappingId) {
149DEBUG ((
150DEBUG_ERROR,
151"Invalid Unregister - ID Registered: %x Mismatch\n",
152TempService.ServiceInfo[FoundIndex].Id
153));
a56f62ecRaymond-MS1 years ago154ReturnVal = NOTIFICATION_STATUS_INVALID_PARAMETER;
155break;
1cf65721Raymond-MS1 years ago156/* If the Source IDs do not match, it is an error */
157} else if (TempService.ServiceInfo[FoundIndex].SourceId != Request->SourceId) {
158DEBUG ((
159DEBUG_ERROR,
160"Invalid Unregister - Source ID: %x Mismatch\n",
161TempService.ServiceInfo[FoundIndex].SourceId
162));
a56f62ecRaymond-MS1 years ago163ReturnVal = NOTIFICATION_STATUS_INVALID_PARAMETER;
164break;
1cf65721Raymond-MS1 years ago165/* Otherwise, clear the data */
a56f62ecRaymond-MS1 years ago166} else {
1cf65721Raymond-MS1 years ago167TempService.ServiceInfo[FoundIndex].Cookie = 0;
168TempService.ServiceInfo[FoundIndex].Id = 0;
169TempService.ServiceInfo[FoundIndex].InUse = FALSE;
170TempService.ServiceInfo[FoundIndex].PerVcpu = FALSE;
171TempService.ServiceInfo[FoundIndex].SourceId = 0;
172TempBitmask &= ~(1 << MappingId);
97eb3c34Raymond-MS1 years ago173}
1cf65721Raymond-MS1 years ago174
175/* Otherwise, we are doing a register */
97eb3c34Raymond-MS1 years ago176} else {
1cf65721Raymond-MS1 years ago177/* If we can find the cookie to register, it is an error */
178if (FoundIndex != NOTIFICATION_NOT_FOUND) {
179DEBUG ((DEBUG_ERROR, "Invalid Register - Cookie: %x Already Registered\n", Cookie));
a56f62ecRaymond-MS1 years ago180ReturnVal = NOTIFICATION_STATUS_INVALID_PARAMETER;
181break;
1cf65721Raymond-MS1 years ago182/* If the Bitmask bit is set, it is an error */
183} else if (TempBitmask & (1 << MappingId)) {
184DEBUG ((DEBUG_ERROR, "Invalid Register - ID: %x Already Registered\n", MappingId));
a56f62ecRaymond-MS1 years ago185ReturnVal = NOTIFICATION_STATUS_INVALID_PARAMETER;
186break;
1cf65721Raymond-MS1 years ago187/* Otherwise, set the data */
a56f62ecRaymond-MS1 years ago188} else {
189/* Need to loop through the bits within the structure and find an empty location */
190EmptyFound = FALSE;
1cf65721Raymond-MS1 years ago191for (EmptyIndex = 0; EmptyIndex < NOTIFICATION_MAX_MAPPINGS; EmptyIndex++) {
192if (!TempService.ServiceInfo[EmptyIndex].InUse) {
a56f62ecRaymond-MS1 years ago193EmptyFound = TRUE;
194break;
195}
97eb3c34Raymond-MS1 years ago196}
197
a56f62ecRaymond-MS1 years ago198/* If we can not find an empty space, it is an error */
199if (!EmptyFound) {
1cf65721Raymond-MS1 years ago200DEBUG ((DEBUG_ERROR, "Register Failed - No Memory Available\n"));
a56f62ecRaymond-MS1 years ago201ReturnVal = NOTIFICATION_STATUS_NO_MEM;
202break;
1cf65721Raymond-MS1 years ago203/* Otherwise, update the data */
a56f62ecRaymond-MS1 years ago204} else {
1cf65721Raymond-MS1 years ago205TempService.ServiceInfo[EmptyIndex].Cookie = Cookie;
206TempService.ServiceInfo[EmptyIndex].Id = MappingId;
207TempService.ServiceInfo[EmptyIndex].InUse = TRUE;
208TempService.ServiceInfo[EmptyIndex].PerVcpu = (PerVcpu) ? TRUE : FALSE;
209TempService.ServiceInfo[EmptyIndex].SourceId = Request->SourceId;
210TempBitmask |= (1 << MappingId);
a56f62ecRaymond-MS1 years ago211}
97eb3c34Raymond-MS1 years ago212}
213}
214
1cf65721Raymond-MS1 years ago215/* Copy the temporaries back if everything was successful */
216if (ReturnVal == NOTIFICATION_STATUS_SUCCESS) {
217CopyMem (Service, &TempService, sizeof (NotifService));
218GlobalBitmask = TempBitmask;
219}
a56f62ecRaymond-MS1 years ago220}
221
97eb3c34Raymond-MS1 years ago222return ReturnVal;
223}
224
225/**
1cf65721Raymond-MS1 years ago226Searches the NotificationServices structure for the provided UUID or an
227empty location to place a new service.
97eb3c34Raymond-MS1 years ago228
1cf65721Raymond-MS1 years ago229@param Uuid The UUID to search for
230@param LocateEmpty Whether or not to search for an empty location
97eb3c34Raymond-MS1 years ago231
1cf65721Raymond-MS1 years ago232@retval A pointer to the service that matches the UUID, an empty location
233or NULL if no match could be found.
97eb3c34Raymond-MS1 years ago234
235**/
236STATIC
1cf65721Raymond-MS1 years ago237NotifService *
238LocateService (
239UINT8 *Uuid,
240BOOLEAN LocateEmpty
97eb3c34Raymond-MS1 years ago241)
242{
1cf65721Raymond-MS1 years ago243UINT8 Index;
244NotifService *Service;
a56f62ecRaymond-MS1 years ago245
1cf65721Raymond-MS1 years ago246Service = NULL;
97eb3c34Raymond-MS1 years ago247
1cf65721Raymond-MS1 years ago248/* Traverse the NotificationServices structure */
a56f62ecRaymond-MS1 years ago249for (Index = 0; Index < NOTIFICATION_MAX_SERVICES; Index++) {
1cf65721Raymond-MS1 years ago250/* If looking for a UUID, check if the service is marked as InUse */
251if (!LocateEmpty && NotificationServices[Index].InUse) {
252/* Check if the UUID matches */
253if (!CompareMem (Uuid, NotificationServices[Index].ServiceUuid, sizeof (Uuid))) {
254Service = &NotificationServices[Index];
255break;
256}
257
258/* If looking for an empty location, check if the service is not marked as InUse */
259} else if (LocateEmpty && !NotificationServices[Index].InUse) {
a56f62ecRaymond-MS1 years ago260Service = &NotificationServices[Index];
97eb3c34Raymond-MS1 years ago261break;
262}
263}
264
1cf65721Raymond-MS1 years ago265return Service;
97eb3c34Raymond-MS1 years ago266}
267
268/**
1cf65721Raymond-MS1 years ago269Handler for Notification Register command
97eb3c34Raymond-MS1 years ago270
271@param Request The incoming message
272@param Response The outgoing message
273
274@retval NOTIFICATION_STATUS_SUCCESS Success
275@retval NOTIFICATION_STATUS_INVALID_PARAMETER Invalid parameter
1cf65721Raymond-MS1 years ago276@retval NOTIFICATION_STATUS_NO_MEM Out of resources
97eb3c34Raymond-MS1 years ago277
278**/
279STATIC
280NotificationStatus
1cf65721Raymond-MS1 years ago281RegisterHandler (
282DIRECT_MSG_ARGS_EX *Request
97eb3c34Raymond-MS1 years ago283)
284{
a56f62ecRaymond-MS1 years ago285NotifService *Service;
286UINT8 Uuid[16];
287NotificationStatus ReturnVal;
288
289ReturnVal = NOTIFICATION_STATUS_NO_MEM;
97eb3c34Raymond-MS1 years ago290
1cf65721Raymond-MS1 years ago291/* Extract the UUID from the message x7-x8 (i.e. Arg3-Arg4) */
292NotificationServiceExtractUuid (Request->Arg3, Request->Arg4, Uuid);
97eb3c34Raymond-MS1 years ago293
1cf65721Raymond-MS1 years ago294/* Attempt to locate the service via the UUID provided */
295Service = LocateService (Uuid, FALSE);
97eb3c34Raymond-MS1 years ago296
297/* The UUID was not found in the list, attempt to find an empty location to add it */
298if (Service == NULL) {
1cf65721Raymond-MS1 years ago299Service = LocateService (Uuid, TRUE);
97eb3c34Raymond-MS1 years ago300}
301
1cf65721Raymond-MS1 years ago302/* Check for a valid UUID */
a56f62ecRaymond-MS1 years ago303if (Service != NULL) {
1cf65721Raymond-MS1 years ago304ReturnVal = UpdateServiceInfo (FALSE, Request, Service);
305/* Check if the update was successful and this was a new addition */
306if ((ReturnVal == NOTIFICATION_STATUS_SUCCESS) && (!Service->InUse)) {
307/* Update the UUID and set the location to InUse */
308CopyMem (Service->ServiceUuid, Uuid, sizeof (Uuid));
309Service->InUse = TRUE;
310}
97eb3c34Raymond-MS1 years ago311} else {
1cf65721Raymond-MS1 years ago312DEBUG ((DEBUG_ERROR, "Service Register Failed - Error Code: %d\n", ReturnVal));
97eb3c34Raymond-MS1 years ago313}
314
315return ReturnVal;
316}
317
318/**
1cf65721Raymond-MS1 years ago319Handler for Notification Unregister command
97eb3c34Raymond-MS1 years ago320
321@param Request The incoming message
322@param Response The outgoing message
323
324@retval NOTIFICATION_STATUS_SUCCESS Success
325@retval NOTIFICATION_STATUS_INVALID_PARAMETER Invalid parameter
326
327**/
328STATIC
329NotificationStatus
1cf65721Raymond-MS1 years ago330UnregisterHandler (
331DIRECT_MSG_ARGS_EX *Request
97eb3c34Raymond-MS1 years ago332)
333{
a56f62ecRaymond-MS1 years ago334NotifService *Service;
335UINT8 Uuid[16];
336NotificationStatus ReturnVal;
337
338ReturnVal = NOTIFICATION_STATUS_INVALID_PARAMETER;
97eb3c34Raymond-MS1 years ago339
1cf65721Raymond-MS1 years ago340/* Extract the UUID from the message x7-x8 (i.e. Arg3-Arg4) */
341NotificationServiceExtractUuid (Request->Arg3, Request->Arg4, Uuid);
97eb3c34Raymond-MS1 years ago342
1cf65721Raymond-MS1 years ago343/* Attempt to locate the service via the UUID provided */
344Service = LocateService (Uuid, FALSE);
97eb3c34Raymond-MS1 years ago345
1cf65721Raymond-MS1 years ago346/* Check for a valid UUID */
a56f62ecRaymond-MS1 years ago347if (Service != NULL) {
1cf65721Raymond-MS1 years ago348ReturnVal = UpdateServiceInfo (TRUE, Request, Service);
97eb3c34Raymond-MS1 years ago349} else {
1cf65721Raymond-MS1 years ago350DEBUG ((DEBUG_ERROR, "Service Unregister Failed - Error Code: %d\n", ReturnVal));
97eb3c34Raymond-MS1 years ago351}
352
353return ReturnVal;
354}
355
356/**
357Initializes the Notification service
358
359**/
360VOID
361NotificationServiceInit (
362VOID
363)
364{
1cf65721Raymond-MS1 years ago365/* Initialize Global Bitmask */
a56f62ecRaymond-MS1 years ago366GlobalBitmask = 0;
367
1cf65721Raymond-MS1 years ago368/* Initialize the Notification Service structure */
369ZeroMem (&NotificationServices[0], sizeof (NotificationServices));
97eb3c34Raymond-MS1 years ago370}
371
372/**
373Deinitializes the Notification service
374
375**/
376VOID
377NotificationServiceDeInit (
378VOID
379)
380{
381/* Nothing to DeInit */
382}
383
384/**
385Handler for Notification service commands
386
387@param Request The incoming message
388@param Response The outgoing message
389
390**/
391VOID
392NotificationServiceHandle (
393DIRECT_MSG_ARGS_EX *Request,
394DIRECT_MSG_ARGS_EX *Response
395)
396{
1cf65721Raymond-MS1 years ago397NotificationStatus ReturnVal;
a56f62ecRaymond-MS1 years ago398
97eb3c34Raymond-MS1 years ago399/* Validate the input parameters before attempting to dereference or pass them along */
400if ((Request == NULL) || (Response == NULL)) {
401return;
402}
403
1cf65721Raymond-MS1 years ago404/* TODO: Figure out how to set x5-x8 */
405/* Set common response register values */
406Response->Arg1 = Request->Arg1;
407Response->Arg2 = Request->Arg2;
408Response->Arg3 = Request->Arg3;
409Response->Arg4 = Request->Arg4;
410Response->Arg5 = Request->Arg5 | MESSAGE_INFO_DIR_RESP;
411
412/* Message ID = Bits[0:1] of x9 (i.e. Arg5)*/
413switch (Request->Arg5 & MESSAGE_INFO_ID_MASK) {
414case NOTIFICATION_OPCODE_ADD:
415case NOTIFICATION_OPCODE_REMOVE:
416ReturnVal = NOTIFICATION_STATUS_NOT_SUPPORTED;
417DEBUG ((DEBUG_ERROR, "Add/Remove Unsupported\n"));
418break;
97eb3c34Raymond-MS1 years ago419
1cf65721Raymond-MS1 years ago420case NOTIFICATION_OPCODE_MEM_ASSIGN:
421case NOTIFICATION_OPCODE_MEM_UNASSIGN:
422ReturnVal = NOTIFICATION_STATUS_NOT_SUPPORTED;
423DEBUG ((DEBUG_ERROR, "Memory Assign/Unassign Unsupported\n"));
97eb3c34Raymond-MS1 years ago424break;
425
1cf65721Raymond-MS1 years ago426case NOTIFICATION_OPCODE_REGISTER:
427ReturnVal = RegisterHandler (Request);
97eb3c34Raymond-MS1 years ago428break;
429
1cf65721Raymond-MS1 years ago430case NOTIFICATION_OPCODE_UNREGISTER:
431ReturnVal = UnregisterHandler (Request);
97eb3c34Raymond-MS1 years ago432break;
433
434default:
1cf65721Raymond-MS1 years ago435ReturnVal = NOTIFICATION_STATUS_INVALID_PARAMETER;
97eb3c34Raymond-MS1 years ago436DEBUG ((DEBUG_ERROR, "Invalid Notification Service Opcode\n"));
437break;
438}
1cf65721Raymond-MS1 years ago439
440/* Update the return status - Bits[0:7] of x10 (i.e. Arg6) */
441Response->Arg6 = (((UINTN)(UINT8)ReturnVal) & RETURN_STATUS_MASK);
97eb3c34Raymond-MS1 years ago442}
443
444/**
445Calls NotificationSet on the given ID with the given flag
446
447@param Id The ID to trigger the event on
448@param ServiceUuid The service containing the ID to trigger
449@param Flag The NotificationSet flag to use
450
451@retval NOTIFICATION_STATUS_SUCCESS Success
452@retval NOTIFICATION_STATUS_INVALID_PARAMETER Invalid parameter
453
454**/
455NotificationStatus
456NotificationServiceIdSet (
1cf65721Raymond-MS1 years ago457UINT32 Cookie,
97eb3c34Raymond-MS1 years ago458UINT8 *ServiceUuid,
459UINT32 Flag
460)
461{
a56f62ecRaymond-MS1 years ago462NotifService *Service;
463NotificationStatus ReturnVal;
464UINT8 Index;
465UINT64 Bitmask;
466EFI_STATUS Status;
467
97eb3c34Raymond-MS1 years ago468/* Validate the incoming function parameters */
469if (ServiceUuid == NULL) {
470return NOTIFICATION_STATUS_INVALID_PARAMETER;
471}
472
a56f62ecRaymond-MS1 years ago473ReturnVal = NOTIFICATION_STATUS_INVALID_PARAMETER;
97eb3c34Raymond-MS1 years ago474
1cf65721Raymond-MS1 years ago475/* Attempt to locate the service via the UUID provided */
476Service = LocateService (ServiceUuid, FALSE);
97eb3c34Raymond-MS1 years ago477
1cf65721Raymond-MS1 years ago478/* Check for a valid UUID */
97eb3c34Raymond-MS1 years ago479if (Service != NULL) {
1cf65721Raymond-MS1 years ago480/* Attempt to find the cookie within the mapped list */
481for (Index = 0; Index < NOTIFICATION_MAX_MAPPINGS; Index++) {
482if (Service->ServiceInfo[Index].Cookie == Cookie) {
483Bitmask = (1 << Service->ServiceInfo[Index].Id);
484if (Service->ServiceInfo[Index].PerVcpu) {
485Flag |= (1 << PER_VCPU_BIT_POS);
486}
487
488Status = FfaNotificationSet (Service->ServiceInfo[Index].SourceId, Flag, Bitmask);
489if (!EFI_ERROR (Status)) {
97eb3c34Raymond-MS1 years ago490ReturnVal = NOTIFICATION_STATUS_SUCCESS;
491}
492
493break;
494}
495}
496}
497
498return ReturnVal;
499}
500
501/**
502Extracts the UUID from the message arguments
503
1cf65721Raymond-MS1 years ago504@param UuidLo The lower bytes of the UUID
505@param UuidHi The higher bytes of the UUID
506@param Uuid The UUID to populate
97eb3c34Raymond-MS1 years ago507
508**/
509VOID
510NotificationServiceExtractUuid (
1cf65721Raymond-MS1 years ago511UINT64 UuidLo,
512UINT64 UuidHi,
513UINT8 *Uuid
97eb3c34Raymond-MS1 years ago514)
515{
1cf65721Raymond-MS1 years ago516UINT8 Index;
517UINT8 UuidHiByte;
518UINT8 UuidLoByte;
a56f62ecRaymond-MS1 years ago519
97eb3c34Raymond-MS1 years ago520/* Validate the incoming function parameters */
1cf65721Raymond-MS1 years ago521if (Uuid == NULL) {
97eb3c34Raymond-MS1 years ago522return;
523}
524
525/* Copy the upper 8 bytes */
a56f62ecRaymond-MS1 years ago526for (Index = 0; Index < 8; Index++) {
03d3c59akuqin121 years ago527UuidHiByte = (UINT8)(UuidHi >> ((7 - Index) * 8));
a56f62ecRaymond-MS1 years ago528Uuid[Index] = UuidHiByte;
97eb3c34Raymond-MS1 years ago529}
530
531/* Copy the lower 8 bytes */
a56f62ecRaymond-MS1 years ago532for (Index = 8; Index < 16; Index++) {
03d3c59akuqin121 years ago533UuidLoByte = (UINT8)(UuidLo >> ((15 - Index) * 8));
a56f62ecRaymond-MS1 years ago534Uuid[Index] = UuidLoByte;
97eb3c34Raymond-MS1 years ago535}
536}