1 /*
2  * Copyright 2024 NXP
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 
18 #include "WiredSeService.h"
19 #include "phNfcStatus.h"
20 
21 #define NFCEE_ESE_ID 0xC0
22 #define NFCEE_EUICC_ID 0xC1
23 #define NFCEE_EUICC2_ID 0xC2
24 #define NFCEE_INVALID_ID 0x00
25 
26 typedef int32_t (*WiredSeStartFunc_t)(WiredSeService** pWiredSeService);
27 typedef int32_t (*WiredSeDispatchEventFunc_t)(WiredSeService* pWiredSeService,
28                                               WiredSeEvt event);
29 
30 /**
31  * Handle to the Power Tracker stack implementation.
32  */
33 typedef struct {
34   // Function to start wired-se.
35   WiredSeStartFunc_t start;
36   // Function to dispatch events to wired-se subsystem.
37   WiredSeDispatchEventFunc_t dispatchEvent;
38   // WiredSeService instance
39   WiredSeService* pWiredSeService;
40   // WiredSe.so dynamic library handle.
41   void* dlHandle;
42 } WiredSeHandle;
43 
44 /*******************************************************************************
45 **
46 ** Function         phNxpNciHal_WiredSeStart()
47 **
48 ** Description      Starts wired-se HAL. This is the first Api to be invoked.
49 **                  Once it is started it will run throughout the process
50 *lifecycle.
51 **                  It is recommended to call from main() of service.
52 **
53 ** Parameters       outHandle - Handle to the Wired SE subsystem.
54 ** Returns          NFCSTATUS_SUCCESS if WiredSe HAL is started.
55 **                  NFCSTATUS_FAILURE otherwise
56 *******************************************************************************/
57 NFCSTATUS phNxpNciHal_WiredSeStart(WiredSeHandle* outHandle);
58 
59 /*******************************************************************************
60 **
61 ** Function         phNxpNciHal_WiredSeDispatchEvent()
62 **
63 ** Description      Dispatch events to wired-se subsystem.
64 **
65 ** Parameters       inHandle - WiredSe Handle
66 ** Returns          NFCSTATUS_SUCCESS if success.
67 **                  NFCSTATUS_FAILURE otherwise
68 *******************************************************************************/
69 NFCSTATUS phNxpNciHal_WiredSeDispatchEvent(
70     WiredSeHandle* inHandle, WiredSeEvtType evtType,
71     WiredSeEvtData evtData = WiredSeEvtData());
72