root/platform/ixus700_sd500/main.c

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

DEFINITIONS

This source file includes following definitions.
  1. core_hook_task_create
  2. core_hook_task_delete
  3. spytask
  4. task_start_hook
  5. remount_filesystem
  6. task_fs
  7. capt_seq_hook
  8. movie_record_hook
  9. my_ncmp
  10. createHook
  11. deleteHook
  12. startup
  13. get_vbatt_min
  14. get_vbatt_max
  15. get_effective_focal_length
  16. get_focal_length
  17. get_zoom_x
  18. rec_switch_state
  19. rec_mode_active

   1 #define VBATT_DEFAULT_MIN (3500)
   2 #define VBATT_DEFAULT_MAX (4100)
   3 
   4 #include "lolevel.h"
   5 #include "platform.h"
   6 #include "core.h"
   7 #include "keyboard.h"
   8 #include "stdlib.h"
   9 
  10 /* Ours stuff */
  11 extern long link_bss_start;
  12 extern long link_bss_end;
  13 extern void boot();
  14 extern void mykbd_task(long ua, long ub, long uc, long ud, long ue, long uf);
  15 
  16 static void core_hook_task_create(void *tcb)
  17 {
  18 }
  19 
  20 static void core_hook_task_delete(void *tcb)
  21 {
  22     char *name = (char*)(*(long*)((char*)tcb+0x34));
  23     if (strcmp(name,"tInitFileM")==0) core_spytask_can_start();
  24 }
  25 
  26 
  27 static int stop_hooking;
  28 
  29 static void (*taskprev)(
  30     long p0,    long p1,    long p2,    long p3,    long p4,
  31     long p5,    long p6,    long p7,    long p8,    long p9);
  32 
  33 static void (*taskfsprev)(
  34     long p0,    long p1,    long p2,    long p3,    long p4,
  35     long p5,    long p6,    long p7,    long p8,    long p9);
  36 
  37 
  38 
  39 void spytask(long ua, long ub, long uc, long ud, long ue, long uf)
  40 {
  41     core_spytask();
  42 }
  43 
  44 
  45 static void task_start_hook(
  46     long p0,    long p1,    long p2,    long p3,    long p4,
  47     long p5,    long p6,    long p7,    long p8,    long p9)
  48 {
  49     _CreateTask("SpyTask", 0x19, 0x2000, spytask, 0);
  50 
  51     taskprev(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9 );
  52 }
  53 
  54 
  55 static void remount_filesystem()
  56 {
  57     _Unmount_FileSystem();
  58     _Mount_FileSystem();
  59 }
  60 
  61 
  62 static void task_fs(
  63     long p0,    long p1,    long p2,    long p3,    long p4,
  64     long p5,    long p6,    long p7,    long p8,    long p9)
  65 {
  66     remount_filesystem();
  67     taskfsprev(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9 );
  68 }
  69 
  70 
  71 static void capt_seq_hook(
  72     long p0,    long p1,    long p2,    long p3,    long p4,
  73     long p5,    long p6,    long p7,    long p8,    long p9)
  74 {
  75     capt_seq_task();
  76 }
  77 
  78 static void movie_record_hook(
  79     long p0,    long p1,    long p2,    long p3,    long p4,
  80     long p5,    long p6,    long p7,    long p8,    long p9)
  81 {
  82     movie_record_task();
  83 }
  84 
  85 
  86 static int my_ncmp(const char *s1, const char *s2, long len)
  87 {
  88     int i;
  89     for (i=0;i<len;i++){
  90         if (s1[i] != s2[i])
  91             return 1;
  92     }
  93     return 0;
  94 }
  95 
  96 void createHook (void *pNewTcb)
  97 {
  98     char *name = (char*)(*(long*)((char*)pNewTcb+0x34));
  99     long *entry = (long*)((char*)pNewTcb+0x74);
 100 
 101     // always hook first task creation
 102     // to create SpyProc
 103     if (!stop_hooking){
 104         taskprev = (void*)(*entry);
 105         *entry = (long)task_start_hook;
 106         stop_hooking = 1;
 107     } else {
 108         // hook/replace another tasks
 109         if (my_ncmp(name, "tSwitchChe", 10) == 0){
 110             *entry = (long)mykbd_task;
 111         }
 112         if (my_ncmp(name, "tInitFileM", 10) == 0){
 113          //   taskfsprev = (void*)(*entry);
 114             *entry = (long)init_file_modules_task;
 115         }
 116 
 117         if (my_ncmp(name, "tCaptSeqTa", 10) == 0){
 118             *entry = (long)capt_seq_hook;
 119         }
 120 
 121         if (my_ncmp(name, "tMovieRecT", 10) == 0){
 122             *entry = (long)movie_record_hook;
 123         }
 124 
 125         core_hook_task_create(pNewTcb);
 126     }
 127 }
 128 
 129 void deleteHook (void *pTcb)
 130 {
 131     core_hook_task_delete(pTcb);
 132 }
 133 
 134 void startup()
 135 {
 136     long *bss = &link_bss_start;
 137 
 138     // sanity check
 139     if ((long)&link_bss_end > (MEMISOSTART + MEMISOSIZE)){
 140         started();
 141         shutdown();
 142     }
 143 
 144     // initialize .bss senment
 145     while (bss<&link_bss_end)
 146         *bss++ = 0;
 147 
 148     // fill memory with this magic value so we could see what
 149     // parts of memory were or not used
 150     
 151     // update:
 152     // this seems to be required for unknown reason
 153     // or else sryproc startup will fail from
 154     // time to time...
 155 #if 0
 156     long *ptr;
 157     for (ptr=(void*)MEMBASEADDR;((long)ptr)<MEMISOSTART;ptr+=4){
 158         ptr[0]=0x55555555;
 159         ptr[1]=0x55555555;
 160         ptr[2]=0x55555555;
 161         ptr[3]=0x55555555;
 162     }
 163 #endif
 164 
 165     boot();
 166 }
 167 
 168 long get_vbatt_min()
 169 {
 170     return 3500;
 171 }
 172 
 173 long get_vbatt_max()
 174 {
 175     return 4100;
 176 }
 177 
 178 
 179 static const int fl_tbl[] = {7700,9030,10490,12520,15600,18780,23100};
 180 #define NUM_FL (sizeof(fl_tbl)/sizeof(fl_tbl[0]))
 181 #define CF_EFL 48052
 182 
 183 const int zoom_points = NUM_FL;
 184 
 185 int get_effective_focal_length(int zp) {
 186     return (CF_EFL*get_focal_length(zp))/10000;
 187 }
 188 
 189 int get_focal_length(int zp) {
 190     if (zp<0) return fl_tbl[0];
 191     else if (zp>NUM_FL-1) return fl_tbl[NUM_FL-1];
 192     else return fl_tbl[zp];
 193 }
 194 
 195 int get_zoom_x(int zp) {
 196     if (zp<1) return 10;
 197     else if (zp>NUM_FL-1) return fl_tbl[NUM_FL-1]*10/fl_tbl[0];
 198     else return fl_tbl[zp]*10/fl_tbl[0];
 199 }
 200 
 201 
 202 #if 0
 203 int rec_switch_state(void) {
 204 //    mode  = (physw_status[0]&0x0F)==0x0B ?  MODE_PLAY : MODE_REC;
 205         return (physw_status[0]&0x0F)!=0x0B;
 206 }
 207 #endif
 208 
 209 int rec_mode_active(void) {
 210     return (playrec_mode==1);
 211 }

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