root/platform/ixus900_sd900/sub/100c/debug.c

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

DEFINITIONS

This source file includes following definitions.
  1. ttyRead
  2. mytty_nextline
  3. mytty_putc
  4. ttyWrite
  5. replaceConsoleDriver
  6. h_ios_tty_Init

   1 #include "lolevel.h"
   2 #include "stdlib.h"
   3 //#include "core.h"
   4 #include "script.h"
   5 
   6 // A550
   7 /*
   8 static int dump_rom() {
   9   volatile int ret = 0;
  10   volatile int fd;
  11 
  12   if ((fd  = open("A/MISC/FW_FFC0.DMP", O_WRONLY|O_CREAT, 0777)) > 0) {
  13     //write(fd, (char*)0xFFC00000, ROMSIZE);
  14     write(fd, (char*)0xFF810000, ROMSIZE);
  15     close(fd);
  16     ret = 1;
  17   }
  18 
  19   return ret;
  20 }
  21 */
  22 
  23 /*
  24 // tty_Init() (console log)
  25 void __attribute__((naked,noinline)) sub_FF811A0C_my(){
  26     asm volatile (
  27         "MOV     R0, #0x1000\n"
  28         "STR     LR, [SP]!\n"
  29         "BL      sub_FF811474\n"   // tty_StartMsg
  30         "MOV     R1, #0x32\n"
  31         "LDR     R2, =aNull\n"   // change console target ?
  32         "MOV     R0, #0x14\n"
  33         "BL      iosInit\n"
  34         "BL      ttyDrv\n"
  35         "LDR     LR, [SP],#arg_4\n"
  36         "B       sub_FF811874\n"
  37     );
  38 */
  39 
  40 #if 0
  41 //#if CAM_CONSOLE_LOG_ENABLED
  42     extern void msleep(long);
  43 
  44     typedef struct {
  45         long dev_hdr[4];
  46         long opened;
  47         long fill[64];
  48     } MY_DEV;
  49 
  50     #define CONS_W (45)
  51     #define CONS_H (128)
  52 
  53     char console_buf[CONS_H][CONS_W];
  54     long console_buf_line = 0;
  55     long console_buf_line_ptr = 0;
  56 
  57     char cmd[100] = "ShowCameraLog\n\0";
  58     int cons_cmd_ptr = -1;
  59 
  60     void mytty_putc(char c);
  61 
  62     int ttyRead(MY_DEV* tty,  char* buffer, int nBytes) {
  63         int r = 1;
  64 
  65         if (cons_cmd_ptr == -1) {
  66             msleep(2000);
  67             cons_cmd_ptr = 0;
  68         }
  69 
  70         mytty_putc('r');
  71 
  72         if (cmd[cons_cmd_ptr] != 0) {
  73             *buffer = cmd[cons_cmd_ptr];
  74             cons_cmd_ptr++;
  75         } else {
  76             while (cons_cmd_ptr != 0) {
  77                 msleep(10);
  78             }
  79             *buffer = cmd[cons_cmd_ptr];
  80             cons_cmd_ptr++;
  81         }
  82 
  83         return r;
  84     }
  85 
  86     void mytty_nextline() {
  87         int i;
  88 
  89         console_buf_line_ptr=0;
  90         console_buf_line++;
  91         if (console_buf_line>=CONS_H) {
  92             console_buf_line = 0;
  93         }
  94         for (i=0;i<15;i++) {
  95             int l=i+console_buf_line;
  96             if (l>=CONS_H)
  97                 l-=CONS_H;
  98             console_buf[l][0] = 0;
  99         }
 100     }
 101 
 102     void mytty_putc(char c) {
 103         if (c == 0xa) {
 104             mytty_nextline();
 105         } else {
 106             if (console_buf_line_ptr>=(CONS_W-1)){
 107                 mytty_nextline();
 108             }
 109 
 110             console_buf[console_buf_line][console_buf_line_ptr++] = c;
 111             console_buf[console_buf_line][console_buf_line_ptr] = 0;
 112         }
 113     }
 114     //int tyWrite = 0xffcddc40;   // A570IS
 115     int tyWrite = 0xFFB5EC84;   // ROM:FFB5EC84
 116 
 117     //ttyWrite seems to work, Read might be broken
 118     int ttyWrite(MY_DEV* tty,  char* buffer, int nBytes) {
 119         int i;
 120 
 121         for (i=0;i<nBytes;i++){
 122             mytty_putc(buffer[i]);
 123         }
 124 
 125         return ((int(*)(void *p, void *p2, int l))tyWrite)(tty, buffer, nBytes);
 126         //return nBytes;
 127     }
 128 
 129     /*
 130     Referenced from ttyDrv_init as
 131     LDR     R11, =TTY_DRV_NUM
 132     and ttyDevCreate as
 133     LDR     R9, =TTY_DRV_NUM
 134     */
 135     int *TTY_DRV_NUM = (int*)0x00011a44;   // A570IS
 136     //int *TTY_DRV_NUM = (int*)0x876A8;   // ??? ROM:FFB5DC20
 137 
 138     static void replaceConsoleDriver() {
 139         // These function addresses are from ttyDrv_init function call
 140         int f0 = 0xffcdccd0;
 141         int f1 = 0;
 142         int f2 = 0xffcdccd0;
 143         int f3 = 0xffcdcd10;
 144         int f6 = 0xffcdcd54;
 145         int fRead = (int)&ttyRead;
 146         int fWrite = (int)&ttyWrite;
 147         int newdriver_id = _iosDrvInstall((void*)f0, (void*)f1, (void*)f2, (void*)f3, (void*)fRead, (void*)fWrite, (void*)f6);
 148 
 149         *TTY_DRV_NUM = newdriver_id;
 150     }
 151 
 152     // ROM:FF811A0C
 153     void h_ios_tty_Init() {
 154         /*
 155         asm volatile (
 156             "MOV     R0, #0x1000"
 157             "BL      sub_FF811474"
 158 
 159             "MOV     R1, #0x32"
 160             "LDR     R2, =aNull"
 161             "MOV     R0, #0x14"
 162             "BL      iosInit"
 163         );
 164         */
 165         _iosInit(0x14, 0x32, "/null");
 166         replaceConsoleDriver();
 167         /*
 168         asm volatile (
 169             "BL      sub_FF811874"
 170         );
 171         */
 172     }
 173 #endif

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