microsoft/mu_feature_ffa

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
89ca181ebb27a1bf7b8d4e233fb5945e10880437

Branches

Tags

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

Clone

HTTPS

Download ZIP

FfaFeaturePkg/Library/TestServiceLib/TestServiceLib.c

114lines · modecode

1/** @file
2 Implementation for the Test Service
3
4 Copyright (c), Microsoft Corporation.
5 SPDX-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/TestServiceLib.h>
13#include <Library/NotificationServiceLib.h>
14#include <Guid/TestServiceFfa.h>
15#include <Guid/NotificationServiceFfa.h>
16
17/* Test Service Defines */
18#define DELAYED_SRI_BIT_POS (1)
19
20/**
21 Handler for Test Notification command
22
23 @param Request The incoming message
24 @param Response The outgoing message
25
26 @retval TEST_STATUS_SUCCESS Success
27 @retval TEST_STATUS_INVALID_PARAMETER Invalid Parameter
28
29**/
30STATIC
31TestStatus
32TestNotificationHandler (
33 DIRECT_MSG_ARGS_EX *Request,
34 DIRECT_MSG_ARGS_EX *Response
35 )
36{
37 UINT8 Uuid[16] = { 0 };
38 TestStatus ReturnVal = TEST_STATUS_INVALID_PARAMETER;
39
40 /* Extract the UUID from the message */
41 NotificationServiceExtractUuid (Request, Uuid);
42
43 /* Set the notification set flag to be a delayed SRI */
44 UINT32 Flag = (1 << DELAYED_SRI_BIT_POS);
45
46 UINT32 LogicalId = Request->Arg3;
47 NotificationStatus Status = NotificationServiceIdSet (LogicalId, Uuid, Flag);
48
49 /* Check for a valid UUID and validate the input parameters */
50 if (Status == NOTIFICATION_STATUS_SUCCESS) {
51 ReturnVal = TEST_STATUS_SUCCESS;
52 } else {
53 DEBUG ((DEBUG_ERROR, "Test Notification Handler Failed\n"));
54 }
55
56 Response->Arg0 = ReturnVal;
57 return ReturnVal;
58}
59
60/**
61 Initializes the Test service
62
63**/
64VOID
65TestServiceInit (
66 VOID
67 )
68{
69 /* Nothing to Init */
70}
71
72/**
73 Deinitializes the Test service
74
75**/
76VOID
77TestServiceDeInit (
78 VOID
79 )
80{
81 /* Nothing to Deinit */
82}
83
84/**
85 Handler for Test service commands
86
87 @param Request The incoming message
88 @param Response The outgoing message
89
90**/
91VOID
92TestServiceHandle (
93 DIRECT_MSG_ARGS_EX *Request,
94 DIRECT_MSG_ARGS_EX *Response
95 )
96{
97 /* Validate the input parameters before attempting to dereference or pass them along */
98 if ((Request == NULL) || (Response == NULL)) {
99 return;
100 }
101
102 UINT64 Opcode = Request->Arg0;
103
104 switch (Opcode) {
105 case TEST_OPCODE_TEST_NOTIFICATION:
106 TestNotificationHandler (Request, Response);
107 break;
108
109 default:
110 Response->Arg0 = TEST_STATUS_INVALID_PARAMETER;
111 DEBUG ((DEBUG_ERROR, "Invalid Test Service Opcode\n"));
112 break;
113 }
114}