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
28
Issues
28
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
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
e403f209
Commit
e403f209
authored
Jun 28, 2012
by
Tomasz Wlostowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: removed lm32-loader and vuart_console (they are part of spec-sw)
parent
93c65e0a
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
10 additions
and
1739 deletions
+10
-1739
Makefile
tools/Makefile
+10
-19
com.c
tools/com.c
+0
-207
lm32-loader.c
tools/lm32-loader.c
+0
-159
Makefile
tools/mini_bone/Makefile
+0
-4
minibone_lib.c
tools/mini_bone/minibone_lib.c
+0
-207
minibone_lib.h
tools/mini_bone/minibone_lib.h
+0
-14
ptpd_netif.c
tools/mini_bone/ptpd_netif.c
+0
-241
ptpd_netif.h
tools/mini_bone/ptpd_netif.h
+0
-239
rawrabbit.h
tools/rawrabbit.h
+0
-153
rr_io.c
tools/rr_io.c
+0
-233
rr_io.h
tools/rr_io.h
+0
-13
vuart_console.c
tools/vuart_console.c
+0
-43
wb_uart.h
tools/wb_uart.h
+0
-104
wb_vuart.h
tools/wb_vuart.h
+0
-103
No files found.
tools/Makefile
View file @
e403f209
CFLAGS
=
-Wall
-ggdb
-I
.
-I
../include
-Imini_bone
AS
=
$(CROSS_COMPILE)
as
LD
=
$(CROSS_COMPILE)
ld
CC
=
$(CROSS_COMPILE)
gcc
AS
=
as
LD
=
ld
CC
=
gcc
CPP
=
$(CC)
-E
AR
=
$(CROSS_COMPILE)
ar
NM
=
$(CROSS_COMPILE)
nm
STRIP
=
$(CROSS_COMPILE)
strip
OBJCOPY
=
$(CROSS_COMPILE)
objcopy
OBJDUMP
=
$(CROSS_COMPILE)
objdump
AR
=
ar
NM
=
nm
STRIP
=
strip
OBJCOPY
=
objcopy
OBJDUMP
=
objdump
all
:
lm32-loader genraminit genramvhd vuart_console
all
:
genraminit genramvhd
OBJS_LOADER
=
lm32-loader.o rr_io.o mini_bone/ptpd_netif.o mini_bone/minibone_lib.o
lm32-loader
:
$(OBJS_LOADER)
make
-C
mini_bone
${
CC
}
-o
lm32-loader
$(OBJS_LOADER)
genraminit
:
genraminit.o
${
CC
}
-o
genraminit genraminit.o
genramvhd
:
genramvhd.o
${
CC
}
-o
genramvhd genramvhd.o
vuart_console
:
vuart_console.o rr_io.o
${
CC
}
-o
vuart_console vuart_console.o rr_io.o
%.o
:
%.c
${
CC
}
-c
$^
$(CFLAGS)
-O0
clean
:
rm
-f
$(ALL)
*
.o
*
~ mini_bone/
*
.o mini_bone/
*
~
rm
-f
$(ALL)
*
.o
tools/com.c
deleted
100755 → 0
View file @
93c65e0a
/*
* Building: cc -o com com.c
* Usage : ./com /dev/device [speed]
* Example : ./com /dev/ttyS0 [115200]
* Keys : Ctrl-A - exit, Ctrl-X - display control lines status
* Darcs : darcs get http://tinyserial.sf.net/
* Homepage: http://tinyserial.sourceforge.net
* Version : 2009-03-05
*
* Ivan Tikhonov, http://www.brokestream.com, kefeer@brokestream.com
* Patches by Jim Kou, Henry Nestler, Jon Miner, Alan Horstmann
*
*/
/* Copyright (C) 2007 Ivan Tikhonov
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Ivan Tikhonov, kefeer@brokestream.com
*/
#include <termios.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/signal.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <errno.h>
int
transfer_byte
(
int
from
,
int
to
,
int
is_control
);
typedef
struct
{
char
*
name
;
int
flag
;
}
speed_spec
;
void
print_status
(
int
fd
)
{
int
status
;
unsigned
int
arg
;
status
=
ioctl
(
fd
,
TIOCMGET
,
&
arg
);
fprintf
(
stderr
,
"[STATUS]: "
);
if
(
arg
&
TIOCM_RTS
)
fprintf
(
stderr
,
"RTS "
);
if
(
arg
&
TIOCM_CTS
)
fprintf
(
stderr
,
"CTS "
);
if
(
arg
&
TIOCM_DSR
)
fprintf
(
stderr
,
"DSR "
);
if
(
arg
&
TIOCM_CAR
)
fprintf
(
stderr
,
"DCD "
);
if
(
arg
&
TIOCM_DTR
)
fprintf
(
stderr
,
"DTR "
);
if
(
arg
&
TIOCM_RNG
)
fprintf
(
stderr
,
"RI "
);
fprintf
(
stderr
,
"
\r\n
"
);
}
FILE
*
f_log
=
NULL
;
int
main
(
int
argc
,
char
*
argv
[])
{
int
comfd
;
struct
termios
oldtio
,
newtio
;
//place for old and new port settings for serial port
struct
termios
oldkey
,
newkey
;
//place tor old and new port settings for keyboard teletype
char
*
devicename
=
argv
[
1
];
int
need_exit
=
0
;
speed_spec
speeds
[]
=
{
{
"1200"
,
B1200
},
{
"2400"
,
B2400
},
{
"4800"
,
B4800
},
{
"9600"
,
B9600
},
{
"19200"
,
B19200
},
{
"38400"
,
B38400
},
{
"57600"
,
B57600
},
{
"115200"
,
B115200
},
{
NULL
,
0
}
};
int
speed
=
B9600
;
if
(
argc
<
2
)
{
fprintf
(
stderr
,
"example: %s /dev/ttyS0 [115200] [log file]
\n
"
,
argv
[
0
]);
exit
(
1
);
}
comfd
=
open
(
devicename
,
O_RDWR
|
O_NOCTTY
|
O_NONBLOCK
);
if
(
comfd
<
0
)
{
perror
(
devicename
);
exit
(
-
1
);
}
if
(
argc
>
2
)
{
speed_spec
*
s
;
for
(
s
=
speeds
;
s
->
name
;
s
++
)
{
if
(
strcmp
(
s
->
name
,
argv
[
2
])
==
0
)
{
speed
=
s
->
flag
;
fprintf
(
stderr
,
"setting speed %s
\n
"
,
s
->
name
);
break
;
}
}
}
if
(
argc
>
3
)
{
f_log
=
fopen
(
argv
[
3
],
"rb+"
);
if
(
!
f_log
)
f_log
=
fopen
(
argv
[
3
],
"wb"
);
fseek
(
f_log
,
0
,
SEEK_END
);
}
fprintf
(
stderr
,
"C-a exit, C-x modem lines status
\n
"
);
tcgetattr
(
STDIN_FILENO
,
&
oldkey
);
newkey
.
c_cflag
=
B9600
|
CRTSCTS
|
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
);
tcgetattr
(
comfd
,
&
oldtio
);
// save current port settings
newtio
.
c_cflag
=
speed
|
CS8
|
CLOCAL
|
CREAD
;
newtio
.
c_iflag
=
IGNPAR
;
newtio
.
c_oflag
=
0
;
newtio
.
c_lflag
=
0
;
newtio
.
c_cc
[
VMIN
]
=
1
;
newtio
.
c_cc
[
VTIME
]
=
0
;
tcflush
(
comfd
,
TCIFLUSH
);
tcsetattr
(
comfd
,
TCSANOW
,
&
newtio
);
print_status
(
comfd
);
while
(
!
need_exit
)
{
fd_set
fds
;
int
ret
;
FD_ZERO
(
&
fds
);
FD_SET
(
STDIN_FILENO
,
&
fds
);
FD_SET
(
comfd
,
&
fds
);
ret
=
select
(
comfd
+
1
,
&
fds
,
NULL
,
NULL
,
NULL
);
if
(
ret
==
-
1
)
{
perror
(
"select"
);
}
else
if
(
ret
>
0
)
{
if
(
FD_ISSET
(
STDIN_FILENO
,
&
fds
))
{
need_exit
=
transfer_byte
(
STDIN_FILENO
,
comfd
,
1
);
}
if
(
FD_ISSET
(
comfd
,
&
fds
))
{
need_exit
=
transfer_byte
(
comfd
,
STDIN_FILENO
,
0
);
}
}
}
tcsetattr
(
comfd
,
TCSANOW
,
&
oldtio
);
tcsetattr
(
STDIN_FILENO
,
TCSANOW
,
&
oldkey
);
close
(
comfd
);
return
0
;
}
int
transfer_byte
(
int
from
,
int
to
,
int
is_control
)
{
char
c
;
int
ret
;
do
{
ret
=
read
(
from
,
&
c
,
1
);
}
while
(
ret
<
0
&&
errno
==
EINTR
);
if
(
ret
==
1
)
{
if
(
f_log
&&
to
==
STDIN_FILENO
)
{
fwrite
(
&
c
,
1
,
1
,
f_log
);
fflush
(
f_log
);
}
if
(
is_control
)
{
if
(
c
==
'\x01'
)
{
// C-a
return
-
1
;
}
else
if
(
c
==
'\x18'
)
{
// C-x
print_status
(
to
);
return
0
;
}
}
while
(
write
(
to
,
&
c
,
1
)
==
-
1
)
{
if
(
errno
!=
EAGAIN
&&
errno
!=
EINTR
)
{
perror
(
"write failed"
);
break
;
}
}
}
else
{
fprintf
(
stderr
,
"
\n
nothing to read. probably port disconnected.
\n
"
);
return
-
2
;
}
return
0
;
}
tools/lm32-loader.c
deleted
100644 → 0
View file @
93c65e0a
/*
* Copyright (c) 2011 Grzegorz Daniluk <g.daniluk@elproma.com.pl>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
/*
* zpu-loader is a simple program created for White Rabbit PTP Core(WRPC).
* It loads the zpu firmware, given as the argument, directly to a dual-port RAM,
* which is the part of WRPC. This way, there is no need to synthesize whole
* FPGA project if one change anything in ZPU firmware.
* The binary file taken by zpu-loader is the result of the following action:
*
* ${CC} -o $(OUTPUT).elf $(OBJS) $(LDFLAGS)
* ${OBJCOPY} -O binary $(OUTPUT).elf $(OUTPUT).bin
*
* zpu-loader uses rawrabbit kernel driver written by Alessandro Rubini.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#define BASE_PCIE 0x80000
#define BASE_MBONE 0x00000
#define RST_ADDR 0x20400
#define MEM_ADDR 0x0
#include "rr_io.h"
#include "minibone_lib.h"
static
void
*
mb_handle
=
NULL
;
static
void
spec_writel
(
uint32_t
value
,
uint32_t
addr
)
{
if
(
mb_handle
)
mbn_writel
(
mb_handle
,
value
,
(
BASE_MBONE
+
addr
)
>>
2
);
else
rr_writel
(
value
,
BASE_PCIE
+
addr
);
}
static
uint32_t
spec_readl
(
uint32_t
addr
)
{
uint32_t
rval
;
if
(
mb_handle
)
rval
=
mbn_readl
(
mb_handle
,
(
BASE_MBONE
+
addr
)
>>
2
);
else
rval
=
rr_readl
(
BASE_PCIE
+
addr
);
return
rval
;
}
int
conv_endian
(
int
x
)
{
return
((
x
&
0xff000000
)
>>
24
)
+
((
x
&
0x00ff0000
)
>>
8
)
+
((
x
&
0x0000ff00
)
<<
8
)
+
((
x
&
0x000000ff
)
<<
24
);
}
void
rst_lm32
(
int
rst
)
{
spec_writel
(
rst
?
0x1deadbee
:
0x0deadbee
,
RST_ADDR
);
}
void
copy_lm32
(
uint32_t
*
buf
,
int
buf_nwords
,
uint32_t
base_addr
)
{
int
i
;
printf
(
"Writing memory: "
);
for
(
i
=
0
;
i
<
buf_nwords
;
i
++
)
{
spec_writel
(
conv_endian
(
buf
[
i
]),
base_addr
+
i
*
4
);
if
(
!
(
i
&
0xfff
))
{
printf
(
"."
);
fflush
(
stdout
);
}
}
printf
(
"
\n
Verifing memory: "
);
for
(
i
=
0
;
i
<
buf_nwords
;
i
++
)
{
uint32_t
x
=
spec_readl
(
base_addr
+
i
*
4
);
if
(
conv_endian
(
buf
[
i
])
!=
x
)
{
printf
(
"Verify failed (%x vs %x)
\n
"
,
conv_endian
(
buf
[
i
]),
x
);
return
;
}
if
(
!
(
i
&
0xfff
))
{
printf
(
"."
);
fflush
(
stdout
);
}
}
printf
(
"OK.
\n
"
);
}
int
main
(
int
argc
,
char
**
argv
)
{
int
num_words
;
uint32_t
*
buf
;
uint8_t
target_mac
[
6
];
FILE
*
f
;
char
if_name
[
16
];
if
(
argc
<
2
)
{
fprintf
(
stderr
,
"No parameters specified !
\n
"
);
fprintf
(
stderr
,
"Usage:
\n\t
%s <binary file> [-m network_if mac_addr]
\n
"
,
argv
[
0
]);
fprintf
(
stderr
,
"By default the loader assumes that the card is in a PCIe slot.
\n
"
);
fprintf
(
stderr
,
"-m option enables remove programming via ethernet.
\n
"
);
return
-
1
;
}
if
(
argc
>=
4
&&
!
strcmp
(
argv
[
2
],
"-m"
))
{
sscanf
(
argv
[
3
],
"%s"
,
if_name
);
sscanf
(
argv
[
4
],
"%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx"
,
&
target_mac
[
0
],
&
target_mac
[
1
],
&
target_mac
[
2
],
&
target_mac
[
3
],
&
target_mac
[
4
],
&
target_mac
[
5
]);
mb_handle
=
mbn_open
(
if_name
,
target_mac
);
if
(
!
mb_handle
)
{
fprintf
(
stderr
,
"Connection failed....
\n
"
);
return
-
1
;
}
}
else
if
(
rr_init
()
<
0
)
{
fprintf
(
stderr
,
"Can't initialize rawrabbit :(
\n
"
);
return
-
1
;
}
f
=
fopen
(
argv
[
1
],
"rb"
);
if
(
!
f
)
{
fprintf
(
stderr
,
"Input file not found.
\n
"
);
return
-
1
;
}
fseek
(
f
,
0
,
SEEK_END
);
int
size
=
ftell
(
f
);
rewind
(
f
);
buf
=
malloc
(
size
+
4
);
fread
(
buf
,
1
,
size
,
f
);
fclose
(
f
);
rst_lm32
(
1
);
rst_lm32
(
1
);
rst_lm32
(
1
);
rst_lm32
(
1
);
copy_lm32
(
buf
,
(
size
+
3
)
/
4
,
0
);
rst_lm32
(
0
);
if
(
mb_handle
)
{
mbn_stats
(
mb_handle
);
mbn_close
(
mb_handle
);
}
return
0
;
}
tools/mini_bone/Makefile
deleted
100644 → 0
View file @
93c65e0a
OBJS
=
minibone_lib.o ptpd_netif.o
all
:
$(OBJS)
gcc
-c
-o
m
$(OBJS)
tools/mini_bone/minibone_lib.c
deleted
100644 → 0
View file @
93c65e0a
/* MiniBone library. BUGGY CRAP CODE INTENDED FOR TESTING ONLY! */
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <sys/socket.h>
#include <sys/time.h>
#include "ptpd_netif.h"
#define F_SEL(x) (x & 0xf)
#define F_ERROR (1<<1)
#define F_READBACK (1<<0)
#define F_WRITE (1<<4)
#define RX_TIMEOUT 10
#define MBN_ETHERTYPE 0xa0a0
struct
mbn_packet
{
uint16_t
flags
;
uint32_t
a_d
;
uint32_t
d
;
}
__attribute__
((
packed
));
struct
mb_device
{
mac_addr_t
dest
;
uint16_t
ethertype
;
wr_socket_t
*
sock
;
int
tx_packets
,
rx_packets
,
tx_retries
,
rx_retries
;
};
typedef
struct
{
uint64_t
start_tics
;
uint64_t
timeout
;
}
timeout_t
;
static
uint64_t
get_tics
()
{
struct
timezone
tz
=
{
0
,
0
};
struct
timeval
tv
;
gettimeofday
(
&
tv
,
&
tz
);
return
(
uint64_t
)
tv
.
tv_sec
*
1000000ULL
+
(
uint64_t
)
tv
.
tv_usec
;
}
static
inline
int
tmo_init
(
timeout_t
*
tmo
,
uint32_t
milliseconds
)
{
tmo
->
start_tics
=
get_tics
();
tmo
->
timeout
=
(
uint64_t
)
milliseconds
*
1000ULL
;
return
0
;
}
static
inline
int
tmo_restart
(
timeout_t
*
tmo
)
{
tmo
->
start_tics
=
get_tics
();
return
0
;
}
static
inline
int
tmo_expired
(
timeout_t
*
tmo
)
{
return
(
get_tics
()
-
tmo
->
start_tics
>
tmo
->
timeout
);
}
void
*
mbn_open
(
const
char
*
if_name
,
mac_addr_t
target
)
{
struct
mb_device
*
dev
=
malloc
(
sizeof
(
struct
mb_device
));
wr_sockaddr_t
saddr
;
if
(
!
dev
)
return
NULL
;
memset
(
dev
,
0
,
sizeof
(
struct
mb_device
));
memcpy
(
dev
->
dest
,
target
,
6
);
strcpy
(
saddr
.
if_name
,
if_name
);
memcpy
(
saddr
.
mac
,
target
,
6
);
saddr
.
ethertype
=
htons
(
MBN_ETHERTYPE
);
saddr
.
family
=
PTPD_SOCK_RAW_ETHERNET
;
dev
->
sock
=
ptpd_netif_create_socket
(
PTPD_SOCK_RAW_ETHERNET
,
0
,
&
saddr
);
if
(
!
dev
->
sock
)
{
free
(
dev
);
return
NULL
;
}
return
(
void
*
)
dev
;
}
static
int
mbn_send
(
void
*
priv
,
uint8_t
*
data
,
int
size
)
{
struct
mb_device
*
dev
=
(
struct
mb_device
*
)
priv
;
wr_sockaddr_t
to
;
memcpy
(
to
.
mac
,
dev
->
dest
,
6
);
to
.
ethertype
=
MBN_ETHERTYPE
;
return
ptpd_netif_sendto
(
dev
->
sock
,
&
to
,
(
void
*
)
data
,
size
,
NULL
);
}
static
int
mbn_recv
(
void
*
handle
,
uint8_t
*
data
,
int
size
,
int
timeout
)
{
struct
mb_device
*
dev
=
(
struct
mb_device
*
)
handle
;
wr_sockaddr_t
from
;
timeout_t
rx_tmo
;
tmo_init
(
&
rx_tmo
,
timeout
);
do
{
int
n
=
ptpd_netif_recvfrom
(
dev
->
sock
,
&
from
,
(
void
*
)
data
,
size
,
NULL
);
if
(
n
>
0
&&
from
.
ethertype
==
MBN_ETHERTYPE
&&
!
memcmp
(
from
.
mac
,
dev
->
dest
,
6
))
{
dev
->
rx_packets
++
;
return
n
;
}
// dev->rx_retries++;
}
while
(
!
tmo_expired
(
&
rx_tmo
));
return
0
;
}
void
mbn_writel
(
void
*
handle
,
uint32_t
d
,
uint32_t
a
)
{
struct
mb_device
*
dev
=
(
struct
mb_device
*
)
handle
;
int
n_retries
=
3
;
struct
mbn_packet
pkt
;
while
(
n_retries
--
)
{
pkt
.
flags
=
htons
(
F_SEL
(
0xf
)
|
F_WRITE
);
pkt
.
a_d
=
htonl
(
a
);
pkt
.
d
=
htonl
(
d
);
mbn_send
(
handle
,
(
uint8_t
*
)
&
pkt
,
sizeof
(
pkt
));
int
n
=
mbn_recv
(
handle
,
(
uint8_t
*
)
&
pkt
,
sizeof
(
pkt
),
RX_TIMEOUT
);
pkt
.
flags
=
ntohs
(
pkt
.
flags
);
if
(
n
==
sizeof
(
pkt
)
&&
!
(
!
(
pkt
.
flags
&&
F_READBACK
)
&&
!
(
pkt
.
flags
&
F_ERROR
)))
{
int
i
;
fprintf
(
stderr
,
"
\n
BadPacket: "
);
for
(
i
=
0
;
i
<
n
;
i
++
)
fprintf
(
stderr
,
"%02x "
,
*
(
uint8_t
*
)
(
&
pkt
+
i
));
fprintf
(
stderr
,
"
\n
"
);
}
if
(
n
==
sizeof
(
pkt
)
&&
!
(
pkt
.
flags
&&
F_READBACK
)
&&
!
(
pkt
.
flags
&
F_ERROR
))
{
int
i
;
// fprintf(stderr,"GoodFlags: %x\n", pkt.flags);
/*fprintf(stderr,"\nGoodPacket: ");
for(i=0;i<n; i++) fprintf(stderr,"%02x ", *(uint8_t*) (&pkt + i));
fprintf(stderr,"\n");*/
dev
->
tx_packets
++
;
return
;
}
dev
->
tx_retries
++
;
}
fprintf
(
stderr
,
"No ack.
\n
"
);
}
uint32_t
mbn_readl
(
void
*
handle
,
uint32_t
a
)
{
int
n_retries
=
3
;
struct
mb_device
*
dev
=
(
struct
mb_device
*
)
handle
;
struct
mbn_packet
pkt
;
pkt
.
flags
=
htons
(
F_SEL
(
0xf
));
pkt
.
a_d
=
htonl
(
a
);
while
(
n_retries
--
)
{
mbn_send
(
handle
,
(
uint8_t
*
)
&
pkt
,
sizeof
(
pkt
));
int
n
=
mbn_recv
(
handle
,
(
uint8_t
*
)
&
pkt
,
sizeof
(
pkt
),
RX_TIMEOUT
);
pkt
.
flags
=
ntohs
(
pkt
.
flags
);
if
(
n
==
sizeof
(
pkt
)
&&
(
pkt
.
flags
&
F_READBACK
)
&&
!
(
pkt
.
flags
&
F_ERROR
))
{
return
ntohl
(
pkt
.
a_d
);
}
dev
->
tx_retries
++
;
}
fprintf
(
stderr
,
"No ack.
\n
"
);
}
void
mbn_stats
(
void
*
handle
)
{
struct
mb_device
*
dev
=
(
struct
mb_device
*
)
handle
;
fprintf
(
stderr
,
"Sent: %d [retries: %d], rcvd: %d [retries: %d]
\n
"
,
dev
->
tx_packets
,
dev
->
tx_retries
,
dev
->
rx_packets
,
dev
->
rx_retries
);
}
void
mbn_close
(
void
*
handle
)
{
struct
mb_device
*
dev
=
(
struct
mb_device
*
)
handle
;
ptpd_netif_close_socket
(
dev
->
sock
);
}
\ No newline at end of file
tools/mini_bone/minibone_lib.h
deleted
100644 → 0
View file @
93c65e0a
/* MiniBone library. BUGGY CRAP CODE INTENDED FOR TESTING ONLY! */
#ifndef __MINIBONE_LIB_H
#define __MINIBONE_LIB_H
#include <stdint.h>
void
*
mbn_open
(
const
char
*
if_name
,
uint8_t
target_mac
[]);
void
mbn_writel
(
void
*
handle
,
uint32_t
d
,
uint32_t
a
);
uint32_t
mbn_readl
(
void
*
handle
,
uint32_t
a
);
void
mbn_close
(
void
*
handle
);
#endif
tools/mini_bone/ptpd_netif.c
deleted
100644 → 0
View file @
93c65e0a
// Supports only raw ethernet now.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <arpa/inet.h>
#include <linux/if_packet.h>
#include <linux/if_ether.h>
#include <linux/if_arp.h>
#include <linux/errqueue.h>
#include <linux/sockios.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <asm/types.h>
#include <fcntl.h>
#include <errno.h>
#include <asm/socket.h>
#include "ptpd_netif.h"
#ifdef NETIF_VERBOSE
#define netif_dbg(...) printf(__VA_ARGS__)
#else
#define netif_dbg(...)
#endif
#define ETHER_MTU 1518
#define DMTD_UPDATE_INTERVAL 100
struct
scm_timestamping
{
struct
timespec
systime
;
struct
timespec
hwtimetrans
;
struct
timespec
hwtimeraw
;
};
PACKED
struct
etherpacket
{
struct
ethhdr
ether
;
char
data
[
ETHER_MTU
];
};
struct
tx_timestamp
{
int
valid
;
wr_timestamp_t
ts
;
uint32_t
tag
;
uint64_t
t_acq
;
};
struct
my_socket
{
int
fd
;
wr_sockaddr_t
bind_addr
;
mac_addr_t
local_mac
;
int
if_index
;
// parameters for linearization of RX timestamps
uint32_t
clock_period
;
uint32_t
phase_transition
;
uint32_t
dmtd_phase
;
};
struct
nasty_hack
{
char
if_name
[
20
];
int
clockedAsPrimary
;
};
#ifdef MACIEK_HACKs
struct
nasty_hack
locking_hack
;
#endif
wr_socket_t
*
ptpd_netif_create_socket
(
int
sock_type
,
int
flags
,
wr_sockaddr_t
*
bind_addr
)
{
struct
my_socket
*
s
;
struct
sockaddr_ll
sll
;
struct
ifreq
f
;
int
fd
;
// fprintf(stderr,"CreateSocket!\n");
if
(
sock_type
!=
PTPD_SOCK_RAW_ETHERNET
)
return
NULL
;
fd
=
socket
(
PF_PACKET
,
SOCK_RAW
,
htons
(
ETH_P_ALL
));
if
(
fd
<
0
)
{
perror
(
"socket()"
);