Skip to content

Commit fe755d8

Browse files
committed
hexagonrpcd: listener: remove interp2 support
With the remote method definitions converted to interp4, the interp2 definitions are no longer needed. Replace the interp2 definitions with the interp4 definitions recently added. Signed-off-by: Richard Acayan <[email protected]>
1 parent 09a72e2 commit fe755d8

File tree

5 files changed

+27
-136
lines changed

5 files changed

+27
-136
lines changed

hexagonrpcd/apps_mem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ void fastrpc_apps_mem_deinit(struct fastrpc_interface *iface)
128128
static const struct fastrpc_function_impl apps_mem_procs[] = {
129129
{ .def = NULL, .impl = NULL, },
130130
{ .def = NULL, .impl = NULL, },
131-
{ .def4 = &apps_mem_request_map64_def, .impl = apps_mem_request_map64, },
131+
{ .def = &apps_mem_request_map64_def, .impl = apps_mem_request_map64, },
132132
{ .def = NULL, .impl = NULL, },
133133
{ .def = NULL, .impl = NULL, },
134134
{ .def = NULL, .impl = NULL, },

hexagonrpcd/apps_std.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -408,23 +408,23 @@ static const struct fastrpc_function_impl apps_std_procs[] = {
408408
{ .def = NULL, .impl = NULL, },
409409
{ .def = NULL, .impl = NULL, },
410410
{
411-
.def4 = &apps_std_fflush_def,
411+
.def = &apps_std_fflush_def,
412412
.impl = apps_std_fflush,
413413
},
414414
{
415-
.def4 = &apps_std_fclose_def,
415+
.def = &apps_std_fclose_def,
416416
.impl = apps_std_fclose,
417417
},
418418
{
419-
.def4 = &apps_std_fread_def,
419+
.def = &apps_std_fread_def,
420420
.impl = apps_std_fread,
421421
},
422422
{ .def = NULL, .impl = NULL, },
423423
{ .def = NULL, .impl = NULL, },
424424
{ .def = NULL, .impl = NULL, },
425425
{ .def = NULL, .impl = NULL, },
426426
{
427-
.def4 = &apps_std_fseek_def,
427+
.def = &apps_std_fseek_def,
428428
.impl = apps_std_fseek,
429429
},
430430
{ .def = NULL, .impl = NULL, },
@@ -437,7 +437,7 @@ static const struct fastrpc_function_impl apps_std_procs[] = {
437437
{ .def = NULL, .impl = NULL, },
438438
{ .def = NULL, .impl = NULL, },
439439
{
440-
.def4 = &apps_std_fopen_with_env_def,
440+
.def = &apps_std_fopen_with_env_def,
441441
.impl = apps_std_fopen_with_env,
442442
},
443443
{ .def = NULL, .impl = NULL, },
@@ -447,21 +447,21 @@ static const struct fastrpc_function_impl apps_std_procs[] = {
447447
{ .def = NULL, .impl = NULL, },
448448
{ .def = NULL, .impl = NULL, },
449449
{
450-
.def4 = &apps_std_opendir_def,
450+
.def = &apps_std_opendir_def,
451451
.impl = apps_std_opendir,
452452
},
453453
{
454-
.def4 = &apps_std_closedir_def,
454+
.def = &apps_std_closedir_def,
455455
.impl = apps_std_closedir,
456456
},
457457
{
458-
.def4 = &apps_std_readdir_def,
458+
.def = &apps_std_readdir_def,
459459
.impl = apps_std_readdir,
460460
},
461461
{ .def = NULL, .impl = NULL, },
462462
{ .def = NULL, .impl = NULL, },
463463
{
464-
.def4 = &apps_std_stat_def,
464+
.def = &apps_std_stat_def,
465465
.impl = apps_std_stat,
466466
},
467467
};

hexagonrpcd/listener.c

Lines changed: 14 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
#include <inttypes.h>
2323
#include <libhexagonrpc/error.h>
24-
#include <libhexagonrpc/fastrpc.h>
2524
#include <libhexagonrpc/hexagonrpc.h>
2625
#include <stddef.h>
2726
#include <stdint.h>
@@ -417,83 +416,6 @@ static struct fastrpc_io_buffer *alloc_outbufs4(const struct hrpc_method_def_int
417416
return NULL;
418417
}
419418

420-
static struct fastrpc_io_buffer *allocate_outbufs(const struct fastrpc_function_def_interp2 *def,
421-
uint32_t *first_inbuf)
422-
{
423-
struct fastrpc_io_buffer *out;
424-
size_t out_count;
425-
size_t i, j;
426-
off_t off;
427-
uint32_t *sizes;
428-
429-
out_count = def->out_bufs + (def->out_nums && 1);
430-
/*
431-
* POSIX allows malloc to return a non-NULL pointer to a zero-size area
432-
* in memory. Since the code below assumes non-zero size if the pointer
433-
* is non-NULL, exit early if we do not need to allocate anything.
434-
*/
435-
if (out_count == 0)
436-
return NULL;
437-
438-
out = malloc(sizeof(struct fastrpc_io_buffer) * out_count);
439-
if (out == NULL)
440-
return NULL;
441-
442-
out[0].s = def->out_nums * 4;
443-
if (out[0].s) {
444-
out[0].p = malloc(def->out_nums * 4);
445-
if (out[0].p == NULL)
446-
goto err_free_out;
447-
}
448-
449-
off = def->out_nums && 1;
450-
sizes = &first_inbuf[def->in_nums + def->in_bufs];
451-
452-
for (i = 0; i < def->out_bufs; i++) {
453-
out[off + i].s = sizes[i];
454-
out[off + i].p = malloc(sizes[i]);
455-
if (out[off + i].p == NULL)
456-
goto err_free_prev;
457-
}
458-
459-
return out;
460-
461-
err_free_prev:
462-
for (j = 0; j < i; j++)
463-
free(out[off + j].p);
464-
465-
err_free_out:
466-
free(out);
467-
return NULL;
468-
}
469-
470-
static int check_inbuf_sizes(const struct fastrpc_function_def_interp2 *def,
471-
const struct fastrpc_io_buffer *inbufs)
472-
{
473-
uint8_t i;
474-
const uint32_t *sizes = &((const uint32_t *) inbufs[0].p)[def->in_nums];
475-
476-
if (inbufs[0].s != 4U * (def->in_nums
477-
+ def->in_bufs
478-
+ def->out_bufs)) {
479-
fprintf(stderr, "Invalid number of input numbers: %zu (expected %u)\n",
480-
inbufs[0].s,
481-
4 * (def->in_nums
482-
+ def->in_bufs
483-
+ def->out_bufs));
484-
return -1;
485-
}
486-
487-
for (i = 0; i < def->in_bufs; i++) {
488-
if (inbufs[i + 1].s != sizes[i]) {
489-
fprintf(stderr, "Invalid buffer size\n");
490-
return -1;
491-
}
492-
}
493-
494-
return 0;
495-
}
496-
497419
static int return_for_next_invoke(int fd,
498420
uint32_t result,
499421
uint32_t *rctx,
@@ -576,8 +498,6 @@ static int invoke_requested_procedure(size_t n_ifaces,
576498
struct fastrpc_io_buffer **returned)
577499
{
578500
const struct fastrpc_function_impl *impl;
579-
uint8_t in_count;
580-
uint8_t out_count;
581501
uint32_t method = REMOTE_SCALARS_METHOD(sc);
582502
int ret;
583503

@@ -613,53 +533,26 @@ static int invoke_requested_procedure(size_t n_ifaces,
613533

614534
impl = &ifaces[handle]->procs[method];
615535

616-
if ((impl->def == NULL && impl->def4 == NULL) || impl->impl == NULL) {
536+
if (impl->def == NULL || impl->impl == NULL) {
617537
fprintf(stderr, "Unsupported method: %u (%08x)\n", method, sc);
618538
*result = AEE_EUNSUPPORTED;
619539
return 1;
620540
}
621541

622-
if (impl->def4) {
623-
ret = count_sizes4(impl->def4, REMOTE_SCALARS_INBUFS(sc),
624-
REMOTE_SCALARS_OUTBUFS(sc), decoded);
625-
if (ret) {
626-
fprintf(stderr, "Inconsistent buffer sizes\n");
627-
*result = AEE_EBADPARM;
628-
return 1;
629-
}
630-
631-
*returned = alloc_outbufs4(impl->def4, decoded,
632-
REMOTE_SCALARS_OUTBUFS(sc));
633-
if (*returned == NULL && impl->def4->n_args > 0) {
634-
perror("Could not allocate output buffers");
635-
*result = AEE_ENOMEMORY;
636-
return 1;
637-
}
638-
} else {
639-
in_count = impl->def->in_bufs + ((impl->def->in_nums
640-
|| impl->def->in_bufs
641-
|| impl->def->out_bufs) && 1);
642-
out_count = impl->def->out_bufs + (impl->def->out_nums && 1);
643-
644-
if (REMOTE_SCALARS_INBUFS(sc) != in_count
645-
|| REMOTE_SCALARS_OUTBUFS(sc) != out_count) {
646-
fprintf(stderr, "Unexpected buffer count: %08x\n", sc);
647-
*result = AEE_EBADPARM;
648-
return 1;
649-
}
650-
651-
ret = check_inbuf_sizes(impl->def, decoded);
652-
if (ret) {
653-
*result = AEE_EBADPARM;
654-
return 1;
655-
}
542+
ret = count_sizes4(impl->def, REMOTE_SCALARS_INBUFS(sc),
543+
REMOTE_SCALARS_OUTBUFS(sc), decoded);
544+
if (ret) {
545+
fprintf(stderr, "Inconsistent buffer sizes\n");
546+
*result = AEE_EBADPARM;
547+
return 1;
548+
}
656549

657-
*returned = allocate_outbufs(impl->def, decoded[0].p);
658-
if (*returned == NULL && out_count > 0) {
659-
perror("Could not allocate output buffers");
660-
*result = AEE_ENOMEMORY;
661-
return 1;
662-
}
550+
*returned = alloc_outbufs4(impl->def, decoded,
551+
REMOTE_SCALARS_OUTBUFS(sc));
552+
if (*returned == NULL && impl->def->n_args > 0) {
553+
perror("Could not allocate output buffers");
554+
*result = AEE_ENOMEMORY;
555+
return 1;
663556
}
664557

665558
*result = impl->impl(ifaces[handle]->data, decoded, *returned);

hexagonrpcd/listener.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,14 @@
2222
#ifndef LISTENER_H
2323
#define LISTENER_H
2424

25-
#include <libhexagonrpc/fastrpc.h>
2625
#include <libhexagonrpc/hexagonrpc.h>
2726
#include <stddef.h>
2827
#include <stdint.h>
2928

3029
#include "iobuffer.h"
3130

3231
struct fastrpc_function_impl {
33-
const struct fastrpc_function_def_interp2 *def;
34-
const struct hrpc_method_def_interp4 *def4;
32+
const struct hrpc_method_def_interp4 *def;
3533
uint32_t (*impl)(void *data,
3634
const struct fastrpc_io_buffer *inbufs,
3735
struct fastrpc_io_buffer *outbufs);

hexagonrpcd/localctl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ void fastrpc_localctl_deinit(struct fastrpc_interface *iface)
145145
}
146146

147147
static const struct fastrpc_function_impl localctl_procs[] = {
148-
{ .def4 = &remotectl_open_def, .impl = localctl_open, },
149-
{ .def4 = &remotectl_close_def, .impl = localctl_close, },
148+
{ .def = &remotectl_open_def, .impl = localctl_open, },
149+
{ .def = &remotectl_close_def, .impl = localctl_close, },
150150
};
151151

152152
const struct fastrpc_interface localctl_interface = {

0 commit comments

Comments
 (0)