root/platform/ixus50_sd400/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 
   9 /* Ours stuff */
  10 extern long link_bss_start;
  11 extern long link_bss_end;
  12 extern void boot();
  13 extern void mykbd_task(long ua, long ub, long uc, long ud, long ue, long uf);
  14 
  15 static void core_hook_task_create(__attribute__ ((unused))void *tcb)
  16 {
  17 }
  18 
  19 static void core_hook_task_delete(void *tcb)
  20 {
  21     char *name = (char*)(*(long*)((char*)tcb+0x34));
  22     if (strcmp(name,"tInitFileM")==0) core_spytask_can_start();
  23 }
  24 
  25 
  26 static int stop_hooking;
  27 
  28 static void (*taskprev)(
  29     long p0,    long p1,    long p2,    long p3,    long p4,
  30     long p5,    long p6,    long p7,    long p8,    long p9);
  31 
  32 static void (*taskfsprev)(
  33     long p0,    long p1,    long p2,    long p3,    long p4,
  34     long p5,    long p6,    long p7,    long p8,    long p9);
  35 
  36 
  37 
  38 void spytask(long ua, long ub, long uc, long ud, long ue, long uf)
  39 {
  40     (void)ua; (void)ub; (void)uc; (void)ud; (void)ue; (void)uf;
  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     (void)p0; (void)p1; (void)p2; (void)p3; (void)p4; (void)p5; (void)p6; (void)p7; (void)p8; (void)p9;
  76     capt_seq_task();
  77 }
  78 
  79 static void movie_record_hook(
  80     long p0,    long p1,    long p2,    long p3,    long p4,
  81     long p5,    long p6,    long p7,    long p8,    long p9)
  82 {
  83     (void)p0; (void)p1; (void)p2; (void)p3; (void)p4; (void)p5; (void)p6; (void)p7; (void)p8; (void)p9;
  84     movie_record_task();
  85 }
  86 
  87 
  88 static int my_ncmp(const char *s1, const char *s2, long len)
  89 {
  90     int i;
  91     for (i=0;i<len;i++){
  92         if (s1[i] != s2[i])
  93             return 1;
  94     }
  95     return 0;
  96 }
  97 
  98 void createHook (void *pNewTcb)
  99 {
 100     char *name = (char*)(*(long*)((char*)pNewTcb+0x34));
 101     long *entry = (long*)((char*)pNewTcb+0x74);
 102         
 103         // always hook first task creation
 104     // to create SpyProc
 105     if (!stop_hooking){
 106         taskprev = (void*)(*entry);
 107         *entry = (long)task_start_hook;
 108         stop_hooking = 1;
 109     } else {
 110         // hook/replace another tasks
 111         if (my_ncmp(name, "tSwitchChe", 10) == 0){
 112             *entry = (long)mykbd_task;
 113         }
 114         if (my_ncmp(name, "tInitFileM", 10) == 0){
 115             taskfsprev = (void*)(*entry);
 116             *entry = (long)task_fs;
 117         }
 118         
 119         if (my_ncmp(name, "tCaptSeqTa", 10) == 0){
 120             *entry = (long)capt_seq_hook;
 121         }
 122         
 123         if (my_ncmp(name, "tMovieRecT", 10) == 0){
 124             *entry = (long)movie_record_hook;
 125         }
 126         
 127         core_hook_task_create(pNewTcb);
 128     }
 129 }
 130 
 131 void deleteHook (void *pTcb)
 132 {
 133     core_hook_task_delete(pTcb);
 134 }
 135 
 136 void startup()
 137 {
 138     long *bss = &link_bss_start;
 139 
 140     // sanity check
 141     if ((long)&link_bss_end > (MEMISOSTART + MEMISOSIZE)){
 142         started();
 143         shutdown();
 144     }
 145 
 146     // initialize .bss senment
 147     while (bss<&link_bss_end)
 148         *bss++ = 0;
 149 
 150     // fill memory with this magic value so we could see what
 151     // parts of memory were or not used
 152     
 153     // update:
 154     // this seems to be required for unknown reason
 155     // or else sryproc startup will fail from
 156     // time to time...
 157 #if 0
 158     long *ptr;
 159     for (ptr=(void*)MEMBASEADDR;((long)ptr)<MEMISOSTART;ptr+=4){
 160         ptr[0]=0x55555555;
 161         ptr[1]=0x55555555;
 162         ptr[2]=0x55555555;
 163         ptr[3]=0x55555555;
 164     }
 165 #endif
 166 
 167     boot();
 168 }
 169 
 170 long get_vbatt_min()
 171 {
 172     return 3500;
 173 }
 174 
 175 long get_vbatt_max()
 176 {
 177     return 4100;
 178 }
 179 
 180 
 181 static const int fl_tbl[] = {5800, 7109, 8462, 10093, 12120, 14421, 17400}; // exif for each zoom step
 182 #define NUM_FL (int)(sizeof(fl_tbl)/sizeof(fl_tbl[0]))
 183 #define CF_EFL 60345 // for 1/2,5" sensor (60345) for 1/1,8" sensor (47946)
 184 
 185 const int zoom_points = NUM_FL;
 186 
 187 int get_effective_focal_length(int zp) {
 188     return (CF_EFL*get_focal_length(zp))/10000;
 189 }
 190 
 191 int get_focal_length(int zp) {
 192     if (zp<0) return fl_tbl[0];
 193     else if (zp>NUM_FL-1) return fl_tbl[NUM_FL-1];
 194     else return fl_tbl[zp];
 195 }
 196 
 197 int get_zoom_x(int zp) {
 198     if (zp<1) return 10;
 199     else if (zp>NUM_FL-1) return fl_tbl[NUM_FL-1]*10/fl_tbl[0];
 200     else return fl_tbl[zp]*10/fl_tbl[0];
 201 }
 202 
 203 
 204 #if 0
 205 int rec_switch_state(void) {
 206         // mode  = (physw_status[0]&0x07)==0x01 ?  MODE_PLAY : MODE_REC;
 207         return (physw_status[0]&0x07)==0x01 ?  0 : 1;
 208 }
 209 #endif
 210 
 211 int rec_mode_active(void) {
 212     return playrec_mode==1;
 213 }

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