Commit 17153d0b authored by Alessandro Rubini's avatar Alessandro Rubini

use mini-rpc instead of wripc

parent 61536e33
...@@ -13,8 +13,7 @@ WR_INSTALL_ROOT ?= $(WRS_OUTPUT_DIR)/images/wr ...@@ -13,8 +13,7 @@ WR_INSTALL_ROOT ?= $(WRS_OUTPUT_DIR)/images/wr
WRDEV_DIR ?= $(WRS_BASE_DIR)/.. WRDEV_DIR ?= $(WRS_BASE_DIR)/..
# subdirectories we want to compile # subdirectories we want to compile
SUBDIRS = mini-rpc SUBDIRS = mini-rpc libswitchhw libptpnetif
SUBDIRS += libswitchhw libwripc libptpnetif
SUBDIRS += wrsw_hal wrsw_rtud spll_dbg_proxy SUBDIRS += wrsw_hal wrsw_rtud spll_dbg_proxy
SUBDIRS += wr_mon rtu_stat #test_rtu SUBDIRS += wr_mon rtu_stat #test_rtu
......
...@@ -27,7 +27,32 @@ typedef struct{ ...@@ -27,7 +27,32 @@ typedef struct{
#define PTPDEXP_COMMAND_TRACKING 1 #define PTPDEXP_COMMAND_TRACKING 1
#define PTPDEXP_COMMAND_MAN_ADJUST_PHASE 2 #define PTPDEXP_COMMAND_MAN_ADJUST_PHASE 2
void ptpdexp_get_sync_state(ptpdexp_sync_state_t *state); extern int ptpdexp_get_sync_state(ptpdexp_sync_state_t *state);
void ptpdexp_cmd(int cmd, int value); extern int ptpdexp_cmd(int cmd, int value);
/* Export structures, shared by server and client for argument matching */
#ifdef PTP_EXPORT_STRUCTURES
//int ptpdexp_get_sync_state(ptpdexp_sync_state_t *state);
struct minipc_pd __rpcdef_get_sync_state = {
.name = "get_sync_state",
.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_STRUCT, ptpdexp_sync_state_t),
.args = {
MINIPC_ARG_END,
},
};
//int ptpdexp_cmd(int cmd, int value);
struct minipc_pd __rpcdef_cmd = {
.name = "cmd",
.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
.args = {
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
MINIPC_ARG_END,
},
};
#endif /* PTP_EXPORT_STRUCTURES */
#endif #endif
CC = $(CROSS_COMPILE)gcc CC = $(CROSS_COMPILE)gcc
AR = $(CROSS_COMPILE)ar AR = $(CROSS_COMPILE)ar
CFLAGS = -I. -O2 -I../include -I../wrsw_hal -I../libwripc -DDEBUG CFLAGS = -I. -O2 -I../include -I../wrsw_hal -I../mini-rpc -DDEBUG
OBJS = hal_client.o netif_test.o ptpd_netif.o OBJS = hal_client.o netif_test.o ptpd_netif.o
......
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <minipc.h>
#define HAL_EXPORT_STRUCTURES
#include "hal_exports.h" #include "hal_exports.h"
#include <wr_ipc.h> #define DEFAULT_TO 200 /* ms */
static wripc_handle_t hal_cli; static struct minipc_ch *hal_ch;
int halexp_check_running() int halexp_check_running()
{ {
...@@ -22,34 +25,47 @@ int halexp_reset_port(const char *port_name) ...@@ -22,34 +25,47 @@ int halexp_reset_port(const char *port_name)
int halexp_calibration_cmd(const char *port_name, int command, int on_off) int halexp_calibration_cmd(const char *port_name, int command, int on_off)
{ {
int rval; int ret, rval;
wripc_call(hal_cli, "halexp_calibration_cmd", &rval,3, A_STRING(port_name), A_INT32(command), A_INT32(on_off)); ret = minipc_call(hal_ch, DEFAULT_TO, &__rpcdef_calibration_cmd,
&rval, port_name, command, on_off);
if (ret < 0)
return ret;
return rval; return rval;
} }
int halexp_lock_cmd(const char *port_name, int command, int priority) int halexp_lock_cmd(const char *port_name, int command, int priority)
{ {
int rval; int ret, rval;
wripc_call(hal_cli, "halexp_lock_cmd", &rval, 3, A_STRING(port_name), A_INT32(command), A_INT32(priority)); ret = minipc_call(hal_ch, DEFAULT_TO, &__rpcdef_lock_cmd,
&rval, port_name, command, priority);
if (ret < 0)
return ret;
return rval; return rval;
} }
int halexp_query_ports(hexp_port_list_t *list) int halexp_query_ports(hexp_port_list_t *list)
{ {
wripc_call(hal_cli, "halexp_query_ports", list, 0); int ret;
return 0; ret = minipc_call(hal_ch, DEFAULT_TO, &__rpcdef_query_ports,
list /* return val */);
return ret;
} }
int halexp_get_port_state(hexp_port_state_t *state, const char *port_name) int halexp_get_port_state(hexp_port_state_t *state, const char *port_name)
{ {
wripc_call(hal_cli, "halexp_get_port_state", state, 1, A_STRING(port_name)); int ret;
return 0; ret = minipc_call(hal_ch, DEFAULT_TO, &__rpcdef_query_ports,
state /* retval */, port_name);
return ret;
} }
int halexp_pps_cmd(int cmd, hexp_pps_params_t *params) int halexp_pps_cmd(int cmd, hexp_pps_params_t *params)
{ {
int rval; int ret, rval;
wripc_call(hal_cli, "halexp_pps_cmd", &rval, 2, A_INT32(cmd), A_STRUCT(*params)); ret = minipc_call(hal_ch, DEFAULT_TO, &__rpcdef_pps_cmd,
&rval, cmd, params);
if (ret < 0)
return ret;
return rval; return rval;
} }
...@@ -57,7 +73,7 @@ int halexp_pps_cmd(int cmd, hexp_pps_params_t *params) ...@@ -57,7 +73,7 @@ int halexp_pps_cmd(int cmd, hexp_pps_params_t *params)
int halexp_pll_cmd(int cmd, hexp_pll_cmd_t *params) int halexp_pll_cmd(int cmd, hexp_pll_cmd_t *params)
{ {
int rval; int rval;
wripc_call(hal_cli, "halexp_pll_cmd", &rval, 2, A_INT32(cmd), A_STRUCT(*params)); wripc_call(hal_ch, "halexp_pll_cmd", &rval, 2, A_INT32(cmd), A_STRUCT(*params));
return rval; return rval;
} }
...@@ -65,9 +81,18 @@ int halexp_pll_cmd(int cmd, hexp_pll_cmd_t *params) ...@@ -65,9 +81,18 @@ int halexp_pll_cmd(int cmd, hexp_pll_cmd_t *params)
int halexp_client_init() int halexp_client_init()
{ {
hal_cli = wripc_connect(WRSW_HAL_SERVER_ADDR); hal_ch = minipc_client_create(WRSW_HAL_SERVER_ADDR, 0);
if(hal_cli < 0) if (!hal_ch)
return -1; return -1;
else else
return 0; return 0;
} }
int halexp_extsrc_cmd(int command)
{
int ret, rval;
ret = minipc_call(hal_ch, DEFAULT_TO, &__rpcdef_extsrc_cmd,
&rval, command);
return rval;
}
CC = $(CROSS_COMPILE)gcc
AR = $(CROSS_COMPILE)ar
CFLAGS = -I. -O2 -I../include
OBJS = helper_arm.o wr_ipc.o
LIB = libwripc.a
all: $(LIB)
$(LIB): $(OBJS)
$(AR) rc $@ $^
install: all
install -d $(WR_INSTALL_ROOT)/lib
install $(LIB) $(WR_INSTALL_ROOT)/lib
clean:
rm -f $(LIB) $(OBJS)
// architecture-specific _do_call() functions
#ifdef __i386__
static int _do_call(void *func_ptr, void *args, int args_size)
{
int rval;
asm volatile (
"movl %%esp, %%edi\n"
"movl %%ebx, %%ecx\n"
"subl %%ebx, %%edi\n"
"shrl $2, %%ecx\n"
"cld\n"
"rep\n"
"movsl\n"
"subl %3, %%esp\n"
"call *%%eax\n"
"addl %3, %%esp\n"
: "=a"(rval)
: "a"(func_ptr), "S"(args), "b"(args_size)
:
);
/* "si", "di", "ax", "bx", "cx", "memory" */
return rval;
}
#endif
#ifdef __arm__
extern int _do_call(void *func_ptr, void *args, int args_size);
#endif
.global _do_call
_do_call:
stmfd sp!, {r4, r5, r6, r7, fp, lr}
mov r4, r1 // r4 = args_buffer
mov lr, r0 // lr = func_ptr
mov r5, r2 // r5 = args_size
ldr r0, [r4, #0]
ldr r1, [r4, #4]
ldr r2, [r4, #8]
ldr r3, [r4, #12]
mov fp, sp
sub r5, #16
cmp r5, #0
blt do_call
add r4, #16
mov r7, sp
sub r7, r5
sub sp, r5
copy_args:
ldr r6, [r4]
str r6, [r7]
add r7, #4
add r4, #4
sub r5, #4
cmp r5, #0
bne copy_args
do_call:
mov r6, lr
mov lr, pc
bx r6
mov sp, fp
ldmfd sp!, {r4, r5, r6, r7, fp, lr}
bx lr
struct test_struct {
int apples;
int peas;
char name[80];
float value;
};
struct state_struct {
char state_name[80];
float t;
int x;
};
void test_void(double *ptr, double a, double b)
{
*ptr = a+b;
}
main()
{
test_void(1000, 1.123, 2.245);
}
\ No newline at end of file
#include <stdio.h>
#include "wr_ipc.h"
#include "structs.h"
main()
{
wripc_handle_t cli;
int res_int;
float result, a,b;
struct state_struct s;
cli = wripc_connect("test");
wripc_call(cli, "bigfunc", &res_int, 8, A_INT32(1), A_INT32(2), A_INT32(3), A_INT32(4), A_INT32(5), A_INT32(6), A_INT32(7), A_INT32(8));
printf("1+...+8 = %d\n", res_int);
a=2.2; b= 4.4;
wripc_call(cli, "add", &result, 2, A_FLOAT(a), A_FLOAT(b));
printf("%.1f + %.1f = %.1f\n", a,b,result);
wripc_call(cli, "get_state", &s, 1, A_INT32(12345));
printf("state->name %s\n", s.state_name);
printf("state->t %.3f\n", s.t);
printf("state->x %d\n", s.x);
struct test_struct s2;
s2.apples = 10;
s2.peas = 15;
strcpy(s2.name, "Javier");
s2.value = 17.50;
// wripc_call(cli, "structure_test", &result, 1, A_STRUCT(s2));
wripc_call(cli, "string_test", &res_int, 3, A_STRING("Hello, world"), A_INT32(1), A_INT32(100));
printf("rval = %d\n", res_int);
usleep(1000);
wripc_close(cli);
}
float ret_float() { return 1.0; }
double ret_double() { return 1.0; }
void test_float(double a)
{
*(volatile double *) 0xdeadbee0 = a;
}
main()
{
float x = 123.345;
test_float(x);
}
\ No newline at end of file
#include <stdio.h>
#include <string.h>
#include "wr_ipc.h"
#include "structs.h"
int bigfunc(int a, int b, int c, int d, int e, int f, int g, int h)
{
printf("Call bigfunc: %d %d %d %d %d %d %d %d\n" ,a,b,c,d,e,f,g,h);
return a+b+c+d+e+f+g+h;
}
void add(float *rval, float a, float b)
{
printf("Call add: %.3f + %.3f\n", a,b);
*rval = a + b;
}
int string_test(char *string, int a, int b)
{
printf("Call string_test: a = %d, b= %d, string = '%s'\n", a,b,string);
return 12345;
}
void structure_test(struct test_struct *s)
{
printf("Call structure_test: %s got %d apples and %d peas of total value %.3f\n",s->name, s->apples, s->peas, s->value);
}
void get_state(struct state_struct *rval, int request)
{
printf("Call get_state: request = %d\n", request);
rval->t = 123.0;
strcpy(rval->state_name, "SomeState");
rval->x = request;
}
int main()
{
wripc_handle_t srv;
srv = wripc_create_server("test");
// add(10000, 1.0, 2.0);
wripc_export(srv, T_INT32, "bigfunc", bigfunc, 8, T_INT32, T_INT32, T_INT32, T_INT32, T_INT32, T_INT32, T_INT32, T_INT32 );
wripc_export(srv, T_FLOAT, "add", add, 2, T_FLOAT, T_FLOAT);
wripc_export(srv, T_INT32, "sub", add, 2, T_INT32, T_INT32);
wripc_export(srv, T_INT32, "string_test", string_test, 3, T_STRING, T_INT32, T_INT32);
wripc_export(srv, T_VOID, "structure_test", structure_test, 1, T_STRUCT(struct test_struct));
wripc_export(srv, T_STRUCT(struct state_struct), "get_state", get_state, 1, T_INT32);
for(;;) wripc_process(srv);
return 0;
}
This diff is collapsed.
#ifndef __WR_IPC_H
#define __WR_IPC_H
//#include <inttypes.h> -- now in ptpd-wrappers.h
#define T_INT32 1
#define T_INT16 2
#define T_INT8 3
#define T_STRING 4
#define T_FLOAT 5
#define T_DOUBLE 6
#define T_STRUCT_TYPE 7
#define T_STRUCT(type) (T_STRUCT_TYPE | (sizeof(type) << 8))
#define T_VOID 8
#define A_INT8(x) T_INT8,(x)
#define A_INT16(x) T_INT16,(x)
#define A_INT32(x) T_INT32,(x)
#define A_STRING(x) T_STRING,(x)
#define A_FLOAT(x) T_FLOAT,(x)
#define A_DOUBLE(x) T_DOUBLE,(x)
#define A_STRUCT(x) T_STRUCT(x),&x
#define WRIPC_ERROR_INVALID_REQUEST -1
#define WRIPC_ERROR_UNKNOWN_FUNCTION -2
#define WRIPC_ERROR_MALFORMED_PACKET -3
#define WRIPC_ERROR_INVALID_ARG -4
#define WRIPC_ERROR_NO_MEMORY -5
#define WRIPC_ERROR_TIMEOUT -6
#define WRIPC_ERROR_NETWORK_FAIL -7
typedef int wripc_handle_t;
wripc_handle_t wripc_create_server(const char *name);
wripc_handle_t wripc_connect(const char *name);
void wripc_close(wripc_handle_t h);
int wripc_export (wripc_handle_t handle, int rval_type, const char *name, void *func_ptr, int num_args, ...);
int wripc_call (wripc_handle_t handle, const char *name, void *rval, int num_args, ...);
int wripc_process(wripc_handle_t handle);
int wripc_publish_event(wripc_handle_t handle, int event_id, void *buf, int buf_len);
int wripc_subscribe_event(wripc_handle_t handle, int event_id);
int wripc_receive_event(wripc_handle_t handle, int *event_id, void *buf, int buf_len);
#endif
ptp-noposix @ 80b47ffe
Subproject commit 8de7f89461d772d1818bbf2bc534ac643668c2d3 Subproject commit 80b47ffe3fe7fbcb9ded920c3bbce2fa3e015fcd
...@@ -12,9 +12,9 @@ OBJDUMP = $(CROSS_COMPILE)objdump ...@@ -12,9 +12,9 @@ OBJDUMP = $(CROSS_COMPILE)objdump
OBJS = rtu_stat.o OBJS = rtu_stat.o
CFLAGS = -O2 -I../include -DDEBUG -I$(LINUX)/include -I../libptpnetif \ CFLAGS = -O2 -I../include -DDEBUG -I$(LINUX)/include -I../libptpnetif \
-I../wrsw_hal -I../libwripc -I../wrsw_rtud -g -I../wrsw_hal -I../wrsw_rtud -I../mini-rpc -g
LDFLAGS = -L$(WR_INSTALL_ROOT)/lib -lwripc LDFLAGS = -L$(WR_INSTALL_ROOT)/lib -L../mini-rpc -lminipc
BINARY = rtu_stat BINARY = rtu_stat
......
...@@ -4,15 +4,16 @@ ...@@ -4,15 +4,16 @@
#include <string.h> #include <string.h>
#include <hal_client.h> #include <hal_client.h>
#include <minipc.h>
#include <rtud_exports.h> #include <rtud_exports.h>
#include <wr_ipc.h>
static int rtud_ipc; static struct minipc_ch *rtud_ch;
void rtudexp_get_fd_list(rtudexp_fd_list_t *list, int start_from) void rtudexp_get_fd_list(rtudexp_fd_list_t *list, int start_from)
{ {
wripc_call(rtud_ipc, "rtudexp_get_fd_list", list, 1, A_INT32(start_from)); minipc_call(rtud_ch, 200, &rtud_export_get_fd_list, list,
start_from);
} }
#define RTU_MAX_ENTRIES 8192 #define RTU_MAX_ENTRIES 8192
...@@ -89,9 +90,9 @@ main() ...@@ -89,9 +90,9 @@ main()
int n_entries; int n_entries;
int i; int i;
rtud_ipc = wripc_connect("rtud"); rtud_ch = minipc_client_create("rtud", 0);
if(rtud_ipc < 0) if(!rtud_ch)
{ {
printf("Can't conenct to RTUd wripc server\n"); printf("Can't conenct to RTUd wripc server\n");
return 0; return 0;
...@@ -111,4 +112,4 @@ main() ...@@ -111,4 +112,4 @@ main()
printf("%-25s %-22s %s\n", mac_to_string(fd_list[i].mac), decode_ports(fd_list[i].dpm), fd_list[i].dynamic ? "DYNAMIC":"STATIC"); printf("%-25s %-22s %s\n", mac_to_string(fd_list[i].mac), decode_ports(fd_list[i].dpm), fd_list[i].dynamic ? "DYNAMIC":"STATIC");
} }
printf("\n"); printf("\n");
} }
\ No newline at end of file
...@@ -13,9 +13,10 @@ OBJDUMP = $(CROSS_COMPILE)objdump ...@@ -13,9 +13,10 @@ OBJDUMP = $(CROSS_COMPILE)objdump
MON_OBJS = wr_mon.o term.o MON_OBJS = wr_mon.o term.o
CFLAGS += -O2 -DDEBUG -I$(LINUX)/include -I../include \ CFLAGS += -O2 -DDEBUG -I$(LINUX)/include -I../include \
-I../libptpnetif -I../wrsw_hal -I../libwripc -I../libptpnetif -I../wrsw_hal -I../mini-rpc
LDFLAGS = -L$(WR_INSTALL_ROOT)/lib -lptpnetif -lwripc LDFLAGS = -L$(WR_INSTALL_ROOT)/lib -L../mini-rpc -L../libptpnetif \
-lptpnetif -lminipc
BINARY = wr_mon BINARY = wr_mon
......
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <wr_ipc.h> #include <minipc.h>
#include "term.h" #include "term.h"
#define PTP_EXPORT_STRUCTURES
#include "ptpd_exports.h" #include "ptpd_exports.h"
#include "hal_client.h" #include "hal_client.h"
hexp_port_list_t port_list; hexp_port_list_t port_list;
wripc_handle_t h_ptp; static struct minipc_ch *ptp_ch;
void init() void init()
{ {
halexp_client_init(); halexp_client_init();
if( (h_ptp = wripc_connect("ptpd")) < 0) ptp_ch = minipc_client_create("ptpd", 0);
if (!ptp_ch)
{ {
fprintf(stderr,"Can't establish WRIPC connection " fprintf(stderr,"Can't establish WRIPC connection "
"to the PTP daemon!\n"); "to the PTP daemon!\n");
...@@ -70,7 +73,8 @@ void show_ports() ...@@ -70,7 +73,8 @@ void show_ports()
void show_servo() void show_servo()
{ {
ptpdexp_sync_state_t ss; ptpdexp_sync_state_t ss;
wripc_call(h_ptp, "ptpdexp_get_sync_state", &ss, 0);
minipc_call(ptp_ch, 200, &__rpcdef_get_sync_state, 0, &ss);
term_cprintf(C_BLUE, "\n\nSynchronization status:\n\n"); term_cprintf(C_BLUE, "\n\nSynchronization status:\n\n");
...@@ -165,9 +169,9 @@ main() ...@@ -165,9 +169,9 @@ main()
if(c=='t') { if(c=='t') {
int rval; int rval;
track_onoff = 1-track_onoff; track_onoff = 1-track_onoff;
wripc_call(h_ptp, "ptpdexp_cmd", &rval, 2, minipc_call(ptp_ch, 200, &__rpcdef_cmd,
A_INT32(PTPDEXP_COMMAND_TRACKING), &rval, PTPDEXP_COMMAND_TRACKING,
A_INT32(track_onoff)); track_onoff);
} }
} }
......
...@@ -12,11 +12,11 @@ WR_INCLUDE = $(WR_INSTALL_ROOT)/include ...@@ -12,11 +12,11 @@ WR_INCLUDE = $(WR_INSTALL_ROOT)/include
WR_LIB = $(WR_INSTALL_ROOT)/lib WR_LIB = $(WR_INSTALL_ROOT)/lib
CFLAGS = -g -Wall -DDEBUG \ CFLAGS = -g -Wall -DDEBUG \
-I. -I../../../ptp-noposix-v3/libwripc -I../include -I../3rdparty/include -I$(WR_INCLUDE) -I../include -I../mini-rpc -I$(WR_INCLUDE)
LDFLAGS = -L$(WR_INSTALL_ROOT)/lib -L../3rdparty/lib -L$(WR_LIB) \ LDFLAGS = -L$(WR_INSTALL_ROOT)/lib -L../3rdparty/lib -L$(WR_LIB) \
-L../../../ptp-noposix-v3 -L../libswitchhw \ -L../libswitchhw -L../mini-rpc \
-lwripc -llua -lm -ldl -lswitchhw -lminipc -llua -lm -ldl -lswitchhw
all: $(BINARY) all: $(BINARY)
......
...@@ -8,11 +8,13 @@ ...@@ -8,11 +8,13 @@
#include <hw/dmpll.h> #include <hw/dmpll.h>
#include "wrsw_hal.h" #include "wrsw_hal.h"
#include "hal_exports.h" /* for exported structs/function protos */
#include <wr_ipc.h> #include <minipc.h>
#define HAL_EXPORT_STRUCTURES
#include "hal_exports.h" /* for exported structs/function protos */
static wripc_handle_t hal_ipc; static struct minipc_ch *hal_ch;
/* Dummy WRIPC export, used by the clients to check if the HAL is responding */ /* Dummy WRIPC export, used by the clients to check if the HAL is responding */
int halexp_check_running() int halexp_check_running()
...@@ -147,26 +149,69 @@ int halexp_pll_cmd(int cmd, hexp_pll_cmd_t *params) ...@@ -147,26 +149,69 @@ int halexp_pll_cmd(int cmd, hexp_pll_cmd_t *params)
static void hal_cleanup_wripc() static void hal_cleanup_wripc()
{ {
wripc_close(hal_ipc); minipc_close(hal_ch);
}
/* The functions to manage packet/args conversions */
static int export_pps_cmd(const struct minipc_pd *pd,
uint32_t *args, void *ret)
{
int rval;
/* First argument is command next is param structure */
rval = halexp_pps_cmd(args[0], (hexp_pps_params_t *)(args + 1));
*(int *)ret = rval;
return 0;
}
static int export_get_port_state(const struct minipc_pd *pd,
uint32_t *args, void *ret)
{
hexp_port_state_t *state = ret;
return halexp_get_port_state(state, (char *)args /* name */);
}
static int export_lock_cmd(const struct minipc_pd *pd,
uint32_t *args, void *ret)
{
int rval;
char *pname = (void *)args;
/* jump over the string */
args = minipc_get_next_arg(args, pd->args[0]);
rval = halexp_lock_cmd(pname, args[0] /* cmd */, args[1] /* prio */);
*(int *)ret = rval;
return 0;
}
static int export_query_ports(const struct minipc_pd *pd,
uint32_t *args, void *ret)
{
hexp_port_list_t *list = ret;
halexp_query_ports(list);
return 0;
} }
/* Creates a wripc server and exports all public API functions */ /* Creates a wripc server and exports all public API functions */
int hal_init_wripc() int hal_init_wripc()
{ {
hal_ipc = wripc_create_server(WRSW_HAL_SERVER_ADDR); hal_ch = minipc_server_create(WRSW_HAL_SERVER_ADDR, 0);
if(hal_ipc < 0) if(hal_ch < 0)
return -1; return -1;
wripc_export(hal_ipc, T_INT32, "halexp_pps_cmd", halexp_pps_cmd, 2, T_INT32, T_STRUCT(hexp_pps_params_t)); /* NOTE: check_running is not remotely called, so I don't export it */
wripc_export(hal_ipc, T_INT32, "halexp_pll_cmd", halexp_pll_cmd, 2, T_INT32, T_STRUCT(hexp_pll_cmd_t));
wripc_export(hal_ipc, T_INT32, "halexp_check_running", halexp_check_running, 0);
wripc_export(hal_ipc, T_STRUCT(hexp_port_state_t), "halexp_get_port_state", halexp_get_port_state, 1, T_STRING);
wripc_export(hal_ipc, T_INT32, "halexp_lock_cmd", halexp_lock_cmd, 3, T_STRING, T_INT32, T_INT32);
wripc_export(hal_ipc, T_STRUCT(hexp_port_list_t), "halexp_query_ports", halexp_query_ports, 0);
/* fill the function pointers */
__rpcdef_pps_cmd.f = export_pps_cmd;
__rpcdef_get_port_state.f = export_get_port_state;
__rpcdef_lock_cmd.f = export_lock_cmd;
__rpcdef_query_ports.f = export_query_ports;
/* FIXME: pll_cmd is empty anyways???? */
hal_add_cleanup_callback(hal_cleanup_wripc); hal_add_cleanup_callback(hal_cleanup_wripc);
...@@ -178,7 +223,8 @@ int hal_init_wripc() ...@@ -178,7 +223,8 @@ int hal_init_wripc()
/* wripc update function, must be called in the main program loop */ /* wripc update function, must be called in the main program loop */
int hal_update_wripc() int hal_update_wripc()
{ {
return wripc_process(hal_ipc); minipc_server_action(hal_ch, 200 /* ms */);
return 0;
} }
...@@ -186,15 +232,11 @@ int hal_update_wripc() ...@@ -186,15 +232,11 @@ int hal_update_wripc()
launching multiple HALs simultaneously. */ launching multiple HALs simultaneously. */
int hal_check_running() int hal_check_running()
{ {
wripc_handle_t fd; struct minipc_ch *ch;
fd = wripc_connect(WRSW_HAL_SERVER_ADDR);
if(fd >= 0)
{
wripc_close(fd);
return 1;
}
return 0;
ch = minipc_client_create(WRSW_HAL_SERVER_ADDR, 0);
if (!ch)
return 0;
minipc_close(ch);
return 1;
} }
This diff is collapsed.
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <wr_ipc.h> //#include <minipc.h>
#include <hw/trace.h> #include <hw/trace.h>
#include <hw/switch_hw.h> #include <hw/switch_hw.h>
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include <linux/if_arp.h> #include <linux/if_arp.h>
#include <linux/if.h> #include <linux/if.h>
#include <wr_ipc.h> //#include <wr_ipc.h>
/* LOTs of hardware includes */ /* LOTs of hardware includes */
#include <hw/trace.h> #include <hw/trace.h>
......
...@@ -13,10 +13,12 @@ WR_INCLUDE = $(WR_INSTALL_ROOT)/include ...@@ -13,10 +13,12 @@ WR_INCLUDE = $(WR_INSTALL_ROOT)/include
WR_LIB = $(WR_INSTALL_ROOT)/lib WR_LIB = $(WR_INSTALL_ROOT)/lib
CFLAGS = -O2 -DDEBUG -Wall -ggdb -DTRACE_ALL \ CFLAGS = -O2 -DDEBUG -Wall -ggdb -DTRACE_ALL \
-I. -I../include -I$(WR_INCLUDE) -I$(LINUX)/include -I../libptpnetif -I../wrsw_hal \
-I../mini-rpc -I../include -I$(WR_INCLUDE) -I$(LINUX)/include
# -I$(CROSS_COMPILE_ARM_PATH)/../include # -I$(CROSS_COMPILE_ARM_PATH)/../include
LDFLAGS := -L$(WR_LIB) -lswitchhw -lptpnetif -lwripc -lpthread LDFLAGS := -L$(WR_LIB) -L../libptpnetif -L../libswitchhw -L../mini-rpc\
-lswitchhw -lptpnetif -lpthread -lminipc
RM := rm -f RM := rm -f
......
...@@ -31,37 +31,24 @@ ...@@ -31,37 +31,24 @@
#include <stdint.h> #include <stdint.h>
#include <errno.h> #include <errno.h>
#include <wr_ipc.h>
#include <hw/trace.h> #include <hw/trace.h>
#include "minipc.h"
#include "rtu.h" #include "rtu.h"
#include "rtu_fd.h" #include "rtu_fd.h"
#include "rtud_exports.h" #include "rtud_exports.h"
#include "mac.h" #include "mac.h"
static int rtud_ipc; /* The channel */
static struct minipc_ch *rtud_ch;
/* The exported function */
int rtudexp_get_fd_list(const struct minipc_pd *pd,
uint32_t *args, void *ret)
int rtud_init_exports()
{
rtud_ipc = wripc_create_server("rtud");
if(rtud_ipc < 0)
return rtud_ipc;
TRACE(TRACE_INFO,"wripc server created [fd %d]", rtud_ipc);
wripc_export(rtud_ipc, T_STRUCT(rtudexp_fd_list_t), "rtudexp_get_fd_list", rtudexp_get_fd_list, 1, T_INT32);
return 0;
}
void rtudexp_get_fd_list(rtudexp_fd_list_t *list, int start_from)
{ {
int i; int i;
rtudexp_fd_list_t *list = ret;
int start_from = args[0];
//TRACE(TRACE_INFO,"GetFDList start=%d",start_from); //TRACE(TRACE_INFO,"GetFDList start=%d",start_from);
...@@ -82,9 +69,28 @@ void rtudexp_get_fd_list(rtudexp_fd_list_t *list, int start_from) ...@@ -82,9 +69,28 @@ void rtudexp_get_fd_list(rtudexp_fd_list_t *list, int start_from)
list->num_rules = i; list->num_rules = i;
list->next = (i < 8 ? 0 : start_from+i); list->next = (i < 8 ? 0 : start_from+i);
return 0;
}
int rtud_init_exports()
{
rtud_ch = minipc_server_create("rtud", 0);
if(!rtud_ch < 0)
return -1;
TRACE(TRACE_INFO,"wripc server created [fd %d]",
minipc_fileno(rtud_ch));
rtud_export_get_fd_list.f = rtudexp_get_fd_list;
if (minipc_export(rtud_ch, &rtud_export_get_fd_list) < 0)
return -1;
return 0;
} }
void rtud_handle_wripc() void rtud_handle_wripc()
{ {
wripc_process(rtud_ipc); minipc_server_action(rtud_ch, 100);
} }
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#define __RTUD_EXPORTS_H #define __RTUD_EXPORTS_H
#include <stdint.h> #include <stdint.h>
#include <minipc.h>
typedef struct typedef struct
{ {
...@@ -47,6 +48,15 @@ typedef struct { ...@@ -47,6 +48,15 @@ typedef struct {
int next; int next;
} rtudexp_fd_list_t; } rtudexp_fd_list_t;
void rtudexp_get_fd_list(rtudexp_fd_list_t *list, int start_from); /* Export this function: it returns a structure */
struct minipc_pd rtud_export_get_fd_list = {
.name = "get_fd_list",
.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_STRUCT,
rtudexp_fd_list_t),
.args = {
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
MINIPC_ARG_END,
},
};
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment