source: rtems/cpukit/rtems/src/systemeventreceive.c @ 57c676c6

5
Last change on this file since 57c676c6 was dce48791, checked in by Sebastian Huber <sebastian.huber@…>, on 05/23/16 at 11:37:59

score: Add Status_Control for all APIs

Unify the status codes of the Classic and POSIX API to use the new enum
Status_Control. This eliminates the Thread_Control::Wait::timeout_code
field and the timeout parameter of _Thread_queue_Enqueue_critical() and
_MPCI_Send_request_packet(). It gets rid of the status code translation
tables and instead uses simple bit operations to get the status for a
particular API. This enables translation of status code constants at
compile time. Add _Thread_Wait_get_status() to avoid direct access of
thread internal data structures.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup ClassicEventSystem
5 *
6 * @brief rtems_event_system_receive() implementation.
7 */
8
9/*
10 * Copyright (c) 2012 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Obere Lagerstr. 30
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.org/license/LICENSE.
21 */
22
23#if HAVE_CONFIG_H
24  #include "config.h"
25#endif
26
27#include <rtems/rtems/eventimpl.h>
28#include <rtems/rtems/tasks.h>
29#include <rtems/score/statesimpl.h>
30#include <rtems/score/threadimpl.h>
31
32rtems_status_code rtems_event_system_receive(
33  rtems_event_set  event_in,
34  rtems_option     option_set,
35  rtems_interval   ticks,
36  rtems_event_set *event_out
37)
38{
39  rtems_status_code sc;
40
41  if ( event_out != NULL ) {
42    ISR_lock_Context   lock_context;
43    Thread_Control    *executing;
44    RTEMS_API_Control *api;
45    Event_Control     *event;
46
47    executing = _Thread_Lock_acquire_default_for_executing( &lock_context );
48    api = executing->API_Extensions[ THREAD_API_RTEMS ];
49    event = &api->System_event;
50
51    if ( !_Event_sets_Is_empty( event_in ) ) {
52      sc = _Event_Seize(
53        event_in,
54        option_set,
55        ticks,
56        event_out,
57        executing,
58        event,
59        THREAD_WAIT_CLASS_SYSTEM_EVENT,
60        STATES_WAITING_FOR_SYSTEM_EVENT,
61        &lock_context
62      );
63    } else {
64      *event_out = event->pending_events;
65      _Thread_Lock_release_default( executing, &lock_context );
66      sc = RTEMS_SUCCESSFUL;
67    }
68  } else {
69    sc = RTEMS_INVALID_ADDRESS;
70  }
71
72  return sc;
73}
Note: See TracBrowser for help on using the repository browser.