]>
Commit | Line | Data |
---|---|---|
3cf595e5 | 1 | /* Machine-dependent details of interruptible RPC messaging. i386 version. |
b168057a | 2 | Copyright (C) 1995-2015 Free Software Foundation, Inc. |
478b92f0 | 3 | This file is part of the GNU C Library. |
3cf595e5 | 4 | |
478b92f0 | 5 | The GNU C Library is free software; you can redistribute it and/or |
41bdb6e2 AJ |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
3cf595e5 | 9 | |
478b92f0 UD |
10 | The GNU C Library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
3cf595e5 | 14 | |
41bdb6e2 | 15 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
16 | License along with the GNU C Library; if not, see |
17 | <http://www.gnu.org/licenses/>. */ | |
3cf595e5 RM |
18 | |
19 | ||
38e30b39 RM |
20 | /* Note that we must mark OPTION and TIMEOUT as outputs of this operation, |
21 | to indicate that the signal thread might mutate them as part | |
22 | of sending us to a signal handler. */ | |
3cf595e5 RM |
23 | #define INTR_MSG_TRAP(msg, option, send_size, rcv_size, rcv_name, timeout, notify) \ |
24 | ({ \ | |
25 | error_t err; \ | |
26 | asm (".globl _hurd_intr_rpc_msg_do_trap\n" \ | |
27 | ".globl _hurd_intr_rpc_msg_in_trap\n" \ | |
28 | ".globl _hurd_intr_rpc_msg_cx_sp\n" \ | |
29 | ".globl _hurd_intr_rpc_msg_sp_restored\n" \ | |
30 | " movl %%esp, %%ecx\n" \ | |
38e30b39 | 31 | " leal %3, %%esp\n" \ |
3cf595e5 RM |
32 | "_hurd_intr_rpc_msg_cx_sp: movl $-25, %%eax\n" \ |
33 | "_hurd_intr_rpc_msg_do_trap: lcall $7, $0 # status in %0\n" \ | |
34 | "_hurd_intr_rpc_msg_in_trap: movl %%ecx, %%esp\n" \ | |
35 | "_hurd_intr_rpc_msg_sp_restored:" \ | |
38e30b39 RM |
36 | : "=a" (err), "=m" (option), "=m" (timeout) \ |
37 | : "m" ((&msg)[-1]), "1" (option), "2" (timeout) \ | |
38 | : "%ecx"); \ | |
3cf595e5 RM |
39 | err; \ |
40 | }) | |
41 | ||
42 | ||
43 | static void inline | |
44 | INTR_MSG_BACK_OUT (struct i386_thread_state *state) | |
45 | { | |
46 | extern const void _hurd_intr_rpc_msg_cx_sp; | |
47 | if (state->eip >= (natural_t) &_hurd_intr_rpc_msg_cx_sp) | |
48 | state->uesp = state->ecx; | |
49 | else | |
50 | state->ecx = state->uesp; | |
51 | } | |
4ca84cff RM |
52 | \f |
53 | #include "hurdfault.h" | |
54 | ||
8a0746ae RM |
55 | /* This cannot be an inline function because it calls setjmp. */ |
56 | #define SYSCALL_EXAMINE(state, callno) \ | |
57 | ({ \ | |
58 | struct { unsigned int c[2]; } *p = (void *) ((state)->eip - 7); \ | |
59 | int result; \ | |
60 | if (_hurdsig_catch_memory_fault (p)) \ | |
61 | return 0; \ | |
62 | if (result = p->c[0] == 0x0000009a && (p->c[1] & 0x00ffffff) == 0x00000700) \ | |
63 | /* The PC is just after an `lcall $7,$0' instruction. \ | |
64 | This is a system call in progress; %eax holds the call number. */ \ | |
65 | *(callno) = (state)->eax; \ | |
66 | _hurdsig_end_catch_fault (); \ | |
67 | result; \ | |
68 | }) | |
4ca84cff RM |
69 | |
70 | ||
71 | struct mach_msg_trap_args | |
72 | { | |
73 | void *retaddr; /* Address mach_msg_trap will return to. */ | |
74 | /* This is the order of arguments to mach_msg_trap. */ | |
75 | mach_msg_header_t *msg; | |
76 | mach_msg_option_t option; | |
77 | mach_msg_size_t send_size; | |
78 | mach_msg_size_t rcv_size; | |
79 | mach_port_t rcv_name; | |
80 | mach_msg_timeout_t timeout; | |
81 | mach_port_t notify; | |
82 | }; | |
83 | ||
84 | ||
8a0746ae RM |
85 | /* This cannot be an inline function because it calls setjmp. */ |
86 | #define MSG_EXAMINE(state, msgid, rcvname, send_name, opt, tmout) \ | |
87 | ({ \ | |
88 | const struct mach_msg_trap_args *args = (const void *) (state)->uesp; \ | |
89 | mach_msg_header_t *msg; \ | |
90 | _hurdsig_catch_memory_fault (args) ? -1 : \ | |
91 | ({ \ | |
92 | msg = args->msg; \ | |
93 | *(opt) = args->option; \ | |
94 | *(tmout) = args->timeout; \ | |
95 | *(rcvname) = args->rcv_name; \ | |
96 | _hurdsig_end_catch_fault (); \ | |
97 | if (msg == 0) \ | |
98 | { \ | |
99 | *(send_name) = MACH_PORT_NULL; \ | |
100 | *(msgid) = 0; \ | |
101 | } \ | |
102 | else \ | |
103 | { \ | |
104 | if (_hurdsig_catch_memory_fault (msg)) \ | |
105 | return -1; \ | |
106 | *(send_name) = msg->msgh_remote_port; \ | |
107 | *(msgid) = msg->msgh_id; \ | |
108 | _hurdsig_end_catch_fault (); \ | |
109 | } \ | |
110 | 0; \ | |
111 | }); \ | |
112 | }) |