Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Simple VME FMC Carrier SVEC - Software
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
Simple VME FMC Carrier SVEC - Software
Commits
19e9ae2b
Commit
19e9ae2b
authored
Nov 30, 2012
by
Juan David González Cobas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: add options for non-D32 access
parent
7be8a692
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
13 deletions
+61
-13
vme.c
tools/vme.c
+61
-13
No files found.
tools/vme.c
View file @
19e9ae2b
...
...
@@ -7,8 +7,9 @@
#include <libvmebus.h>
static
char
usage_string
[]
=
"usage: %s [-oh?] [ -w word ] [-v vme_address]
\n
"
"[-s skip_bytes ] [-d data_width] "
"usage: %s [-oh?] [-w word] [-v vme_address]
\n
"
"[-s skip_bytes] [-d data_width] [-D effective_width]"
"[-l map_length] "
"[-a address_modifier] [-n word_count]
\n
"
;
void
usage
(
char
*
prog
)
...
...
@@ -16,28 +17,39 @@ void usage(char *prog)
fprintf
(
stderr
,
usage_string
,
prog
);
exit
(
1
);
}
int
invalid
(
int
data_width
)
{
return
(
data_width
!=
8
&&
data_width
!=
16
&&
data_width
!=
32
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
struct
vme_mapping
map
;
struct
vme_mapping
*
mapp
=
&
map
;
volatile
void
*
ptr
;
unsigned
int
vmebase
,
am
,
data_width
;
unsigned
int
vmebase
,
am
,
data_width
,
access_width
;
unsigned
int
offset
,
skip_bytes
;
unsigned
int
length
;
int
i
,
count
;
int
c
;
int
write
,
offsets_on
;
int
width
;
uint32_t
word
;
/* vme defaults */
count
=
1
;
am
=
VME_A32_USER_DATA_SCT
;
data_width
=
VME_D32
;
data_width
=
access_width
=
VME_D32
;
write
=
0
;
offsets_on
=
1
;
skip_bytes
=
0
;
while
((
c
=
getopt
(
argc
,
argv
,
"ov:s:d:a:n:w:"
))
!=
-
1
)
{
length
=
0x80000
;
while
((
c
=
getopt
(
argc
,
argv
,
"ov:s:D:d:a:n:w:l:"
))
!=
-
1
)
{
switch
(
c
)
{
case
'o'
:
offsets_on
=
0
;
...
...
@@ -49,7 +61,16 @@ int main(int argc, char *argv[])
vmebase
=
strtoul
(
optarg
,
NULL
,
0
);
break
;
case
'd'
:
data_width
=
strtoul
(
optarg
,
NULL
,
0
);
case
'D'
:
width
=
strtoul
(
optarg
,
NULL
,
0
);
if
(
invalid
(
width
))
{
fprintf
(
stderr
,
"invalid data width %d
\n
"
,
width
);
exit
(
1
);
}
if
(
c
==
'd'
)
data_width
=
width
;
else
access_width
=
width
;
break
;
case
'a'
:
am
=
strtoul
(
optarg
,
NULL
,
0
);
...
...
@@ -57,6 +78,9 @@ int main(int argc, char *argv[])
case
'n'
:
count
=
strtoul
(
optarg
,
NULL
,
0
);
break
;
case
'l'
:
length
=
strtoul
(
optarg
,
NULL
,
0
);
break
;
case
'w'
:
write
=
1
;
word
=
strtoul
(
optarg
,
NULL
,
0
);
...
...
@@ -73,8 +97,8 @@ int main(int argc, char *argv[])
memset
(
mapp
,
0
,
sizeof
(
*
mapp
));
mapp
->
am
=
am
;
mapp
->
data_width
=
data_width
;
mapp
->
sizel
=
0x80000
;
mapp
->
data_width
=
(
data_width
==
8
)
?
16
:
data_width
;
mapp
->
sizel
=
length
;
mapp
->
vme_addrl
=
vmebase
;
if
((
ptr
=
vme_map
(
mapp
,
1
))
==
NULL
)
{
...
...
@@ -82,17 +106,41 @@ int main(int argc, char *argv[])
exit
(
1
);
}
fprintf
(
stderr
,
"vme 0x%08x kernel
0x%p user 0x
%p
\n
"
,
fprintf
(
stderr
,
"vme 0x%08x kernel
%p user
%p
\n
"
,
vmebase
,
mapp
->
kernel_va
,
mapp
->
user_va
);
offset
=
skip_bytes
;
for
(
i
=
0
;
i
<
count
;
i
++
,
offset
+=
4
)
{
volatile
uint32_t
*
addr
=
ptr
+
offset
;
volatile
void
*
addr
=
ptr
+
offset
;
if
(
!
write
)
{
uint32_t
datum
;
switch
(
access_width
)
{
case
8
:
datum
=
*
(
uint8_t
*
)
addr
;
break
;
case
16
:
datum
=
ntohs
(
*
(
uint16_t
*
)
addr
);
break
;
case
32
:
datum
=
ntohl
(
*
(
uint32_t
*
)
addr
);
break
;
}
if
(
offsets_on
)
printf
(
"%08x: "
,
vmebase
+
offset
);
printf
(
"%08x
\n
"
,
ntohl
(
*
addr
));
}
else
*
addr
=
htonl
(
word
);
printf
(
"%08x
\n
"
,
datum
);
}
else
{
switch
(
access_width
)
{
case
8
:
*
(
uint8_t
*
)
addr
=
word
;
break
;
case
16
:
*
(
uint16_t
*
)
addr
=
htons
(
word
);
break
;
case
32
:
*
(
uint32_t
*
)
addr
=
htonl
(
word
);
break
;
}
}
}
vme_unmap
(
mapp
,
1
);
...
...
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