Back to index

glibc  2.9
intr-msg.h
Go to the documentation of this file.
00001 /* Machine-dependent details of interruptible RPC messaging.  Mips version.
00002    Copyright (C) 1996, 1997 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 
00021 #ifdef __mips64
00022 #define INTR_MSG_TRAP(msg, option, send_size, rcv_size, rcv_name, timeout, notify) \
00023 ({                                                                   \
00024   error_t err;                                                              \
00025   mach_port_t __rcv_name = (rcv_name);                                      \
00026   mach_msg_timeout_t __timeout = (timeout);                                        \
00027   mach_port_t __notify = (notify);                                   \
00028   asm (".globl _hurd_intr_rpc_msg_do_trap\n"                                \
00029        ".globl _hurd_intr_rpc_msg_in_trap\n"                                \
00030        "                           move $4, %1\n"                           \
00031        "                           move $5, %2\n"                           \
00032        "                           move $6, %3\n"                           \
00033        "                           move $7, %4\n"                           \
00034        "                           move $8, %5\n"                           \
00035        "                           move $9, %6\n"                           \
00036        "                           move $10, %7\n"                          \
00037        "                           dli $2, -25\n"                           \
00038        "_hurd_intr_rpc_msg_do_trap:       syscall\n"                        \
00039        "_hurd_intr_rpc_msg_in_trap:       move %0, $2\n"                           \
00040        : "=r" (err)                                                  \
00041        : "r" (msg), "r" (option), "r" (send_size), "r" (rcv_size),          \
00042          "r" (__rcv_name), "r" (__timeout), "r" (__notify)                  \
00043        : "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10",       \
00044          "$11", "$12", "$13", "$14", "$15", "$24", "$25", "$28");           \
00045   err;                                                               \
00046 })
00047 #else
00048 #define INTR_MSG_TRAP(msg, option, send_size, rcv_size, rcv_name, timeout, notify) \
00049 ({                                                                   \
00050   error_t err;                                                              \
00051   mach_port_t __rcv_name = (rcv_name);                                      \
00052   mach_msg_timeout_t __timeout = (timeout);                                        \
00053   mach_port_t __notify = (notify);                                   \
00054   asm (".globl _hurd_intr_rpc_msg_do_trap\n"                                \
00055        ".globl _hurd_intr_rpc_msg_in_trap\n"                                \
00056        "                           move $4, %1\n"                           \
00057        "                           move $5, %2\n"                           \
00058        "                           move $6, %3\n"                           \
00059        "                           move $7, %4\n"                           \
00060        "                           move $8, %5\n"                           \
00061        "                           move $9, %6\n"                           \
00062        "                           move $10, %7\n"                          \
00063        "                           li $2, -25\n"                     \
00064        "_hurd_intr_rpc_msg_do_trap:       syscall\n"                        \
00065        "_hurd_intr_rpc_msg_in_trap:       move %0, $2\n"                           \
00066        : "=r" (err)                                                  \
00067        : "r" (msg), "r" (option), "r" (send_size), "r" (rcv_size),          \
00068          "r" (__rcv_name), "r" (__timeout), "r" (__notify)                  \
00069        : "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10",       \
00070          "$11", "$12", "$13", "$14", "$15", "$24", "$25", "$28");           \
00071   err;                                                               \
00072 })
00073 #endif
00074 
00075 static inline void
00076 INTR_MSG_BACK_OUT (struct mips_thread_state *state)
00077 {
00078   return;
00079 }
00080 
00081 #include "hurdfault.h"
00082 
00083 static inline int
00084 SYSCALL_EXAMINE (struct mips_thread_state *state, int *callno)
00085 {
00086   u_int32_t *p = (void *) (state->pc - 4);
00087   int result;
00088   if (_hurdsig_catch_memory_fault (p))
00089     return 0;
00090   if (result = (*p == 0x0000000c))
00091     /* The PC is just after a `syscall' instruction.
00092        This is a system call in progress; v0($2) holds the call number.  */
00093     *callno = state->r2;
00094   _hurdsig_end_catch_fault ();
00095   return result;
00096 }
00097 
00098 
00099 struct mach_msg_trap_args
00100   {
00101     /* This is the order of arguments to mach_msg_trap.  */
00102     mach_msg_header_t *msg;
00103     mach_msg_option_t option;
00104     mach_msg_size_t send_size;
00105     mach_msg_size_t rcv_size;
00106     mach_port_t rcv_name;
00107     mach_msg_timeout_t timeout;
00108     mach_port_t notify;
00109   };
00110 
00111 
00112 static inline mach_port_t
00113 MSG_EXAMINE (struct mips_thread_state *state, int *msgid)
00114 {
00115   mach_msg_header_t *msg;
00116   mach_port_t send_port;
00117 
00118   msg = (mach_msg_header_t *) state->r4;
00119 
00120   if (_hurdsig_catch_memory_fault (msg))
00121     return MACH_PORT_NULL;
00122   send_port = msg->msgh_remote_port;
00123   *msgid = msg->msgh_id;
00124   _hurdsig_end_catch_fault ();
00125 
00126   return send_port;
00127 }