bios: add command to print df debug info

This commit is contained in:
Sebastien Bourdeauducq 2012-08-03 18:51:39 +02:00
parent 0642f0ca94
commit eb751f6e80
4 changed files with 70 additions and 1 deletions

View File

@ -1,7 +1,7 @@
M2DIR=../..
include $(M2DIR)/software/common.mak
OBJECTS=crt0.o isr.o ddrinit.o main.o microudp.o tftp.o boot-helper.o boot.o
OBJECTS=crt0.o isr.o ddrinit.o main.o microudp.o tftp.o boot-helper.o boot.o dataflow.o
all: bios.bin

42
software/bios/dataflow.c Normal file
View File

@ -0,0 +1,42 @@
#include <stdio.h>
#include "dataflow.h"
void print_isd_info(unsigned int baseaddr)
{
volatile unsigned int *regs;
int neps;
int nbytes;
int i, j;
int offset;
unsigned int ack_count, nack_count, cur_status;
regs = (unsigned int *)baseaddr;
if((regs[0] != 0x6a) || (regs[1] != 0xb4)) {
printf("Incorrect magic number\n");
return;
}
neps = regs[2];
nbytes = (regs[3] + 7)/8;
// regs[4] is reset
offset = 5;
for(i=0;i<neps;i++) {
ack_count = 0;
for(j=0;j<nbytes;j++) {
ack_count <<= 8;
ack_count |= regs[offset++];
}
nack_count = 0;
for(j=0;j<nbytes;j++) {
nack_count <<= 8;
nack_count |= regs[offset++];
}
cur_status = regs[offset++];
printf("#%d: ACK_CNT:%10u NAK_CNT:%10u %s %s\n",
i, ack_count, nack_count,
cur_status & 1 ? "stb" : " ",
cur_status & 2 ? "ack" : " ");
}
}

7
software/bios/dataflow.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef __DATAFLOW_H
#define __DATAFLOW_H
void print_isd_info(unsigned int baseaddr);
#endif /* __DATAFLOW_H */

View File

@ -14,6 +14,7 @@
#include <hw/minimac.h>
#include "ddrinit.h"
#include "dataflow.h"
#include "boot.h"
enum {
@ -285,6 +286,23 @@ static void wcsr(char *csr, char *value)
}
}
static void dfs(char *baseaddr)
{
char *c;
unsigned int addr;
if(*baseaddr == 0) {
printf("dfs <address>\n");
return;
}
addr = strtoul(baseaddr, &c, 0);
if(*c != 0) {
printf("incorrect address\n");
return;
}
print_isd_info(addr);
}
/* Init + command line */
static void help(void)
@ -350,6 +368,8 @@ static void do_command(char *c)
else if(strcmp(token, "memtest") == 0) memtest();
else if(strcmp(token, "ddrinit") == 0) ddrinit();
else if(strcmp(token, "dfs") == 0) dfs(get_token(&c));
else if(strcmp(token, "") != 0)
printf("Command not found\n");
}