paul@3 | 1 | /* |
paul@3 | 2 | * Common input event server functionality. |
paul@3 | 3 | * |
paul@3 | 4 | * (c) 2018 Paul Boddie <paul@boddie.org.uk> |
paul@3 | 5 | * |
paul@3 | 6 | * This program is free software; you can redistribute it and/or |
paul@3 | 7 | * modify it under the terms of the GNU General Public License as |
paul@3 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@3 | 9 | * the License, or (at your option) any later version. |
paul@3 | 10 | * |
paul@3 | 11 | * This program is distributed in the hope that it will be useful, |
paul@3 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@3 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@3 | 14 | * GNU General Public License for more details. |
paul@3 | 15 | * |
paul@3 | 16 | * You should have received a copy of the GNU General Public License |
paul@3 | 17 | * along with this program; if not, write to the Free Software |
paul@3 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@3 | 19 | * Boston, MA 02110-1301, USA |
paul@3 | 20 | */ |
paul@3 | 21 | |
paul@3 | 22 | #pragma once |
paul@3 | 23 | |
paul@3 | 24 | #ifdef __cplusplus |
paul@3 | 25 | |
paul@17 | 26 | #include "input-event-client.h" |
paul@17 | 27 | |
paul@3 | 28 | #include <l4/cxx/ipc_server> |
paul@3 | 29 | #include <l4/re/dataspace> |
paul@3 | 30 | #include <l4/re/env> |
paul@3 | 31 | #include <l4/re/event> |
paul@3 | 32 | #include <l4/sys/icu> |
paul@3 | 33 | #include <l4/sys/types.h> |
paul@3 | 34 | |
paul@3 | 35 | /* Server object to provide input event source access. */ |
paul@3 | 36 | |
paul@17 | 37 | class Input_event_server : public L4::Server_object_t<Input_event_interface> |
paul@3 | 38 | { |
paul@3 | 39 | private: |
paul@3 | 40 | L4::Cap<L4Re::Dataspace> _mem; |
paul@3 | 41 | L4::Cap<L4::Irq> _irq; |
paul@3 | 42 | L4Re::Event_buffer _events; |
paul@3 | 43 | |
paul@3 | 44 | public: |
paul@3 | 45 | /* Initialise the server with a capability referencing the exported memory |
paul@3 | 46 | and an event buffer through which events will be communicated. */ |
paul@3 | 47 | |
paul@17 | 48 | explicit Input_event_server(L4::Cap<L4Re::Dataspace> mem, |
paul@3 | 49 | L4Re::Event_buffer events) |
paul@17 | 50 | : _mem(mem), _events(events) |
paul@3 | 51 | { |
paul@3 | 52 | } |
paul@3 | 53 | |
paul@3 | 54 | int dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios); |
paul@3 | 55 | |
paul@3 | 56 | /* Event sending methods. */ |
paul@3 | 57 | |
paul@3 | 58 | void send_event(int type, int code, int value); |
paul@3 | 59 | }; |
paul@3 | 60 | |
paul@3 | 61 | #endif |
paul@3 | 62 | |
paul@3 | 63 | int run(void); |