OpenCores
URL https://opencores.org/ocsvn/pcie_ds_dma/pcie_ds_dma/trunk

Subversion Repositories pcie_ds_dma

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /pcie_ds_dma/trunk/soft/linux/application/board_exam
    from Rev 2 to Rev 6
    Reverse comparison

Rev 2 → Rev 6

/main.cpp
1,6 → 1,6
 
#ifndef __PEX_H__
#include "pex_board.h"
#ifndef __BOARD_H__
#include "board.h"
#endif
 
#include <cassert>
10,6 → 10,7
#include <iomanip>
#include <climits>
#include <cstdio>
#include <dlfcn.h>
 
//-----------------------------------------------------------------------------
 
16,58 → 17,136
using namespace std;
 
//-----------------------------------------------------------------------------
#define NUM_BLOCK 4
#define BLOCK_SIZE 0x1000
#define NUM_BLOCK 8
#define BLOCK_SIZE 0x10000
//-----------------------------------------------------------------------------
 
int main(int argc, char *argv[])
{
if(argc == 1) {
std::cerr << "usage: %s <device name>" << argv[0] << endl;
if(argc != 3) {
std::cerr << "usage: " << argv[0] << " <libname.so> </dev/devname>" << endl;
return -1;
}
 
std ::cout << "Start testing device " << argv[1] << endl;
 
char *libname = argv[1];
char *devname = argv[2];
int dmaChan = 0;
void* pBuffers[NUM_BLOCK] = {NULL};
void* pBuffers[NUM_BLOCK] = {NULL,NULL,NULL,NULL};
void *hlib = NULL;
board_factory factory = NULL;
board *brd = NULL;
u32 *buffer = NULL;
 
board *brd = new pex_board();
brd->brd_open(argv[1]);
std ::cout << "Loading library: " << libname << endl;
 
hlib = dlopen(libname, RTLD_LAZY);
if(!hlib) {
fprintf(stderr, "%s\n", dlerror());
return -1;
}
 
factory = (board_factory)dlsym(hlib, "create_board");
if(!factory) {
fprintf(stderr, "%s\n", dlerror());
dlclose(hlib);
return -1;
}
 
std ::cout << "Start testing device " << devname << endl;
 
brd = factory();
if(!brd) {
dlclose(hlib);
return -1;
}
 
if(brd->brd_open(devname) < 0) {
 
delete brd;
 
if(hlib) {
int res = dlclose(hlib);
if(res < 0) {
fprintf(stderr, "%s\n", dlerror());
return -1;
}
}
 
return -1;
}
 
brd->brd_init();
brd->brd_pld_info();
 
std::cout << "Reset FPGA..." << std::endl;
brd->brd_reg_poke_ind(0,0,1);
brd->brd_delay(100);
brd->brd_reg_poke_ind(0,0,0);
brd->brd_delay(100);
 
std::cout << "Init FPGA..." << std::endl;
for( int trd=0; trd<8; trd++ ) {
brd->brd_reg_poke_ind( trd, 0, 1 );
}
for( int trd=0; trd<8; trd++ ) {
for( int ii=1; ii<32; ii++ ) {
brd->brd_reg_poke_ind( trd, ii, 0 );
}
}
for( int trd=0; trd<8; trd++ ) {
brd->brd_reg_poke_ind( trd, 0, 0 );
}
 
std ::cout << "Press enter to allocate DMA memory..." << endl;
getchar();
 
int DmaChan = 1;
 
// Check BRDSHELL DMA interface
BRDctrl_StreamCBufAlloc sSCA = {
1, //dir
1,
1,
NUM_BLOCK,
BLOCK_SIZE,
&pBuffers[0],
pBuffers,
NULL,
};
 
brd->dma_alloc(dmaChan, &sSCA);
 
brd->dma_set_local_addr(DmaChan, 0x1000);
brd->dma_stop(DmaChan);
brd->dma_reset_fifo(DmaChan);
brd->dma_reset_fifo(DmaChan);
 
std ::cout << "Press enter to start DMA channel..." << endl;
getchar();
 
// fill data buffers
for(int j=0; j<NUM_BLOCK; j++) {
buffer = (u32*)pBuffers[j];
for(unsigned i=0; i<32; i++) {
buffer[i] = 0xAA556677;
}
}
 
brd->dma_start(dmaChan, 0);
 
std ::cout << "Press enter to stop DMA channel..." << endl;
getchar();
 
 
brd->dma_stop(dmaChan);
 
std ::cout << "Press enter to view DMA data (buffer 0)..." << endl;
getchar();
// show data buffers
for(int j=0; j<NUM_BLOCK; j++) {
 
u32 *buffer = (u32*)pBuffers[0];
for(unsigned i=0; i<BLOCK_SIZE/4; i+=128) {
std::cout << hex << buffer[i] << " ";
std ::cout << "DMA data buffer " << j << ":" << endl;
buffer = (u32*)pBuffers[j];
for(unsigned i=0; i<32; i++) {
std::cout << hex << buffer[i] << " ";
}
std ::cout << endl;
}
std::cout << dec << endl;
 
75,19 → 154,18
getchar();
 
brd->dma_free_memory(dmaChan);
/*
for(int i=0; i<16; i++)
std ::cout << "BAR0[" << i << "] = 0x" << hex << brd->brd_bar0_read(i) << dec << endl;
 
fprintf(stderr, "Press enter to read BAR1...\n");
getchar();
 
for(int i=0; i<16; i++)
std ::cout << "BAR1[" << i << "] = 0x" << hex << brd->brd_bar1_read(i) << dec << endl;
*/
brd->brd_close();
 
delete brd;
 
if(hlib) {
int res = dlclose(hlib);
if(res < 0) {
fprintf(stderr, "%s\n", dlerror());
return -1;
}
}
 
return 0;
}
/Makefile
1,6 → 1,3
#
#change this makefile for your target...
#
 
PHONY = clean
TARGET_NAME = pex_board_test
7,21 → 4,31
 
all: $(TARGET_NAME)
 
ROOT_DIR = $(shell pwd)
BINPATH := ../..
BINDIR := $(BINPATH)/bin
LIBPATH := ../..
LIBDIR := $(LIBPATH)/lib
 
CC = $(CROSS_COMPILE)g++
LD = $(CROSS_COMPILE)g++
CC := $(CROSS_COMPILE)g++
LD := $(CROSS_COMPILE)g++
 
CFLAGS := -D__LINUX__ -g -Wall -I../../driver/pexdrv -I../../common/board -I../../common/pex -I../adm_test/src/utils
LFLAGS := -Wl
SRCDIR := ../../common/board ../../common/pex
#SRCFILE := $(wildcard *.cpp) $(wildcard $(SRCDIR)/*.cpp)
SRCFILE := $(wildcard *.cpp) $(wildcard ../../common/board/*.cpp)
SRCFILE += $(wildcard *.cpp) $(wildcard ../../common/pex/*.cpp)
OBJFILE := $(patsubst %.cpp,%.o, $(SRCFILE))
INCDIR := . \
../../driver/pexdrv \
../../common/board \
../../common/utils
 
$(TARGET_NAME): $(OBJFILE)
$(LD) $(LFLAGS) $(notdir $^) -o $(TARGET_NAME)
INCLUDE := $(addprefix -I, $(INCDIR))
 
#CFLAGS := -D__linux__ -D__VERBOSE__ -g -Wall $(INCLUDE)
CFLAGS := -D__linux__ -O2 -Wall $(INCLUDE)
LFLAGS := -Wl,-rpath $(LIBDIR) -L"$(LIBDIR)" -lboard -ldl -lpthread
 
#EXTFILES := ../common/net/net_board.cpp
#EXTFILES := ../common/net/netcmn.cpp
 
$(TARGET_NAME): $(patsubst %.cpp,%.o, $(wildcard *.cpp)) $(EXTFILES)
$(LD) -o $(TARGET_NAME) $(notdir $^) $(LFLAGS)
cp $(TARGET_NAME) $(BINDIR)
rm -f *.o *~ core
 
%.o: %.cpp
30,6 → 37,9
include $(wildcard *.d)
 
 
test:
@echo $(SRC)
 
clean:
rm -f *.o *~ core
rm -f *.d *~ core
39,7 → 49,3
rm -f *.o *~ core
rm -f *.d *~ core
rm -f $(TARGET_NAME)
 
src:
@echo $(SRCFILE)
@echo $(OBJFILE)

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.