1 /* 2 * Copyright (C) 2015 The Android Open Source Project 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 17 /* 18 * NFC FRI Main Header. 19 */ 20 21 #ifndef PHFRINFC_H 22 #define PHFRINFC_H 23 #include <phNfcTypes.h> 24 25 #define LOCK_BITS_CHECK_ENABLE 26 27 #define NFCSTATUS_INVALID_DEVICE_REQUEST (0x10F5) 28 29 /* 30 * Completion Routine 31 * 32 * NFC-FRI components that work in an overlapped style need to provide a 33 * function that is compatible to this definition. It is mandatory to define 34 * such a routine for components that interact with other components up or down 35 * the stack. Moreover, such components shall provide a function within their 36 * API to enable the setting of the Completion Routine address and parameters. 37 * 38 * First Parameter: Context 39 * Set to the address of the called instance (component instance context 40 * structure). For instance, a component that needs to give control to a 41 * component up the stack needs to call the completion routine of the upper 42 * component. The value to assign to this parameter is the address of the 43 * context structure instance of the called component. Such a structure 44 * usually contains all variables, data or state information a component member 45 * needs for operation. The address of the upper instance must be known by 46 * the lower (completing) instance. The mechanism to ensure that this 47 * information is present involves the structure phFriNfc_CplRt_t . See its 48 * documentation for further information. 49 * 50 * Second Parameter: Status Value 51 * The lower layer hands over the completion status via this parameter. The 52 * completion routine that has been called needs to process the status in a way 53 * that is comparable to what a regular function return value would 54 * require. 55 * 56 * The prototype of the component's Process(ing) functions has to be 57 * compatible to this function pointer declaration for components interacting 58 * with others. In other cases, where there is no interaction or 59 * asynchronous processing the definition of the Process(ing) function can 60 * be arbitrary, if present at all. 61 */ 62 typedef void (*pphFriNfc_Cr_t)(void*, NFCSTATUS); 63 64 /* 65 * Completion Routine structure 66 * 67 * This structure finds itself within each component that requires to report 68 * completion to an upper (calling) component. Depending on the actual 69 * implementation (static or dynamic completion information) the stack 70 * Initialization or the calling component needs to inform the initialized or 71 * called component about the completion path. This information is submitted via 72 * this structure. 73 */ 74 typedef struct phFriNfc_CplRt { 75 pphFriNfc_Cr_t CompletionRoutine; /* Address of the upper Layer's Process(ing) 76 * function to call upon completion. The 77 * stack initializer (or depending on the 78 * implementation: the calling component) 79 * needs to set this member to the address 80 * of the function that needs to be within 81 * the completion path: A calling 82 * component would give its own processing 83 * function address to the lower layer. 84 */ 85 void* Context; /* Instance address (context) parameter. 86 * The stack initializer (or depending on the 87 * implementation: the calling component) 88 * needs to set this member to the address of 89 * the component context structure instance 90 * within the completion path: A 91 * calling component would give its own 92 * instance address to the lower layer. 93 */ 94 } phFriNfc_CplRt_t; 95 96 #endif /* __PHFRINFC_H__ */ 97