root/platform/a550/debug.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. blink
  2. dbg_start
  3. dbg_stop
  4. dbg_log
  5. dump_rom
  6. go_debug

   1 
   2 #include "stdlib.h"
   3 #include "conf.h"
   4 
   5 void dbg_log(char *str);
   6 
   7 #define LED_PR 0xc0220084
   8 
   9 static void blink(int cnt)
  10 {
  11         volatile long *p=(void*)LED_PR;
  12         int i;
  13 
  14         for(;cnt>0;cnt--){
  15                 p[0]=0x46;
  16 
  17                 for(i=0;i<0x200000;i++){
  18                         asm ("nop\n");
  19                         asm ("nop\n");
  20                 }
  21                 p[0]=0x44;
  22                 for(i=0;i<0x200000;i++){
  23                         asm ("nop\n");
  24                         asm ("nop\n");
  25                 }
  26         }
  27 }
  28 
  29 #define ROMSIZE (4*1024*1024)
  30 
  31 static int dbg_fh = 0;
  32 
  33 void dbg_start() {
  34   if (0 == dbg_fh) {
  35     if ((dbg_fh = open("A/MISC/DEBUG.LOG", O_WRONLY|O_CREAT, 0777)) > 0) {
  36       lseek(dbg_fh, 0, SEEK_END);
  37     }
  38   }
  39 }
  40 
  41 void dbg_stop() {
  42 /*
  43   static int mem_dmp = 0;
  44   if (0 == mem_dmp) {
  45     dbg_log("Memdump: 0x00001900 - (0x02000000-0x1900) -> A/MISC/MEMDMP01.BIN\n");
  46     if ((mem_dmp = open("A/MISC/MEMDMP01.BIN", O_WRONLY|O_CREAT, 0777)) > 0) {
  47       lseek(mem_dmp, 0, SEEK_SET);
  48       write(mem_dmp, (char*)0x00001900, 32*1024*1024-0x1900);
  49       close(mem_dmp);
  50     }
  51     dbg_log("Memdump: 0x10000000 - 0x01000000 -> A/MISC/MEMDMP02.BIN\n");
  52     if ((mem_dmp = open("A/MISC/MEMDMP02.BIN", O_WRONLY|O_CREAT, 0777)) > 0) {
  53       lseek(mem_dmp, 0, SEEK_SET);
  54       write(mem_dmp, (char*)0x10000000, 0x01000000);
  55       close(mem_dmp);
  56     }
  57   }
  58 */
  59   
  60   if (dbg_fh > 0) {
  61     close(dbg_fh);
  62     dbg_fh = 0;
  63   }
  64 }
  65 
  66 void dbg_log(char *str) {
  67   blink(2);
  68   if (dbg_fh > 0) {
  69     write(dbg_fh, str, strlen(str));
  70   }
  71 }
  72 
  73 static int dump_rom() {
  74   volatile int ret = 0;
  75   volatile int fd;
  76 
  77   if ((fd  = open("A/MISC/FW_FFC0.DMP", O_WRONLY|O_CREAT, 0777)) > 0) {
  78     write(fd, (char*)0xFFC00000, ROMSIZE);
  79     close(fd);
  80     ret = 1;
  81   }
  82 
  83   return ret;
  84 }
  85 
  86 void go_debug(long kbd_state[]) {
  87 /*
  88   long ckey = kbd_state[2];
  89   for (; 0 != ckey; ckey /= 2) {
  90     blink(1);
  91   }
  92 */
  93 
  94 /*
  95   blink(2);
  96   if (1 == dump_rom()) {
  97     blink(3);
  98   }
  99   blink(1);
 100 */
 101 }
 102 
 103 

/* [<][>][^][v][top][bottom][index][help] */