1 /* 2 * Copyright (C) 2019-2020 NXP Semiconductors 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 #include <hardware/nfc.h> 18 #include "NxpNfc.h" 19 #include "phNfcStatus.h" 20 #include "phNxpConfig.h" 21 #include "phNxpLog.h" 22 23 /****************************************************************************** 24 ** Function phNxpNciHal_ioctlIf 25 ** 26 ** Description This function shall be called from HAL when libnfc-nci 27 ** calls phNxpNciHal_ioctl() to perform any IOCTL operation 28 ** 29 ** Returns return 0 on success and -1 on fail, 30 ******************************************************************************/ 31 int phNxpNciHal_ioctlIf(long arg, void* p_data); 32 33 /******************************************************************************* 34 ** 35 ** Function phNxpNciHal_savePersistLog 36 ** 37 ** Description Save persist log with “reason” at available index. 38 ** 39 ** Parameters uint8_t reason 40 ** 41 ** Returns returns the index of saved reason/Log. 42 *******************************************************************************/ 43 uint8_t phNxpNciHal_savePersistLog(uint8_t reason); 44 45 /******************************************************************************* 46 ** 47 ** Function phNxpNciHal_loadPersistLog 48 ** 49 ** Description If given index is valid, return a log at the given index. 50 ** 51 ** Parameters uint8_t index 52 ** 53 ** Returns If index found, return a log as string else 54 ** return a "" string 55 *******************************************************************************/ 56 string phNxpNciHal_loadPersistLog(uint8_t index); 57 58 /******************************************************************************* 59 ** 60 ** Function phNxpNciHal_getSystemProperty 61 ** 62 ** Description It shall be used to get property value of the given Key 63 ** 64 ** Parameters string key 65 ** 66 ** Returns It returns the property value of the key 67 *******************************************************************************/ 68 string phNxpNciHal_getSystemProperty(string key); 69 70 /******************************************************************************* 71 ** 72 ** Function phNxpNciHal_setSystemProperty 73 ** 74 ** Description It shall be used to save/chage value to system property 75 ** based on provided key. 76 ** 77 ** Parameters string key, string value 78 ** 79 ** Returns true if success, false if fail 80 *******************************************************************************/ 81 bool phNxpNciHal_setSystemProperty(string key, string value); 82 83 /******************************************************************************* 84 ** 85 ** Function phNxpNciHal_getNxpConfig 86 ** 87 ** Description It shall be used to read config values from the 88 *libnfc-nxp.conf 89 ** 90 ** Parameters nxpConfigs config 91 ** 92 ** Returns void 93 *******************************************************************************/ 94 string phNxpNciHal_getNxpConfigIf(); 95 96 /******************************************************************************* 97 ** 98 ** Function phNxpNciHal_resetEse 99 ** 100 ** Description It shall be used to to reset eSE by proprietary command. 101 ** 102 ** Parameters None 103 ** 104 ** Returns status of eSE reset response 105 *******************************************************************************/ 106 NFCSTATUS phNxpNciHal_resetEse(uint64_t resetType); 107 108 /****************************************************************************** 109 ** Function phNxpNciHal_setNxpTransitConfig 110 ** 111 ** Description This function overwrite libnfc-nxpTransit.conf file 112 ** with transitConfValue. 113 ** 114 ** Returns bool. 115 ** 116 *******************************************************************************/ 117 bool phNxpNciHal_setNxpTransitConfig(char* transitConfValue); 118 119 /******************************************************************************* 120 ** 121 ** Function: phNxpNciHal_CheckFwRegFlashRequired() 122 ** 123 ** Description: Updates FW and Reg configurations if required 124 ** 125 ** Returns: status 126 ** 127 ********************************************************************************/ 128 int phNxpNciHal_CheckFwRegFlashRequired(uint8_t* fw_update_req, 129 uint8_t* rf_update_req, 130 uint8_t skipEEPROMRead); 131 132 /******************************************************************************* 133 ** 134 ** Function: property_get_intf() 135 ** 136 ** Description: Gets property value for the input property name 137 ** 138 ** Parameters propName: Name of the property whichs value need to get 139 ** valueStr: output value of the property. 140 ** defaultStr: default value of the property if value is not 141 ** there this will be set to output value. 142 ** 143 ** Returns: actual length of the property value 144 ** 145 ********************************************************************************/ 146 int property_get_intf(const char* propName, char* valueStr, 147 const char* defaultStr); 148 149 /******************************************************************************* 150 ** 151 ** Function: property_set_intf() 152 ** 153 ** Description: Sets property value for the input property name 154 ** 155 ** Parameters propName: Name of the property whichs value need to set 156 ** valueStr: value of the property. 157 ** 158 ** Returns: returns 0 on success, < 0 on failure 159 ** 160 ********************************************************************************/ 161 int property_set_intf(const char* propName, const char* valueStr); 162 163 /******************************************************************************* 164 ** 165 ** Function: phNxpNciHal_Abort() 166 ** 167 ** Description: This function shall be used to trigger the abort 168 ** 169 ** Parameters None 170 ** 171 ** Returns: returns 0 on success, < 0 on failure 172 ** 173 ********************************************************************************/ 174 bool phNxpNciHal_Abort(); 175 176 #undef PROPERTY_VALUE_MAX 177 #define PROPERTY_VALUE_MAX 92 178 #define property_get(a, b, c) property_get_intf(a, b, c) 179 #define property_set(a, b) property_set_intf(a, b)