Commit 0c436917 authored by Jens Korinth's avatar Jens Korinth

Merge branch 'ATSBackports' into '2017.1'

Ports changes of the ATS Branch of TPC to Tapasco

See merge request !1
parents a543f07d bfcfeb64
......@@ -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 = 0x502000;
base_addr = 0x508000;
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 = 0x504000;
base_addr = 0x508100;
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);
......
......@@ -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/SizedFIFO.v</spirit:name>
<spirit:name>src/SyncFIFO1.v</spirit:name>
<spirit:fileType>verilogSource</spirit:fileType>
</spirit:file>
<spirit:file>
<spirit:name>src/SyncFIFO1.v</spirit:name>
<spirit:name>src/SyncRegister.v</spirit:name>
<spirit:fileType>verilogSource</spirit:fileType>
</spirit:file>
<spirit:file>
<spirit:name>src/SyncFIFO.v</spirit:name>
<spirit:name>src/FIFO1.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/FIFO2.v</spirit:name>
<spirit:name>src/SizedFIFO.v</spirit:name>
<spirit:fileType>verilogSource</spirit:fileType>
</spirit:file>
<spirit:file>
<spirit:name>src/FIFO1.v</spirit:name>
<spirit:name>src/SyncFIFO.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/SizedFIFO.v</spirit:name>
<spirit:name>src/SyncFIFO1.v</spirit:name>
<spirit:fileType>verilogSource</spirit:fileType>
</spirit:file>
<spirit:file>
<spirit:name>src/SyncFIFO1.v</spirit:name>
<spirit:name>src/SyncRegister.v</spirit:name>
<spirit:fileType>verilogSource</spirit:fileType>
</spirit:file>
<spirit:file>
<spirit:name>src/SyncFIFO.v</spirit:name>
<spirit:name>src/FIFO1.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/FIFO2.v</spirit:name>
<spirit:name>src/SizedFIFO.v</spirit:name>
<spirit:fileType>verilogSource</spirit:fileType>
</spirit:file>
<spirit:file>
<spirit:name>src/FIFO1.v</spirit:name>
<spirit:name>src/SyncFIFO.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-06-09T13:48:43Z</xilinx:coreCreationDateTime>
<xilinx:coreCreationDateTime>2017-07-06T11:01:37Z</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>
......
This diff is collapsed.
//
// Generated by Bluespec Compiler, version 2015.09.beta2 (build 34689, 2015-09-07)
//
// On Fri Jun 9 15:48:16 CEST 2017
// On Thu Jul 6 13:00:49 CEST 2017
//
//
// Ports:
......
......@@ -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/FIFO1.v</spirit:name>
<spirit:name>src/SizedFIFO.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/FIFO1.v</spirit:name>
<spirit:name>src/SizedFIFO.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-06-09T13:47:07Z</xilinx:coreCreationDateTime>
<xilinx:coreCreationDateTime>2017-07-05T16:28:24Z</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>
......
set_false_path -to [get_cells system_i/InterruptControl/msix_intr_ctrl/inst/interrupts_*]
set_false_path -through [get_pins system_i/InterruptControl/msix_intr_ctrl/interrupt*]
This diff is collapsed.
......@@ -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})
......@@ -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;
......
......@@ -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("\nSUCCESS\n");
else
fprintf(stderr, "\nFAILURE\n");
......
......@@ -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("\nSUCCESS\n");
else
fprintf(stderr, "\nFAILURE\n");
......
......@@ -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_writel((unsigned long)device_buffer, device_base_addr + REG_FPGA_ADDR);
pcie_writeq((unsigned long)device_buffer, device_base_addr + REG_FPGA_ADDR);
/* DA */
pcie_writel(host_handle, device_base_addr + REG_HOST_ADDR);
pcie_writeq(host_handle, device_base_addr + REG_HOST_ADDR);
/* btt */
pcie_writel(btt, device_base_addr + REG_BTT);
pcie_writeq(btt, device_base_addr + REG_BTT);
/* presvious data have to be written first */
wmb();
/* start cmd */
pcie_writel(CMD_READ, device_base_addr + REG_CMD);
pcie_writeq(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_writel(host_handle, device_base_addr + REG_HOST_ADDR);
pcie_writeq(host_handle, device_base_addr + REG_HOST_ADDR);
/* DA */
pcie_writel((unsigned long)device_buffer, device_base_addr + REG_FPGA_ADDR);
pcie_writeq((unsigned long)device_buffer, device_base_addr + REG_FPGA_ADDR);
/* btt */
pcie_writel(btt, device_base_addr + REG_BTT);
pcie_writeq(btt, device_base_addr + REG_BTT);
/* presvious data have to be written first */
wmb();
/* start cmd */
pcie_writel(CMD_WRITE, device_base_addr + REG_CMD);
pcie_writeq(CMD_WRITE, device_base_addr + REG_CMD);
//mutex_unlock(&dma_regs_mutex);
}
......
......@@ -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));
}
cdev_del(&char_user_cdev);
error_add_to_system:
......@@ -397,8 +413,8 @@ void char_user_unregister(void)
fflink_info("Tidy up\n");
for(i = 0; i < FFLINK_USER_NODES; i++) {
device_destroy(char_user_class, MKDEV(MAJOR(char_user_dev_t), MINOR(char_user_dev_t)+i));
for (i = 0; i < FFLINK_USER_NODES; i++) {
device_destroy(char_user_class, MKDEV(MAJOR(char_user_dev_t), MINOR(char_user_dev_t) + i));
}
cdev_del(&char_user_cdev);
......
......@@ -41,7 +41,9 @@ struct pci_dev* get_pcie_dev(void);
/* wrapper to read/write from pcie-bar0 */
void pcie_writel(unsigned long data, void * addr);
void pcie_writeq(unsigned long long data, void * addr);
unsigned long pcie_readl(void * addr);
unsigned long long pcie_readq(void * addr);
void pcie_writel_bar2(unsigned long data, void * addr);
unsigned long pcie_readl_bar2(void * addr);
......
......@@ -66,9 +66,14 @@ static const fflink_dma_t fflink_dma[] = {
void dma_ctrl_init(void * device_base_addr)
{
if(pcie_readl(device_base_addr + REG_ID) == 0xE5A0023) {
uint64_t id = pcie_readq(device_base_addr + REG_ID);
if ((id & 0xFFFFFFFF) == 0xE5A0023) {
dma_used = DMA_USED_BLUE;
fflink_warn("Detected BlueDMA\n");
fflink_warn("PCIE Beats per Burst: %u\n", (uint8_t)(id >> 32));
fflink_warn("FPGA Beats per Burst: %u\n", (uint8_t)(id >> 40));
fflink_warn("Smallest alignment: %u\n", (uint8_t)(id >> 48));
} else {
dma_used = DMA_USED_DUAL;
fflink_warn("Detected DualDMA\n");
......
......@@ -79,7 +79,8 @@ void dual_dma_transmit_from_device(void * device_buffer, dma_addr_t host_handle,
/* SA */
pcie_writel((unsigned long) device_buffer, device_base_addr + REG_FPGA_ADDR_LOW);
/* DA */
pcie_writel(host_handle, device_base_addr + REG_HOST_ADDR_LOW);
pcie_writel((uint32_t)host_handle, device_base_addr + REG_HOST_ADDR_LOW);
pcie_writel((uint32_t) (host_handle >> 32), device_base_addr + REG_HOST_ADDR_HIGH);
/* btt */
pcie_writel(btt, device_base_addr + REG_BTT);
/* presvious data have to be written first */
......@@ -105,7 +106,8 @@ void dual_dma_transmit_to_device(void * device_buffer, dma_addr_t host_handle, i
// fflink_warn("got killed while aquiring the mutex\n");
/* SA */
pcie_writel(host_handle, device_base_addr + REG_HOST_ADDR_LOW);
pcie_writel((uint32_t)host_handle, device_base_addr + REG_HOST_ADDR_LOW);
pcie_writel((uint32_t) (host_handle >> 32), device_base_addr + REG_HOST_ADDR_HIGH);
/* DA */
pcie_writel((unsigned long) device_buffer, device_base_addr + REG_FPGA_ADDR_LOW);
/* btt */
......
......@@ -46,19 +46,19 @@ static int __init fflink_init(void)
fflink_notice("Init char-dev(s), dev-entries and register pci-device\n");
err = pcie_register();
if(err) {
if (err) {
fflink_info("Could not register pcie device\n");
goto error_pcie_register;
}
err = char_dma_register();
if(err) {
if (err) {
fflink_info("Could not register dma char device(s)\n");
goto error_dma_register;
}
err = char_user_register();
if(err) {
if (err) {
fflink_info("Could not register user char device(s)\n");
goto error_user_register;
}
......@@ -67,13 +67,11 @@ static int __init fflink_init(void)
return 0;
error_dma_register:
return -EACCES;
error_user_register:
char_dma_unregister();
return -EACCES;
error_dma_register:
pcie_unregister();
error_pcie_register:
char_user_unregister();
return -EACCES;
}
......
......@@ -46,7 +46,7 @@ static int claim_device(struct pci_dev *pdev)
/* wake up the pci device */
err = pci_enable_device(pdev);
if(err) {
if (err) {
fflink_warn("failed to enable pci device %d\n", err);
goto error_pci_en;
}
......@@ -95,22 +95,9 @@ error_pci_en:
* */
static int configure_device(struct pci_dev *pdev)
{
//int err = 0;