summaryrefslogtreecommitdiff
path: root/cesar/hle/tools/src
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
parenta94edc0e6abc8ec1230fa64866e101f41b0ddaa3 (diff)
cesar/hle/tools: add basic RPC message handling, closes #2209
Diffstat (limited to 'cesar/hle/tools/src')
-rw-r--r--cesar/hle/tools/src/rpc.c56
-rw-r--r--cesar/hle/tools/src/tools.c10
2 files changed, 66 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");
+}
+
diff --git a/cesar/hle/tools/src/tools.c b/cesar/hle/tools/src/tools.c
index cbc2625560..ac6bd1776d 100644
--- a/cesar/hle/tools/src/tools.c
+++ b/cesar/hle/tools/src/tools.c
@@ -16,6 +16,7 @@
#include "hal/hle/defs.h"
#include "inc/context.h"
#include "inc/debug_dump.h"
+#include "inc/rpc.h"
/** Global context. */
hle_tools_t hle_tools_global;
@@ -45,6 +46,15 @@ hle_tools_recv_msg (hle_tools_t *ctx, const u32 *msg, uint length)
hle_tools_debug_dump_send_buffer (ctx->ipmbox, (u32 *) msg[1], 0);
break;
#endif
+#if CONFIG_HLE_TOOLS_RPC
+ case HLE_MSG_TYPE_RPC:
+ hle_tools_rpc_recv (
+ ctx,
+ BF_GET (IPMBOX_REG__PARAM_RPC_FORWARD_LENGTH, msg[0]),
+ BF_GET (IPMBOX_REG__PARAM_RPC_REVERSE_LENGTH_KB, msg[0]) * 1024,
+ BF_GET (IPMBOX_REG__PARAM_RPC_COOKIE, msg[0]), (u32 *) msg[1]);
+ break;
+#endif
default:
/* Ignore message. */
break;