Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tapasco
tapasco
Commits
0c436917
Commit
0c436917
authored
Jul 06, 2017
by
Jens Korinth
Browse files
Merge branch 'ATSBackports' into '2017.1'
Ports changes of the ATS Branch of TPC to Tapasco See merge request
!1
parents
a543f07d
bfcfeb64
Changes
20
Expand all
Hide whitespace changes
Inline
Side-by-side
arch/tests/debug-screens/BlueDebugScreen.hpp
View file @
0c436917
...
...
@@ -72,12 +72,12 @@ protected:
platform
::
platform_read_ctl
(
base_addr
,
sizeof
(
intr
.
interrupts
[
i
].
vector_control
),
&
intr
.
interrupts
[
i
].
vector_control
,
platform
::
PLATFORM_CTL_FLAGS_RAW
);
base_addr
+=
4
;
}
base_addr
=
0x50
2
000
;
base_addr
=
0x50
8
000
;
for
(
int
i
=
0
;
i
<
1
+
(
total_interrupts
/
64
)
+
((
total_interrupts
%
64
)
!=
0
);
++
i
)
{
platform
::
platform_read_ctl
(
base_addr
,
sizeof
(
intr
.
pba
[
i
]),
&
intr
.
pba
[
i
],
platform
::
PLATFORM_CTL_FLAGS_RAW
);
base_addr
+=
8
;
}
base_addr
=
0x50
40
00
;
base_addr
=
0x50
81
00
;
platform
::
platform_read_ctl
(
base_addr
,
sizeof
(
intr
.
core_id
),
&
intr
.
core_id
,
platform
::
PLATFORM_CTL_FLAGS_RAW
);
base_addr
+=
4
;
platform
::
platform_read_ctl
(
base_addr
,
sizeof
(
intr
.
enableAndMask
),
&
intr
.
enableAndMask
,
platform
::
PLATFORM_CTL_FLAGS_RAW
);
...
...
common/ip/BlueDMA/component.xml
View file @
0c436917
...
...
@@ -1096,7 +1096,7 @@
<spirit:parameters>
<spirit:parameter>
<spirit:name>
viewChecksum
</spirit:name>
<spirit:value>
34326147
</spirit:value>
<spirit:value>
ded3be7f
</spirit:value>
</spirit:parameter>
</spirit:parameters>
</spirit:view>
...
...
@@ -1112,7 +1112,7 @@
<spirit:parameters>
<spirit:parameter>
<spirit:name>
viewChecksum
</spirit:name>
<spirit:value>
34326147
</spirit:value>
<spirit:value>
ded3be7f
</spirit:value>
</spirit:parameter>
</spirit:parameters>
</spirit:view>
...
...
@@ -2953,27 +2953,27 @@
<spirit:fileType>
verilogSource
</spirit:fileType>
</spirit:file>
<spirit:file>
<spirit:name>
src/S
ized
FIFO.v
</spirit:name>
<spirit:name>
src/S
ync
FIFO
1
.v
</spirit:name>
<spirit:fileType>
verilogSource
</spirit:fileType>
</spirit:file>
<spirit:file>
<spirit:name>
src/Sync
FIFO1
.v
</spirit:name>
<spirit:name>
src/Sync
Register
.v
</spirit:name>
<spirit:fileType>
verilogSource
</spirit:fileType>
</spirit:file>
<spirit:file>
<spirit:name>
src/
Sync
FIFO.v
</spirit:name>
<spirit:name>
src/FIFO
1
.v
</spirit:name>
<spirit:fileType>
verilogSource
</spirit:fileType>
</spirit:file>
<spirit:file>
<spirit:name>
src/
SyncRegister
.v
</spirit:name>
<spirit:name>
src/
FIFO2
.v
</spirit:name>
<spirit:fileType>
verilogSource
</spirit:fileType>
</spirit:file>
<spirit:file>
<spirit:name>
src/FIFO
2
.v
</spirit:name>
<spirit:name>
src/
Sized
FIFO.v
</spirit:name>
<spirit:fileType>
verilogSource
</spirit:fileType>
</spirit:file>
<spirit:file>
<spirit:name>
src/FIFO
1
.v
</spirit:name>
<spirit:name>
src/
Sync
FIFO.v
</spirit:name>
<spirit:fileType>
verilogSource
</spirit:fileType>
</spirit:file>
<spirit:file>
...
...
@@ -2983,7 +2983,7 @@
<spirit:file>
<spirit:name>
src/mkBlueDMAVivado.v
</spirit:name>
<spirit:fileType>
verilogSource
</spirit:fileType>
<spirit:userFileType>
CHECKSUM_
0e8625c1
</spirit:userFileType>
<spirit:userFileType>
CHECKSUM_
578878b6
</spirit:userFileType>
</spirit:file>
</spirit:fileSet>
<spirit:fileSet>
...
...
@@ -2993,27 +2993,27 @@
<spirit:fileType>
verilogSource
</spirit:fileType>
</spirit:file>
<spirit:file>
<spirit:name>
src/S
ized
FIFO.v
</spirit:name>
<spirit:name>
src/S
ync
FIFO
1
.v
</spirit:name>
<spirit:fileType>
verilogSource
</spirit:fileType>
</spirit:file>
<spirit:file>
<spirit:name>
src/Sync
FIFO1
.v
</spirit:name>
<spirit:name>
src/Sync
Register
.v
</spirit:name>
<spirit:fileType>
verilogSource
</spirit:fileType>
</spirit:file>
<spirit:file>
<spirit:name>
src/
Sync
FIFO.v
</spirit:name>
<spirit:name>
src/FIFO
1
.v
</spirit:name>
<spirit:fileType>
verilogSource
</spirit:fileType>
</spirit:file>
<spirit:file>
<spirit:name>
src/
SyncRegister
.v
</spirit:name>
<spirit:name>
src/
FIFO2
.v
</spirit:name>
<spirit:fileType>
verilogSource
</spirit:fileType>
</spirit:file>
<spirit:file>
<spirit:name>
src/FIFO
2
.v
</spirit:name>
<spirit:name>
src/
Sized
FIFO.v
</spirit:name>
<spirit:fileType>
verilogSource
</spirit:fileType>
</spirit:file>
<spirit:file>
<spirit:name>
src/FIFO
1
.v
</spirit:name>
<spirit:name>
src/
Sync
FIFO.v
</spirit:name>
<spirit:fileType>
verilogSource
</spirit:fileType>
</spirit:file>
<spirit:file>
...
...
@@ -3055,7 +3055,7 @@
<xilinx:displayName>
BlueDMA
</xilinx:displayName>
<xilinx:definitionSource>
package_project
</xilinx:definitionSource>
<xilinx:coreRevision>
1
</xilinx:coreRevision>
<xilinx:coreCreationDateTime>
2017-0
6
-0
9
T1
3:48:43
Z
</xilinx:coreCreationDateTime>
<xilinx:coreCreationDateTime>
2017-0
7
-0
6
T1
1:01:37
Z
</xilinx:coreCreationDateTime>
<xilinx:tags>
<xilinx:tag
xilinx:name=
"nopcore"
/>
</xilinx:tags>
...
...
@@ -3065,7 +3065,7 @@
<xilinx:checksum
xilinx:scope=
"busInterfaces"
xilinx:value=
"4abcc88b"
/>
<xilinx:checksum
xilinx:scope=
"addressSpaces"
xilinx:value=
"39f16c3a"
/>
<xilinx:checksum
xilinx:scope=
"memoryMaps"
xilinx:value=
"5dd283ff"
/>
<xilinx:checksum
xilinx:scope=
"fileGroups"
xilinx:value=
"
b6d869fa
"
/>
<xilinx:checksum
xilinx:scope=
"fileGroups"
xilinx:value=
"
d8fab998
"
/>
<xilinx:checksum
xilinx:scope=
"ports"
xilinx:value=
"8523f8a5"
/>
<xilinx:checksum
xilinx:scope=
"parameters"
xilinx:value=
"1bb46e31"
/>
</xilinx:packagingInfo>
...
...
common/ip/BlueDMA/src/mkBlueDMA.v
View file @
0c436917
This diff is collapsed.
Click to expand it.
common/ip/BlueDMA/src/mkBlueDMAVivado.v
View file @
0c436917
//
// Generated by Bluespec Compiler, version 2015.09.beta2 (build 34689, 2015-09-07)
//
// On
Fri
Ju
n
9
1
5:48:16
CEST 2017
// On
Thu
Ju
l
6
1
3:00:49
CEST 2017
//
//
// Ports:
...
...
common/ip/MSIXIntrCtrl/component.xml
View file @
0c436917
...
...
@@ -427,7 +427,7 @@
<spirit:parameters>
<spirit:parameter>
<spirit:name>
viewChecksum
</spirit:name>
<spirit:value>
93bc1b6f
</spirit:value>
<spirit:value>
558b72aa
</spirit:value>
</spirit:parameter>
</spirit:parameters>
</spirit:view>
...
...
@@ -443,7 +443,7 @@
<spirit:parameters>
<spirit:parameter>
<spirit:name>
viewChecksum
</spirit:name>
<spirit:value>
93bc1b6f
</spirit:value>
<spirit:value>
558b72aa
</spirit:value>
</spirit:parameter>
</spirit:parameters>
</spirit:view>
...
...
@@ -1249,11 +1249,11 @@
<spirit:fileSet>
<spirit:name>
xilinx_anylanguagesynthesis_view_fileset
</spirit:name>
<spirit:file>
<spirit:name>
src/
SizedFIFO
.v
</spirit:name>
<spirit:name>
src/
BRAM2BE
.v
</spirit:name>
<spirit:fileType>
verilogSource
</spirit:fileType>
</spirit:file>
<spirit:file>
<spirit:name>
src/
BRAM2BE
.v
</spirit:name>
<spirit:name>
src/
FIFO1
.v
</spirit:name>
<spirit:fileType>
verilogSource
</spirit:fileType>
</spirit:file>
<spirit:file>
...
...
@@ -1261,23 +1261,23 @@
<spirit:fileType>
verilogSource
</spirit:fileType>
</spirit:file>
<spirit:file>
<spirit:name>
src/FIFO
1
.v
</spirit:name>
<spirit:name>
src/
Sized
FIFO.v
</spirit:name>
<spirit:fileType>
verilogSource
</spirit:fileType>
</spirit:file>
<spirit:file>
<spirit:name>
src/mkMSIXIntrCtrl.v
</spirit:name>
<spirit:fileType>
verilogSource
</spirit:fileType>
<spirit:userFileType>
CHECKSUM_
3366b868
</spirit:userFileType>
<spirit:userFileType>
CHECKSUM_
7049b426
</spirit:userFileType>
</spirit:file>
</spirit:fileSet>
<spirit:fileSet>
<spirit:name>
xilinx_anylanguagebehavioralsimulation_view_fileset
</spirit:name>
<spirit:file>
<spirit:name>
src/
SizedFIFO
.v
</spirit:name>
<spirit:name>
src/
BRAM2BE
.v
</spirit:name>
<spirit:fileType>
verilogSource
</spirit:fileType>
</spirit:file>
<spirit:file>
<spirit:name>
src/
BRAM2BE
.v
</spirit:name>
<spirit:name>
src/
FIFO1
.v
</spirit:name>
<spirit:fileType>
verilogSource
</spirit:fileType>
</spirit:file>
<spirit:file>
...
...
@@ -1285,7 +1285,7 @@
<spirit:fileType>
verilogSource
</spirit:fileType>
</spirit:file>
<spirit:file>
<spirit:name>
src/FIFO
1
.v
</spirit:name>
<spirit:name>
src/
Sized
FIFO.v
</spirit:name>
<spirit:fileType>
verilogSource
</spirit:fileType>
</spirit:file>
<spirit:file>
...
...
@@ -1323,7 +1323,7 @@
<xilinx:displayName>
MSIXIntrCtrl
</xilinx:displayName>
<xilinx:definitionSource>
package_project
</xilinx:definitionSource>
<xilinx:coreRevision>
1
</xilinx:coreRevision>
<xilinx:coreCreationDateTime>
2017-0
6
-0
9
T1
3:47:07
Z
</xilinx:coreCreationDateTime>
<xilinx:coreCreationDateTime>
2017-0
7
-0
5
T1
6:28:24
Z
</xilinx:coreCreationDateTime>
<xilinx:tags>
<xilinx:tag
xilinx:name=
"nopcore"
/>
</xilinx:tags>
...
...
@@ -1333,7 +1333,7 @@
<xilinx:checksum
xilinx:scope=
"busInterfaces"
xilinx:value=
"a9103989"
/>
<xilinx:checksum
xilinx:scope=
"addressSpaces"
xilinx:value=
"39f94240"
/>
<xilinx:checksum
xilinx:scope=
"memoryMaps"
xilinx:value=
"2b2da2c0"
/>
<xilinx:checksum
xilinx:scope=
"fileGroups"
xilinx:value=
"
5c9a1c13
"
/>
<xilinx:checksum
xilinx:scope=
"fileGroups"
xilinx:value=
"
057aaeb0
"
/>
<xilinx:checksum
xilinx:scope=
"ports"
xilinx:value=
"19368f77"
/>
<xilinx:checksum
xilinx:scope=
"parameters"
xilinx:value=
"4b2b81b7"
/>
</xilinx:packagingInfo>
...
...
common/ip/MSIXIntrCtrl/msix_intr_ctrl.xdc
View file @
0c436917
set_false_path -t
o
[get_
cell
s system_i/InterruptControl/msix_intr_ctrl/
inst/
interrupt
s_
*]
set_false_path -t
hrough
[get_
pin
s system_i/InterruptControl/msix_intr_ctrl/interrupt*]
common/ip/MSIXIntrCtrl/src/mkMSIXIntrCtrl.v
View file @
0c436917
This diff is collapsed.
Click to expand it.
examples/examples.cmake
View file @
0c436917
...
...
@@ -31,7 +31,7 @@ set(FF_ROOT "$ENV{FF_ROOT}")
endif
(
${
REQUIRES_FASTFLOW
}
)
# link_directories(${TAPASCO_HOME}/arch/lib/${ARCH} ${TAPASCO_HOME}/arch/lib/${ARCH}/static ${TAPASCO_HOME}/platform/lib/${ARCH} ${TAPASCO_HOME}/platform/lib/${ARCH}/static)
link_directories
(
${
TAPASCO_HOME
}
/arch/lib/
${
ARCH
}
/static
${
TAPASCO_HOME
}
/platform/lib/
${
ARCH
}
/static
)
link_directories
(
${
TAPASCO_HOME
}
/arch/lib/
${
ARCH
}
${
TAPASCO_HOME
}
/platform/lib/
${
ARCH
}
)
include_directories
(
${
TAPASCO_HOME
}
/arch/common/include
${
TAPASCO_HOME
}
/platform/common/include
${
FF_ROOT
}
)
examples/memcheck/memcheck-mt-ff.cc
View file @
0c436917
...
...
@@ -82,7 +82,8 @@ static int runTest(int const s)
assert
(
rarr
!=
NULL
);
// get tapasco handle
tapasco_handle_t
h
=
tapasco_device_alloc
(
dev
,
arr_szs
[
s
]
*
sizeof
(
int
),
0
);
tapasco_handle_t
h
;
tapasco_device_alloc
(
dev
,
&
h
,
arr_szs
[
s
]
*
sizeof
(
int
),
0
);
std
::
cout
<<
s
<<
": handle = 0x"
<<
std
::
hex
<<
std
::
setfill
(
'0'
)
<<
std
::
setw
(
8
)
<<
static_cast
<
uint32_t
>
(
h
)
<<
", size = "
<<
arr_szs
[
s
]
*
sizeof
(
int
)
<<
" bytes"
...
...
@@ -112,7 +113,7 @@ static int runTest(int const s)
merr
+=
1
;
}
__sync_add_and_fetch
(
&
errs
,
merr
);
tapasco_device_free
(
dev
,
h
);
tapasco_device_free
(
dev
,
h
,
0
);
if
(
!
merr
)
std
::
cout
<<
s
<<
": Array size "
<<
arr_szs
[
s
]
<<
" ("
...
...
@@ -167,7 +168,7 @@ int main(int argc, char **argv)
std
::
vector
<
ff_node
*>
f
;
for
(
int
i
=
0
;
i
<
sysconf
(
_SC_NPROCESSORS_CONF
);
++
i
)
f
.
push_back
(
new
Worker
);
Emitter
e
;
Collector
c
;
ff_farm
<>
farm
(
f
,
&
e
,
&
c
);
...
...
@@ -176,7 +177,7 @@ int main(int argc, char **argv)
farm
.
cleanup_workers
();
farm
.
run_and_wait_end
();
if
(
!
errs
)
if
(
!
errs
)
std
::
cout
<<
"SUCCESS!"
<<
std
::
endl
;
else
std
::
cerr
<<
"FAILURE"
<<
std
::
endl
;
...
...
examples/memcheck/memcheck-mt.c
View file @
0c436917
...
...
@@ -75,7 +75,7 @@ static void *test_thread(void *p)
long
int
s
;
while
((
s
=
__atomic_sub_fetch
(
&
runs
,
1
,
__ATOMIC_SEQ_CST
))
>
0
)
{
s
=
s
%
sc
;
//printf("%ld: Checking array size %zd (%zd byte) ...\n",
//printf("%ld: Checking array size %zd (%zd byte) ...\n",
// s, arr_szs[s], arr_szs[s] * sizeof(int));
// allocate and fill array
int
*
arr
=
(
int
*
)
malloc
(
arr_szs
[
s
]
*
sizeof
(
int
));
...
...
@@ -86,7 +86,8 @@ static void *test_thread(void *p)
assert
(
rarr
!=
NULL
);
// get tapasco handle
tapasco_handle_t
h
=
tapasco_device_alloc
(
dev
,
arr_szs
[
s
]
*
sizeof
(
int
),
0
);
tapasco_handle_t
h
;
tapasco_device_alloc
(
dev
,
&
h
,
arr_szs
[
s
]
*
sizeof
(
int
),
0
);
// printf("%ld: handle = 0x%08lx, size = %zd bytes\n", s,
// (unsigned long)h, arr_szs[s] * sizeof(int));
assert
((
unsigned
long
)
h
>
0
);
...
...
@@ -113,7 +114,7 @@ static void *test_thread(void *p)
merr
+=
1
;
}
__atomic_add_fetch
(
&
errs
,
merr
,
__ATOMIC_SEQ_CST
);
tapasco_device_free
(
dev
,
h
);
tapasco_device_free
(
dev
,
h
,
0
);
if
(
!
merr
)
/*printf("%ld: Array size %zd (%zd byte) ok!\n",
...
...
@@ -157,7 +158,7 @@ int main(int argc, char **argv) {
pthread_join
(
thrds
[
s
],
NULL
);
}
if
(
!
errs
)
if
(
!
errs
)
printf
(
"
\n
SUCCESS
\n
"
);
else
fprintf
(
stderr
,
"
\n
FAILURE
\n
"
);
...
...
examples/memcheck/memcheck.c
View file @
0c436917
...
...
@@ -73,7 +73,7 @@ int main(int argc, char **argv) {
check_fpga
(
tapasco_create_device
(
ctx
,
0
,
&
dev
,
0
));
for
(
int
s
=
0
;
s
<
sizeof
(
arr_szs
)
/
sizeof
(
*
arr_szs
)
&&
errs
==
0
;
++
s
)
{
printf
(
"Checking array size %zd (%zd byte) ...
\n
"
,
printf
(
"Checking array size %zd (%zd byte) ...
\n
"
,
arr_szs
[
s
],
arr_szs
[
s
]
*
sizeof
(
int
));
// allocate and fill array
int
*
arr
=
(
int
*
)
malloc
(
arr_szs
[
s
]
*
sizeof
(
int
));
...
...
@@ -83,7 +83,8 @@ int main(int argc, char **argv) {
int
*
rarr
=
(
int
*
)
malloc
(
arr_szs
[
s
]
*
sizeof
(
int
));
// get fpga handle
tapasco_handle_t
h
=
tapasco_device_alloc
(
dev
,
arr_szs
[
s
]
*
sizeof
(
int
),
0
);
tapasco_handle_t
h
;
tapasco_device_alloc
(
dev
,
&
h
,
arr_szs
[
s
]
*
sizeof
(
int
),
0
);
printf
(
"handle = 0x%08lx
\n
"
,
(
unsigned
long
)
h
);
check
((
unsigned
long
)
h
);
...
...
@@ -92,7 +93,7 @@ int main(int argc, char **argv) {
check_fpga
(
tapasco_device_copy_to
(
dev
,
arr
,
h
,
arr_szs
[
s
]
*
sizeof
(
int
),
0
));
check_fpga
(
tapasco_device_copy_from
(
dev
,
h
,
rarr
,
arr_szs
[
s
]
*
sizeof
(
int
),
0
));
tapasco_device_free
(
dev
,
h
);
tapasco_device_free
(
dev
,
h
,
0
);
int
merr
=
compare_arrays
(
arr
,
rarr
,
arr_szs
[
s
]);
errs
=+
merr
;
...
...
@@ -108,7 +109,7 @@ int main(int argc, char **argv) {
free
(
rarr
);
}
if
(
!
errs
)
if
(
!
errs
)
printf
(
"
\n
SUCCESS
\n
"
);
else
fprintf
(
stderr
,
"
\n
FAILURE
\n
"
);
...
...
platform/vc709/module/blue_dma_ctrl.c
View file @
0c436917
...
...
@@ -72,15 +72,15 @@ void blue_dma_transmit_from_device(void * device_buffer, dma_addr_t host_handle,
// fflink_warn("got killed while aquiring the mutex\n");
/* SA */
pcie_write
l
((
unsigned
long
)
device_buffer
,
device_base_addr
+
REG_FPGA_ADDR
);
pcie_write
q
((
unsigned
long
)
device_buffer
,
device_base_addr
+
REG_FPGA_ADDR
);
/* DA */
pcie_write
l
(
host_handle
,
device_base_addr
+
REG_HOST_ADDR
);
pcie_write
q
(
host_handle
,
device_base_addr
+
REG_HOST_ADDR
);
/* btt */
pcie_write
l
(
btt
,
device_base_addr
+
REG_BTT
);
pcie_write
q
(
btt
,
device_base_addr
+
REG_BTT
);
/* presvious data have to be written first */
wmb
();
/* start cmd */
pcie_write
l
(
CMD_READ
,
device_base_addr
+
REG_CMD
);
pcie_write
q
(
CMD_READ
,
device_base_addr
+
REG_CMD
);
//mutex_unlock(&dma_regs_mutex);
}
...
...
@@ -100,15 +100,15 @@ void blue_dma_transmit_to_device(void * device_buffer, dma_addr_t host_handle, i
// fflink_warn("got killed while aquiring the mutex\n");
/* SA */
pcie_write
l
(
host_handle
,
device_base_addr
+
REG_HOST_ADDR
);
pcie_write
q
(
host_handle
,
device_base_addr
+
REG_HOST_ADDR
);
/* DA */
pcie_write
l
((
unsigned
long
)
device_buffer
,
device_base_addr
+
REG_FPGA_ADDR
);
pcie_write
q
((
unsigned
long
)
device_buffer
,
device_base_addr
+
REG_FPGA_ADDR
);
/* btt */
pcie_write
l
(
btt
,
device_base_addr
+
REG_BTT
);
pcie_write
q
(
btt
,
device_base_addr
+
REG_BTT
);
/* presvious data have to be written first */
wmb
();
/* start cmd */
pcie_write
l
(
CMD_WRITE
,
device_base_addr
+
REG_CMD
);
pcie_write
q
(
CMD_WRITE
,
device_base_addr
+
REG_CMD
);
//mutex_unlock(&dma_regs_mutex);
}
...
...
platform/vc709/module/char_device_user.c
View file @
0c436917
...
...
@@ -111,26 +111,27 @@ static int user_close(struct inode *inode, struct file *filp)
static
ssize_t
user_read
(
struct
file
*
filp
,
char
__user
*
buf
,
size_t
count
,
loff_t
*
f_pos
)
{
struct
user_rw_params
params
;
uint32_t
i
,
err
=
0
,
static_buffer
[
STATIC_BUFFER_SIZE
],
*
copy_buffer
;
uint32_t
i
,
err
=
0
;
uint32_t
static_buffer
[
STATIC_BUFFER_SIZE
],
*
copy_buffer
;
bool
use_dynamic
=
false
;
fflink_notice
(
"Called for device minor %d
\n
"
,
((
struct
priv_data_struct
*
)
filp
->
private_data
)
->
minor
);
copy_buffer
=
static_buffer
;
if
(
count
!=
sizeof
(
struct
user_rw_params
))
{
if
(
count
!=
sizeof
(
struct
user_rw_params
))
{
fflink_warn
(
"Wrong size to parse parameters accordingly %ld vs %ld
\n
"
,
count
,
sizeof
(
struct
user_rw_params
));
return
-
EACCES
;
}
if
(
copy_from_user
(
&
params
,
buf
,
count
))
{
if
(
copy_from_user
(
&
params
,
buf
,
count
))
{
fflink_warn
(
"Couldn't copy all bytes from user-space to parse parameters
\n
"
);
return
-
EACCES
;
}
if
(
params
.
btt
>
STATIC_BUFFER_SIZE
*
REGISTER_BYTE_SIZE
)
{
fflink_info
(
"Allocating %d bytes dynamically - only %d available statically
\n
"
,
params
.
btt
,
STATIC_BUFFER_SIZE
*
REGISTER_BYTE_SIZE
);
if
(
params
.
btt
>
STATIC_BUFFER_SIZE
*
REGISTER_BYTE_SIZE
)
{
fflink_info
(
"Allocating %d bytes dynamically - only %d available statically
\n
"
,
params
.
btt
,
STATIC_BUFFER_SIZE
*
REGISTER_BYTE_SIZE
);
copy_buffer
=
kmalloc
(
params
.
btt
,
GFP_KERNEL
);
if
(
!
copy_buffer
)
{
if
(
!
copy_buffer
)
{
fflink_warn
(
"Couldn't allocate dynamic buffer for transfer
\n
"
);
return
-
EACCES
;
}
...
...
@@ -139,15 +140,23 @@ static ssize_t user_read(struct file *filp, char __user *buf, size_t count, loff
}
fflink_info
(
"Copy %d bytes from address %llX to address %llX
\n
"
,
params
.
btt
,
params
.
fpga_addr
,
params
.
host_addr
);
for
(
i
=
0
;
i
<
params
.
btt
/
4
;
i
++
)
copy_buffer
[
i
]
=
pcie_readl
((
void
*
)
(
params
.
fpga_addr
+
i
*
4
));
if
(
copy_to_user
((
void
*
)
params
.
host_addr
,
copy_buffer
,
params
.
btt
))
{
if
(
params
.
btt
==
4
)
{
copy_buffer
[
0
]
=
pcie_readl
((
void
*
)
params
.
fpga_addr
);
}
else
if
(
params
.
btt
==
8
)
{
((
uint64_t
*
)
copy_buffer
)[
0
]
=
pcie_readq
((
void
*
)
params
.
fpga_addr
);
}
else
{
for
(
i
=
0
;
i
<
params
.
btt
/
4
;
i
++
)
copy_buffer
[
i
]
=
pcie_readl
((
void
*
)
(
params
.
fpga_addr
+
i
*
4
));
}
if
(
copy_to_user
((
void
*
)
params
.
host_addr
,
copy_buffer
,
params
.
btt
))
{
fflink_warn
(
"Couldn't copy all bytes to user-space
\n
"
);
err
=
-
EACCES
;
}
if
(
unlikely
(
use_dynamic
))
{
if
(
unlikely
(
use_dynamic
))
{
fflink_info
(
"Freeing dynamic buffer
\n
"
);
kfree
(
copy_buffer
);
}
...
...
@@ -173,20 +182,20 @@ static ssize_t user_write(struct file *filp, const char __user *buf, size_t coun
copy_buffer
=
static_buffer
;
if
(
count
!=
sizeof
(
struct
user_rw_params
))
{
if
(
count
!=
sizeof
(
struct
user_rw_params
))
{
fflink_warn
(
"Wrong size to parse parameters accordingly %ld vs %ld
\n
"
,
count
,
sizeof
(
struct
user_rw_params
));
return
-
EACCES
;
}
if
(
copy_from_user
(
&
params
,
buf
,
count
))
{
if
(
copy_from_user
(
&
params
,
buf
,
count
))
{
fflink_warn
(
"Couldn't copy all bytes from user-space to parse parameters
\n
"
);
return
-
EACCES
;
}
if
(
params
.
btt
>
STATIC_BUFFER_SIZE
*
REGISTER_BYTE_SIZE
)
{
fflink_info
(
"Allocating %d bytes dynamically - only %d available statically
\n
"
,
params
.
btt
,
STATIC_BUFFER_SIZE
*
REGISTER_BYTE_SIZE
);
if
(
params
.
btt
>
STATIC_BUFFER_SIZE
*
REGISTER_BYTE_SIZE
)
{
fflink_info
(
"Allocating %d bytes dynamically - only %d available statically
\n
"
,
params
.
btt
,
STATIC_BUFFER_SIZE
*
REGISTER_BYTE_SIZE
);
copy_buffer
=
kmalloc
(
params
.
btt
,
GFP_KERNEL
);
if
(
!
copy_buffer
)
{
if
(
!
copy_buffer
)
{
fflink_warn
(
"Couldn't allocate dynamic buffer for transfer
\n
"
);
return
-
EACCES
;
}
...
...
@@ -194,18 +203,25 @@ static ssize_t user_write(struct file *filp, const char __user *buf, size_t coun
use_dynamic
=
true
;
}
if
(
copy_from_user
(
copy_buffer
,
(
void
*
)
params
.
host_addr
,
params
.
btt
))
{
if
(
copy_from_user
(
copy_buffer
,
(
void
*
)
params
.
host_addr
,
params
.
btt
))
{
fflink_warn
(
"Couldn't copy all bytes from user-space
\n
"
);
err
=
-
EACCES
;
goto
USER_WRITE_CLEANUP
;
}
fflink_info
(
"Copy %d bytes to address %llX from address %llX
\n
"
,
params
.
btt
,
params
.
fpga_addr
,
params
.
host_addr
);
for
(
i
=
0
;
i
<
params
.
btt
/
4
;
i
++
)
pcie_writel
(
copy_buffer
[
i
],
(
void
*
)
(
params
.
fpga_addr
+
i
*
4
));
if
(
params
.
btt
==
4
)
{
pcie_writel
(
copy_buffer
[
0
],
(
void
*
)
params
.
fpga_addr
);
}
else
if
(
params
.
btt
==
8
)
{
pcie_writeq
(((
uint64_t
*
)
copy_buffer
)[
0
],
(
void
*
)
params
.
fpga_addr
);
}
else
{
for
(
i
=
0
;
i
<
params
.
btt
/
4
;
i
++
)
pcie_writel
(
copy_buffer
[
i
],
(
void
*
)
(
params
.
fpga_addr
+
i
*
4
));
}
USER_WRITE_CLEANUP:
if
(
unlikely
(
use_dynamic
))
{
if
(
unlikely
(
use_dynamic
))
{
fflink_info
(
"Freeing dynamic buffer
\n
"
);
kfree
(
copy_buffer
);
}
...
...
@@ -232,33 +248,33 @@ static long user_ioctl(struct file *filp, unsigned int ioctl_num, unsigned long
struct
user_ioctl_params
params
;
fflink_notice
(
"Called for device minor %d
\n
"
,
p
->
minor
);
if
(
_IOC_SIZE
(
ioctl_num
)
!=
sizeof
(
struct
user_ioctl_params
))
{
if
(
_IOC_SIZE
(
ioctl_num
)
!=
sizeof
(
struct
user_ioctl_params
))
{
fflink_warn
(
"Wrong size to read out registers %d vs %ld
\n
"
,
_IOC_SIZE
(
ioctl_num
),
sizeof
(
struct
user_ioctl_params
));
return
-
EACCES
;
}
if
(
copy_from_user
(
&
params
,
(
void
*
)
ioctl_param
,
_IOC_SIZE
(
ioctl_num
)))
{
if
(
copy_from_user
(
&
params
,
(
void
*
)
ioctl_param
,
_IOC_SIZE
(
ioctl_num
)))
{
fflink_warn
(
"Couldn't copy all bytes
\n
"
);
return
-
EACCES
;
}
switch
(
ioctl_num
)
{
case
IOCTL_CMD_USER_WAIT_EVENT
:
fflink_info
(
"IOCTL_CMD_USER_WAIT_EVENT with Param-Size: %d byte
\n
"
,
_IOC_SIZE
(
ioctl_num
));
fflink_info
(
"Want to write %X to address %llX with event %d
\n
"
,
params
.
data
,
params
.
fpga_addr
,
params
.
event
);
irq_counter
=
priv_data
.
user_condition
[
params
.
event
];
switch
(
ioctl_num
)
{
case
IOCTL_CMD_USER_WAIT_EVENT
:
fflink_info
(
"IOCTL_CMD_USER_WAIT_EVENT with Param-Size: %d byte
\n
"
,
_IOC_SIZE
(
ioctl_num
));
fflink_info
(
"Want to write %X to address %llX with event %d
\n
"
,
params
.
data
,
params
.
fpga_addr
,
params
.
event
);
pcie_writel
(
params
.
data
,
(
void
*
)
params
.
fpga_addr
)
;
irq_counter
=
priv_data
.
user_condition
[
params
.
event
]
;
if
(
wait_event_interruptible
(
p
->
user_wait_queue
[
params
.
event
],
(
irq_counter
!=
p
->
user_condition
[
params
.
event
])))
{
fflink_warn
(
"got killed while hanging in waiting queue
\n
"
);
break
;
}
pcie_writel
(
params
.
data
,
(
void
*
)
params
.
fpga_addr
);
if
(
wait_event_interruptible
(
p
->
user_wait_queue
[
params
.
event
],
(
irq_counter
!=
p
->
user_condition
[
params
.
event
])))
{
fflink_warn
(
"got killed while hanging in waiting queue
\n
"
);
break
;
default:
fflink_warn
(
"default case - nothing to do here
\n
"
);
break
;
}
break
;
default:
fflink_warn
(
"default case - nothing to do here
\n
"
);
break
;
}
return
0
;
...
...
@@ -296,7 +312,7 @@ static int user_mmap(struct file *filp, struct vm_area_struct *vma)
irqreturn_t
intr_handler_user
(
int
irq
,
void
*
dev_id
)
{
int
irq_translated
=
pcie_translate_irq_number
(
irq
)
-
4
;
if
(
irq_translated
!=
-
1
)
{
if
(
irq_translated
!=
-
1
)
{
fflink_info
(
"User interrupt for IRQ %d called with irq %d
\n
"
,
irq_translated
,
irq
);
priv_data
.
user_condition
[
irq_translated
]
+=
1
;
wake_up_interruptible_sync
(
&
priv_data
.
user_wait_queue
[
irq_translated
]);
...
...
@@ -345,9 +361,9 @@ int char_user_register(void)
goto
error_add_to_system
;
}
for
(
i
=
0
;
i
<
FFLINK_USER_NODES
;
i
++
)
{
for
(
i
=
0
;
i
<
FFLINK_USER_NODES
;
i
++
)
{
/* create device file via udev */
device
=
device_create
(
char_user_class
,
NULL
,
MKDEV
(
MAJOR
(
char_user_dev_t
),
MINOR
(
char_user_dev_t
)
+
i
),
NULL
,
FFLINK_USER_NAME
"_%d"
,
MINOR
(
char_user_dev_t
)
+
i
);
device
=
device_create
(
char_user_class
,
NULL
,
MKDEV
(
MAJOR
(
char_user_dev_t
),
MINOR
(
char_user_dev_t
)
+
i
),
NULL
,
FFLINK_USER_NAME
"_%d"
,
MINOR
(
char_user_dev_t
)
+
i
);
if
(
IS_ERR
(
device
))
{
err
=
PTR_ERR
(
device
);
fflink_warn
(
"failed while device create %d
\n
"
,
MINOR
(
char_user_dev_t
));
...
...
@@ -359,13 +375,13 @@ int char_user_register(void)
/* check if ID core is readable */
hw_id
=
pcie_readl
((
void
*
)
HW_ID_ADDR
);
if
(
hw_id
!=
HW_ID_MAGIC
)
{
if
(
hw_id
!=
HW_ID_MAGIC
)
{
fflink_warn
(
"ID Core not found (was %X - should: %X)
\n
"
,
hw_id
,
HW_ID_MAGIC
);
return
-
ENOTEMPTY
;
goto
error_device_create
;
}
/* init control structures for synchron sys-calls */
for
(
i
=
0
;
i
<
PE_IRQS
;
++
i
)
{
for
(
i
=
0
;
i
<
PE_IRQS
;
++
i
)
{
init_waitqueue_head
(
&
priv_data
.
user_wait_queue
[
i
]);
priv_data
.
user_condition
[
i
]
=
0
;
}
...
...
@@ -374,8 +390,8 @@ int char_user_register(void)
/* tidy up for everything successfully allocated */
error_device_create:
for
(
i
=
i
-
1
;
i
>=
0
;
i
--
)
{
device_destroy
(
char_user_class
,
MKDEV
(
MAJOR
(
char_user_dev_t
),
MINOR
(
char_user_dev_t
)
+
i
));
for
(
i
=
i
-
1
;
i
>=
0
;
i
--
)
{
device_destroy
(
char_user_class
,
MKDEV
(
MAJOR
(
char_user_dev_t
),
MINOR
(
char_user_dev_t
)
+
i
));