microsoft/mu_feature_ffa

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
fix_upload

Branches

Tags

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

Clone

HTTPS

Download ZIP

FfaFeaturePkg/Library/TestServiceLib/TestServiceLib.c

117lines · modeblame

ac0f2cf1Raymond-MS1 years ago1/** @file
2Implementation for the Test 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/TestServiceLib.h>
13#include <Library/NotificationServiceLib.h>
0585e78fRaymond-MS1 years ago14#include <Guid/TestServiceFfa.h>
15#include <Guid/NotificationServiceFfa.h>
ac0f2cf1Raymond-MS1 years ago16
17/* Test Service Defines */
18#define DELAYED_SRI_BIT_POS (1)
19
20/**
21Handler 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 (
33DIRECT_MSG_ARGS_EX *Request,
34DIRECT_MSG_ARGS_EX *Response
35)
36{
a56f62ecRaymond-MS1 years ago37UINT8 Uuid[16];
38TestStatus ReturnVal;
39UINT32 Flag;
1cf65721Raymond-MS1 years ago40UINT32 Cookie;
a56f62ecRaymond-MS1 years ago41NotificationStatus Status;
42
43ReturnVal = TEST_STATUS_INVALID_PARAMETER;
ac0f2cf1Raymond-MS1 years ago44
1cf65721Raymond-MS1 years ago45/* Extract the UUID from the message x5-x6 (i.e. Arg1-Arg2) */
46NotificationServiceExtractUuid (Request->Arg1, Request->Arg2, Uuid);
ac0f2cf1Raymond-MS1 years ago47
48/* Set the notification set flag to be a delayed SRI */
1cf65721Raymond-MS1 years ago49Flag = (1 << DELAYED_SRI_BIT_POS);
50Cookie = Request->Arg3;
51Status = NotificationServiceIdSet (Cookie, Uuid, Flag);
ac0f2cf1Raymond-MS1 years ago52
53/* Check for a valid UUID and validate the input parameters */
54if (Status == NOTIFICATION_STATUS_SUCCESS) {
55ReturnVal = TEST_STATUS_SUCCESS;
56} else {
57DEBUG ((DEBUG_ERROR, "Test Notification Handler Failed\n"));
58}
59
60Response->Arg0 = ReturnVal;
61return ReturnVal;
62}
63
64/**
65Initializes the Test service
66
67**/
68VOID
69TestServiceInit (
70VOID
71)
72{
73/* Nothing to Init */
74}
75
76/**
77Deinitializes the Test service
78
79**/
80VOID
81TestServiceDeInit (
82VOID
83)
84{
85/* Nothing to Deinit */
86}
87
88/**
89Handler for Test service commands
90
91@param Request The incoming message
92@param Response The outgoing message
93
94**/
95VOID
96TestServiceHandle (
97DIRECT_MSG_ARGS_EX *Request,
98DIRECT_MSG_ARGS_EX *Response
99)
100{
101/* Validate the input parameters before attempting to dereference or pass them along */
102if ((Request == NULL) || (Response == NULL)) {
103return;
104}
105
1cf65721Raymond-MS1 years ago106/* Command Opcode = x4 (i.e. Arg0)*/
107switch (Request->Arg0) {
ac0f2cf1Raymond-MS1 years ago108case TEST_OPCODE_TEST_NOTIFICATION:
109TestNotificationHandler (Request, Response);
110break;
111
112default:
113Response->Arg0 = TEST_STATUS_INVALID_PARAMETER;
114DEBUG ((DEBUG_ERROR, "Invalid Test Service Opcode\n"));
115break;
116}
117}