Skip to content

Commit 8df463a

Browse files
committed
hexagonrpcd: listener: remove interp2 support
1 parent faa9f71 commit 8df463a

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>
@@ -425,83 +424,6 @@ static struct fastrpc_io_buffer *alloc_outbufs4(const struct hrpc_method_def_int
425424
return NULL;
426425
}
427426

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

@@ -616,53 +536,26 @@ static int invoke_requested_procedure(size_t n_ifaces,
616536

617537
impl = &ifaces[handle]->procs[method];
618538

619-
if ((impl->def == NULL && impl->def4 == NULL) || impl->impl == NULL) {
539+
if (impl->def == NULL || impl->impl == NULL) {
620540
fprintf(stderr, "Unsupported method: %u (%08x)\n", method, sc);
621541
*result = AEE_EUNSUPPORTED;
622542
return 1;
623543
}
624544

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

660-
*returned = allocate_outbufs(impl->def, decoded[0].p);
661-
if (*returned == NULL && out_count > 0) {
662-
perror("Could not allocate output buffers");
663-
*result = AEE_ENOMEMORY;
664-
return 1;
665-
}
553+
*returned = alloc_outbufs4(impl->def, decoded,
554+
REMOTE_SCALARS_OUTBUFS(sc));
555+
if (*returned == NULL && impl->def->n_args > 0) {
556+
perror("Could not allocate output buffers");
557+
*result = AEE_ENOMEMORY;
558+
return 1;
666559
}
667560

668561
*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)