• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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 #include <ese/ese.h>
19 #include <ese/teq1.h>
20 
21 #include "ese_operations_interface.h"
22 #include "ese_operations_wrapper.h"
23 
InitializeEse(struct EseInterface * ese,EseOperationsInterface * ops_interface)24 void EseOperationsWrapper::InitializeEse(
25     struct EseInterface *ese, EseOperationsInterface *ops_interface) {
26   EseOperationsWrapperData data;
27   data.ops_interface = ops_interface;
28   ese_init(ese, data.wrapper);
29 }
30 
EseOpen(struct EseInterface * ese,void * data)31 static int EseOpen(struct EseInterface *ese, void *data) {
32   return EseOperationsWrapperData::ops_interface->EseOpen(ese, data);
33 }
34 
EseHwReceive(struct EseInterface * ese,uint8_t * data,uint32_t len,int complete)35 static uint32_t EseHwReceive(struct EseInterface *ese, uint8_t *data, uint32_t len, int complete) {
36   return EseOperationsWrapperData::ops_interface->EseHwReceive(ese, data, len, complete);
37 }
38 
EseHwTransmit(struct EseInterface * ese,const uint8_t * data,uint32_t len,int complete)39 static uint32_t EseHwTransmit(struct EseInterface *ese, const uint8_t *data, uint32_t len, int complete) {
40   return EseOperationsWrapperData::ops_interface->EseHwTransmit(ese, data, len, complete);
41 }
42 
EseReset(struct EseInterface * ese)43 static int EseReset(struct EseInterface *ese) {
44   return EseOperationsWrapperData::ops_interface->EseReset(ese);
45 }
46 
EseTransceive(struct EseInterface * ese,const struct EseSgBuffer * tx_sg,uint32_t tx_nsg,struct EseSgBuffer * rx_sg,uint32_t rx_nsg)47 static uint32_t EseTransceive(struct EseInterface *ese, const struct EseSgBuffer *tx_sg, uint32_t tx_nsg,
48                                struct EseSgBuffer *rx_sg, uint32_t rx_nsg) {
49   return EseOperationsWrapperData::ops_interface->EseTransceive(ese, tx_sg, tx_nsg, rx_sg, rx_nsg);
50 }
51 
EsePoll(struct EseInterface * ese,uint8_t poll_for,float timeout,int complete)52 static int EsePoll(struct EseInterface *ese, uint8_t poll_for, float timeout, int complete) {
53   return EseOperationsWrapperData::ops_interface->EsePoll(ese, poll_for, timeout, complete);
54 }
55 
EseClose(struct EseInterface * ese)56 static void EseClose(struct EseInterface *ese) {
57   return EseOperationsWrapperData::ops_interface->EseClose(ese);
58 }
59 
60 EseOperationsInterface *EseOperationsWrapperData::ops_interface =
61   reinterpret_cast<EseOperationsInterface *>(NULL);
62 
63 static const char *kErrors[] = {
64     TEQ1_ERROR_MESSAGES,
65 };
66 
67 const struct EseOperations EseOperationsWrapperData::ops = {
68   .name = "EseOperationsWrapper HW",
69   .open = &EseOpen,
70   .hw_receive = &EseHwReceive,
71   .hw_transmit = &EseHwTransmit,
72   .hw_reset = &EseReset,
73   .poll = &EsePoll,
74   .transceive = &EseTransceive,
75   .close = &EseClose,
76   .opts = NULL,
77   .errors = kErrors,
78   .errors_count = sizeof(kErrors),
79 };
80 const struct EseOperations *EseOperationsWrapperData::wrapper_ops =
81   &EseOperationsWrapperData::ops;
82