Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dma_ip_drivers
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
dma_ip_drivers
Commits
c6cd2468
Commit
c6cd2468
authored
Oct 22, 2021
by
Karen Xie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
XDMA: fixed reg_rw access beyond 32K
parent
7d44836c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
45 deletions
+36
-45
XDMA/linux-kernel/tools/reg_rw.c
XDMA/linux-kernel/tools/reg_rw.c
+25
-38
XDMA/linux-kernel/xdma/Makefile
XDMA/linux-kernel/xdma/Makefile
+9
-1
XDMA/linux-kernel/xdma/cdev_ctrl.c
XDMA/linux-kernel/xdma/cdev_ctrl.c
+1
-2
XDMA/linux-kernel/xdma/libxdma.h
XDMA/linux-kernel/xdma/libxdma.h
+0
-3
XDMA/linux-kernel/xdma/version.h
XDMA/linux-kernel/xdma/version.h
+1
-1
No files found.
XDMA/linux-kernel/tools/reg_rw.c
View file @
c6cd2468
...
...
@@ -39,17 +39,14 @@
#define FATAL do { fprintf(stderr, "Error at line %d, file %s (%d) [%s]\n", __LINE__, __FILE__, errno, strerror(errno)); exit(1); } while(0)
#define MAP_SIZE (32*1024UL)
#define MAP_MASK (MAP_SIZE - 1)
int
main
(
int
argc
,
char
**
argv
)
{
int
fd
;
void
*
map
_base
,
*
virt_addr
;
void
*
map
;
uint32_t
read_result
,
writeval
;
off_t
target
;
/* access width */
int
access_width
=
'w'
;
char
access_width
=
'w'
;
char
*
device
;
/* not enough arguments given? */
...
...
@@ -64,20 +61,14 @@ int main(int argc, char **argv)
exit
(
1
);
}
printf
(
"argc = %d
\n
"
,
argc
);
device
=
strdup
(
argv
[
1
]);
printf
(
"device: %s
\n
"
,
device
);
target
=
strtoul
(
argv
[
2
],
0
,
0
);
printf
(
"address: 0x%08x
\n
"
,
(
unsigned
int
)
target
);
printf
(
"access type: %s
\n
"
,
argc
>=
4
?
"write"
:
"read"
);
printf
(
"device: %s, address: 0x%08x, access %s: %s.
\n
"
,
device
,
(
unsigned
int
)
target
,
argc
>=
4
?
"write"
:
"read"
);
/* data given? */
if
(
argc
>=
4
)
{
printf
(
"access width given.
\n
"
);
if
(
argc
>=
4
)
access_width
=
tolower
(
argv
[
3
][
0
]);
}
printf
(
"access width: "
);
if
(
access_width
==
'b'
)
printf
(
"byte (8-bits)
\n
"
);
...
...
@@ -86,7 +77,7 @@ int main(int argc, char **argv)
else
if
(
access_width
==
'w'
)
printf
(
"word (32-bits)
\n
"
);
else
{
printf
(
"word (32-bits)
\n
"
);
printf
(
"
default to
word (32-bits)
\n
"
);
access_width
=
'w'
;
}
...
...
@@ -95,42 +86,38 @@ int main(int argc, char **argv)
printf
(
"character device %s opened.
\n
"
,
argv
[
1
]);
fflush
(
stdout
);
/* map one page */
map_base
=
mmap
(
0
,
MAP_SIZE
,
PROT_READ
|
PROT_WRITE
,
MAP_SHARED
,
fd
,
0
);
if
(
map_base
==
(
void
*
)
-
1
)
map
=
mmap
(
0
,
4
,
PROT_READ
|
PROT_WRITE
,
MAP_SHARED
,
fd
,
target
);
if
(
map
==
(
void
*
)
-
1
)
FATAL
;
printf
(
"Memory
mapped at address %p.
\n
"
,
map_base
);
printf
(
"Memory
0x%lx mapped at address %p.
\n
"
,
target
,
map
);
fflush
(
stdout
);
/* calculate the virtual address to be accessed */
virt_addr
=
map_base
+
target
;
/* read only */
if
(
argc
<=
4
)
{
//printf("Read from address %p.\n", virt_addr);
switch
(
access_width
)
{
case
'b'
:
read_result
=
*
((
uint8_t
*
)
virt_addr
);
read_result
=
*
((
uint8_t
*
)
map
);
printf
(
"Read 8-bits value at address 0x%08x (%p): 0x%02x
\n
"
,
(
unsigned
int
)
target
,
virt_addr
,
(
unsigned
int
)
target
,
map
,
(
unsigned
int
)
read_result
);
break
;
case
'h'
:
read_result
=
*
((
uint16_t
*
)
virt_addr
);
read_result
=
*
((
uint16_t
*
)
map
);
/* swap 16-bit endianess if host is not little-endian */
read_result
=
ltohs
(
read_result
);
printf
(
"Read 16-bit value at address 0x%08x (%p): 0x%04x
\n
"
,
(
unsigned
int
)
target
,
virt_addr
,
(
unsigned
int
)
target
,
map
,
(
unsigned
int
)
read_result
);
break
;
case
'w'
:
read_result
=
*
((
uint32_t
*
)
virt_addr
);
read_result
=
*
((
uint32_t
*
)
map
);
/* swap 32-bit endianess if host is not little-endian */
read_result
=
ltohl
(
read_result
);
printf
(
"Read 32-bit value at address 0x%08x (%p): 0x%08x
\n
"
,
(
unsigned
int
)
target
,
virt_addr
,
(
unsigned
int
)
target
,
map
,
(
unsigned
int
)
read_result
);
return
(
int
)
read_result
;
break
;
...
...
@@ -148,11 +135,11 @@ int main(int argc, char **argv)
case
'b'
:
printf
(
"Write 8-bits value 0x%02x to 0x%08x (0x%p)
\n
"
,
(
unsigned
int
)
writeval
,
(
unsigned
int
)
target
,
virt_addr
);
*
((
uint8_t
*
)
virt_addr
)
=
writeval
;
map
);
*
((
uint8_t
*
)
map
)
=
writeval
;
#if 0
if (argc > 4) {
read_result = *((uint8_t *)
virt_addr
);
read_result = *((uint8_t *)
map
);
printf("Written 0x%02x; readback 0x%02x\n",
writeval, read_result);
}
...
...
@@ -161,13 +148,13 @@ int main(int argc, char **argv)
case
'h'
:
printf
(
"Write 16-bits value 0x%04x to 0x%08x (0x%p)
\n
"
,
(
unsigned
int
)
writeval
,
(
unsigned
int
)
target
,
virt_addr
);
map
);
/* swap 16-bit endianess if host is not little-endian */
writeval
=
htols
(
writeval
);
*
((
uint16_t
*
)
virt_addr
)
=
writeval
;
*
((
uint16_t
*
)
map
)
=
writeval
;
#if 0
if (argc > 4) {
read_result = *((uint16_t *)
virt_addr
);
read_result = *((uint16_t *)
map
);
printf("Written 0x%04x; readback 0x%04x\n",
writeval, read_result);
}
...
...
@@ -176,13 +163,13 @@ int main(int argc, char **argv)
case
'w'
:
printf
(
"Write 32-bits value 0x%08x to 0x%08x (0x%p)
\n
"
,
(
unsigned
int
)
writeval
,
(
unsigned
int
)
target
,
virt_addr
);
map
);
/* swap 32-bit endianess if host is not little-endian */
writeval
=
htoll
(
writeval
);
*
((
uint32_t
*
)
virt_addr
)
=
writeval
;
*
((
uint32_t
*
)
map
)
=
writeval
;
#if 0
if (argc > 4) {
read_result = *((uint32_t *)
virt_addr
);
read_result = *((uint32_t *)
map
);
printf("Written 0x%08x; readback 0x%08x\n",
writeval, read_result);
}
...
...
@@ -191,7 +178,7 @@ int main(int argc, char **argv)
}
fflush
(
stdout
);
}
if
(
munmap
(
map
_base
,
MAP_SIZE
)
==
-
1
)
if
(
munmap
(
map
,
4
)
==
-
1
)
FATAL
;
close
(
fd
);
return
0
;
...
...
XDMA/linux-kernel/xdma/Makefile
View file @
c6cd2468
SHELL
=
/bin/bash
#
# optional makefile parameters:
# - DEBUG=<0|1>, enable verbose debug print-out in the driver
# - xvc_bar_num=, xvc pci bar #
# - xvc_bar_offset=, xvc register base offset
#
ifneq
($(xvc_bar_num),)
XVC_FLAGS
+=
-D__XVC_BAR_NUM__
=
$(xvc_bar_num)
endif
...
...
@@ -14,7 +20,9 @@ topdir := $(shell cd $(src)/.. && pwd)
TARGET_MODULE
:=
xdma
EXTRA_CFLAGS
:=
-I
$(topdir)
/include
$(XVC_FLAGS)
#EXTRA_CFLAGS += -D__LIBXDMA_DEBUG__
ifeq
($(DEBUG),1)
EXTRA_CFLAGS
+=
-D__LIBXDMA_DEBUG__
endif
#EXTRA_CFLAGS += -DINTERNAL_TESTING
ifneq
($(KERNELRELEASE),)
...
...
XDMA/linux-kernel/xdma/cdev_ctrl.c
View file @
c6cd2468
...
...
@@ -216,8 +216,7 @@ int bridge_mmap(struct file *file, struct vm_area_struct *vma)
dbg_sg
(
"mmap(): cdev->bar = %d
\n
"
,
xcdev
->
bar
);
dbg_sg
(
"mmap(): xdev = 0x%p
\n
"
,
xdev
);
dbg_sg
(
"mmap(): pci_dev = 0x%08lx
\n
"
,
(
unsigned
long
)
xdev
->
pdev
);
dbg_sg
(
"off = 0x%lx
\n
"
,
off
);
dbg_sg
(
"off = 0x%lx, vsize 0x%lu, psize 0x%lu.
\n
"
,
off
,
vsize
,
psize
);
dbg_sg
(
"start = 0x%llx
\n
"
,
(
unsigned
long
long
)
pci_resource_start
(
xdev
->
pdev
,
xcdev
->
bar
));
...
...
XDMA/linux-kernel/xdma/libxdma.h
View file @
c6cd2468
...
...
@@ -63,9 +63,6 @@
*/
//#define XDMA_CONFIG_BAR_NUM 1
/* Switch debug printing on/off */
#define XDMA_DEBUG 0
/* SECTION: Preprocessor macros/constants */
#define XDMA_BAR_NUM (6)
...
...
XDMA/linux-kernel/xdma/version.h
View file @
c6cd2468
...
...
@@ -22,7 +22,7 @@
#define DRV_MOD_MAJOR 2020
#define DRV_MOD_MINOR 2
#define DRV_MOD_PATCHLEVEL
0
#define DRV_MOD_PATCHLEVEL
1
#define DRV_MODULE_VERSION \
__stringify(DRV_MOD_MAJOR) "." \
...
...
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