Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EtherBone Core
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Projects
EtherBone Core
Commits
d2ba4111
Commit
d2ba4111
authored
13 years ago
by
Wesley W. Terpstra
Browse files
Options
Downloads
Patches
Plain Diff
Add writeable memory to the snoop demo
parent
3c566721
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
api/demo/eb-snoop.c
+19
-6
19 additions, 6 deletions
api/demo/eb-snoop.c
with
19 additions
and
6 deletions
api/demo/eb-snoop.c
+
19
−
6
View file @
d2ba4111
...
@@ -29,17 +29,18 @@
...
@@ -29,17 +29,18 @@
#include
<stdlib.h>
#include
<stdlib.h>
#include
"../etherbone.h"
#include
"../etherbone.h"
static
uint8_t
my_memory
[
256
];
static
eb_status_t
my_read
(
eb_user_data_t
user
,
eb_address_t
address
,
eb_width_t
width
,
eb_data_t
*
data
)
{
static
eb_status_t
my_read
(
eb_user_data_t
user
,
eb_address_t
address
,
eb_width_t
width
,
eb_data_t
*
data
)
{
eb_data_t
out
;
eb_data_t
out
;
fprintf
(
stdout
,
"Received read to address %016"
EB_ADDR_FMT
" of %d bits
\n
"
,
address
,
(
width
&
EB_DATAX
)
*
8
);
fprintf
(
stdout
,
"Received read to address %016"
EB_ADDR_FMT
" of %d bits
\n
"
,
address
,
(
width
&
EB_DATAX
)
*
8
);
/*
Pretend to
be
a
bigendian
device with the identity function
*/
/*
Software slaves must
be bigendian */
width
&=
EB_DATAX
;
out
=
0
;
for
(
out
=
0
;
width
>
0
;
--
width
)
{
for
(
width
&=
EB_DATAX
;
width
>
0
;
--
width
)
{
out
<<=
8
;
out
<<=
8
;
out
|=
address
&
0xFF
;
out
|=
my_memory
[
address
++
&
0xff
];
++
address
;
}
}
*
data
=
out
;
*
data
=
out
;
...
@@ -48,7 +49,14 @@ static eb_status_t my_read(eb_user_data_t user, eb_address_t address, eb_width_t
...
@@ -48,7 +49,14 @@ static eb_status_t my_read(eb_user_data_t user, eb_address_t address, eb_width_t
static
eb_status_t
my_write
(
eb_user_data_t
user
,
eb_address_t
address
,
eb_width_t
width
,
eb_data_t
data
)
{
static
eb_status_t
my_write
(
eb_user_data_t
user
,
eb_address_t
address
,
eb_width_t
width
,
eb_data_t
data
)
{
fprintf
(
stdout
,
"Received write to address %016"
EB_ADDR_FMT
" of %d bits: %016"
EB_DATA_FMT
"
\n
"
,
address
,
(
width
&
EB_DATAX
)
*
8
,
data
);
fprintf
(
stdout
,
"Received write to address %016"
EB_ADDR_FMT
" of %d bits: %016"
EB_DATA_FMT
"
\n
"
,
address
,
(
width
&
EB_DATAX
)
*
8
,
data
);
return
(
address
==
0
)
?
EB_FAIL
:
EB_OK
;
/* Software slaves must be bigendian */
for
(
width
&=
EB_DATAX
;
width
>
0
;
--
width
)
{
my_memory
[(
address
+
width
-
1
)
&
0xff
]
=
data
&
0xff
;
data
>>=
8
;
}
return
EB_OK
;
}
}
int
main
(
int
argc
,
const
char
**
argv
)
{
int
main
(
int
argc
,
const
char
**
argv
)
{
...
@@ -56,6 +64,7 @@ int main(int argc, const char** argv) {
...
@@ -56,6 +64,7 @@ int main(int argc, const char** argv) {
const
char
*
port
;
const
char
*
port
;
eb_status_t
status
;
eb_status_t
status
;
eb_socket_t
socket
;
eb_socket_t
socket
;
int
i
;
if
(
argc
!=
4
)
{
if
(
argc
!=
4
)
{
fprintf
(
stderr
,
"Syntax: %s <port> <address> <mask>
\n
"
,
argv
[
0
]);
fprintf
(
stderr
,
"Syntax: %s <port> <address> <mask>
\n
"
,
argv
[
0
]);
...
@@ -70,6 +79,10 @@ int main(int argc, const char** argv) {
...
@@ -70,6 +79,10 @@ int main(int argc, const char** argv) {
handler
.
read
=
&
my_read
;
handler
.
read
=
&
my_read
;
handler
.
write
=
&
my_write
;
handler
.
write
=
&
my_write
;
/* Initialize the system 'memory' */
for
(
i
=
0
;
i
<
256
;
++
i
)
my_memory
[
i
]
=
i
;
if
((
status
=
eb_socket_open
(
port
,
EB_DATAX
|
EB_ADDRX
,
&
socket
))
!=
EB_OK
)
{
if
((
status
=
eb_socket_open
(
port
,
EB_DATAX
|
EB_ADDRX
,
&
socket
))
!=
EB_OK
)
{
fprintf
(
stderr
,
"Failed to open Etherbone socket: %s
\n
"
,
eb_status
(
status
));
fprintf
(
stderr
,
"Failed to open Etherbone socket: %s
\n
"
,
eb_status
(
status
));
return
1
;
return
1
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment