root/platform/a540/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   if (dbg_fh > 0) {
  68     write(dbg_fh, str, strlen(str));
  69   }
  70 }
  71 
  72 static int dump_rom() {
  73   volatile int ret = 0;
  74   volatile int fd;
  75 
  76   if ((fd  = open("A/MISC/FW_FFC0.DMP", O_WRONLY|O_CREAT, 0777)) > 0) {
  77     write(fd, (char*)0xFFC00000, ROMSIZE);
  78     close(fd);
  79     ret = 1;
  80   }
  81 
  82   return ret;
  83 }
  84 
  85 void go_debug(long kbd_state[]) {
  86 /*
  87   long ckey = kbd_state[2];
  88   for (; 0 != ckey; ckey /= 2) {
  89     blink(1);
  90   }
  91 */
  92 
  93 /*
  94   blink(2);
  95   if (1 == dump_rom()) {
  96     blink(3);
  97   }
  98   blink(1);
  99 */
 100 }
 101 
 102 

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