Subversion Repositories HelenOS

Rev

Rev 1649 | Rev 1787 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * Copyright (C) 2006 Martin Decky
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  *
  9.  * - Redistributions of source code must retain the above copyright
  10.  *   notice, this list of conditions and the following disclaimer.
  11.  * - Redistributions in binary form must reproduce the above copyright
  12.  *   notice, this list of conditions and the following disclaimer in the
  13.  *   documentation and/or other materials provided with the distribution.
  14.  * - The name of the author may not be used to endorse or promote products
  15.  *   derived from this software without specific prior written permission.
  16.  *
  17.  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  18.  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  19.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  20.  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  21.  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  22.  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  23.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  24.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  26.  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27.  */
  28.  
  29. /** @addtogroup kbdppc32 ppc32
  30.  * @brief   HelenOS ppc32 arch dependent parts of uspace keyboard handler.
  31.  * @ingroup  kbd
  32.  * @{
  33.  */
  34. /** @file
  35.  */
  36.  
  37. #include <arch/kbd.h>
  38. #include <ipc/ipc.h>
  39. #include <sysinfo.h>
  40. #include <kbd.h>
  41. #include <keys.h>
  42.  
  43. irq_cmd_t cuda_cmds[1] = {
  44.     { CMD_PPC32_GETCHAR, 0, 0, 2 }
  45. };
  46.  
  47. irq_code_t cuda_kbd = {
  48.     1,
  49.     cuda_cmds
  50. };
  51.  
  52.  
  53. #define SPECIAL     255
  54. #define FUNCTION_KEYS 0x100
  55.  
  56.  
  57. static int lchars[0x80] = {
  58.     'a',
  59.     's',
  60.     'd',
  61.     'f',
  62.     'h',
  63.     'g',
  64.     'z',
  65.     'x',
  66.     'c',
  67.     'v',
  68.     SPECIAL,
  69.     'b',
  70.     'q',
  71.     'w',
  72.     'e',
  73.     'r',
  74.     'y',
  75.     't',
  76.     '1',
  77.     '2',
  78.     '3',
  79.     '4',
  80.     '6',
  81.     '5',
  82.     '=',
  83.     '9',
  84.     '7',
  85.     '-',
  86.     '8',
  87.     '0',
  88.     ']',
  89.     'o',
  90.     'u',
  91.     '[',
  92.     'i',
  93.     'p',
  94.     '\n',                 /* Enter */
  95.     'l',
  96.     'j',
  97.     '\'',
  98.     'k',
  99.     ';',
  100.     '\\',
  101.     ',',
  102.     '/',
  103.     'n',
  104.     'm',
  105.     '.',
  106.     '\t',                 /* Tab */
  107.     ' ',
  108.     '`',
  109.     '\b',                 /* Backspace */
  110.     SPECIAL,
  111.     SPECIAL,              /* Escape */
  112.     SPECIAL,              /* Ctrl */
  113.     SPECIAL,              /* Alt */
  114.     SPECIAL,              /* Shift */
  115.     SPECIAL,              /* Caps-Lock */
  116.     SPECIAL,              /* RAlt */
  117.     SPECIAL,              /* Left */
  118.     SPECIAL,              /* Right */
  119.     SPECIAL,              /* Down */
  120.     SPECIAL,              /* Up */
  121.     SPECIAL,
  122.     SPECIAL,
  123.     '.',                  /* Keypad . */
  124.     SPECIAL,
  125.     '*',                  /* Keypad * */
  126.     SPECIAL,
  127.     '+',                  /* Keypad + */
  128.     SPECIAL,
  129.     SPECIAL,              /* NumLock */
  130.     SPECIAL,
  131.     SPECIAL,
  132.     SPECIAL,
  133.     '/',                  /* Keypad / */
  134.     '\n',                 /* Keypad Enter */
  135.     SPECIAL,
  136.     '-',                  /* Keypad - */
  137.     SPECIAL,
  138.     SPECIAL,
  139.     SPECIAL,
  140.     '0',                  /* Keypad 0 */
  141.     '1',                  /* Keypad 1 */
  142.     '2',                  /* Keypad 2 */
  143.     '3',                  /* Keypad 3 */
  144.     '4',                  /* Keypad 4 */
  145.     '5',                  /* Keypad 5 */
  146.     '6',                  /* Keypad 6 */
  147.     '7',                  /* Keypad 7 */
  148.     SPECIAL,
  149.     '8',                  /* Keypad 8 */
  150.     '9',                  /* Keypad 9 */
  151.     SPECIAL,
  152.     SPECIAL,
  153.     SPECIAL,
  154.     (FUNCTION_KEYS | 5),  /* F5 */
  155.     (FUNCTION_KEYS | 6),  /* F6 */
  156.     (FUNCTION_KEYS | 7),  /* F7 */
  157.     (FUNCTION_KEYS | 3),  /* F3 */
  158.     (FUNCTION_KEYS | 8),  /* F8 */
  159.     (FUNCTION_KEYS | 9),  /* F9 */
  160.     SPECIAL,
  161.     (FUNCTION_KEYS | 11), /* F11 */
  162.     SPECIAL,
  163.     (FUNCTION_KEYS | 13), /* F13 */
  164.     SPECIAL,
  165.     SPECIAL,              /* ScrollLock */
  166.     SPECIAL,
  167.     (FUNCTION_KEYS | 10), /* F10 */
  168.     SPECIAL,
  169.     (FUNCTION_KEYS | 12), /* F12 */
  170.     SPECIAL,
  171.     SPECIAL,              /* Pause */
  172.     SPECIAL,              /* Insert */
  173.     SPECIAL,              /* Home */
  174.     SPECIAL,              /* PageUp */
  175.     SPECIAL,              /* Delete */
  176.     (FUNCTION_KEYS | 4),  /* F4 */
  177.     SPECIAL,              /* End */
  178.     (FUNCTION_KEYS | 2),  /* F2 */
  179.     SPECIAL,              /* PageDown */
  180.     (FUNCTION_KEYS | 1)   /* F1 */
  181. };
  182.  
  183.  
  184. int kbd_arch_init(void)
  185. {
  186.     return ipc_register_irq(sysinfo_value("cuda.irq"), &cuda_kbd);
  187. }
  188.  
  189.  
  190. int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call)
  191. {
  192.     int param = IPC_GET_ARG2(*call);
  193.  
  194.     if (param != -1) {
  195.         uint8_t scancode = (uint8_t) param;
  196.    
  197.         if ((scancode & 0x80) != 0x80) {
  198.             int key = lchars[scancode & 0x7f];
  199.            
  200.             if (key != SPECIAL)
  201.                 keybuffer_push(keybuffer, key);
  202.         }
  203.     }
  204.    
  205.     return 1;
  206. }
  207.  
  208. /** @}
  209.  */
  210.  
  211.