Commit d73c9ce9 authored by Dimitris Lampridis's avatar Dimitris Lampridis

sw/tools/wrc: add simple standalone rellocation tool

parent 712f07b1
......@@ -10,7 +10,7 @@ CFLAGS += -I $(VME_INC)
LDFLAGS += -L.
LDLIBS += -lvfchd.$(CPU)
TARGETS = vfchd-vuart.$(CPU) vfchd-wrc_loader.$(CPU) vfchd-eeprom_loader.$(CPU)
TARGETS = vfchd-vuart.$(CPU) vfchd-wrc_loader.$(CPU) vfchd-eeprom_loader.$(CPU) vfchd-relloc.$(CPU)
all: $(TARGETS)
......
/* A simple tool to rellocate the VFC-HD (to the same address as the geographical address) in both
A24 and A32 */
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include "vfchdlib.h"
extern int _vfchd_vme64x_rellocate(struct vfchd_dev *);
void _vfchd_relloc_print_usage(const char *progname)
{
fprintf(stderr,
"\nUsage: \"%s "
"-l SLOT [...]\n", progname);
}
int main(int argc, char **argv)
{
struct vfchd_dev *dev;
int c;
// Required arguments
uint8_t slot = 0;
// Process cmd line arguments
while ((c = getopt (argc, argv, "l:")) != -1)
switch (c)
{
case 'l':
slot = strtol(optarg, NULL, 0);
break;
case '?':
default:
_vfchd_relloc_print_usage(argv[0]);
return EINVAL;
}
if (!slot) {
fprintf(stderr, "(EE): missing SLOT argument.\n");
_vfchd_relloc_print_usage(argv[0]);
return EINVAL;
}
// Allocate and init the device structure
dev = malloc(sizeof(struct vfchd_dev));
if (!dev)
return ENOMEM;
dev->slot = slot;
// Perform VME64x rellocation if necessary
if (_vfchd_vme64x_rellocate(dev) < 0) {
fprintf(stderr,"(EE): VME64x rellocation failed.\n");
free(dev);
return -1;
}
return 0;
}
Markdown is supported
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