1 /*
2  * Copyright (C) 2016 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 #ifndef __NANOHUBCOMMAND_H
18 #define __NANOHUBCOMMAND_H
19 
20 #include <stdint.h>
21 
22 #define NANOHUB_FAST_DONT_ACK       0xFFFFFFFE
23 #define NANOHUB_FAST_UNHANDLED_ACK  0xFFFFFFFF
24 
25 struct NanohubCommand {
26     uint32_t reason;
27     uint32_t (*fastHandler)(void *, uint8_t, void *, uint64_t);
28     uint32_t (*handler)(void *, uint8_t, void *, uint64_t);
29     uint8_t minDataLen;
30     uint8_t maxDataLen;
31 };
32 
33 void nanohubInitCommand(void);
34 void nanohubPrefetchTx(uint32_t interrupt, uint32_t wakeup, uint32_t nonwakeup);
35 const struct NanohubCommand *nanohubFindCommand(uint32_t packetReason);
36 
37 struct NanohubHalLegacyCommand {
38     uint8_t msg;
39     void (*handler)(void *, uint8_t);
40 };
41 
42 const struct NanohubHalLegacyCommand *nanohubHalLegacyFindCommand(uint8_t msg);
43 
44 struct NanohubHalCommand {
45     uint8_t msg;
46     void (*handler)(void *, uint8_t, uint32_t);
47     uint8_t minDataLen;
48     uint8_t maxDataLen;
49 };
50 
51 const struct NanohubHalCommand *nanohubHalFindCommand(uint8_t msg);
52 uint64_t hostGetTime(void);
53 int64_t hostGetTimeDelta(void);
54 
55 #endif /* __NANOHUBCOMMAND_H */
56