Skip to content
Snippets Groups Projects
Commit 3c566721 authored by Wesley W. Terpstra's avatar Wesley W. Terpstra
Browse files

Support sub-word access with the command-line tools.

Provide a slave which is useful for testing endian.
parent 3aeba2c2
Branches
Tags
No related merge requests found
......@@ -48,19 +48,24 @@ int main(int argc, const char** argv) {
eb_status_t status;
eb_device_t device;
eb_width_t width;
eb_width_t op_width;
eb_cycle_t cycle;
eb_address_t address;
const char* netaddress;
int stop;
if (argc != 3) {
fprintf(stderr, "Syntax: %s <protocol/host/port> <address>\n", argv[0]);
if (argc < 3 || argc > 4) {
fprintf(stderr, "Syntax: %s <protocol/host/port> <address> [width]\n", argv[0]);
return 1;
}
netaddress = argv[1];
address = strtoll(argv[2], 0, 0);
op_width = EB_DATAX;
if (argc == 4)
op_width &= strtol(argv[3], 0, 0);
if ((status = eb_socket_open(0, EB_DATAX|EB_ADDRX, &socket)) != EB_OK) {
fprintf(stderr, "Failed to open Etherbone socket: %s\n", eb_status(status));
return 1;
......@@ -82,7 +87,7 @@ int main(int argc, const char** argv) {
return 1;
}
eb_cycle_read(cycle, address, EB_DATAX, 0);
eb_cycle_read(cycle, address, op_width, 0);
eb_cycle_close(cycle);
stop = 0;
......
......@@ -30,9 +30,20 @@
#include "../etherbone.h"
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;
fprintf(stdout, "Received read to address %016"EB_ADDR_FMT" of %d bits\n", address, (width&EB_DATAX)*8);
*data = UINT64_C(0x1234567890abcdef);
return (address==0)?EB_FAIL:EB_OK;
/* Pretend to be a bigendian device with the identity function */
width &= EB_DATAX;
for (out = 0; width > 0; --width) {
out <<= 8;
out |= address & 0xFF;
++address;
}
*data = out;
return EB_OK;
}
static eb_status_t my_write(eb_user_data_t user, eb_address_t address, eb_width_t width, eb_data_t data) {
......
......@@ -48,14 +48,15 @@ int main(int argc, const char** argv) {
eb_status_t status;
eb_device_t device;
eb_width_t width;
eb_width_t op_width;
eb_cycle_t cycle;
eb_address_t address;
eb_data_t data;
const char* netaddress;
int stop;
if (argc != 4) {
fprintf(stderr, "Syntax: %s <protocol/host/port> <address> <data>\n", argv[0]);
if (argc < 4 || argc > 5) {
fprintf(stderr, "Syntax: %s <protocol/host/port> <address> <data> [width]\n", argv[0]);
return 1;
}
......@@ -63,6 +64,10 @@ int main(int argc, const char** argv) {
address = strtoll(argv[2], 0, 0);
data = strtoll(argv[3], 0, 0);
op_width = EB_DATAX;
if (argc == 5)
op_width &= strtol(argv[4], 0, 0);
if ((status = eb_socket_open(0, EB_DATAX|EB_ADDRX, &socket)) != EB_OK) {
fprintf(stderr, "Failed to open Etherbone socket: %s\n", eb_status(status));
return 1;
......@@ -84,7 +89,7 @@ int main(int argc, const char** argv) {
return 1;
}
eb_cycle_write(cycle, address, EB_DATAX, data);
eb_cycle_write(cycle, address, op_width, data);
eb_cycle_close(cycle);
stop = 0;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment