Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
E
EPICS support for Wishbone peripherals
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
EPICS support for Wishbone peripherals
Commits
4a166dda
Commit
4a166dda
authored
Jun 15, 2015
by
Benoit Rat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x1052: add multiple handles to use with various PCIe slots
parent
edf85285
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
19 deletions
+49
-19
WBMemX1052Con.cpp
src/WBMemX1052Con.cpp
+41
-17
WBMemX1052Con.h
src/WBMemX1052Con.h
+8
-2
No files found.
src/WBMemX1052Con.cpp
View file @
4a166dda
...
...
@@ -20,8 +20,9 @@
#include "WBMemX1052Con.h"
#define TRACE_P_VDEBUG(...) TRACE_P_DEBUG( __VA_ARGS__)
#define TRACE_P_VDEBUG(...)
//
TRACE_P_DEBUG( __VA_ARGS__)
#define TRACE_P_VVDEBUG(...) //TRACE_P_DEBUG( __VA_ARGS__)
int
WBMemX1052Con
::
nHandles
=
-
1
;
//!< Initiate static nHandles to count number of PCIe slot opened
/**
...
...
@@ -33,15 +34,22 @@
*
* \param[in] idxPCIe The index of PCIe slot for X1052 Devices
*/
WBMemX1052Con
::
WBMemX1052Con
(
uint32_
t
idxPCIe
,
uint32_t
magic_addr
,
uint32_t
magic_val
)
:
WBMemCon
(
WBMemCon
::
X1052
,
"X1052"
)
WBMemX1052Con
::
WBMemX1052Con
(
in
t
idxPCIe
,
uint32_t
magic_addr
,
uint32_t
magic_val
)
:
WBMemCon
(
WBMemCon
::
X1052
,
"X1052"
)
,
hBiDma
(
NULL
),
hDev
(
NULL
)
{
uint32_t
dwStatus
,
tmp
;
dwStatus
=
X1052_LibInit
();
if
(
WD_STATUS_SUCCESS
!=
dwStatus
)
if
(
nHandles
<
0
)
{
TRACE_P_ERROR
(
"Failed to init the X1052 library: %s"
,
X1052_GetLastErr
());
dwStatus
=
X1052_LibInit
();
if
(
WD_STATUS_SUCCESS
!=
dwStatus
)
{
TRACE_P_ERROR
(
"Failed to init the X1052 library: %s"
,
X1052_GetLastErr
());
}
else
{
nHandles
=
0
;
}
}
//Obtain version info
...
...
@@ -50,6 +58,8 @@ WBMemX1052Con::WBMemX1052Con(uint32_t idxPCIe,uint32_t magic_addr, uint32_t magi
char
buf
[
MAX_DESC
];
X1052_GetInfo
(
buf
,
'v'
);
ss1
<<
buf
;
X1052_GetInfo
(
buf
,
'r'
);
ss1
<<
"; "
<<
buf
;
ret
=
X1052_GetInfo
(
buf
,
'w'
);
ss1
<<
" (WD:"
<<
ret
/
100
<<
"."
<<
ret
%
100
<<
")"
;
ver
=
ss1
.
str
();
...
...
@@ -59,6 +69,17 @@ WBMemX1052Con::WBMemX1052Con(uint32_t idxPCIe,uint32_t magic_addr, uint32_t magi
/* Find and open a X1052 device (by default ID) */
hDev
=
X1052_DeviceOpen
(
idxPCIe
);
if
(
hDev
)
nHandles
++
;
TRACE_P_INFO
(
"Slot Index #%d : hDev=0x%x (nHandles=%d)"
,
idxPCIe
,
hDev
,
nHandles
);
hBiDma
=
X1052_BiDMAGetHandle
(
hDev
);
if
(
hBiDma
==
NULL
)
{
X1052_DeviceClose
(
hDev
);
hDev
=
NULL
;
TRACE_P_ERROR
(
"Failed to Create BiDMA object"
);
}
/* Finaly check the magic address value */
if
(
magic_addr
!=
0xFFFFFFFF
)
...
...
@@ -88,13 +109,17 @@ WBMemX1052Con::~WBMemX1052Con()
{
/* Perform necessary cleanup before exiting the program */
X1052_DeviceClose
(
hDev
);
nHandles
--
;
}
dwStatus
=
X1052_LibUninit
();
if
(
WD_STATUS_SUCCESS
!=
dwStatus
)
if
(
nHandles
<=
0
)
{
TRACE_P_ERROR
(
"Failed to un-init the X1052 library: %s"
,
X1052_GetLastErr
());
dwStatus
=
X1052_LibUninit
();
if
(
WD_STATUS_SUCCESS
!=
dwStatus
)
{
TRACE_P_ERROR
(
"Failed to un-init the X1052 library: %s"
,
X1052_GetLastErr
());
}
}
}
...
...
@@ -118,9 +143,9 @@ bool WBMemX1052Con::mem_access(uint32_t wb_addr, uint32_t* data, bool to_dev)
{
int
status
;
TRACE_CHECK_PTR
(
hDev
,
false
);
if
(
to_dev
)
status
=
X1052_Wishbone_CSR
(
hDev
,
wb_addr
,
data
,(
int
)
to_dev
);
else
status
=
X1052_Wishbone_CSR
(
hDev
,
wb_addr
,
data
,
to_dev
);
status
=
X1052_Wishbone_CSR
(
hDev
,
wb_addr
,
data
,(
int
)
to_dev
);
TRACE_CHECK_VA
(
status
==
S_OK
,
false
,
"%s@%08X %s %08x (%d)"
,(
to_dev
)
?
"W"
:
"R"
,
wb_addr
,(
to_dev
)
?
"=>"
:
"<="
,
*
data
,
status
);
TRACE_P_VDEBUG
(
"%s@%08X %s %08x (%d)"
,(
to_dev
)
?
"W"
:
"R"
,
wb_addr
,(
to_dev
)
?
"=>"
:
"<="
,
*
data
,
status
);
return
(
status
==
S_OK
);
...
...
@@ -150,11 +175,10 @@ bool WBMemX1052Con::mem_block_access(uint32_t dev_addr, uint32_t nsize,bool to_d
TRACE_P_WARNING
(
"@0x%08X: buffer size %d truncated to %d bytes"
,
dev_addr
,
nsize
,
X1052_DMA_TRANSFER_MAXB
);
}
if
(
to_dev
)
mbps
=
X1052_DMAToDev
(
0
,
dev_addr
,
nsize
);
else
mbps
=
X1052_DMAFromDev
(
0
,
dev_addr
,
nsize
);
mbps
=
X1052_DMATransfer
(
hBiDma
,
to_dev
,
0
,
dev_addr
,
nsize
);
block_busy
=
false
;
TRACE_P_
VDEBUG
(
"%s@%08X %s (nsize=%d, %.2f Gpbs)"
,(
to_dev
)
?
"W"
:
"R"
,
dev_addr
,(
to_dev
)
?
"=>"
:
"<="
,
nsize
,
mbps
/
1000.0
);
TRACE_P_
DEBUG
(
"%s@%08X %s (nsize=%d (0x%x), %.2f Gpbs)"
,(
to_dev
)
?
"W"
:
"R"
,
dev_addr
,(
to_dev
)
?
"=>"
:
"<="
,
nsize
,
nsize
,
mbps
/
1000.0
);
TRACE_CHECK_VA
(
mbps
>
0
,
false
,
"DMA failed #%d %s
\n
%s@%08X %s (nsize=%d)"
,
...
...
@@ -177,7 +201,7 @@ bool WBMemX1052Con::mem_block_access(uint32_t dev_addr, uint32_t nsize,bool to_d
*/
uint32_t
WBMemX1052Con
::
get_block_buffer
(
uint32_t
**
hDma
,
bool
to_dev
)
{
(
*
hDma
)
=
(
uint32_t
*
)
X1052_
DMAGetUserSpaceBuffer
(
(
int
)
to_dev
);
(
*
hDma
)
=
(
uint32_t
*
)
X1052_
BiDMAGetUserSpaceBuffer
(
hBiDma
,
(
int
)
to_dev
);
return
X1052_DMA_TRANSFER_MAXB
;
}
...
...
src/WBMemX1052Con.h
View file @
4a166dda
...
...
@@ -19,7 +19,10 @@
#include "WBNode.h"
#ifndef _WDC_LIB_H_
typedef
void
*
WDC_DEVICE_HANDLE
;
//!< Hack to not include all the X1052 api in this header
typedef
void
*
WDC_DEVICE_HANDLE
;
//!< Hack to not include all the X1052 api in this header
#endif
#ifndef _X1052_LIB_H_
typedef
void
*
X1052_BIDMA_HANDLE
;
//!< Hack to not include all the X1052 api in this header
#endif
/**
...
...
@@ -34,7 +37,7 @@ typedef void *WDC_DEVICE_HANDLE; //!< Hack to not include all the X1052 api in t
*/
class
WBMemX1052Con
:
public
WBMemCon
{
public
:
WBMemX1052Con
(
uint32_
t
idPCIe
,
uint32_t
magic_addr
=
0xFFFFFFFF
,
uint32_t
magic_val
=-
1
);
WBMemX1052Con
(
in
t
idPCIe
,
uint32_t
magic_addr
=
0xFFFFFFFF
,
uint32_t
magic_val
=-
1
);
virtual
~
WBMemX1052Con
();
bool
isValid
();
...
...
@@ -45,6 +48,9 @@ public:
private
:
WDC_DEVICE_HANDLE
hDev
;
X1052_BIDMA_HANDLE
hBiDma
;
static
int
nHandles
;
};
#endif
/* WBMEMX1052CON_H_ */
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