summaryrefslogtreecommitdiff
path: root/boot-proxy-exc/notifyServer.c
diff options
context:
space:
mode:
authorroot <root@(null).(none)>2009-05-03 17:20:00 +0200
committerroot <root@(null).(none)>2009-05-03 17:20:00 +0200
commite0faf22f31c48fb27b43c1825897d26e58feafc4 (patch)
tree65a09372b31e08a3a865bd0a88cd2718bafcd643 /boot-proxy-exc/notifyServer.c
This is my initial working version.
There is a bug in boot in this version: subhurd sometimes cannot boot.
Diffstat (limited to 'boot-proxy-exc/notifyServer.c')
-rw-r--r--boot-proxy-exc/notifyServer.c353
1 files changed, 353 insertions, 0 deletions
diff --git a/boot-proxy-exc/notifyServer.c b/boot-proxy-exc/notifyServer.c
new file mode 100644
index 00000000..7965461a
--- /dev/null
+++ b/boot-proxy-exc/notifyServer.c
@@ -0,0 +1,353 @@
+/* Module notify */
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE 1
+#endif
+
+#define EXPORT_BOOLEAN
+#include <mach/boolean.h>
+#include <mach/kern_return.h>
+#include <mach/message.h>
+#include <mach/mig_errors.h>
+#include <mach/mig_support.h>
+
+#ifndef mig_internal
+#define mig_internal static
+#endif
+
+#ifndef mig_external
+#define mig_external
+#endif
+
+#ifndef TypeCheck
+#define TypeCheck 1
+#endif
+
+#ifndef UseExternRCSId
+#define UseExternRCSId 1
+#endif
+
+#define BAD_TYPECHECK(type, check) ({\
+ union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\
+ _t.t = *(type); _c.t = *(check); _t.w != _c.w; })
+#define msgh_request_port msgh_local_port
+#define MACH_MSGH_BITS_REQUEST(bits) MACH_MSGH_BITS_LOCAL(bits)
+#define msgh_reply_port msgh_remote_port
+#define MACH_MSGH_BITS_REPLY(bits) MACH_MSGH_BITS_REMOTE(bits)
+
+#include <mach/std_types.h>
+
+/* SimpleRoutine mach_notify_port_deleted */
+mig_internal void _Xmach_notify_port_deleted
+ (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
+{
+ typedef struct {
+ mach_msg_header_t Head;
+ mach_msg_type_t nameType;
+ mach_port_t name;
+ } Request;
+
+ typedef struct {
+ mach_msg_header_t Head;
+ mach_msg_type_t RetCodeType;
+ kern_return_t RetCode;
+ } Reply;
+
+ register Request *In0P = (Request *) InHeadP;
+ register Reply *OutP = (Reply *) OutHeadP;
+ mig_external kern_return_t do_mach_notify_port_deleted
+ (mach_port_t notify, mach_port_t name);
+
+ auto const mach_msg_type_t nameCheck = {
+ /* msgt_name = */ 15,
+ /* msgt_size = */ 32,
+ /* msgt_number = */ 1,
+ /* msgt_inline = */ TRUE,
+ /* msgt_longform = */ FALSE,
+ /* msgt_deallocate = */ FALSE,
+ /* msgt_unused = */ 0
+ };
+
+#if TypeCheck
+ if ((In0P->Head.msgh_size != 32) ||
+ (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))
+ { OutP->RetCode = MIG_BAD_ARGUMENTS; return; }
+#endif /* TypeCheck */
+
+#if TypeCheck
+ if (BAD_TYPECHECK(&In0P->nameType, &nameCheck))
+ { OutP->RetCode = MIG_BAD_ARGUMENTS; return; }
+#endif /* TypeCheck */
+
+ OutP->RetCode = do_mach_notify_port_deleted(In0P->Head.msgh_request_port, In0P->name);
+}
+
+/* SimpleRoutine mach_notify_msg_accepted */
+mig_internal void _Xmach_notify_msg_accepted
+ (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
+{
+ typedef struct {
+ mach_msg_header_t Head;
+ mach_msg_type_t nameType;
+ mach_port_t name;
+ } Request;
+
+ typedef struct {
+ mach_msg_header_t Head;
+ mach_msg_type_t RetCodeType;
+ kern_return_t RetCode;
+ } Reply;
+
+ register Request *In0P = (Request *) InHeadP;
+ register Reply *OutP = (Reply *) OutHeadP;
+ mig_external kern_return_t do_mach_notify_msg_accepted
+ (mach_port_t notify, mach_port_t name);
+
+ auto const mach_msg_type_t nameCheck = {
+ /* msgt_name = */ 15,
+ /* msgt_size = */ 32,
+ /* msgt_number = */ 1,
+ /* msgt_inline = */ TRUE,
+ /* msgt_longform = */ FALSE,
+ /* msgt_deallocate = */ FALSE,
+ /* msgt_unused = */ 0
+ };
+
+#if TypeCheck
+ if ((In0P->Head.msgh_size != 32) ||
+ (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))
+ { OutP->RetCode = MIG_BAD_ARGUMENTS; return; }
+#endif /* TypeCheck */
+
+#if TypeCheck
+ if (BAD_TYPECHECK(&In0P->nameType, &nameCheck))
+ { OutP->RetCode = MIG_BAD_ARGUMENTS; return; }
+#endif /* TypeCheck */
+
+ OutP->RetCode = do_mach_notify_msg_accepted(In0P->Head.msgh_request_port, In0P->name);
+}
+
+/* SimpleRoutine mach_notify_port_destroyed */
+mig_internal void _Xmach_notify_port_destroyed
+ (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
+{
+ typedef struct {
+ mach_msg_header_t Head;
+ mach_msg_type_t rightsType;
+ mach_port_t rights;
+ } Request;
+
+ typedef struct {
+ mach_msg_header_t Head;
+ mach_msg_type_t RetCodeType;
+ kern_return_t RetCode;
+ } Reply;
+
+ register Request *In0P = (Request *) InHeadP;
+ register Reply *OutP = (Reply *) OutHeadP;
+ mig_external kern_return_t do_mach_notify_port_destroyed
+ (mach_port_t notify, mach_port_t rights);
+
+ auto const mach_msg_type_t rightsCheck = {
+ /* msgt_name = */ 16,
+ /* msgt_size = */ 32,
+ /* msgt_number = */ 1,
+ /* msgt_inline = */ TRUE,
+ /* msgt_longform = */ FALSE,
+ /* msgt_deallocate = */ FALSE,
+ /* msgt_unused = */ 0
+ };
+
+#if TypeCheck
+ if ((In0P->Head.msgh_size != 32) ||
+ !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))
+ { OutP->RetCode = MIG_BAD_ARGUMENTS; return; }
+#endif /* TypeCheck */
+
+#if TypeCheck
+ if (BAD_TYPECHECK(&In0P->rightsType, &rightsCheck))
+ { OutP->RetCode = MIG_BAD_ARGUMENTS; return; }
+#endif /* TypeCheck */
+
+ OutP->RetCode = do_mach_notify_port_destroyed(In0P->Head.msgh_request_port, In0P->rights);
+}
+
+/* SimpleRoutine mach_notify_no_senders */
+mig_internal void _Xmach_notify_no_senders
+ (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
+{
+ typedef struct {
+ mach_msg_header_t Head;
+ mach_msg_type_t mscountType;
+ mach_port_mscount_t mscount;
+ } Request;
+
+ typedef struct {
+ mach_msg_header_t Head;
+ mach_msg_type_t RetCodeType;
+ kern_return_t RetCode;
+ } Reply;
+
+ register Request *In0P = (Request *) InHeadP;
+ register Reply *OutP = (Reply *) OutHeadP;
+ mig_external kern_return_t do_mach_notify_no_senders
+ (mach_port_t notify, mach_port_mscount_t mscount);
+
+ auto const mach_msg_type_t mscountCheck = {
+ /* msgt_name = */ 2,
+ /* msgt_size = */ 32,
+ /* msgt_number = */ 1,
+ /* msgt_inline = */ TRUE,
+ /* msgt_longform = */ FALSE,
+ /* msgt_deallocate = */ FALSE,
+ /* msgt_unused = */ 0
+ };
+
+#if TypeCheck
+ if ((In0P->Head.msgh_size != 32) ||
+ (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))
+ { OutP->RetCode = MIG_BAD_ARGUMENTS; return; }
+#endif /* TypeCheck */
+
+#if TypeCheck
+ if (BAD_TYPECHECK(&In0P->mscountType, &mscountCheck))
+ { OutP->RetCode = MIG_BAD_ARGUMENTS; return; }
+#endif /* TypeCheck */
+
+ OutP->RetCode = do_mach_notify_no_senders(In0P->Head.msgh_request_port, In0P->mscount);
+}
+
+/* SimpleRoutine mach_notify_send_once */
+mig_internal void _Xmach_notify_send_once
+ (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
+{
+ typedef struct {
+ mach_msg_header_t Head;
+ } Request;
+
+ typedef struct {
+ mach_msg_header_t Head;
+ mach_msg_type_t RetCodeType;
+ kern_return_t RetCode;
+ } Reply;
+
+ register Request *In0P = (Request *) InHeadP;
+ register Reply *OutP = (Reply *) OutHeadP;
+ mig_external kern_return_t do_mach_notify_send_once
+ (mach_port_t notify);
+
+#if TypeCheck
+ if ((In0P->Head.msgh_size != 24) ||
+ (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))
+ { OutP->RetCode = MIG_BAD_ARGUMENTS; return; }
+#endif /* TypeCheck */
+
+ OutP->RetCode = do_mach_notify_send_once(In0P->Head.msgh_request_port);
+}
+
+/* SimpleRoutine mach_notify_dead_name */
+mig_internal void _Xmach_notify_dead_name
+ (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
+{
+ typedef struct {
+ mach_msg_header_t Head;
+ mach_msg_type_t nameType;
+ mach_port_t name;
+ } Request;
+
+ typedef struct {
+ mach_msg_header_t Head;
+ mach_msg_type_t RetCodeType;
+ kern_return_t RetCode;
+ } Reply;
+
+ register Request *In0P = (Request *) InHeadP;
+ register Reply *OutP = (Reply *) OutHeadP;
+ mig_external kern_return_t do_mach_notify_dead_name
+ (mach_port_t notify, mach_port_t name);
+
+ auto const mach_msg_type_t nameCheck = {
+ /* msgt_name = */ 15,
+ /* msgt_size = */ 32,
+ /* msgt_number = */ 1,
+ /* msgt_inline = */ TRUE,
+ /* msgt_longform = */ FALSE,
+ /* msgt_deallocate = */ FALSE,
+ /* msgt_unused = */ 0
+ };
+
+#if TypeCheck
+ if ((In0P->Head.msgh_size != 32) ||
+ (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))
+ { OutP->RetCode = MIG_BAD_ARGUMENTS; return; }
+#endif /* TypeCheck */
+
+#if TypeCheck
+ if (BAD_TYPECHECK(&In0P->nameType, &nameCheck))
+ { OutP->RetCode = MIG_BAD_ARGUMENTS; return; }
+#endif /* TypeCheck */
+
+ OutP->RetCode = do_mach_notify_dead_name(In0P->Head.msgh_request_port, In0P->name);
+}
+
+static mig_routine_t notify_server_routines[] = {
+ 0,
+ _Xmach_notify_port_deleted,
+ _Xmach_notify_msg_accepted,
+ 0,
+ 0,
+ _Xmach_notify_port_destroyed,
+ _Xmach_notify_no_senders,
+ _Xmach_notify_send_once,
+ _Xmach_notify_dead_name,
+};
+
+mig_external boolean_t notify_server
+ (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
+{
+ register mach_msg_header_t *InP = InHeadP;
+ register mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP;
+
+ auto const mach_msg_type_t RetCodeType = {
+ /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32,
+ /* msgt_size = */ 32,
+ /* msgt_number = */ 1,
+ /* msgt_inline = */ TRUE,
+ /* msgt_longform = */ FALSE,
+ /* msgt_deallocate = */ FALSE,
+ /* msgt_unused = */ 0
+ };
+
+ register mig_routine_t routine;
+
+ OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0);
+ OutP->Head.msgh_size = sizeof *OutP;
+ OutP->Head.msgh_remote_port = InP->msgh_reply_port;
+ OutP->Head.msgh_local_port = MACH_PORT_NULL;
+ OutP->Head.msgh_seqno = 0;
+ OutP->Head.msgh_id = InP->msgh_id + 100;
+
+ OutP->RetCodeType = RetCodeType;
+
+ if ((InP->msgh_id > 72) || (InP->msgh_id < 64) ||
+ ((routine = notify_server_routines[InP->msgh_id - 64]) == 0)) {
+ OutP->RetCode = MIG_BAD_ID;
+ return FALSE;
+ }
+ (*routine) (InP, &OutP->Head);
+ return TRUE;
+}
+
+mig_external mig_routine_t notify_server_routine
+ (const mach_msg_header_t *InHeadP)
+{
+ register int msgh_id;
+
+ msgh_id = InHeadP->msgh_id - 64;
+
+ if ((msgh_id > 8) || (msgh_id < 0))
+ return 0;
+
+ return notify_server_routines[msgh_id];
+}
+