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

   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     (void)ua; (void)ub; (void)uc; (void)ud; (void)ue; (void)uf;
  70     /* WARNING
  71      * Stack pointer manipulation performed here!
  72      * This means (but not limited to):
  73      *  function arguments destroyed;
  74      *  function CAN NOT return properly;
  75      *  MUST NOT call or use stack variables before stack
  76      *  is setup properly;
  77      *
  78      */
  79 
  80     register int i;
  81     register long *newstack;
  82 
  83     newstack = (void*)kbd_stack;
  84 
  85     for (i=0;i<NEW_SS/4;i++)
  86         newstack[i]=0xdededede;
  87 
  88     asm volatile (
  89         "MOV    SP, %0"
  90         :: "r"(((char*)newstack)+NEW_SS)
  91         : "memory"
  92     );
  93 
  94     mykbd_task_proceed();
  95 
  96     /* function can be modified to restore SP here...
  97      */
  98 
  99     _ExitTask();
 100 }
 101 
 102 
 103 // function below aDerror0x02x0x0
 104 long __attribute__((naked,noinline)) wrap_kbd_p1_f()
 105 {
 106 //    kbd_prev_state[0] = kbd_new_state[0];
 107     kbd_prev_state[1] = kbd_new_state[1];
 108 //    kbd_prev_state[2] = kbd_new_state[2];
 109 
 110     asm volatile(
 111                  "STMFD   SP!, {R4-R10,LR}\n"
 112                  "LDR     R4, =physw_status-0x10\n"
 113                  "SUB     SP, SP, #0x18\n"
 114                  "BL      _kbd_p1_1\n"
 115                  "BL      _kbd_p1_2\n"
 116                  "MOV     R0, #0x32\n"
 117                  "BL      _kbd_p1_3\n"
 118                  "MOV     R0, R4\n"
 119                  "BL      _platformsub_kbd_fetch_data_my\n"
 120                  "B       _kbd_p1_f_cont\n"
 121 
 122     );
 123     return 0; // shut up the compiler
 124 }
 125 
 126 // functions below called from assembler in boot.c
 127 long my_kbd_read_keys(long x)
 128 {
 129  kbd_new_state[1]=x & 0xFFFF;
 130  if (kbd_process() == 0) return x; else return (kbd_new_state[1]&~KEYS_MASK1) | (kbd_mod_state[1] & KEYS_MASK1);
 131 }

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