writeword.c 912 Bytes
/*
 * Simple app to test memory interface for writing words.  
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <netinet/in.h>
#include <bstring.h>

#include <diag.h>
#include <dbg_comm.h>

int commtype=DG_VERILOG;

void main(int argc, char **argv) {
    unsigned int vaddr, data;

    if (argc == 3) {
	vaddr = (int)strtoul (argv[1], (char **)NULL, 0);
	data = (int)strtoul (argv[2], (char **)NULL, 0);
    } else {
	printf("Usage: writeword vaddr len data\n");
	exit (1);
    }
    
    printf("vaddr 0x%x data 0x%x\n", vaddr, data);

    if ( dgInitComm() ) {
	fprintf(stderr,
	  "%s: unable to initialize communication with target system.\n",
	  argv[0]);
	exit(1);
    }

    if ( dgWriteMem (vaddr, 4, (char *) (&data) ) ) {
	fprintf(stderr,
	  "%s: unable to write target system memory.\n",
	  argv[0]);
    }
    exit(0);
}
void
errlog()
{
}