1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/pkg/devices/cpm/src/server/cpm-server.cc Sun May 13 01:34:16 2018 +0200
1.3 @@ -0,0 +1,69 @@
1.4 +/*
1.5 + * Common CPM server functionality.
1.6 + *
1.7 + * (c) 2018 Paul Boddie <paul@boddie.org.uk>
1.8 + *
1.9 + * This program is free software; you can redistribute it and/or
1.10 + * modify it under the terms of the GNU General Public License as
1.11 + * published by the Free Software Foundation; either version 2 of
1.12 + * the License, or (at your option) any later version.
1.13 + *
1.14 + * This program is distributed in the hope that it will be useful,
1.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.17 + * GNU General Public License for more details.
1.18 + *
1.19 + * You should have received a copy of the GNU General Public License
1.20 + * along with this program; if not, write to the Free Software
1.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor,
1.22 + * Boston, MA 02110-1301, USA
1.23 + */
1.24 +
1.25 +#include "cpm-client.h"
1.26 +#include "cpm-server.h"
1.27 +#include "cpm-ops.h"
1.28 +
1.29 +#include <l4/cxx/ipc_server>
1.30 +#include <l4/re/env>
1.31 +#include <l4/sys/typeinfo_svr>
1.32 +#include <l4/util/util.h>
1.33 +
1.34 +/* Handle invocations. */
1.35 +
1.36 +int
1.37 +Cpm_server::dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios)
1.38 +{
1.39 + l4_msgtag_t tag;
1.40 +
1.41 + (void) obj;
1.42 + ios >> tag;
1.43 +
1.44 + switch (tag.label())
1.45 + {
1.46 + case L4::Meta::Protocol:
1.47 + return L4::Util::handle_meta_request<Cpm_device_interface>(ios);
1.48 +
1.49 + case Cpm_op_set_lcd_frequencies:
1.50 + uint32_t pclk;
1.51 + int multiplier;
1.52 + ios >> pclk;
1.53 + ios >> multiplier;
1.54 + _chip->set_lcd_frequencies(pclk, multiplier);
1.55 + return L4_EOK;
1.56 +
1.57 + case Cpm_op_start_lcd:
1.58 + _chip->start_lcd();
1.59 + return L4_EOK;
1.60 +
1.61 + case Cpm_op_stop_lcd:
1.62 + _chip->stop_lcd();
1.63 + return L4_EOK;
1.64 +
1.65 + case Cpm_op_update_output_frequency:
1.66 + _chip->update_output_frequency();
1.67 + return L4_EOK;
1.68 +
1.69 + default:
1.70 + return -L4_EBADPROTO;
1.71 + }
1.72 +}