L4Re Operating System Framework – Interface and Usage Documentation
Loading...
Searching...
No Matches
cmd_control
1// -*- Mode: C++ -*-
2// vim:ft=cpp
3/*
4 * Copyright (C) 2016 Kernkonzept GmbH.
5 * Author(s): Sarah Hoffmann <sarah.hoffmann@kernkonzept.com>
6 *
7 * This file is distributed under the terms of the GNU General Public
8 * License, version 2. Please see the COPYING-GPL-2 file for details.
9 */
10#pragma once
11
12#include <l4/sys/cxx/ipc_epiface>
13#include <l4/sys/cxx/ipc_string>
14
15namespace L4Re { namespace Ned {
16
17/**
18 * Direct control interface for Ned.
19 */
20class Cmd_control : public L4::Kobject_0t<Cmd_control>
21{
22 L4_INLINE_RPC_NF(long, execute, (L4::Ipc::String<> cmd,
23 L4::Ipc::Array<char> &result));
24
25public:
26 /**
27 * Execute the given Lua code.
28 *
29 * \param[in] cmd String with Lua code to execute.
30 *
31 * \retval L4_EOK Code was successfully executed.
32 * \retval -L4_EINVAL Code could not be parsed.
33 * \retval -L4_EIO Error during code execution.
34 *
35 * The code is executed using the global Lua state of ned
36 * which is retained between successive calls to execute.
37 * Thus you may define data in one call to execute and use
38 * it in a subsequent call.
39 *
40 * This function does not return any results from the execution
41 * of the Lua code itself.
42 */
43 long execute(L4::Ipc::String<> cmd) noexcept
44 {
45 L4::Ipc::Array<char> res(0, NULL);
46 return execute_t::call(c(), cmd, res);
47 }
48
49 /**
50 * Execute the given Lua code.
51 *
52 * \param[in] cmd String with Lua code to execute.
53 * \param[out] result The first return value of the Lua code block
54 * as string.
55 *
56 * \retval L4_EOK Code was successfully executed.
57 * \retval -L4_EINVAL Code could not be parsed.
58 * \retval -L4_EIO Error during code execution.
59 *
60 * The code is executed using the global Lua state of ned
61 * which is retained between successive calls to execute.
62 * Thus you may define data in one call to execute and use
63 * it in a subsequent call.
64 */
65 long execute(L4::Ipc::String<> cmd,
66 L4::Ipc::String<char> *result) noexcept
67 {
68 L4::Ipc::Array<char> res(result->length, result->data);
69 long r = execute_t::call(c(), cmd, res);
70 if (r >= 0)
71 result->length = res.length;
72 return r;
73 }
74
75 typedef L4::Typeid::Rpcs<execute_t> Rpcs;
76};
77
78} } // namespace