Skip to content

Commit a9e337f

Browse files
committed
chrecd: interface: switch chre_slpi interface to interp4
1 parent 5219a6d commit a9e337f

File tree

6 files changed

+106
-73
lines changed

6 files changed

+106
-73
lines changed

chrecd/interface/chre_slpi.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Context Hub Runtime Environment interface - method definitions
3+
*
4+
* Copyright (C) 2025 HexagonRPC Contributors
5+
*
6+
* This file is part of HexagonRPC.
7+
*
8+
* HexagonRPC is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation, either version 3 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
*/
21+
22+
#include <stdint.h>
23+
#include <libhexagonrpc/hexagonrpc.h>
24+
25+
__thread uint32_t chre_slpi;
26+
27+
struct hrpc_method_def_interp4 chre_slpi_start_thread_def = {
28+
.msg_id = 0,
29+
.n_args = 0,
30+
.args = NULL,
31+
.n_inner_types = 0,
32+
.inner_types = NULL,
33+
};
34+
35+
struct hrpc_method_def_interp4 chre_slpi_wait_on_thread_exit_def = {
36+
.msg_id = 1,
37+
.n_args = 0,
38+
.args = NULL,
39+
.n_inner_types = 0,
40+
.inner_types = NULL,
41+
};

chrecd/interface/chre_slpi.h

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Context Hub Runtime Environment interface - API
3+
*
4+
* Copyright (C) 2025 HexagonRPC Contributors
5+
*
6+
* This file is part of HexagonRPC.
7+
*
8+
* HexagonRPC is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation, either version 3 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
*/
21+
22+
#ifndef INTERFACE_CHRE_SLPI_H
23+
#define INTERFACE_CHRE_SLPI_H
24+
25+
#include <stdint.h>
26+
#include <libhexagonrpc/handle.h>
27+
#include <libhexagonrpc/hexagonrpc.h>
28+
#include <libhexagonrpc/session.h>
29+
30+
extern __thread uint32_t chre_slpi;
31+
static inline int hrpc_open_chre_slpi(size_t n_err, char *err)
32+
{
33+
return hexagonrpc_open("chre_slpi",
34+
&chre_slpi,
35+
n_err, err);
36+
}
37+
38+
static inline void hrpc_close_chre_slpi(void)
39+
{
40+
hexagonrpc_close(chre_slpi);
41+
}
42+
43+
extern struct hrpc_method_def_interp4 chre_slpi_start_thread_def;
44+
static inline int chre_slpi_start_thread()
45+
{
46+
return hexagonrpc(&chre_slpi_start_thread_def,
47+
hexagonrpc_fd, chre_slpi);
48+
}
49+
50+
extern struct hrpc_method_def_interp4 chre_slpi_wait_on_thread_exit_def;
51+
static inline int chre_slpi_wait_on_thread_exit()
52+
{
53+
return hexagonrpc(&chre_slpi_wait_on_thread_exit_def,
54+
hexagonrpc_fd, chre_slpi);
55+
}
56+
57+
58+
#endif /* INTERFACE_CHRE_SLPI_H */

chrecd/interfaces.c

Lines changed: 0 additions & 24 deletions
This file was deleted.

chrecd/interfaces/chre_slpi.def

Lines changed: 0 additions & 30 deletions
This file was deleted.

chrecd/main.c

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,53 +20,41 @@
2020
*/
2121

2222
#include <errno.h>
23-
#include <libhexagonrpc/fastrpc.h>
24-
#include <libhexagonrpc/handle.h>
23+
#include <libhexagonrpc/hexagonrpc.h>
2524
#include <libhexagonrpc/session.h>
2625
#include <stdio.h>
2726
#include <stdlib.h>
2827
#include <string.h>
2928

30-
#include "interfaces/chre_slpi.def"
31-
32-
static int chre_slpi_start_thread(int fd, uint32_t handle)
33-
{
34-
return fastrpc2(&chre_slpi_start_thread_def, fd, handle);
35-
}
36-
37-
static int chre_slpi_wait_on_thread_exit(int fd, uint32_t handle)
38-
{
39-
return fastrpc2(&chre_slpi_wait_on_thread_exit_def, fd, handle);
40-
}
29+
#include "interface/chre_slpi.h"
4130

4231
int main()
4332
{
44-
uint32_t handle;
4533
char err[256];
4634
int fd, ret;
4735

4836
fd = hexagonrpc_fd_from_env();
4937
if (fd == -1)
5038
return 1;
5139

52-
ret = hexagonrpc_open("chre_slpi", &handle, 256, err);
40+
ret = hrpc_open_chre_slpi(256, err);
5341
if (ret) {
5442
fprintf(stderr, "Could not open CHRE remote interface: %s\n", err);
5543
return 1;
5644
}
5745

58-
ret = chre_slpi_start_thread(fd, handle);
46+
ret = chre_slpi_start_thread();
5947
if (ret) {
6048
fprintf(stderr, "Could not start CHRE\n");
6149
goto err;
6250
}
6351

64-
ret = chre_slpi_wait_on_thread_exit(fd, handle);
52+
ret = chre_slpi_wait_on_thread_exit();
6553
if (ret) {
6654
fprintf(stderr, "Could not wait for CHRE thread\n");
6755
goto err;
6856
}
6957

7058
err:
71-
hexagonrpc_close(handle);
59+
hrpc_close_chre_slpi();
7260
}

chrecd/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
executable('chrecd',
2-
'interfaces.c',
2+
'interface/chre_slpi.c',
33
'main.c',
44
c_args : cflags,
55
include_directories : include,

0 commit comments

Comments
 (0)