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

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