Subversion Repositories HelenOS-historic

Rev

Rev 1694 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1508 vana 1
/*
2
 * Copyright (C) 2006 Josef Cejka
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
 
1649 cejka 29
/** @addtogroup kbdia64 ia64
30
 * @brief   HelenOS ia64 arch dependent parts of uspace keyboard handler.
31
 * @ingroup  kbd
32
 * @{
33
 */
34
/** @file
35
 */
36
 
1508 vana 37
#include <arch/kbd.h>
38
#include <ipc/ipc.h>
39
#include <sysinfo.h>
1694 palkovsky 40
#include <kbd.h>
41
#include <keys.h>
1508 vana 42
 
1569 vana 43
#define KEY_F1 0x504f1b
44
#define KEY_F2 0x514f1b
45
#define KEY_F3 0x524f1b
46
#define KEY_F4 0x534f1b
47
#define KEY_F5 0x7e35315b1b
48
#define KEY_F6 0x7e37315b1b
49
#define KEY_F7 0x7e38315b1b
50
#define KEY_F8 0x7e39315b1b
51
#define KEY_F9 0x7e30325b1b
52
#define KEY_F10 0x7e31325b1b
53
#define KEY_F11 0x7e33325b1b
54
#define KEY_F12 0x7e34325b1b
55
 
56
 
57
#define FUNCTION_KEYS 0x100
58
 
1508 vana 59
irq_cmd_t ski_cmds[1] = {
1694 palkovsky 60
    { CMD_IA64_GETCHAR, 0, 0, 2 }
1508 vana 61
};
62
 
63
irq_code_t ski_kbd = {
64
    1,
65
    ski_cmds
66
};
67
 
68
int kbd_arch_init(void)
69
{
1740 jermar 70
    if (sysinfo_value("kbd")) {
1508 vana 71
        ipc_register_irq(sysinfo_value("kbd.irq"), &ski_kbd);
1694 palkovsky 72
        return 0;
1508 vana 73
    }  
1694 palkovsky 74
    return 1;
1508 vana 75
}
76
 
1569 vana 77
/*
78
* Please preserve this code (it can be used to determine scancodes)
79
*
80
int to_hex(int v)
1508 vana 81
{
1569 vana 82
    return "0123456789ABCDEF"[v];
83
}
84
*/
85
 
1694 palkovsky 86
int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call)
1569 vana 87
{
88
    static unsigned long long buf=0;
89
    static int count=0;
1645 vana 90
    static int esc_count=0;
1694 palkovsky 91
    int scan_code = IPC_GET_ARG2(*call);
1569 vana 92
 
93
 
94
    /*
1740 jermar 95
     * Please preserve this code (it can be used to determine scancodes)
96
     */
1645 vana 97
    //keybuffer_push(keybuffer, to_hex((scan_code>>4)&0xf));
98
    //keybuffer_push(keybuffer, to_hex(scan_code&0xf));
99
    //keybuffer_push(keybuffer, ' ');
100
    //keybuffer_push(keybuffer, ' ');
101
    //*/
1508 vana 102
 
1740 jermar 103
    if (scan_code) {
104
        buf |= (unsigned long long) scan_code<<(8*(count++));
1645 vana 105
    } else {
106
 
107
 
1740 jermar 108
        if (buf == 0x1b) {
1645 vana 109
            esc_count++;
1740 jermar 110
            if (esc_count == 3) {
111
                __SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE);
1645 vana 112
            }  
113
        } else {
1740 jermar 114
            esc_count = 0;
1645 vana 115
        }
116
 
1740 jermar 117
        if (!(buf & 0xff00)) {
1569 vana 118
            keybuffer_push(keybuffer, buf);
1740 jermar 119
        } else {
120
            switch (buf) {
1569 vana 121
                case KEY_F1:
1740 jermar 122
                    keybuffer_push(keybuffer, FUNCTION_KEYS | 1);
1569 vana 123
                    break;
124
                case KEY_F2:
1740 jermar 125
                    keybuffer_push(keybuffer, FUNCTION_KEYS | 2);
1569 vana 126
                    break;
127
                case KEY_F3:
1740 jermar 128
                    keybuffer_push(keybuffer, FUNCTION_KEYS | 3);
1569 vana 129
                    break;
130
                case KEY_F4:
1740 jermar 131
                    keybuffer_push(keybuffer, FUNCTION_KEYS | 4);
1569 vana 132
                    break;
133
                case KEY_F5:
1740 jermar 134
                    keybuffer_push(keybuffer, FUNCTION_KEYS | 5);
1569 vana 135
                    break;
136
                case KEY_F6:
1740 jermar 137
                    keybuffer_push(keybuffer, FUNCTION_KEYS | 6);
1569 vana 138
                    break;
139
                case KEY_F7:
1740 jermar 140
                    keybuffer_push(keybuffer, FUNCTION_KEYS | 7);
1569 vana 141
                    break;
142
                case KEY_F8:
1740 jermar 143
                    keybuffer_push(keybuffer, FUNCTION_KEYS | 8);
1569 vana 144
                    break;
145
                case KEY_F9:
1740 jermar 146
                    keybuffer_push(keybuffer, FUNCTION_KEYS | 9);
1569 vana 147
                    break;
148
                case KEY_F10:
1740 jermar 149
                    keybuffer_push(keybuffer, FUNCTION_KEYS | 10);
1569 vana 150
                    break;
151
                case KEY_F11:
1740 jermar 152
                    keybuffer_push(keybuffer, FUNCTION_KEYS | 11);
1569 vana 153
                    break;
154
                case KEY_F12:
1740 jermar 155
                    keybuffer_push(keybuffer, FUNCTION_KEYS | 12);
1569 vana 156
                    break;
157
            }
158
        }
1740 jermar 159
        buf = count = 0;
1569 vana 160
    }
161
 
1508 vana 162
    return  1;
163
}
1649 cejka 164
 
165
/**
166
 * @}
167
 */