summaryrefslogtreecommitdiff
path: root/debian/patches/0009-boot-improve-the-demuxer.patch
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches/0009-boot-improve-the-demuxer.patch')
-rw-r--r--debian/patches/0009-boot-improve-the-demuxer.patch111
1 files changed, 111 insertions, 0 deletions
diff --git a/debian/patches/0009-boot-improve-the-demuxer.patch b/debian/patches/0009-boot-improve-the-demuxer.patch
new file mode 100644
index 00000000..c5757264
--- /dev/null
+++ b/debian/patches/0009-boot-improve-the-demuxer.patch
@@ -0,0 +1,111 @@
+From 7d2b4a67e17e2ace8fcbbe6b975be5aa18d9a176 Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Fri, 7 Nov 2014 10:43:47 +0100
+Subject: [PATCH hurd 09/14] boot: improve the demuxer
+
+Handle multiple request types as recommended by the Mach Server
+Writer's Guide section 4, subsection "Handling Multiple Request
+Types". This avoids initializing the reply message in every X_server
+function.
+
+* boot/boot.c (mig_reply_setup): Provide local version.
+(request_server): Rename to `boot_demuxer', and improve the dispatch.
+---
+ boot/boot.c | 67 ++++++++++++++++++++++++++++++++++++++++++++-----------------
+ 1 file changed, 49 insertions(+), 18 deletions(-)
+
+diff --git a/boot/boot.c b/boot/boot.c
+index 747ab73..e2cb907 100644
+--- a/boot/boot.c
++++ b/boot/boot.c
+@@ -169,22 +169,55 @@ useropen (const char *name, int flags, int mode)
+ return open (name, flags, mode);
+ }
+
+-int
+-request_server (mach_msg_header_t *inp,
+- mach_msg_header_t *outp)
+-{
+- extern int io_server (mach_msg_header_t *, mach_msg_header_t *);
+- extern int device_server (mach_msg_header_t *, mach_msg_header_t *);
+- extern int notify_server (mach_msg_header_t *, mach_msg_header_t *);
+- extern int term_server (mach_msg_header_t *, mach_msg_header_t *);
+-/* extern int tioctl_server (mach_msg_header_t *, mach_msg_header_t *); */
+- extern int bootstrap_server (mach_msg_header_t *, mach_msg_header_t *);
++/* XXX: glibc should provide mig_reply_setup but does not. */
++/* Fill in default response. */
++void
++mig_reply_setup (
++ const mach_msg_header_t *in,
++ mach_msg_header_t *out)
++{
++ static 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
++ };
++
++#define InP (in)
++#define OutP ((mig_reply_header_t *) out)
++ OutP->Head.msgh_bits =
++ MACH_MSGH_BITS(MACH_MSGH_BITS_REMOTE(InP->msgh_bits), 0);
++ OutP->Head.msgh_size = sizeof *OutP;
++ OutP->Head.msgh_remote_port = InP->msgh_remote_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;
++ OutP->RetCode = MIG_BAD_ID;
++#undef InP
++#undef OutP
++}
+
+- return (io_server (inp, outp)
+- || device_server (inp, outp)
+- || notify_server (inp, outp)
+- || term_server (inp, outp)
+- /* || tioctl_server (inp, outp) */);
++int
++boot_demuxer (mach_msg_header_t *inp,
++ mach_msg_header_t *outp)
++{
++ mig_routine_t routine;
++ mig_reply_setup (inp, outp);
++ if ((routine = io_server_routine (inp)) ||
++ (routine = device_server_routine (inp)) ||
++ (routine = notify_server_routine (inp)) ||
++ (routine = term_server_routine (inp))
++ /* (routine = tioctl_server_routine (inp)) */)
++ {
++ (*routine) (inp, outp);
++ return TRUE;
++ }
++ else
++ return FALSE;
+ }
+
+ vm_address_t
+@@ -710,15 +743,13 @@ main (int argc, char **argv, char **envp)
+ else /* We hosed */
+ error (5, errno, "select");
+ }
+-
+-/* mach_msg_server (request_server, __vm_page_size * 2, receive_set); */
+ }
+
+ void *
+ msg_thread (void *arg)
+ {
+ while (1)
+- mach_msg_server (request_server, 0, receive_set);
++ mach_msg_server (boot_demuxer, 0, receive_set);
+ }
+
+
+--
+2.1.1
+