root/platform/ixus50_sd400/kbd.c

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

DEFINITIONS

This source file includes following definitions.
  1. mykbd_task_proceed
  2. mykbd_task_proceed_2
  3. mykbd_task
  4. wrap_kbd_p1_f
  5. my_kbd_read_keys
  6. usb_power_status_override

   1 #include "lolevel.h"
   2 #include "platform.h"
   3 #include "conf.h"
   4 #include "core.h"
   5 #include "keyboard.h"
   6 #include "kbd_common.h"
   7 
   8 long kbd_new_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
   9 long kbd_prev_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
  10 long kbd_mod_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
  11 
  12 KeyMap keymap[] = {
  13     /* tiny bug: key order matters. see kbd_get_pressed_key()
  14      * for example
  15      */
  16         {1, KEY_UP      , 0x00000020 },
  17         {1, KEY_DOWN    , 0x00000040 },
  18         {1, KEY_LEFT    , 0x00000080 },
  19         {1, KEY_RIGHT   , 0x00000100 },
  20         {1, KEY_SET     , 0x00000200 },
  21         {1, KEY_SHOOT_FULL, 0x00000006 }, // note 6 here!
  22     {1, KEY_SHOOT_FULL_ONLY, 0x00000004 },
  23         {1, KEY_SHOOT_HALF, 0x00000002 },
  24         {1, KEY_ZOOM_IN , 0x00000008 },
  25         {1, KEY_ZOOM_OUT        , 0x00000010 },
  26         {1, KEY_MENU    , 0x00000400 },
  27         {1, KEY_DISPLAY , 0x00000800 },
  28         {1, KEY_PRINT   , 0x00002000 },
  29         {0, 0, 0 }
  30 };
  31 
  32 #define NEW_SS (0x2000)
  33 
  34 static char kbd_stack[NEW_SS];
  35 
  36 long __attribute__((naked)) wrap_kbd_p1_f();
  37 void __attribute__((naked,noinline)) mykbd_task_proceed_2();
  38 extern void h_kbd_p2_f();
  39 
  40 
  41 static void __attribute__((noinline)) mykbd_task_proceed()
  42 {
  43     asm volatile(
  44                  "STMFD   SP!, {R4,LR}\n"
  45                  "B       mykbd_task_proceed_2\n"
  46         );
  47 }
  48 
  49 
  50 
  51 // function above  aDerror0x02x0x0
  52 void __attribute__((noinline)) mykbd_task_proceed_2()
  53 {
  54     asm volatile(
  55 "loc_FF828CCC:\n"
  56                  "MOV     R0, #0xA\n"
  57                  "BL      _SleepTask\n"
  58                  "BL      wrap_kbd_p1_f\n"
  59                  "CMP     R0, #1\n"
  60                  "BNE     loc_FF828CCC\n"
  61                  "B       h_kbd_p2_f\n"
  62         );
  63 }
  64 
  65 
  66 void __attribute__((naked,noinline))
  67 mykbd_task(long ua, long ub, long uc, long ud, long ue, long uf)
  68 {
  69     /* WARNING
  70      * Stack pointer manipulation performed here!
  71      * This means (but not limited to):
  72      *  function arguments destroyed;
  73      *  function CAN NOT return properly;
  74      *  MUST NOT call or use stack variables before stack
  75      *  is setup properly;
  76      *
  77      */
  78 
  79     register int i;
  80     register long *newstack;
  81 
  82     newstack = (void*)kbd_stack;
  83 
  84     for (i=0;i<NEW_SS/4;i++)
  85         newstack[i]=0xdededede;
  86 
  87     asm volatile (
  88         "MOV    SP, %0"
  89         :: "r"(((char*)newstack)+NEW_SS)
  90         : "memory"
  91     );
  92 
  93     mykbd_task_proceed();
  94 
  95     /* function can be modified to restore SP here...
  96      */
  97 
  98     _ExitTask();
  99 }
 100 
 101 
 102 // function below aDerror0x02x0x0
 103 long __attribute__((naked,noinline)) wrap_kbd_p1_f()
 104 {
 105 //    kbd_prev_state[0] = kbd_new_state[0];
 106     kbd_prev_state[1] = kbd_new_state[1];
 107 //    kbd_prev_state[2] = kbd_new_state[2];
 108 
 109     asm volatile(
 110                  "STMFD   SP!, {R4-R10,LR}\n"
 111                  "LDR     R4, =physw_status-0x10\n"
 112                  "SUB     SP, SP, #0x18\n"
 113                  "BL      _kbd_p1_1\n"
 114                  "BL      _kbd_p1_2\n"
 115                  "MOV     R0, #0x32\n"
 116                  "BL      _kbd_p1_3\n"
 117                  "MOV     R0, R4\n"
 118                  "BL      _platformsub_kbd_fetch_data_my\n"
 119                  "B       _kbd_p1_f_cont\n"
 120 
 121     );
 122     return 0; // shut up the compiler
 123 }
 124 
 125 // functions below called from assembler in boot.c
 126 long my_kbd_read_keys(long x)
 127 {
 128  kbd_new_state[1]=x & 0xFFFF;
 129  if (kbd_process() == 0) return x; else return (kbd_new_state[1]&~KEYS_MASK1) | (kbd_mod_state[1] & KEYS_MASK1);
 130 }
 131 
 132 extern int forced_usb_port;
 133 int usb_power_status_override(int status){
 134     if (forced_usb_port) {
 135         return status | USB_MASK;
 136     }
 137         if (conf.remote_enable) {
 138                 return status &~USB_MASK;
 139         }
 140     return status;
 141 }

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