paul@0 | 1 | /* |
paul@0 | 2 | * Common CPM server functionality. |
paul@0 | 3 | * |
paul@0 | 4 | * (c) 2018 Paul Boddie <paul@boddie.org.uk> |
paul@0 | 5 | * |
paul@0 | 6 | * This program is free software; you can redistribute it and/or |
paul@0 | 7 | * modify it under the terms of the GNU General Public License as |
paul@0 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@0 | 9 | * the License, or (at your option) any later version. |
paul@0 | 10 | * |
paul@0 | 11 | * This program is distributed in the hope that it will be useful, |
paul@0 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@0 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@0 | 14 | * GNU General Public License for more details. |
paul@0 | 15 | * |
paul@0 | 16 | * You should have received a copy of the GNU General Public License |
paul@0 | 17 | * along with this program; if not, write to the Free Software |
paul@0 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@0 | 19 | * Boston, MA 02110-1301, USA |
paul@0 | 20 | */ |
paul@0 | 21 | |
paul@0 | 22 | #include "cpm-client.h" |
paul@0 | 23 | #include "cpm-server.h" |
paul@0 | 24 | #include "cpm-ops.h" |
paul@0 | 25 | |
paul@0 | 26 | #include <l4/cxx/ipc_server> |
paul@0 | 27 | #include <l4/re/env> |
paul@0 | 28 | #include <l4/sys/typeinfo_svr> |
paul@0 | 29 | #include <l4/util/util.h> |
paul@0 | 30 | |
paul@0 | 31 | /* Handle invocations. */ |
paul@0 | 32 | |
paul@0 | 33 | int |
paul@0 | 34 | Cpm_server::dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios) |
paul@0 | 35 | { |
paul@0 | 36 | l4_msgtag_t tag; |
paul@0 | 37 | |
paul@0 | 38 | (void) obj; |
paul@0 | 39 | ios >> tag; |
paul@0 | 40 | |
paul@0 | 41 | switch (tag.label()) |
paul@0 | 42 | { |
paul@0 | 43 | case L4::Meta::Protocol: |
paul@0 | 44 | return L4::Util::handle_meta_request<Cpm_device_interface>(ios); |
paul@0 | 45 | |
paul@0 | 46 | case Cpm_op_set_lcd_frequencies: |
paul@0 | 47 | uint32_t pclk; |
paul@0 | 48 | int multiplier; |
paul@0 | 49 | ios >> pclk; |
paul@0 | 50 | ios >> multiplier; |
paul@0 | 51 | _chip->set_lcd_frequencies(pclk, multiplier); |
paul@0 | 52 | return L4_EOK; |
paul@0 | 53 | |
paul@0 | 54 | case Cpm_op_start_lcd: |
paul@0 | 55 | _chip->start_lcd(); |
paul@0 | 56 | return L4_EOK; |
paul@0 | 57 | |
paul@0 | 58 | case Cpm_op_stop_lcd: |
paul@0 | 59 | _chip->stop_lcd(); |
paul@0 | 60 | return L4_EOK; |
paul@0 | 61 | |
paul@0 | 62 | case Cpm_op_update_output_frequency: |
paul@0 | 63 | _chip->update_output_frequency(); |
paul@0 | 64 | return L4_EOK; |
paul@0 | 65 | |
paul@0 | 66 | default: |
paul@0 | 67 | return -L4_EBADPROTO; |
paul@0 | 68 | } |
paul@0 | 69 | } |