Commit a74e0f3e authored by Grzegorz Daniluk's avatar Grzegorz Daniluk

wrcore_v2: little cosmetic changes in lm32-loader

parent cd91f910
......@@ -15,7 +15,7 @@ all: lm32-loader genraminit vuart_console
OBJS_LOADER = lm32-loader.o rr_io.o mini_bone/ptpd_netif.o mini_bone/minibone_lib.o
lm32-loader: $(OBJS_LOADER)
# make -C mini_bone
make -C mini_bone
${CC} -o lm32-loader $(OBJS_LOADER)
genraminit: genraminit.o
......@@ -28,4 +28,4 @@ vuart_console: vuart_console.o rr_io.o
${CC} -c $^ $(CFLAGS) -O0
clean:
rm -f $(ALL) *.o *~
rm -f $(ALL) *.o *~ mini_bone/*.o mini_bone/*~
......@@ -36,23 +36,21 @@ static void *mb_handle = NULL;
static void spec_writel(uint32_t value, uint32_t addr)
{
if(mb_handle)
mbn_writel(mb_handle, value, (BASE_MBONE + addr)>>2);
else
rr_writel(value, BASE_PCIE + addr);
if(mb_handle)
mbn_writel(mb_handle, value, (BASE_MBONE + addr)>>2);
else
rr_writel(value, BASE_PCIE + addr);
}
static uint32_t spec_readl(uint32_t addr)
{
uint32_t rval;
if(mb_handle)
rval = mbn_readl(mb_handle, (BASE_MBONE + addr)>>2);
else
rval = rr_readl(BASE_PCIE + addr);
uint32_t rval;
if(mb_handle)
rval = mbn_readl(mb_handle, (BASE_MBONE + addr)>>2);
else
rval = rr_readl(BASE_PCIE + addr);
// printf("readl: value %x addr %x\n", addr, rval);
return rval;
return rval;
}
......@@ -73,35 +71,35 @@ void copy_lm32(uint32_t *buf, int buf_nwords, uint32_t base_addr)
for(i=0;i<buf_nwords;i++)
{
spec_writel(conv_endian(buf[i]), base_addr + i *4);
if(!(i & 0xfff)) { printf("."); fflush(stdout); }
spec_writel(conv_endian(buf[i]), base_addr + i *4);
if(!(i & 0xfff)) { printf("."); fflush(stdout); }
}
printf("\nVerifing memory: ");
for(i=0;i<buf_nwords;i++)
{
uint32_t x = spec_readl(base_addr+ i*4);
if(conv_endian(buf[i]) != x)
{
printf("Verify failed (%x vs %x)\n", conv_endian(buf[i]), x);
return ;
}
if(!(i & 0xfff)) { printf("."); fflush(stdout); }
uint32_t x = spec_readl(base_addr+ i*4);
if(conv_endian(buf[i]) != x)
{
printf("Verify failed (%x vs %x)\n", conv_endian(buf[i]), x);
return ;
}
if(!(i & 0xfff)) { printf("."); fflush(stdout); }
}
printf("OK.\n");
printf("OK.\n");
}
int main(int argc, char **argv)
{
int num_words;
uint32_t *buf;
uint8_t target_mac[6];
FILE *f;
char if_name[16];
int num_words;
uint32_t *buf;
uint8_t target_mac[6];
FILE *f;
char if_name[16];
if(argc<2)
{
fprintf(stderr, "No parameters specified !\n");
......@@ -113,45 +111,49 @@ int main(int argc, char **argv)
if(argc >= 4 && !strcmp(argv[2], "-m"))
{
sscanf(argv[3], "%s",if_name);
sscanf(argv[4], "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx", &target_mac[0], &target_mac[1], &target_mac[2], &target_mac[3], &target_mac[4], &target_mac[5]);
mb_handle = mbn_open(if_name, target_mac);
if(!mb_handle)
{
fprintf(stderr,"Connection failed....\n");
return -1;
}
sscanf(argv[3], "%s",if_name);
sscanf(argv[4], "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx", &target_mac[0], &target_mac[1], &target_mac[2], &target_mac[3], &target_mac[4], &target_mac[5]);
mb_handle = mbn_open(if_name, target_mac);
if(!mb_handle)
{
fprintf(stderr,"Connection failed....\n");
return -1;
}
} else if( rr_init() < 0)
{
fprintf(stderr,"Can't initialize rawrabbit :(\n");
return -1;
fprintf(stderr,"Can't initialize rawrabbit :(\n");
return -1;
}
f=fopen(argv[1],"rb");
if(!f)
{
fprintf(stderr, "Input file not found.\n");
return -1;
}
fseek(f, 0, SEEK_END);
int size = ftell(f);
rewind(f);
buf = malloc(size + 4);
fread(buf, 1, size, f);
fclose(f);
rst_lm32(1);
rst_lm32(1);
rst_lm32(1);
rst_lm32(1);
copy_lm32(buf, (size + 3) / 4, 0);
rst_lm32(0);
if(mb_handle)
{
mbn_stats(mb_handle);
mbn_close(mb_handle);
}
f=fopen(argv[1],"rb");
if(!f)
{
fprintf(stderr, "Input file not found.\n");
return -1;
}
fseek(f, 0, SEEK_END);
int size = ftell(f);
rewind(f);
buf = malloc(size + 4);
fread(buf, 1, size, f);
fclose(f);
rst_lm32(1);
rst_lm32(1);
rst_lm32(1);
rst_lm32(1);
copy_lm32(buf, (size + 3) / 4, 0);
rst_lm32(0);
// mbn_stats(mb_handle);
return 0;
}
OBJS = minibone_lib.o ptpd_netif.o
all: $(OBJS)
gcc -o m $(OBJS)
\ No newline at end of file
gcc -c -o m $(OBJS)
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