The Pedigree Project 0.1
kernel/machine/mach_pc/Keyboard.h
1/*
2 * Copyright (c) 2008-2014, Pedigree Developers
3 *
4 * Please see the CONTRIB file in the root of the source tree for a full
5 * list of contributors.
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20#ifndef MACHINE_X86_KEYBOARD_H
21#define MACHINE_X86_KEYBOARD_H
22#include "pedigree/kernel/compiler.h"
23#include "pedigree/kernel/machine/Keyboard.h"
24#include "pedigree/kernel/machine/KeymapManager.h"
25#include "pedigree/kernel/machine/types.h"
26#include "pedigree/kernel/process/Mutex.h"
27#include "pedigree/kernel/process/OwnedThread.h"
28#include "pedigree/kernel/processor/types.h"
29
30#include <config.h>
31
32class Ps2Controller;
33
34#define BUFLEN 256
35
39class X86Keyboard : public Keyboard {
40 public:
41 X86Keyboard(Ps2Controller* controller);
42 virtual ~X86Keyboard();
43
45 virtual void initialise();
46
47 virtual void setDebugState(bool enableDebugState);
48 virtual bool getDebugState();
49
50 virtual char getChar();
51 virtual char getCharNonBlock();
52
53 virtual char getLedState();
54 virtual void setLedState(char state);
55
56 void startReaderThread();
57 void stopReaderThread();
58
59 private:
60 static int readerThreadTrampoline(void*);
61 void readerThread();
62
63 void updateLedState(char state, bool toggle);
64 void handleLedResponse(uint8_t response);
65
67 char scancodeToAscii(uint8_t scancode);
68
71
73 KeymapManager::EscapeState m_Escape;
74
76 irq_id_t m_IrqId;
77
80
81 enum LedCommandState { LedIdle, LedCommandAck, LedDataAck };
82 LedCommandState m_LedCommandState;
83 uint8_t m_LedSent;
84 size_t m_LedRetries;
85 Mutex m_LedLock;
86
89};
90
91#endif
Definition Mutex.h:56
KeymapManager::EscapeState m_Escape
The current escape state.
char m_LedState
Current LED state.
Ps2Controller * m_pPs2Controller
Parent PS/2 controller.
virtual char getLedState()
OwnedThread m_ReaderThread
The controller buffer may block this worker until teardown wakes it.
virtual void setDebugState(bool enableDebugState)
virtual void initialise()
Initialises the device.
virtual char getCharNonBlock()
virtual void setLedState(char state)
char scancodeToAscii(uint8_t scancode)
Converts a scancode into an ASCII character (for use in debug state)
virtual char getChar()