1/*  *********************************************************************
2    *  Broadcom Common Firmware Environment (CFE)
3    *
4    *  PC-style keyboard interface		File: KBD_SUBR.C
5    *
6    *  This module converts a stream of scancodes into ASCII
7    *  characters.  The scan codes come from a PC-style
8    *  keyboard.
9    *
10    *  Author:  Mitch Lichtenberg
11    *
12    *********************************************************************
13    *
14    *  Copyright 2000,2001,2002,2003
15    *  Broadcom Corporation. All rights reserved.
16    *
17    *  This software is furnished under license and may be used and
18    *  copied only in accordance with the following terms and
19    *  conditions.  Subject to these conditions, you may download,
20    *  copy, install, use, modify and distribute modified or unmodified
21    *  copies of this software in source and/or binary form.  No title
22    *  or ownership is transferred hereby.
23    *
24    *  1) Any source code used, modified or distributed must reproduce
25    *     and retain this copyright notice and list of conditions
26    *     as they appear in the source file.
27    *
28    *  2) No right is granted to use any trade name, trademark, or
29    *     logo of Broadcom Corporation.  The "Broadcom Corporation"
30    *     name may not be used to endorse or promote products derived
31    *     from this software without the prior written permission of
32    *     Broadcom Corporation.
33    *
34    *  3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
35    *     IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
36    *     WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
37    *     PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
38    *     SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
39    *     PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
40    *     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
41    *     (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
42    *     GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
43    *     BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
44    *     OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
45    *     TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
46    *     THE POSSIBILITY OF SUCH DAMAGE.
47    ********************************************************************* */
48
49
50/*  *********************************************************************
51    *  Constants
52    ********************************************************************* */
53
54#define KEYQUEUELEN	16
55
56#define KBDCMD_RESET	0xFF
57#define KBDCMD_SETLEDS	0xED
58
59/*  *********************************************************************
60    *  Structures
61    ********************************************************************* */
62
63typedef struct keystate_s {
64    int		ks_shiftflags;
65    char	ks_queue[KEYQUEUELEN];
66    int		ks_head;
67    int		ks_tail;
68    int		(*ks_setleds)(struct keystate_s *ks,int leds);
69    void	*ks_ref;
70} keystate_t;
71
72/*  *********************************************************************
73    *  Prototypes
74    ********************************************************************* */
75
76int kbd_read(keystate_t *ks);
77int kbd_inpstat(keystate_t *ks);
78void kbd_init(keystate_t *ks,int (*setleds)(keystate_t *,int),void *ref);
79void kbd_doscan(keystate_t *ks,uint8_t scan);
80#define kbd_getref(x) ((x)->ks_ref)
81
82
83