1 /*
2 * Copyright (C) 2022 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 #pragma once
17
18 #include <stddef.h>
19 #include <stdint.h>
20 #include <sys/types.h>
21 #include <sys/uio.h>
22 #include <uapi/trusty_uuid.h>
23
24 #define INFINITE_TIME 1
25 #define IPC_MAX_MSG_HANDLES 8
26
27 #define IPC_PORT_ALLOW_TA_CONNECT 0x1
28 #define IPC_PORT_ALLOW_NS_CONNECT 0x2
29
30 #define IPC_CONNECT_WAIT_FOR_PORT 0x1
31
32 #define IPC_HANDLE_POLL_HUP 0x1
33 #define IPC_HANDLE_POLL_MSG 0x2
34 #define IPC_HANDLE_POLL_SEND_UNBLOCKED 0x4
35
36 typedef int handle_t;
37
38 typedef struct ipc_msg {
39 uint32_t num_iov;
40 iovec* iov;
41 uint32_t num_handles;
42 handle_t* handles;
43 } ipc_msg_t;
44
45 typedef struct ipc_msg_info {
46 size_t len;
47 uint32_t id;
48 uint32_t num_handles;
49 } ipc_msg_info_t;
50
51 typedef struct uevent {
52 uint32_t event;
53 } uevent_t;
54
port_create(const char *,uint32_t,uint32_t,uint32_t)55 static inline handle_t port_create(const char*, uint32_t, uint32_t, uint32_t) {
56 return 0;
57 }
connect(const char *,uint32_t)58 static inline handle_t connect(const char*, uint32_t) {
59 return 0;
60 }
accept(handle_t,uuid_t *)61 static inline handle_t accept(handle_t, uuid_t*) {
62 return 0;
63 }
set_cookie(handle_t,void *)64 static inline int set_cookie(handle_t, void*) {
65 return 0;
66 }
handle_set_create(void)67 static inline handle_t handle_set_create(void) {
68 return 0;
69 }
handle_set_ctrl(handle_t,uint32_t,struct uevent *)70 static inline int handle_set_ctrl(handle_t, uint32_t, struct uevent*) {
71 return 0;
72 }
wait(handle_t,uevent_t *,uint32_t)73 static inline int wait(handle_t, uevent_t*, uint32_t) {
74 return 0;
75 }
wait_any(uevent_t *,uint32_t)76 static inline int wait_any(uevent_t*, uint32_t) {
77 return 0;
78 }
get_msg(handle_t,ipc_msg_info_t *)79 static inline int get_msg(handle_t, ipc_msg_info_t*) {
80 return 0;
81 }
read_msg(handle_t,uint32_t,uint32_t,ipc_msg_t *)82 static inline ssize_t read_msg(handle_t, uint32_t, uint32_t, ipc_msg_t*) {
83 return 0;
84 }
put_msg(handle_t,uint32_t)85 static inline int put_msg(handle_t, uint32_t) {
86 return 0;
87 }
send_msg(handle_t,ipc_msg_t *)88 static inline ssize_t send_msg(handle_t, ipc_msg_t*) {
89 return 0;
90 }
91