Subversion Repositories HelenOS-historic

Rev

Rev 1281 | Rev 1293 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1281 Rev 1288
Line 26... Line 26...
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
#include <arch.h>
29
#include <arch.h>
30
#include <proc/task.h>
30
#include <proc/task.h>
31
 
-
 
-
 
31
#include <proc/thread.h>
32
#include <errno.h>
32
#include <errno.h>
33
#include <mm/page.h>
-
 
34
#include <memstr.h>
33
#include <memstr.h>
35
#include <debug.h>
34
#include <debug.h>
36
#include <ipc/ipc.h>
35
#include <ipc/ipc.h>
37
#include <ipc/sysipc.h>
36
#include <ipc/sysipc.h>
38
#include <ipc/irq.h>
37
#include <ipc/irq.h>
39
#include <ipc/ipcrsc.h>
38
#include <ipc/ipcrsc.h>
40
#include <arch/interrupt.h>
39
#include <arch/interrupt.h>
41
 
-
 
42
#include <print.h>
40
#include <print.h>
43
#include <arch.h>
-
 
44
#include <proc/thread.h>
41
#include <syscall/copy.h>
45
 
42
 
46
#define GET_CHECK_PHONE(phone,phoneid,err) { \
43
#define GET_CHECK_PHONE(phone,phoneid,err) { \
47
      if (phoneid > IPC_MAX_PHONES) { err; } \
44
      if (phoneid > IPC_MAX_PHONES) { err; } \
48
      phone = &TASK->phones[phoneid]; \
45
      phone = &TASK->phones[phoneid]; \
49
}
46
}
Line 226... Line 223...
226
               ipc_data_t *reply)
223
               ipc_data_t *reply)
227
{
224
{
228
    call_t call;
225
    call_t call;
229
    phone_t *phone;
226
    phone_t *phone;
230
    int res;
227
    int res;
-
 
228
    int rc;
231
 
229
 
232
    ipc_call_static_init(&call);
230
    ipc_call_static_init(&call);
233
    copy_from_uspace(&call.data.args, &question->args, sizeof(call.data.args));
231
    rc = copy_from_uspace(&call.data.args, &question->args, sizeof(call.data.args));
-
 
232
    if (rc != 0)
-
 
233
        return (__native) rc;
234
 
234
 
235
    GET_CHECK_PHONE(phone, phoneid, return ENOENT);
235
    GET_CHECK_PHONE(phone, phoneid, return ENOENT);
236
 
236
 
237
    if (!(res=request_preprocess(&call))) {
237
    if (!(res=request_preprocess(&call))) {
238
        ipc_call_sync(phone, &call);
238
        ipc_call_sync(phone, &call);
239
        process_answer(&call);
239
        process_answer(&call);
240
    } else
240
    } else
241
        IPC_SET_RETVAL(call.data, res);
241
        IPC_SET_RETVAL(call.data, res);
242
 
242
 
243
    STRUCT_TO_USPACE(&reply->args, &call.data.args);
243
    rc = STRUCT_TO_USPACE(&reply->args, &call.data.args);
-
 
244
    if (rc != 0)
-
 
245
        return rc;
244
 
246
 
245
    return 0;
247
    return 0;
246
}
248
}
247
 
249
 
248
/** Check that the task did not exceed allowed limit
250
/** Check that the task did not exceed allowed limit
Line 295... Line 297...
295
__native sys_ipc_call_async(__native phoneid, ipc_data_t *data)
297
__native sys_ipc_call_async(__native phoneid, ipc_data_t *data)
296
{
298
{
297
    call_t *call;
299
    call_t *call;
298
    phone_t *phone;
300
    phone_t *phone;
299
    int res;
301
    int res;
-
 
302
    int rc;
300
 
303
 
301
    if (check_call_limit())
304
    if (check_call_limit())
302
        return IPC_CALLRET_TEMPORARY;
305
        return IPC_CALLRET_TEMPORARY;
303
 
306
 
304
    GET_CHECK_PHONE(phone, phoneid, return IPC_CALLRET_FATAL);
307
    GET_CHECK_PHONE(phone, phoneid, return IPC_CALLRET_FATAL);
305
 
308
 
306
    call = ipc_call_alloc(0);
309
    call = ipc_call_alloc(0);
307
    copy_from_uspace(&call->data.args, &data->args, sizeof(call->data.args));
310
    rc = copy_from_uspace(&call->data.args, &data->args, sizeof(call->data.args));
-
 
311
    if (rc != 0)
-
 
312
        return (__native) rc;
308
    if (!(res=request_preprocess(call)))
313
    if (!(res=request_preprocess(call)))
309
        ipc_call(phone, call);
314
        ipc_call(phone, call);
310
    else
315
    else
311
        ipc_backsend_err(phone, call, res);
316
        ipc_backsend_err(phone, call, res);
312
 
317
 
Line 391... Line 396...
391
__native sys_ipc_answer(__native callid, ipc_data_t *data)
396
__native sys_ipc_answer(__native callid, ipc_data_t *data)
392
{
397
{
393
    call_t *call;
398
    call_t *call;
394
    ipc_data_t saved_data;
399
    ipc_data_t saved_data;
395
    int saveddata = 0;
400
    int saveddata = 0;
-
 
401
    int rc;
396
 
402
 
397
    call = get_call(callid);
403
    call = get_call(callid);
398
    if (!call)
404
    if (!call)
399
        return ENOENT;
405
        return ENOENT;
400
 
406
 
401
    if (answer_need_old(call)) {
407
    if (answer_need_old(call)) {
402
        memcpy(&saved_data, &call->data, sizeof(call->data));
408
        memcpy(&saved_data, &call->data, sizeof(call->data));
403
        saveddata = 1;
409
        saveddata = 1;
404
    }
410
    }
405
    copy_from_uspace(&call->data.args, &data->args,
411
    rc = copy_from_uspace(&call->data.args, &data->args,
406
             sizeof(call->data.args));
412
             sizeof(call->data.args));
-
 
413
    if (rc != 0)
-
 
414
        return rc;
407
 
415
 
408
    answer_preprocess(call, saveddata ? &saved_data : NULL);
416
    answer_preprocess(call, saveddata ? &saved_data : NULL);
409
   
417
   
410
    ipc_answer(&TASK->answerbox, call);
418
    ipc_answer(&TASK->answerbox, call);
411
 
419