bios: add command to print df debug info
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Fri, 3 Aug 2012 16:51:39 +0000 (18:51 +0200)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Fri, 3 Aug 2012 16:51:39 +0000 (18:51 +0200)
software/bios/Makefile
software/bios/dataflow.c [new file with mode: 0644]
software/bios/dataflow.h [new file with mode: 0644]
software/bios/main.c

index bfd0aafa5e51c4adfca3e21aafb7417d10aee4fb..42aa7bfe4d55c2063907c5cc78d26c684b20b986 100644 (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
 
diff --git a/software/bios/dataflow.c b/software/bios/dataflow.c
new file mode 100644 (file)
index 0000000..b3c64a2
--- /dev/null
@@ -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" : "   ");
+       }
+}
diff --git a/software/bios/dataflow.h b/software/bios/dataflow.h
new file mode 100644 (file)
index 0000000..9659830
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef __DATAFLOW_H
+#define __DATAFLOW_H
+
+void print_isd_info(unsigned int baseaddr);
+
+#endif /* __DATAFLOW_H */
+
index 8df3cab1d46983d83241ac418d8eb7e55729cba3..30cd87187447bea6651a5b2140660817cf45413c 100644 (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)
@@ -349,6 +367,8 @@ static void do_command(char *c)
        else if(strcmp(token, "ddrwr") == 0) ddrwr(get_token(&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");