Home | History | Annotate | Download | only in mifare
      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 function that is compatible
     33  * to this definition.
     34  * It is mandatory to define such a routine for components that interact with other components up or
     35  * down the stack. Moreover, such components shall provide a function within their API to enable the
     36  * 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 structure). For instance,
     40  *      a component that needs to give control to a component up the stack needs to call the completion
     41  *      routine of the upper component. The value to assign to this parameter is the address of
     42  *      the context structure instance of the called component. Such a structure usually contains all
     43  *      variables, data or state information a component member needs for operation. The address of the
     44  *      upper instance must be known by the lower (completing) instance. The mechanism to ensure that this
     45  *      information is present involves the structure phFriNfc_CplRt_t . See its documentation for
     46  *      further information.
     47  *
     48  *      Second Parameter: Status Value
     49  *      The lower layer hands over the completion status via this parameter. The completion
     50  *      routine that has been called needs to process the status in a way that is comparable to what
     51  *      a regular function return value would require.
     52  *
     53  *       The prototype of the component's Process(ing) functions has to be compatible to this
     54  *       function pointer declaration for components interacting with others. In other cases, where
     55  *       there is no interaction or asynchronous processing the definition of the Process(ing)
     56  *       function can be arbitrary, if present at all.
     57  */
     58 typedef void (*pphFriNfc_Cr_t) (void*, NFCSTATUS);
     59 
     60 /*
     61  * Completion Routine structure
     62  *
     63  * This structure finds itself within each component that requires to report completion
     64  * to an upper (calling) component.
     65  * Depending on the actual implementation (static or dynamic completion information) the stack
     66  * Initialization or the calling component needs to inform the initialized or called component
     67  * about the completion path. This information is submitted via this structure.
     68  */
     69 typedef struct phFriNfc_CplRt
     70 {
     71     pphFriNfc_Cr_t    CompletionRoutine; /* Address of the upper Layer's Process(ing) function to call upon completion.
     72                                           *   The stack initializer (or depending on the implementation: the calling component)
     73                                           *   needs to set this member to the address of the function that needs to be within
     74                                           *   the completion path: A calling component would give its own processing function
     75                                           *   address to the lower layer.
     76                                           */
     77     void             *Context;           /* Instance address (context) parameter.
     78                                           *   The stack initializer (or depending on the implementation: the calling component)
     79                                           *   needs to set this member to the address of the component context structure instance
     80                                           *   within the completion path: A calling component would give its own instance address
     81                                           *   to the lower layer.
     82                                           */
     83 } phFriNfc_CplRt_t;
     84 
     85 #endif /* __PHFRINFC_H__ */
     86