1 /******************************************************************************
2 *
3 * Copyright (C) 2018 NXP Semiconductors
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 ******************************************************************************/
18 #include "NxpEse.h"
19 #include "phNxpEse_Api.h"
20
21 namespace vendor {
22 namespace nxp {
23 namespace nxpese {
24 namespace V1_0 {
25 namespace implementation {
26 using ::android::hardware::hidl_vec;
27 // Methods from ::vendor::nxp::nxpese::V1_0::INxpEse follow.
ioctl(uint64_t ioctlType,const hidl_vec<uint8_t> & inOutData,ioctl_cb _hidl_cb)28 Return<void> NxpEse::ioctl(uint64_t ioctlType,
29 const hidl_vec<uint8_t>& inOutData,
30 ioctl_cb _hidl_cb) {
31 ese_nxp_IoctlInOutData_t inpOutData;
32 ese_nxp_IoctlInOutData_t* pInOutData =
33 (ese_nxp_IoctlInOutData_t*)&inOutData[0];
34
35 /*data from proxy->stub is copied to local data which can be updated by
36 * underlying HAL implementation since its an inout argument*/
37 memcpy(&inpOutData, pInOutData, sizeof(ese_nxp_IoctlInOutData_t));
38 ESESTATUS status = phNxpEse_spiIoctl(ioctlType, &inpOutData);
39
40 /*copy data and additional fields indicating status of ioctl operation
41 * and context of the caller. Then invoke the corresponding proxy callback*/
42 inpOutData.out.ioctlType = ioctlType;
43 inpOutData.out.context = pInOutData->inp.context;
44 inpOutData.out.result = status;
45 hidl_vec<uint8_t> outputData;
46 outputData.setToExternal((uint8_t*)&inpOutData.out,
47 sizeof(ese_nxp_ExtnOutputData_t));
48 _hidl_cb(outputData);
49 return Void();
50 }
51
52 // Methods from ::android::hidl::base::V1_0::IBase follow.
53
54 } // namespace implementation
55 } // namespace V1_0
56 } // namespace nxpese
57 } // namespace nxp
58 } // namespace vendor
59