|
20 | 20 | */ |
21 | 21 |
|
22 | 22 | #include <errno.h> |
23 | | -#include <libhexagonrpc/fastrpc.h> |
24 | | -#include <libhexagonrpc/interfaces/remotectl.def> |
| 23 | +#include <libhexagonrpc/hexagonrpc.h> |
| 24 | +#include <libhexagonrpc/interfaces/remotectl.h> |
25 | 25 | #include <libhexagonrpc/session.h> |
26 | 26 | #include <stdio.h> |
27 | 27 | #include <stdlib.h> |
28 | 28 | #include <string.h> |
29 | 29 |
|
30 | | -#include "interfaces/chre_slpi.def" |
| 30 | +#include "interfaces/chre_slpi.h" |
31 | 31 |
|
32 | | -/* TODO move these to libhexagonrpc since most clients use them */ |
33 | | -static int remotectl_open(int fd, char *name, struct fastrpc_context **ctx, void (*err_cb)(const char *err)) |
| 32 | +int main(void) |
34 | 33 | { |
35 | | - uint32_t handle; |
36 | | - int32_t dlret; |
37 | 34 | char err[256]; |
38 | | - int ret; |
39 | | - |
40 | | - ret = fastrpc2(&remotectl_open_def, fd, REMOTECTL_HANDLE, |
41 | | - strlen(name) + 1, name, |
42 | | - &handle, |
43 | | - &dlret, |
44 | | - 256, err); |
45 | | - |
46 | | - if (ret == -1) { |
47 | | - err_cb(strerror(errno)); |
48 | | - return ret; |
49 | | - } |
50 | | - |
51 | | - if (dlret == -5) { |
52 | | - err_cb(err); |
53 | | - return dlret; |
54 | | - } |
55 | | - |
56 | | - *ctx = fastrpc_create_context(fd, handle); |
57 | | - |
58 | | - return ret; |
59 | | -} |
60 | | - |
61 | | -static int remotectl_close(struct fastrpc_context *ctx, void (*err_cb)(const char *err)) |
62 | | -{ |
63 | | - uint32_t dlret; |
64 | | - char err[256]; |
65 | | - int ret; |
66 | | - |
67 | | - ret = fastrpc2(&remotectl_close_def, ctx->fd, REMOTECTL_HANDLE, |
68 | | - ctx->handle, |
69 | | - &dlret, |
70 | | - 256, err); |
71 | | - |
72 | | - if (ret == -1) { |
73 | | - err_cb(strerror(errno)); |
74 | | - return ret; |
75 | | - } |
76 | | - |
77 | | - fastrpc_destroy_context(ctx); |
78 | | - |
79 | | - return ret; |
80 | | -} |
81 | | - |
82 | | -static void remotectl_err(const char *err) |
83 | | -{ |
84 | | - fprintf(stderr, "Could not remotectl: %s\n", err); |
85 | | -} |
86 | | - |
87 | | -static int chre_slpi_start_thread(struct fastrpc_context *ctx) |
88 | | -{ |
89 | | - return fastrpc(&chre_slpi_start_thread_def, ctx); |
90 | | -} |
91 | | - |
92 | | -static int chre_slpi_wait_on_thread_exit(struct fastrpc_context *ctx) |
93 | | -{ |
94 | | - return fastrpc(&chre_slpi_wait_on_thread_exit_def, ctx); |
95 | | -} |
96 | | - |
97 | | -int main() |
98 | | -{ |
99 | | - struct fastrpc_context *ctx; |
100 | 35 | int fd, ret; |
101 | 36 |
|
102 | 37 | fd = hexagonrpc_fd_from_env(); |
103 | 38 | if (fd == -1) |
104 | 39 | return 1; |
105 | 40 |
|
106 | | - ret = remotectl_open(fd, "chre_slpi", &ctx, remotectl_err); |
107 | | - if (ret) |
| 41 | + ret = hrpc_open_chre_slpi(256, err); |
| 42 | + if (ret) { |
| 43 | + fprintf(stderr, "Could not open CHRE: %s\n", err); |
108 | 44 | return 1; |
| 45 | + } |
109 | 46 |
|
110 | | - ret = chre_slpi_start_thread(ctx); |
| 47 | + ret = chre_slpi_start_thread(); |
111 | 48 | if (ret) { |
112 | 49 | fprintf(stderr, "Could not start CHRE\n"); |
113 | | - goto err; |
| 50 | + return 1; |
114 | 51 | } |
115 | 52 |
|
116 | | - ret = chre_slpi_wait_on_thread_exit(ctx); |
| 53 | + ret = chre_slpi_wait_on_thread_exit(); |
117 | 54 | if (ret) { |
118 | 55 | fprintf(stderr, "Could not wait for CHRE thread\n"); |
119 | | - goto err; |
| 56 | + return 1; |
120 | 57 | } |
121 | | - |
122 | | -err: |
123 | | - remotectl_close(ctx, remotectl_err); |
124 | 58 | } |
0 commit comments