Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Switch - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
83
Issues
83
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
White Rabbit Switch - Software
Commits
17153d0b
Commit
17153d0b
authored
Mar 20, 2012
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use mini-rpc instead of wripc
parent
61536e33
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
353 additions
and
1516 deletions
+353
-1516
Makefile
userspace/Makefile
+1
-2
ptpd_exports.h
userspace/include/ptpd_exports.h
+27
-2
Makefile
userspace/libptpnetif/Makefile
+1
-1
hal_client.c
userspace/libptpnetif/hal_client.c
+40
-15
Makefile
userspace/libwripc/Makefile
+0
-20
asm_helpers.h
userspace/libwripc/asm_helpers.h
+0
-40
helper_arm.S
userspace/libwripc/helper_arm.S
+0
-45
structs.h
userspace/libwripc/structs.h
+0
-13
test_arm.c
userspace/libwripc/test_arm.c
+0
-12
test_cli.c
userspace/libwripc/test_cli.c
+0
-46
test_floats.c
userspace/libwripc/test_floats.c
+0
-13
test_srv.c
userspace/libwripc/test_srv.c
+0
-63
wr_ipc.c
userspace/libwripc/wr_ipc.c
+0
-1038
wr_ipc.h
userspace/libwripc/wr_ipc.h
+0
-49
ptp-noposix
userspace/ptp-noposix
+1
-1
Makefile
userspace/rtu_stat/Makefile
+2
-2
rtu_stat.c
userspace/rtu_stat/rtu_stat.c
+7
-6
Makefile
userspace/wr_mon/Makefile
+3
-2
wr_mon.c
userspace/wr_mon/wr_mon.c
+11
-7
Makefile
userspace/wrsw_hal/Makefile
+3
-3
hal_exports.c
userspace/wrsw_hal/hal_exports.c
+65
-23
hal_exports.h
userspace/wrsw_hal/hal_exports.h
+147
-86
hal_main.c
userspace/wrsw_hal/hal_main.c
+1
-1
hal_ports.c
userspace/wrsw_hal/hal_ports.c
+1
-1
Makefile
userspace/wrsw_rtud/Makefile
+4
-2
rtud_exports.c
userspace/wrsw_rtud/rtud_exports.c
+28
-22
rtud_exports.h
userspace/wrsw_rtud/rtud_exports.h
+11
-1
No files found.
userspace/Makefile
View file @
17153d0b
...
...
@@ -13,8 +13,7 @@ WR_INSTALL_ROOT ?= $(WRS_OUTPUT_DIR)/images/wr
WRDEV_DIR
?=
$(WRS_BASE_DIR)
/..
# subdirectories we want to compile
SUBDIRS
=
mini-rpc
SUBDIRS
+=
libswitchhw libwripc libptpnetif
SUBDIRS
=
mini-rpc libswitchhw libptpnetif
SUBDIRS
+=
wrsw_hal wrsw_rtud spll_dbg_proxy
SUBDIRS
+=
wr_mon rtu_stat
#test_rtu
...
...
userspace/include/ptpd_exports.h
View file @
17153d0b
...
...
@@ -27,7 +27,32 @@ typedef struct{
#define PTPDEXP_COMMAND_TRACKING 1
#define PTPDEXP_COMMAND_MAN_ADJUST_PHASE 2
void
ptpdexp_get_sync_state
(
ptpdexp_sync_state_t
*
state
);
void
ptpdexp_cmd
(
int
cmd
,
int
value
);
extern
int
ptpdexp_get_sync_state
(
ptpdexp_sync_state_t
*
state
);
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
userspace/libptpnetif/Makefile
View file @
17153d0b
CC
=
$(CROSS_COMPILE)
gcc
AR
=
$(CROSS_COMPILE)
ar
CFLAGS
=
-I
.
-O2
-I
../include
-I
../wrsw_hal
-I
../
libwri
pc
-DDEBUG
CFLAGS
=
-I
.
-O2
-I
../include
-I
../wrsw_hal
-I
../
mini-r
pc
-DDEBUG
OBJS
=
hal_client.o netif_test.o ptpd_netif.o
...
...
userspace/libptpnetif/hal_client.c
View file @
17153d0b
#include <stdio.h>
#include <stdlib.h>
#include <minipc.h>
#define HAL_EXPORT_STRUCTURES
#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
()
{
...
...
@@ -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
rval
;
wripc_call
(
hal_cli
,
"halexp_calibration_cmd"
,
&
rval
,
3
,
A_STRING
(
port_name
),
A_INT32
(
command
),
A_INT32
(
on_off
));
int
ret
,
rval
;
ret
=
minipc_call
(
hal_ch
,
DEFAULT_TO
,
&
__rpcdef_calibration_cmd
,
&
rval
,
port_name
,
command
,
on_off
);
if
(
ret
<
0
)
return
ret
;
return
rval
;
}
int
halexp_lock_cmd
(
const
char
*
port_name
,
int
command
,
int
priority
)
{
int
rval
;
wripc_call
(
hal_cli
,
"halexp_lock_cmd"
,
&
rval
,
3
,
A_STRING
(
port_name
),
A_INT32
(
command
),
A_INT32
(
priority
));
int
ret
,
rval
;
ret
=
minipc_call
(
hal_ch
,
DEFAULT_TO
,
&
__rpcdef_lock_cmd
,
&
rval
,
port_name
,
command
,
priority
);
if
(
ret
<
0
)
return
ret
;
return
rval
;
}
int
halexp_query_ports
(
hexp_port_list_t
*
list
)
{
wripc_call
(
hal_cli
,
"halexp_query_ports"
,
list
,
0
);
return
0
;
int
ret
;
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
)
{
wripc_call
(
hal_cli
,
"halexp_get_port_state"
,
state
,
1
,
A_STRING
(
port_name
));
return
0
;
int
ret
;
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
rval
;
wripc_call
(
hal_cli
,
"halexp_pps_cmd"
,
&
rval
,
2
,
A_INT32
(
cmd
),
A_STRUCT
(
*
params
));
int
ret
,
rval
;
ret
=
minipc_call
(
hal_ch
,
DEFAULT_TO
,
&
__rpcdef_pps_cmd
,
&
rval
,
cmd
,
params
);
if
(
ret
<
0
)
return
ret
;
return
rval
;
}
...
...
@@ -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 rval;
wripc_call(hal_c
li
, "halexp_pll_cmd", &rval, 2, A_INT32(cmd), A_STRUCT(*params));
wripc_call(hal_c
h
, "halexp_pll_cmd", &rval, 2, A_INT32(cmd), A_STRUCT(*params));
return rval;
}
...
...
@@ -65,9 +81,18 @@ int halexp_pll_cmd(int cmd, hexp_pll_cmd_t *params)
int
halexp_client_init
()
{
hal_c
li
=
wripc_connect
(
WRSW_HAL_SERVER_ADDR
);
if
(
hal_cli
<
0
)
hal_c
h
=
minipc_client_create
(
WRSW_HAL_SERVER_ADDR
,
0
);
if
(
!
hal_ch
)
return
-
1
;
else
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
;
}
userspace/libwripc/Makefile
deleted
100644 → 0
View file @
61536e33
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)
userspace/libwripc/asm_helpers.h
deleted
100644 → 0
View file @
61536e33
// 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
userspace/libwripc/helper_arm.S
deleted
100644 → 0
View file @
61536e33
.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
userspace/libwripc/structs.h
deleted
100644 → 0
View file @
61536e33
struct
test_struct
{
int
apples
;
int
peas
;
char
name
[
80
];
float
value
;
};
struct
state_struct
{
char
state_name
[
80
];
float
t
;
int
x
;
};
userspace/libwripc/test_arm.c
deleted
100644 → 0
View file @
61536e33
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
userspace/libwripc/test_cli.c
deleted
100644 → 0
View file @
61536e33
#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
);
}
userspace/libwripc/test_floats.c
deleted
100644 → 0
View file @
61536e33
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
userspace/libwripc/test_srv.c
deleted
100644 → 0
View file @
61536e33
#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
;
}
userspace/libwripc/wr_ipc.c
deleted
100644 → 0
View file @
61536e33
This diff is collapsed.
Click to expand it.
userspace/libwripc/wr_ipc.h
deleted
100644 → 0
View file @
61536e33
#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 8
de7f89461d772d1818bbf2bc534ac643668c2d3
Subproject commit 8
0b47ffe3fe7fbcb9ded920c3bbce2fa3e015fcd
userspace/rtu_stat/Makefile
View file @
17153d0b
...
...
@@ -12,9 +12,9 @@ OBJDUMP = $(CROSS_COMPILE)objdump
OBJS
=
rtu_stat.o
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
-
lwr
ipc
LDFLAGS
=
-L
$(WR_INSTALL_ROOT)
/lib
-
L
../mini-rpc
-lmin
ipc
BINARY
=
rtu_stat
...
...
userspace/rtu_stat/rtu_stat.c
View file @
17153d0b
...
...
@@ -4,15 +4,16 @@
#include <string.h>
#include <hal_client.h>
#include <minipc.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
)
{
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
...
...
@@ -89,9 +90,9 @@ main()
int
n_entries
;
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
"
);
return
0
;
...
...
@@ -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
(
"
\n
"
);
}
\ No newline at end of file
}
userspace/wr_mon/Makefile
View file @
17153d0b
...
...
@@ -13,9 +13,10 @@ OBJDUMP = $(CROSS_COMPILE)objdump
MON_OBJS
=
wr_mon.o term.o
CFLAGS
+=
-O2
-DDEBUG
-I
$(LINUX)
/include
-I
../include
\
-I
../libptpnetif
-I
../wrsw_hal
-I
../
libwri
pc
-I
../libptpnetif
-I
../wrsw_hal
-I
../
mini-r
pc
LDFLAGS
=
-L
$(WR_INSTALL_ROOT)
/lib
-lptpnetif
-lwripc
LDFLAGS
=
-L
$(WR_INSTALL_ROOT)
/lib
-L
../mini-rpc
-L
../libptpnetif
\
-lptpnetif
-lminipc
BINARY
=
wr_mon
...
...
userspace/wr_mon/wr_mon.c
View file @
17153d0b
#include <stdio.h>
#include <stdlib.h>
#include <
wr_
ipc.h>
#include <
min
ipc.h>
#include "term.h"
#define PTP_EXPORT_STRUCTURES
#include "ptpd_exports.h"
#include "hal_client.h"
hexp_port_list_t
port_list
;
wripc_handle_t
h_ptp
;
static
struct
minipc_ch
*
ptp_ch
;
void
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 "
"to the PTP daemon!
\n
"
);
...
...
@@ -70,7 +73,8 @@ void show_ports()
void
show_servo
()
{
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\n
Synchronization status:
\n\n
"
);
...
...
@@ -165,9 +169,9 @@ main()
if
(
c
==
't'
)
{
int
rval
;
track_onoff
=
1
-
track_onoff
;
wripc_call
(
h_ptp
,
"ptpdexp_cmd"
,
&
rval
,
2
,
A_INT32
(
PTPDEXP_COMMAND_TRACKING
)
,
A_INT32
(
track_onoff
)
);
minipc_call
(
ptp_ch
,
200
,
&
__rpcdef_cmd
,
&
rval
,
PTPDEXP_COMMAND_TRACKING
,
track_onoff
);
}
}
...
...
userspace/wrsw_hal/Makefile
View file @
17153d0b
...
...
@@ -12,11 +12,11 @@ WR_INCLUDE = $(WR_INSTALL_ROOT)/include
WR_LIB
=
$(WR_INSTALL_ROOT)
/lib
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)
\
-L
../../../ptp-noposix-v3
-L
../libswitchhw
\
-l
wr
ipc
-llua
-lm
-ldl
-lswitchhw
-L
../libswitchhw
-L
../mini-rpc
\
-l
min
ipc
-llua
-lm
-ldl
-lswitchhw
all
:
$(BINARY)
...
...
userspace/wrsw_hal/hal_exports.c
View file @
17153d0b
...
...
@@ -8,11 +8,13 @@
#include <hw/dmpll.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 */
int
halexp_check_running
()
...
...
@@ -147,26 +149,69 @@ int halexp_pll_cmd(int cmd, hexp_pll_cmd_t *params)
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 */
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
;
wripc_export
(
hal_ipc
,
T_INT32
,
"halexp_pps_cmd"
,
halexp_pps_cmd
,
2
,
T_INT32
,
T_STRUCT
(
hexp_pps_params_t
));
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
);
/* NOTE: check_running is not remotely called, so I don't export it */
/* 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
);
...
...
@@ -178,7 +223,8 @@ int hal_init_wripc()
/* wripc update function, must be called in the main program loop */
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()
launching multiple HALs simultaneously. */
int
hal_check_running
()
{
wripc_handle_t
fd
;
fd
=
wripc_connect
(
WRSW_HAL_SERVER_ADDR
);
if
(
fd
>=
0
)
{
wripc_close
(
fd
);
return
1
;
}
return
0
;
struct
minipc_ch
*
ch
;
ch
=
minipc_client_create
(
WRSW_HAL_SERVER_ADDR
,
0
);
if
(
!
ch
)
return
0
;
minipc_close
(
ch
);
return
1
;
}
userspace/wrsw_hal/hal_exports.h
View file @
17153d0b
This diff is collapsed.
Click to expand it.
userspace/wrsw_hal/hal_main.c
View file @
17153d0b
...
...
@@ -10,7 +10,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <wr_
ipc.h>
//#include <min
ipc.h>
#include <hw/trace.h>
#include <hw/switch_hw.h>
...
...
userspace/wrsw_hal/hal_ports.c
View file @
17153d0b
...
...
@@ -15,7 +15,7 @@
#include <linux/if_arp.h>
#include <linux/if.h>
#include <wr_ipc.h>
//
#include <wr_ipc.h>
/* LOTs of hardware includes */
#include <hw/trace.h>
...
...
userspace/wrsw_rtud/Makefile
View file @
17153d0b
...
...
@@ -13,10 +13,12 @@ WR_INCLUDE = $(WR_INSTALL_ROOT)/include
WR_LIB
=
$(WR_INSTALL_ROOT)
/lib
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
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
...
...
userspace/wrsw_rtud/rtud_exports.c
View file @
17153d0b
...
...
@@ -31,37 +31,24 @@
#include <stdint.h>
#include <errno.h>
#include <wr_ipc.h>
#include <hw/trace.h>
#include "minipc.h"
#include "rtu.h"
#include "rtu_fd.h"
#include "rtud_exports.h"
#include "mac.h"
static
int
rtud_ipc
;
/* The channel */
static
struct
minipc_ch
*
rtud_ch
;
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
)
/* The exported function */
int
rtudexp_get_fd_list
(
const
struct
minipc_pd
*
pd
,
uint32_t
*
args
,
void
*
ret
)
{
int
i
;
rtudexp_fd_list_t
*
list
=
ret
;
int
start_from
=
args
[
0
];
//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)
list
->
num_rules
=
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
()
{
wripc_process
(
rtud_ipc
);
minipc_server_action
(
rtud_ch
,
100
);
}
userspace/wrsw_rtud/rtud_exports.h
View file @
17153d0b
...
...
@@ -30,6 +30,7 @@
#define __RTUD_EXPORTS_H
#include <stdint.h>
#include <minipc.h>
typedef
struct
{
...
...
@@ -47,6 +48,15 @@ typedef struct {
int
next
;
}
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment