mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-20 17:52:52 +00:00
parent
0c3dfbad65
commit
2b6795df78
@ -55,8 +55,9 @@ append config {
|
||||
</start>
|
||||
|
||||
<start name="ps2_drv">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<resource name="RAM" quantum="2M"/>
|
||||
<provides><service name="Input"/></provides>
|
||||
<config verbose_keyboard="no" verbose_mouse="no" verbose_scancodes="no"/>
|
||||
<route>
|
||||
<service name="CAP"> <parent/> </service>
|
||||
<service name="IO_PORT"> <parent/> </service>
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <input/component.h>
|
||||
#include <input/root.h>
|
||||
#include <cap_session/connection.h>
|
||||
#include <os/config.h>
|
||||
#include <os/server.h>
|
||||
|
||||
/* local includes */
|
||||
@ -43,10 +44,20 @@ struct Main
|
||||
Irq_handler ps2_mouse_irq;
|
||||
Irq_handler ps2_keybd_irq;
|
||||
|
||||
bool _check_verbose(const char * verbose) {
|
||||
using namespace Genode;
|
||||
try {
|
||||
return config()->xml_node().attribute(verbose).has_value("yes");
|
||||
} catch (...) { return false; }
|
||||
}
|
||||
|
||||
Main(Server::Entrypoint &ep)
|
||||
: ep(ep), root(ep.rpc_ep(), session),
|
||||
ps2_mouse(*pl050.aux_interface(), session.event_queue()),
|
||||
ps2_keybd(*pl050.kbd_interface(), session.event_queue(), true),
|
||||
ps2_mouse(*pl050.aux_interface(), session.event_queue(),
|
||||
_check_verbose("verbose_mouse")),
|
||||
ps2_keybd(*pl050.kbd_interface(), session.event_queue(), true,
|
||||
_check_verbose("verbose_keyboard"),
|
||||
_check_verbose("verbose_scancodes")),
|
||||
ps2_mouse_irq(ep, PL050_MOUSE_IRQ, pl050.aux_interface(), ps2_mouse),
|
||||
ps2_keybd_irq(ep, PL050_KEYBD_IRQ, pl050.kbd_interface(), ps2_keybd)
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
TARGET = ps2_drv
|
||||
REQUIRES = pl050
|
||||
SRC_CC = main.cc
|
||||
LIBS = base server
|
||||
LIBS = base server config
|
||||
|
||||
INC_DIR += $(PRG_DIR) $(PRG_DIR)/..
|
||||
|
@ -27,12 +27,11 @@ class Ps2_keyboard : public Input_driver
|
||||
{
|
||||
private:
|
||||
|
||||
static const bool verbose = false;
|
||||
static const bool verbose_scan_codes = false;
|
||||
|
||||
Serial_interface &_kbd;
|
||||
Input::Event_queue &_ev_queue;
|
||||
bool _xlate_mode;
|
||||
bool _verbose;
|
||||
bool _verbose_scan_codes;
|
||||
|
||||
/**
|
||||
* Array for tracking the current keyboard state
|
||||
@ -62,7 +61,7 @@ class Ps2_keyboard : public Input_driver
|
||||
/**
|
||||
* Process value received from the keyboard
|
||||
*/
|
||||
virtual void process(unsigned char v) = 0;
|
||||
virtual void process(unsigned char v, bool) = 0;
|
||||
|
||||
/**
|
||||
* Return true if packet is complete
|
||||
@ -122,7 +121,7 @@ class Ps2_keyboard : public Input_driver
|
||||
_key_code = 0;
|
||||
}
|
||||
|
||||
void process(unsigned char v)
|
||||
void process(unsigned char v, bool verbose_scan_codes)
|
||||
{
|
||||
if (verbose_scan_codes)
|
||||
PLOG("process %02x", v);
|
||||
@ -255,7 +254,7 @@ class Ps2_keyboard : public Input_driver
|
||||
_key_code = 0;
|
||||
}
|
||||
|
||||
void process(unsigned char v)
|
||||
void process(unsigned char v, bool verbose_scan_codes)
|
||||
{
|
||||
if (verbose_scan_codes)
|
||||
PLOG("process %02x", v);
|
||||
@ -363,9 +362,12 @@ class Ps2_keyboard : public Input_driver
|
||||
* If 'xlate_mode' is true, we do not attempt to manually switch the
|
||||
* keyboard to scan code set 2 but just decode the scan-code set 1.
|
||||
*/
|
||||
Ps2_keyboard(Serial_interface &kbd, Input::Event_queue &ev_queue, bool xlate_mode)
|
||||
Ps2_keyboard(Serial_interface &kbd, Input::Event_queue &ev_queue,
|
||||
bool xlate_mode, bool verbose, bool verbose_scancodes)
|
||||
:
|
||||
_kbd(kbd), _ev_queue(ev_queue), _xlate_mode(xlate_mode)
|
||||
_kbd(kbd), _ev_queue(ev_queue), _xlate_mode(xlate_mode),
|
||||
_verbose(verbose),
|
||||
_verbose_scan_codes(verbose_scancodes)
|
||||
{
|
||||
for (int i = 0; i <= Input::KEY_MAX; i++)
|
||||
_key_state[i] = false;
|
||||
@ -420,7 +422,7 @@ class Ps2_keyboard : public Input_driver
|
||||
|
||||
void handle_event()
|
||||
{
|
||||
_state_machine->process(_kbd.read());
|
||||
_state_machine->process(_kbd.read(), _verbose_scan_codes);
|
||||
|
||||
if (!_state_machine->ready())
|
||||
return;
|
||||
@ -440,7 +442,7 @@ class Ps2_keyboard : public Input_driver
|
||||
/* remember new key state */
|
||||
_key_state[key_code] = _state_machine->press();
|
||||
|
||||
if (verbose)
|
||||
if (_verbose)
|
||||
PLOG("post %s, key_code = %d\n",
|
||||
press ? "PRESS" : "RELEASE", key_code);
|
||||
|
||||
|
@ -69,13 +69,12 @@ class Ps2_mouse : public Input_driver
|
||||
|
||||
private:
|
||||
|
||||
static const bool verbose = false;
|
||||
|
||||
Serial_interface &_aux;
|
||||
Input::Event_queue &_ev_queue;
|
||||
|
||||
Type _type;
|
||||
|
||||
bool _verbose;
|
||||
bool _button_state[NUM_BUTTONS];
|
||||
|
||||
unsigned char _packet[MAX_PACKET_LEN];
|
||||
@ -103,7 +102,7 @@ class Ps2_mouse : public Input_driver
|
||||
{
|
||||
if (*old_state == new_state) return;
|
||||
|
||||
if (verbose)
|
||||
if (_verbose)
|
||||
Genode::printf("post %s, key_code = %d\n", new_state ? "PRESS" : "RELEASE", key_code);
|
||||
|
||||
_check_for_event_queue_overflow();
|
||||
@ -160,10 +159,11 @@ class Ps2_mouse : public Input_driver
|
||||
|
||||
public:
|
||||
|
||||
Ps2_mouse(Serial_interface &aux, Input::Event_queue &ev_queue)
|
||||
Ps2_mouse(Serial_interface &aux, Input::Event_queue &ev_queue,
|
||||
bool verbose)
|
||||
:
|
||||
_aux(aux),
|
||||
_ev_queue(ev_queue), _type(PS2),
|
||||
_ev_queue(ev_queue), _type(PS2), _verbose(verbose),
|
||||
_packet_len(PS2_PACKET_LEN), _packet_idx(0)
|
||||
{
|
||||
for (unsigned i = 0; i < NUM_BUTTONS; ++i)
|
||||
@ -231,7 +231,7 @@ class Ps2_mouse : public Input_driver
|
||||
/* mirror y axis to make the movement correspond to screen coordinates */
|
||||
rel_y = -rel_y;
|
||||
|
||||
if (verbose)
|
||||
if (_verbose)
|
||||
Genode::printf("post MOTION, rel_x = %d, rel_y = %d\n", rel_x, rel_y);
|
||||
|
||||
_check_for_event_queue_overflow();
|
||||
@ -253,7 +253,7 @@ class Ps2_mouse : public Input_driver
|
||||
/* mirror y axis to make "scroll up" generate positive values */
|
||||
rel_z = -rel_z;
|
||||
|
||||
if (verbose)
|
||||
if (_verbose)
|
||||
Genode::printf("post WHEEL, rel_z = %d\n", rel_z);
|
||||
|
||||
_check_for_event_queue_overflow();
|
||||
|
@ -19,6 +19,7 @@
|
||||
/* os includes */
|
||||
#include <input/component.h>
|
||||
#include <input/root.h>
|
||||
#include <os/config.h>
|
||||
#include <os/server.h>
|
||||
#include <platform_session/connection.h>
|
||||
|
||||
@ -51,14 +52,23 @@ struct Main
|
||||
|
||||
enum { REG_IOPORT_DATA = 0, REG_IOPORT_STATUS};
|
||||
|
||||
bool _check_verbose(const char * verbose) {
|
||||
using namespace Genode;
|
||||
try {
|
||||
return config()->xml_node().attribute(verbose).has_value("yes");
|
||||
} catch (...) { return false; }
|
||||
}
|
||||
|
||||
Main(Server::Entrypoint &ep)
|
||||
: ep(ep), root(ep.rpc_ep(), session),
|
||||
device_ps2(platform.device("PS2")),
|
||||
i8042(device_ps2.io_port(REG_IOPORT_DATA),
|
||||
device_ps2.io_port(REG_IOPORT_STATUS)),
|
||||
ps2_keybd(*i8042.kbd_interface(), session.event_queue(),
|
||||
i8042.kbd_xlate()),
|
||||
ps2_mouse(*i8042.aux_interface(), session.event_queue()),
|
||||
i8042.kbd_xlate(), _check_verbose("verbose_keyboard"),
|
||||
_check_verbose("verbose_scancodes")),
|
||||
ps2_mouse(*i8042.aux_interface(), session.event_queue(),
|
||||
_check_verbose("verbose_mouse")),
|
||||
ps2_keybd_irq(ep, ps2_keybd, device_ps2.irq(0)),
|
||||
ps2_mouse_irq(ep, ps2_mouse, device_ps2.irq(1))
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
TARGET = ps2_drv
|
||||
REQUIRES = x86 ps2
|
||||
SRC_CC = main.cc
|
||||
LIBS = base server
|
||||
LIBS = base server config
|
||||
|
||||
INC_DIR = $(PRG_DIR)/..
|
||||
|
Loading…
x
Reference in New Issue
Block a user