summaryrefslogtreecommitdiff
path: root/cesar/hle/tools/src/rpc.c
diff options
context:
space:
mode:
authorNicolas Schodet2011-01-12 18:10:04 +0100
committerNicolas Schodet2011-01-14 10:55:43 +0100
commit9d20b2faa56cb55858716004c7770bba186dd2ed (patch)
tree7b4414a6dcf9e2295c2bfbdc12313e121d2202ec /cesar/hle/tools/src/rpc.c
parenta94edc0e6abc8ec1230fa64866e101f41b0ddaa3 (diff)
cesar/hle/tools: add basic RPC message handling, closes #2209
Diffstat (limited to 'cesar/hle/tools/src/rpc.c')
-rw-r--r--cesar/hle/tools/src/rpc.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/cesar/hle/tools/src/rpc.c b/cesar/hle/tools/src/rpc.c
new file mode 100644
index 0000000000..78f0b434d5
--- /dev/null
+++ b/cesar/hle/tools/src/rpc.c
@@ -0,0 +1,56 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2011 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file hle/tools/src/rpc.c
+ * \brief HLE Remote Procedure Call.
+ * \ingroup hle
+ */
+#include "common/std.h"
+#include "hle/tools/tools.h"
+
+#include "hal/hle/ipmbox.h"
+#include "hal/hle/defs.h"
+#include "inc/context.h"
+#include "inc/rpc.h"
+
+/**
+ * Send RPC response.
+ * \param ctx HLE tools context
+ * \param length length of data in buffer
+ * \param more_data true if another buffer as to be sent
+ * \param cookie received cookie
+ * \param buffer received buffer
+ */
+static void
+hle_tools_rpc_send (hle_tools_t *ctx, uint length, bool more_data,
+ uint cookie, u32 *buffer)
+{
+ dbg_assert (ctx);
+ dbg_assert (buffer);
+ u32 msg[2];
+ msg[0] = BF_FILL (IPMBOX_REG,
+ (MSG_TYPE, HLE_MSG_TYPE_RPC),
+ (MSG_LENGTH, COUNT (msg) - 1),
+ (PARAM_RPC_FORWARD_LENGTH, length),
+ (PARAM_RPC_MORE_DATA, more_data),
+ (PARAM_RPC_COOKIE, cookie));
+ msg[1] = (u32) buffer;
+ ipmbox_tx (ctx->ipmbox, msg, COUNT (msg));
+}
+
+void
+hle_tools_rpc_recv (hle_tools_t *ctx, uint forward_length,
+ uint reverse_length, uint cookie, u32 *buffer)
+{
+ dbg_assert (ctx);
+ dbg_assert (buffer);
+ /* Very simple system for the moment, reply and crash. */
+ hle_tools_rpc_send (ctx, 0, false, cookie, buffer);
+ dbg_fatal ("fatal rpc");
+}
+