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
6
Merge Requests
6
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
3ab231ab
Commit
3ab231ab
authored
Mar 18, 2020
by
Tomasz Wlostowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: removed legacy tool (lm32-etheruart)
parent
6b095d26
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
0 additions
and
517 deletions
+0
-517
Makefile
tools/lm32-etheruart/Makefile
+0
-9
lm32-etheruart.c
tools/lm32-etheruart/lm32-etheruart.c
+0
-179
simple-eb.c
tools/lm32-etheruart/simple-eb.c
+0
-218
simple-eb.h
tools/lm32-etheruart/simple-eb.h
+0
-19
wb_uart.h
tools/lm32-etheruart/wb_uart.h
+0
-92
No files found.
tools/lm32-etheruart/Makefile
deleted
100644 → 0
View file @
6b095d26
OBJS
=
simple-eb.o lm32-etheruart.o
CFLAGS
=
-g
-Ietherbone
-I
.
LDFLAGS
=
-Letherbone
-letherbone
all
:
$(OBJS)
gcc
-o
lm32-etheruart
$(OBJS)
$(LDFLAGS)
clean
:
rm
-f
lm32-etheruart
*
.o
\ No newline at end of file
tools/lm32-etheruart/lm32-etheruart.c
deleted
100644 → 0
View file @
6b095d26
/*
Simple Etherbone-VUART bridge.
T.W. 2012, public domain
Todo:
- block polling
- SDB support
- decrappify
WARNING: CRAPPY CODE (as of now).
Building: run make (Etherbone library must be in etherbone subdirectory)
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <termios.h>
#include <string.h>
#include <sys/signal.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <getopt.h>
#include <errno.h>
#include "simple-eb.h"
#include "wb_uart.h"
static
int
vuart_rx
(
eb_device_t
card
)
{
int
rdr
=
ebs_read
(
card
,
0xe0500
+
UART_REG_HOST_RDR
);
if
(
rdr
&
UART_HOST_RDR_RDY
)
return
UART_HOST_RDR_DATA_R
(
rdr
);
else
return
-
1
;
}
static
void
vuart_tx
(
eb_device_t
card
,
int
c
)
{
while
(
ebs_read
(
card
,
0xe0500
+
UART_REG_SR
)
&
UART_SR_RX_RDY
);
ebs_write
(
card
,
0xe0500
+
UART_REG_HOST_TDR
,
UART_HOST_TDR_DATA_W
(
c
));
}
size_t
spec_vuart_rx
(
eb_device_t
card
,
char
*
buffer
,
size_t
size
)
{
size_t
s
=
size
,
n_rx
=
0
;
while
(
s
--
)
{
int
c
=
vuart_rx
(
card
);
if
(
c
<
0
)
return
n_rx
;
*
buffer
++
=
c
;
n_rx
++
;
}
return
n_rx
;
}
size_t
spec_vuart_tx
(
eb_device_t
card
,
char
*
buffer
,
size_t
size
)
{
size_t
s
=
size
;
while
(
s
--
)
vuart_tx
(
card
,
*
buffer
++
);
return
size
;
}
static
eb_device_t
card
;
static
int
transfer_byte
(
int
from
,
int
is_control
)
{
char
c
;
int
ret
;
do
{
ret
=
read
(
from
,
&
c
,
1
);
}
while
(
ret
<
0
&&
errno
==
EINTR
);
if
(
ret
==
1
)
{
if
(
is_control
)
{
if
(
c
==
'\x01'
)
{
// C-a
return
-
1
;
}
}
spec_vuart_tx
(
card
,
&
c
,
1
);
}
else
{
fprintf
(
stderr
,
"nothing to read. Port disconnected?
\n
"
);
return
-
2
;
}
return
0
;
}
uint64_t
get_tics
()
{
struct
timezone
tz
=
{
0
,
0
};
struct
timeval
tv
;
gettimeofday
(
&
tv
,
&
tz
);
return
tv
.
tv_sec
*
1000000ULL
+
tv
.
tv_usec
;
}
void
term_main
(
int
keep_term
)
{
struct
termios
oldkey
,
newkey
;
//above is place for old and new port settings for keyboard teletype
int
need_exit
=
0
;
uint64_t
last_poll
=
get_tics
();
fprintf
(
stderr
,
"[press C-a to exit]
\n
"
);
if
(
!
keep_term
)
{
tcgetattr
(
STDIN_FILENO
,
&
oldkey
);
newkey
.
c_cflag
=
B9600
|
CS8
|
CLOCAL
|
CREAD
;
newkey
.
c_iflag
=
IGNPAR
;
newkey
.
c_oflag
=
0
;
newkey
.
c_lflag
=
0
;
newkey
.
c_cc
[
VMIN
]
=
1
;
newkey
.
c_cc
[
VTIME
]
=
0
;
tcflush
(
STDIN_FILENO
,
TCIFLUSH
);
tcsetattr
(
STDIN_FILENO
,
TCSANOW
,
&
newkey
);
}
while
(
!
need_exit
)
{
fd_set
fds
;
int
ret
;
char
rx
;
struct
timeval
tv
=
{
0
,
10000
};
FD_ZERO
(
&
fds
);
FD_SET
(
STDIN_FILENO
,
&
fds
);
ret
=
select
(
STDIN_FILENO
+
1
,
&
fds
,
NULL
,
NULL
,
&
tv
);
if
(
ret
==
-
1
)
{
perror
(
"select"
);
}
else
if
(
ret
>
0
)
{
if
(
FD_ISSET
(
STDIN_FILENO
,
&
fds
))
{
need_exit
=
transfer_byte
(
STDIN_FILENO
,
1
);
}
}
if
(
get_tics
()
-
last_poll
>
500000
)
{
while
((
spec_vuart_rx
(
card
,
&
rx
,
1
))
==
1
)
fprintf
(
stderr
,
"%c"
,
rx
);
last_poll
=
get_tics
();
}
}
if
(
!
keep_term
)
tcsetattr
(
STDIN_FILENO
,
TCSANOW
,
&
oldkey
);
}
int
main
(
int
argc
,
char
**
argv
)
{
int
bus
=
-
1
,
dev_fn
=
-
1
,
c
;
uint32_t
vuart_base
=
0xe0500
;
int
keep_term
=
0
;
if
(
argc
<
2
)
{
printf
(
"usage: %s address
\n
"
,
argv
[
0
]);
printf
(
"example: %s udp/192.168.1.101"
,
argv
[
0
]);
return
0
;
}
ebs_init
();
ebs_open
(
&
card
,
argv
[
1
]);
term_main
(
0
);
ebs_close
(
card
);
ebs_shutdown
();
return
0
;
}
tools/lm32-etheruart/simple-eb.c
deleted
100644 → 0
View file @
6b095d26
/*
* main.c
*
* Created on: Aug 10, 2012
* Author: bbielawski
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/time.h>
#include <unistd.h>
#include "etherbone.h"
static
eb_socket_t
socket
;
static
inline
void
process_result
(
eb_status_t
result
)
{
if
(
result
!=
EB_OK
)
{
printf
(
"Error: %s
\n
"
,
eb_status
(
result
));
// exit(1);
}
return
;
}
eb_status_t
ebs_block_write
(
eb_device_t
device
,
eb_address_t
address
,
eb_data_t
*
data
,
int
count
,
int
autoincrement_address
)
{
int
write_done
=
0
;
void
wr_callback
(
eb_user_data_t
data
,
eb_device_t
device
,
eb_operation_t
operation
,
eb_status_t
status
)
{
write_done
=
1
;
}
eb_cycle_t
cycle
;
eb_status_t
status
=
eb_cycle_open
(
device
,
NULL
,
wr_callback
,
&
cycle
);
if
(
status
!=
EB_OK
)
return
status
;
int
i
;
for
(
i
=
0
;
i
<
count
;
i
++
)
{
eb_cycle_write
(
cycle
,
address
,
EB_DATA32
|
EB_LITTLE_ENDIAN
,
data
[
i
]);
if
(
autoincrement_address
)
address
+=
4
;
}
eb_cycle_close
(
cycle
);
status
=
eb_device_flush
(
device
);
while
(
!
write_done
)
eb_socket_run
(
socket
,
10
);
//wait forever
return
status
;
}
eb_status_t
ebs_block_read
(
eb_device_t
device
,
eb_address_t
read_address
,
eb_data_t
*
rdata
,
int
count
,
int
autoincrement_address
)
{
int
read_done
=
0
;
void
rd_callback
(
eb_user_data_t
data
,
eb_device_t
device
,
eb_operation_t
op
,
eb_status_t
status
)
{
static
int
c
=
0
;
if
(
status
!=
EB_OK
)
{
fprintf
(
stderr
,
"read failed: %s
\n
"
,
eb_status
(
status
));
exit
(
-
1
);
}
for
(;
op
!=
EB_NULL
;
op
=
eb_operation_next
(
op
))
{
/* We read low bits first */
*
rdata
++
=
eb_operation_data
(
op
);
}
read_done
=
1
;
}
eb_cycle_t
cycle
;
eb_status_t
status
=
eb_cycle_open
(
device
,
NULL
,
rd_callback
,
&
cycle
);
if
(
status
!=
EB_OK
)
return
status
;
int
i
;
for
(
i
=
0
;
i
<
count
;
i
++
)
{
eb_cycle_read
(
cycle
,
read_address
,
EB_DATA32
|
EB_LITTLE_ENDIAN
,
NULL
);
if
(
autoincrement_address
)
read_address
+=
4
;
}
eb_cycle_close
(
cycle
);
status
=
eb_device_flush
(
device
);
while
(
!
read_done
)
eb_socket_run
(
socket
,
-
1
);
//wait forever
return
status
;
}
uint32_t
ebs_read
(
eb_device_t
device
,
eb_address_t
addr
)
{
eb_data_t
rdata
;
ebs_block_read
(
device
,
addr
,
&
rdata
,
1
,
0
);
return
rdata
;
}
void
ebs_write
(
eb_device_t
device
,
eb_address_t
addr
,
eb_data_t
data
)
{
ebs_block_write
(
device
,
addr
,
&
data
,
1
,
0
);
}
eb_status_t
ebs_init
()
{
eb_status_t
status
=
EB_OK
;
status
=
eb_socket_open
(
EB_ABI_CODE
,
0
,
EB_DATA32
|
EB_ADDR32
,
&
socket
);
process_result
(
status
);
}
eb_status_t
ebs_shutdown
()
{
return
eb_socket_close
(
socket
);
}
eb_status_t
ebs_open
(
eb_device_t
*
dev
,
const
char
*
network_address
)
{
eb_status_t
status
=
EB_OK
;
status
=
eb_device_open
(
socket
,
network_address
,
EB_DATA32
|
EB_ADDR32
,
5
,
dev
);
process_result
(
status
);
return
status
;
}
eb_status_t
ebs_close
(
eb_device_t
dev
)
{
return
eb_device_close
(
dev
);
}
struct
bus_record
{
int
i
;
int
stop
;
eb_address_t
addr_first
,
addr_last
;
struct
bus_record
*
parent
;
};
int
ebs_sdb_find_device
(
eb_device_t
dev
,
uint32_t
vendor
,
uint32_t
device
,
int
seq
,
uint32_t
*
base_addr
)
{
struct
bus_record
br
;
int
done
=
0
,
found
=
0
,
n
=
0
;
void
scan_cb
(
eb_user_data_t
user
,
eb_device_t
dev
,
const
struct
sdb_table
*
sdb
,
eb_status_t
status
)
{
struct
bus_record
br
;
int
devices
;
br
.
parent
=
(
struct
bus_record
*
)
user
;
br
.
parent
->
stop
=
1
;
if
(
status
!=
EB_OK
)
{
fprintf
(
stderr
,
"failed to retrieve SDB: %s
\n
"
,
eb_status
(
status
));
exit
(
1
);
}
devices
=
sdb
->
interconnect
.
sdb_records
-
1
;
for
(
br
.
i
=
0
;
br
.
i
<
devices
;
++
br
.
i
)
{
const
union
sdb_record
*
des
;
des
=
&
sdb
->
record
[
br
.
i
];
if
(
des
->
empty
.
record_type
==
sdb_record_device
)
{
if
(
des
->
device
.
sdb_component
.
product
.
vendor_id
==
vendor
&&
des
->
device
.
sdb_component
.
product
.
device_id
==
device
)
{
if
(
n
==
seq
)
{
*
base_addr
=
des
->
device
.
sdb_component
.
addr_first
;
found
=
1
;
return
;
}
n
++
;
}
}
}
done
=
1
;
}
br
.
parent
=
0
;
br
.
i
=
-
1
;
br
.
stop
=
0
;
br
.
addr_first
=
0
;
br
.
addr_last
=
~
(
eb_address_t
)
0
;
br
.
addr_last
>>=
(
sizeof
(
eb_address_t
)
-
(
eb_device_width
(
dev
)
>>
4
))
*
8
;
if
(
eb_sdb_scan_root
(
dev
,
&
br
,
&
scan_cb
)
!=
EB_OK
)
return
-
1
;
while
(
!
done
&&
!
found
)
// fixme: crap code
eb_socket_run
(
eb_device_socket
(
dev
),
-
1
);
return
found
;
}
#if 0
main()
{
eb_device_t dev;
uint32_t base;
ebs_init();
ebs_open(&dev, "udp/192.168.10.11");
ebs_sdb_find_device(dev, 0xce42, 0xf19ede1a, 0, &base);
printf("base addr: %x\n", base);
}
#endif
tools/lm32-etheruart/simple-eb.h
deleted
100644 → 0
View file @
6b095d26
#ifndef __SIMPLE_EB_H
#define __SIMPLE_EB_H
#include <stdint.h>
#include "etherbone.h"
eb_status_t
ebs_block_write
(
eb_device_t
device
,
eb_address_t
address
,
eb_data_t
*
data
,
int
count
,
int
autoincrement_address
);
eb_status_t
ebs_block_read
(
eb_device_t
device
,
eb_address_t
read_address
,
eb_data_t
*
rdata
,
int
count
,
int
autoincrement_address
);
uint32_t
ebs_read
(
eb_device_t
device
,
eb_address_t
addr
);
void
ebs_write
(
eb_device_t
device
,
eb_address_t
addr
,
eb_data_t
data
);
eb_status_t
ebs_init
();
eb_status_t
ebs_shutdown
();
eb_status_t
ebs_open
(
eb_device_t
*
dev
,
const
char
*
network_address
);
eb_status_t
ebs_close
(
eb_device_t
dev
);
int
ebs_sdb_find_device
(
eb_device_t
dev
,
uint32_t
vendor
,
uint32_t
device
,
int
seq
,
uint32_t
*
base_addr
);
#endif
tools/lm32-etheruart/wb_uart.h
deleted
100644 → 0
View file @
6b095d26
/*
Register definitions for slave core: Simple Wishbone UART
* File : wb_uart.h
* Author : auto-generated by wbgen2 from simple_uart_wb.wb
* Created : Thu May 3 17:36:38 2012
* Standard : ANSI C
THIS FILE WAS GENERATED BY wbgen2 FROM SOURCE FILE simple_uart_wb.wb
DO NOT HAND-EDIT UNLESS IT'S ABSOLUTELY NECESSARY!
*/
#ifndef __WBGEN2_REGDEFS_SIMPLE_UART_WB_WB
#define __WBGEN2_REGDEFS_SIMPLE_UART_WB_WB
#include <inttypes.h>
#if defined( __GNUC__)
#define PACKED __attribute__ ((packed))
#else
#error "Unsupported compiler?"
#endif
#ifndef __WBGEN2_MACROS_DEFINED__
#define __WBGEN2_MACROS_DEFINED__
#define WBGEN2_GEN_MASK(offset, size) (((1<<(size))-1) << (offset))
#define WBGEN2_GEN_WRITE(value, offset, size) (((value) & ((1<<(size))-1)) << (offset))
#define WBGEN2_GEN_READ(reg, offset, size) (((reg) >> (offset)) & ((1<<(size))-1))
#define WBGEN2_SIGN_EXTEND(value, bits) (((value) & (1<<bits) ? ~((1<<(bits))-1): 0 ) | (value))
#endif
/* definitions for register: Status Register */
/* definitions for field: TX busy in reg: Status Register */
#define UART_SR_TX_BUSY WBGEN2_GEN_MASK(0, 1)
/* definitions for field: RX ready in reg: Status Register */
#define UART_SR_RX_RDY WBGEN2_GEN_MASK(1, 1)
/* definitions for register: Baudrate control register */
/* definitions for register: Transmit data regsiter */
/* definitions for field: Transmit data in reg: Transmit data regsiter */
#define UART_TDR_TX_DATA_MASK WBGEN2_GEN_MASK(0, 8)
#define UART_TDR_TX_DATA_SHIFT 0
#define UART_TDR_TX_DATA_W(value) WBGEN2_GEN_WRITE(value, 0, 8)
#define UART_TDR_TX_DATA_R(reg) WBGEN2_GEN_READ(reg, 0, 8)
/* definitions for register: Receive data regsiter */
/* definitions for field: Received data in reg: Receive data regsiter */
#define UART_RDR_RX_DATA_MASK WBGEN2_GEN_MASK(0, 8)
#define UART_RDR_RX_DATA_SHIFT 0
#define UART_RDR_RX_DATA_W(value) WBGEN2_GEN_WRITE(value, 0, 8)
#define UART_RDR_RX_DATA_R(reg) WBGEN2_GEN_READ(reg, 0, 8)
/* definitions for register: Host VUART Tx register */
/* definitions for field: TX Data in reg: Host VUART Tx register */
#define UART_HOST_TDR_DATA_MASK WBGEN2_GEN_MASK(0, 8)
#define UART_HOST_TDR_DATA_SHIFT 0
#define UART_HOST_TDR_DATA_W(value) WBGEN2_GEN_WRITE(value, 0, 8)
#define UART_HOST_TDR_DATA_R(reg) WBGEN2_GEN_READ(reg, 0, 8)
/* definitions for field: TX Ready in reg: Host VUART Tx register */
#define UART_HOST_TDR_RDY WBGEN2_GEN_MASK(8, 1)
/* definitions for register: Host VUART Rx register */
/* definitions for field: RX Data in reg: Host VUART Rx register */
#define UART_HOST_RDR_DATA_MASK WBGEN2_GEN_MASK(0, 8)
#define UART_HOST_RDR_DATA_SHIFT 0
#define UART_HOST_RDR_DATA_W(value) WBGEN2_GEN_WRITE(value, 0, 8)
#define UART_HOST_RDR_DATA_R(reg) WBGEN2_GEN_READ(reg, 0, 8)
/* definitions for field: RX Ready in reg: Host VUART Rx register */
#define UART_HOST_RDR_RDY WBGEN2_GEN_MASK(8, 1)
/* definitions for field: RX FIFO Count in reg: Host VUART Rx register */
#define UART_HOST_RDR_COUNT_MASK WBGEN2_GEN_MASK(9, 16)
#define UART_HOST_RDR_COUNT_SHIFT 9
#define UART_HOST_RDR_COUNT_W(value) WBGEN2_GEN_WRITE(value, 9, 16)
#define UART_HOST_RDR_COUNT_R(reg) WBGEN2_GEN_READ(reg, 9, 16)
#define UART_REG_SR 0x0
#define UART_REG_HOST_TDR 0x10
#define UART_REG_HOST_RDR 0x14
#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