Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
32
Issues
32
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
Software for White Rabbit PTP Core
Commits
968ac6f5
Commit
968ac6f5
authored
May 04, 2017
by
Michel Arruat
Committed by
Adam Wujek
Jun 20, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools:wrpc-vuart vuart is now using ldevmap library.
Signed-off-by:
Michel Arruat
<
michel.arruat@cern.ch
>
parent
17614052
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
112 additions
and
28 deletions
+112
-28
Makefile
tools/Makefile
+5
-1
wrpc-vuart.c
tools/wrpc-vuart.c
+107
-27
No files found.
tools/Makefile
View file @
968ac6f5
EB
?=
no
EB
?=
no
SDBFS
?=
no
SDBFS
?=
no
SUPPORT_CERN_VMEBRIDGE
?=
n
CFLAGS
=
-Wall
-ggdb
-I
../include
-I
../liblinux
CFLAGS
=
-Wall
-ggdb
-I
../include
-I
../liblinux
LDFLAGS
=
-lutil
-L
../liblinux
-lwhiterabbit
ifeq
($(SUPPORT_CERN_VMEBRIDGE),
y)
CFLAGS
+=
-DSUPPORT_CERN_VMEBRIDGE
endif
LDFLAGS
=
-lutil
-L
../liblinux
-ldevmap
ALL
=
genraminit genramvhd genrammif
ALL
=
genraminit genramvhd genrammif
ALL
+=
wrpc-w1-read wrpc-w1-write
ALL
+=
wrpc-w1-read wrpc-w1-write
ALL
+=
pfilter-builder
ALL
+=
pfilter-builder
...
...
tools/wrpc-vuart.c
View file @
968ac6f5
...
@@ -5,21 +5,102 @@
...
@@ -5,21 +5,102 @@
#include <stdlib.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include <unistd.h>
#include <unistd.h>
#include <termios.h>
#include <termios.h>
#include <getopt.h>
#include <getopt.h>
#include <errno.h>
#include <errno.h>
#include <arpa/inet.h>
#include <libwhiterabbit.h>
#include <hw/wb_uart.h>
#include <libdevmap.h>
static
void
wrpc_vuart_help
(
char
*
prog
)
static
void
wrpc_vuart_help
(
char
*
prog
)
{
{
fprintf
(
stderr
,
"%s [options]
\n\n
"
,
prog
);
const
char
*
mapping_help_str
;
fprintf
(
stderr
,
"-a 0x<address>
\t
Absolute virtual address for the White Rabbit VUART
\n
"
);
mapping_help_str
=
dev_mapping_help
();
fprintf
(
stderr
,
"%s [options]
\n
"
,
prog
);
fprintf
(
stderr
,
"%s
\n
"
,
mapping_help_str
);
fprintf
(
stderr
,
"Vuart specific option: [-k(keep terminal)]
\n
"
);
}
}
/**
* It receives a single byte
* @param[in] vuart token from dev_map()
*
*
*/
static
int8_t
wr_vuart_rx
(
struct
mapping_desc
*
vuart
)
{
int
rdr
=
((
volatile
struct
UART_WB
*
)
vuart
->
base
)
->
HOST_RDR
;
if
(
vuart
->
is_be
)
rdr
=
ntohl
(
rdr
);
return
(
rdr
&
UART_HOST_RDR_RDY
)
?
UART_HOST_RDR_DATA_R
(
rdr
)
:
-
1
;
}
/**
* It transmits a single byte
* @param[in] vuart token from dev_map()
*/
static
void
wr_vuart_tx
(
struct
mapping_desc
*
vuart
,
char
data
)
{
volatile
struct
UART_WB
*
ptr
=
(
volatile
struct
UART_WB
*
)
vuart
->
base
;
int
sr
=
(
vuart
->
is_be
)
?
ntohl
(
ptr
->
SR
)
:
ptr
->
SR
;
uint32_t
val
;
while
(
sr
&
UART_SR_RX_RDY
)
sr
=
(
vuart
->
is_be
)
?
ntohl
(
ptr
->
SR
)
:
ptr
->
SR
;
val
=
(
vuart
->
is_be
)
?
htonl
(
UART_HOST_TDR_DATA_W
(
data
))
:
UART_HOST_TDR_DATA_W
(
data
);
ptr
->
HOST_TDR
=
val
;
}
static
void
wrpc_vuart_term_main
(
struct
wr_vuart
*
vuart
,
int
keep_term
)
/**
* It reads a number of bytes and it stores them in a given buffer
* @param[in] vuart token from dev_map()
* @param[out] buf destination for read bytes
* @param[in] size numeber of bytes to read
*
* @return the number of read bytes
*/
static
size_t
wr_vuart_read
(
struct
mapping_desc
*
vuart
,
char
*
buf
,
size_t
size
)
{
size_t
s
=
size
,
n_rx
=
0
;
int8_t
c
;
while
(
s
--
)
{
c
=
wr_vuart_rx
(
vuart
);
if
(
c
<
0
)
return
n_rx
;
*
buf
++
=
c
;
n_rx
++
;
}
return
n_rx
;
}
/**
* It writes a number of bytes from a given buffer
* @param[in] vuart token from dev_map()
* @param[in] buf buffer to write
* @param[in] size numeber of bytes to write
*
* @return the number of written bytes
*/
static
size_t
wr_vuart_write
(
struct
mapping_desc
*
vuart
,
char
*
buf
,
size_t
size
)
{
size_t
s
=
size
;
while
(
s
--
)
wr_vuart_tx
(
vuart
,
*
buf
++
);
return
size
;
}
static
void
wrpc_vuart_term_main
(
struct
mapping_desc
*
vuart
,
int
keep_term
)
{
{
struct
termios
oldkey
,
newkey
;
struct
termios
oldkey
,
newkey
;
//above is place for old and new port settings for keyboard teletype
//above is place for old and new port settings for keyboard teletype
...
@@ -94,41 +175,40 @@ static void wrpc_vuart_term_main(struct wr_vuart *vuart, int keep_term)
...
@@ -94,41 +175,40 @@ static void wrpc_vuart_term_main(struct wr_vuart *vuart, int keep_term)
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
char
c
,
*
resource_file
;
char
c
;
int
ret
,
keep_term
=
0
;
int
keep_term
=
0
;
unsigned
int
vuart_base
;
struct
mapping_args
*
map_args
;
struct
wr_vuart
*
vuart
;
struct
mapping_desc
*
vuart
=
NULL
;
while
((
c
=
getopt
(
argc
,
argv
,
"a:f:k"
))
!=
-
1
)
map_args
=
dev_parse_mapping_args
(
argc
,
argv
);
{
if
(
!
map_args
)
{
switch
(
c
)
wrpc_vuart_help
(
argv
[
0
]);
{
goto
out
;
case
'a'
:
}
ret
=
sscanf
(
optarg
,
"0x%x"
,
&
vuart_base
);
if
(
ret
!=
1
)
{
/* Parse specific args */
wrpc_vuart_help
(
argv
[
0
]);
while
((
c
=
getopt
(
argc
,
argv
,
"k"
))
!=
-
1
)
{
return
-
1
;
switch
(
c
)
{
}
break
;
case
'f'
:
resource_file
=
optarg
;
break
;
case
'k'
:
case
'k'
:
keep_term
=
1
;
keep_term
=
1
;
break
;
break
;
default
:
case
'h'
:
wrpc_vuart_help
(
argv
[
0
]);
wrpc_vuart_help
(
argv
[
0
]);
return
-
1
;
break
;
case
'?'
:
break
;
}
}
}
}
vuart
=
wr_vuart_open
(
resource_file
,
vuart_base
);
vuart
=
dev_map
(
map_args
,
sizeof
(
struct
UART_WB
)
);
if
(
!
vuart
)
{
if
(
!
vuart
)
{
fprintf
(
stderr
,
"%s: vuart_open() failed: %s
\n
"
,
argv
[
0
],
strerror
(
errno
));
goto
out
;
goto
out
;
}
}
wrpc_vuart_term_main
(
vuart
,
keep_term
);
wrpc_vuart_term_main
(
vuart
,
keep_term
);
wr_vuart_close
(
vuart
);
dev_unmap
(
vuart
);
return
0
;
return
0
;
out:
out:
...
...
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