mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-21 04:35:38 +08:00
rtems: _Message_queue_Get_interrupt_disable()
Use _Objects_Get_local() for _Message_queue_Get_interrupt_disable() to get rid of the location parameter. Move remote object handling to message queue MPCI support.
This commit is contained in:
@@ -104,15 +104,13 @@ RTEMS_INLINE_ROUTINE void _Message_queue_Free (
|
||||
RTEMS_INLINE_ROUTINE Message_queue_Control *
|
||||
_Message_queue_Get_interrupt_disable(
|
||||
Objects_Id id,
|
||||
Objects_Locations *location,
|
||||
ISR_lock_Context *lock_context
|
||||
)
|
||||
{
|
||||
return (Message_queue_Control *) _Objects_Get_isr_disable(
|
||||
&_Message_queue_Information,
|
||||
return (Message_queue_Control *) _Objects_Get_local(
|
||||
id,
|
||||
location,
|
||||
lock_context
|
||||
lock_context,
|
||||
&_Message_queue_Information
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -79,6 +79,11 @@ typedef struct {
|
||||
#define MESSAGE_QUEUE_MP_PACKET_SIZE \
|
||||
offsetof(Message_queue_MP_Packet, Buffer.buffer)
|
||||
|
||||
RTEMS_INLINE_ROUTINE bool _Message_queue_MP_Is_remote( Objects_Id id )
|
||||
{
|
||||
return _Objects_MP_Is_remote( id, &_Message_queue_Information );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Message_queue_Core_message_queue_mp_support
|
||||
*
|
||||
@@ -107,18 +112,58 @@ void _Message_queue_MP_Send_process_packet (
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief _Message_queue_MP_Send_request_packet
|
||||
*
|
||||
* This routine performs a remote procedure call so that a
|
||||
* directive operation can be initiated on another node.
|
||||
* @brief Issues a remote rtems_message_queue_broadcast() request.
|
||||
*/
|
||||
rtems_status_code _Message_queue_MP_Send_request_packet (
|
||||
Message_queue_MP_Remote_operations operation,
|
||||
Objects_Id message_queue_id,
|
||||
const void *buffer,
|
||||
size_t *size_p,
|
||||
rtems_option option_set,
|
||||
rtems_interval timeout
|
||||
rtems_status_code _Message_queue_MP_Broadcast(
|
||||
rtems_id id,
|
||||
const void *buffer,
|
||||
size_t size,
|
||||
uint32_t *count
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Issues a remote rtems_message_queue_flush() request.
|
||||
*/
|
||||
rtems_status_code _Message_queue_MP_Flush(
|
||||
rtems_id id,
|
||||
uint32_t *count
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Issues a remote rtems_message_queue_get_number_pending() request.
|
||||
*/
|
||||
rtems_status_code _Message_queue_MP_Get_number_pending(
|
||||
rtems_id id,
|
||||
uint32_t *count
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Issues a remote rtems_message_queue_receive() request.
|
||||
*/
|
||||
rtems_status_code _Message_queue_MP_Receive(
|
||||
rtems_id id,
|
||||
void *buffer,
|
||||
size_t *size,
|
||||
rtems_option option_set,
|
||||
rtems_interval timeout
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Issues a remote rtems_message_queue_send() request.
|
||||
*/
|
||||
rtems_status_code _Message_queue_MP_Send(
|
||||
rtems_id id,
|
||||
const void *buffer,
|
||||
size_t size
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Issues a remote rtems_message_queue_urgent() request.
|
||||
*/
|
||||
rtems_status_code _Message_queue_MP_Urgent(
|
||||
rtems_id id,
|
||||
const void *buffer,
|
||||
size_t size
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
+107
-3
@@ -95,17 +95,21 @@ void _Message_queue_MP_Send_process_packet (
|
||||
*
|
||||
*/
|
||||
|
||||
rtems_status_code _Message_queue_MP_Send_request_packet (
|
||||
Message_queue_MP_Remote_operations operation,
|
||||
static rtems_status_code _Message_queue_MP_Send_request_packet (
|
||||
Objects_Id message_queue_id,
|
||||
const void *buffer,
|
||||
size_t *size_p,
|
||||
rtems_option option_set,
|
||||
rtems_interval timeout
|
||||
rtems_interval timeout,
|
||||
Message_queue_MP_Remote_operations operation
|
||||
)
|
||||
{
|
||||
Message_queue_MP_Packet *the_packet;
|
||||
|
||||
if ( !_Message_queue_MP_Is_remote( message_queue_id ) ) {
|
||||
return RTEMS_INVALID_ID;
|
||||
}
|
||||
|
||||
switch ( operation ) {
|
||||
|
||||
case MESSAGE_QUEUE_MP_SEND_REQUEST:
|
||||
@@ -200,6 +204,106 @@ rtems_status_code _Message_queue_MP_Send_request_packet (
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
rtems_status_code _Message_queue_MP_Broadcast(
|
||||
rtems_id id,
|
||||
const void *buffer,
|
||||
size_t size,
|
||||
uint32_t *count
|
||||
)
|
||||
{
|
||||
_Thread_Get_executing()->Wait.return_argument = count;
|
||||
return _Message_queue_MP_Send_request_packet(
|
||||
id,
|
||||
buffer,
|
||||
&size,
|
||||
0,
|
||||
MPCI_DEFAULT_TIMEOUT,
|
||||
MESSAGE_QUEUE_MP_BROADCAST_REQUEST
|
||||
);
|
||||
}
|
||||
|
||||
rtems_status_code _Message_queue_MP_Flush(
|
||||
rtems_id id,
|
||||
uint32_t *count
|
||||
)
|
||||
{
|
||||
_Thread_Get_executing()->Wait.return_argument = count;
|
||||
return _Message_queue_MP_Send_request_packet(
|
||||
id,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
MPCI_DEFAULT_TIMEOUT,
|
||||
MESSAGE_QUEUE_MP_FLUSH_REQUEST
|
||||
);
|
||||
}
|
||||
|
||||
rtems_status_code _Message_queue_MP_Get_number_pending(
|
||||
rtems_id id,
|
||||
uint32_t *count
|
||||
)
|
||||
{
|
||||
_Thread_Get_executing()->Wait.return_argument = count;
|
||||
return _Message_queue_MP_Send_request_packet(
|
||||
id,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
MPCI_DEFAULT_TIMEOUT,
|
||||
MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_REQUEST
|
||||
);
|
||||
}
|
||||
|
||||
rtems_status_code _Message_queue_MP_Receive(
|
||||
rtems_id id,
|
||||
void *buffer,
|
||||
size_t *size,
|
||||
rtems_option option_set,
|
||||
rtems_interval timeout
|
||||
)
|
||||
{
|
||||
return _Message_queue_MP_Send_request_packet(
|
||||
id,
|
||||
buffer,
|
||||
size,
|
||||
option_set,
|
||||
timeout,
|
||||
MESSAGE_QUEUE_MP_RECEIVE_REQUEST
|
||||
);
|
||||
}
|
||||
|
||||
rtems_status_code _Message_queue_MP_Send(
|
||||
rtems_id id,
|
||||
const void *buffer,
|
||||
size_t size
|
||||
)
|
||||
{
|
||||
return _Message_queue_MP_Send_request_packet(
|
||||
id,
|
||||
buffer,
|
||||
&size,
|
||||
0,
|
||||
MPCI_DEFAULT_TIMEOUT,
|
||||
MESSAGE_QUEUE_MP_SEND_REQUEST
|
||||
);
|
||||
}
|
||||
|
||||
rtems_status_code _Message_queue_MP_Urgent(
|
||||
rtems_id id,
|
||||
const void *buffer,
|
||||
size_t size
|
||||
)
|
||||
{
|
||||
return _Message_queue_MP_Send_request_packet(
|
||||
id,
|
||||
buffer,
|
||||
&size,
|
||||
0,
|
||||
MPCI_DEFAULT_TIMEOUT,
|
||||
MESSAGE_QUEUE_MP_URGENT_REQUEST
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* _Message_queue_MP_Send_response_packet
|
||||
*
|
||||
|
||||
@@ -18,17 +18,7 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/chain.h>
|
||||
#include <rtems/score/isr.h>
|
||||
#include <rtems/score/coremsgimpl.h>
|
||||
#include <rtems/score/thread.h>
|
||||
#include <rtems/score/wkspace.h>
|
||||
#include <rtems/rtems/status.h>
|
||||
#include <rtems/rtems/attrimpl.h>
|
||||
#include <rtems/rtems/messageimpl.h>
|
||||
#include <rtems/rtems/options.h>
|
||||
#include <rtems/rtems/support.h>
|
||||
|
||||
rtems_status_code rtems_message_queue_broadcast(
|
||||
rtems_id id,
|
||||
@@ -37,54 +27,39 @@ rtems_status_code rtems_message_queue_broadcast(
|
||||
uint32_t *count
|
||||
)
|
||||
{
|
||||
Message_queue_Control *the_message_queue;
|
||||
Objects_Locations location;
|
||||
CORE_message_queue_Status core_status;
|
||||
ISR_lock_Context lock_context;
|
||||
Message_queue_Control *the_message_queue;
|
||||
ISR_lock_Context lock_context;
|
||||
CORE_message_queue_Status status;
|
||||
|
||||
if ( !buffer )
|
||||
if ( buffer == NULL ) {
|
||||
return RTEMS_INVALID_ADDRESS;
|
||||
}
|
||||
|
||||
if ( !count )
|
||||
if ( count == NULL ) {
|
||||
return RTEMS_INVALID_ADDRESS;
|
||||
}
|
||||
|
||||
the_message_queue = _Message_queue_Get_interrupt_disable(
|
||||
id,
|
||||
&location,
|
||||
&lock_context
|
||||
);
|
||||
switch ( location ) {
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
core_status = _CORE_message_queue_Broadcast(
|
||||
&the_message_queue->message_queue,
|
||||
buffer,
|
||||
size,
|
||||
_Message_queue_Core_message_queue_mp_support,
|
||||
id,
|
||||
count,
|
||||
&lock_context
|
||||
);
|
||||
return
|
||||
_Message_queue_Translate_core_message_queue_return_code( core_status );
|
||||
|
||||
if ( the_message_queue == NULL ) {
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
case OBJECTS_REMOTE:
|
||||
_Thread_Executing->Wait.return_argument = count;
|
||||
|
||||
return
|
||||
_Message_queue_MP_Send_request_packet(
|
||||
MESSAGE_QUEUE_MP_BROADCAST_REQUEST,
|
||||
id,
|
||||
buffer,
|
||||
&size,
|
||||
0, /* option_set not used */
|
||||
MPCI_DEFAULT_TIMEOUT
|
||||
);
|
||||
_Message_queue_MP_Broadcast( id, buffer, size, count );
|
||||
#else
|
||||
return RTEMS_INVALID_ID;
|
||||
#endif
|
||||
|
||||
case OBJECTS_ERROR:
|
||||
break;
|
||||
}
|
||||
return RTEMS_INVALID_ID;
|
||||
|
||||
status = _CORE_message_queue_Broadcast(
|
||||
&the_message_queue->message_queue,
|
||||
buffer,
|
||||
size,
|
||||
_Message_queue_Core_message_queue_mp_support,
|
||||
id,
|
||||
count,
|
||||
&lock_context
|
||||
);
|
||||
return _Message_queue_Translate_core_message_queue_return_code( status );
|
||||
}
|
||||
|
||||
@@ -25,64 +25,55 @@ rtems_status_code rtems_message_queue_delete(
|
||||
rtems_id id
|
||||
)
|
||||
{
|
||||
Message_queue_Control *the_message_queue;
|
||||
Objects_Locations location;
|
||||
ISR_lock_Context lock_context;
|
||||
Message_queue_Control *the_message_queue;
|
||||
ISR_lock_Context lock_context;
|
||||
|
||||
_Objects_Allocator_lock();
|
||||
the_message_queue = _Message_queue_Get_interrupt_disable(
|
||||
id,
|
||||
&location,
|
||||
&lock_context
|
||||
);
|
||||
switch ( location ) {
|
||||
the_message_queue = _Message_queue_Get_interrupt_disable( id, &lock_context );
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
_CORE_message_queue_Acquire_critical(
|
||||
&the_message_queue->message_queue,
|
||||
&lock_context
|
||||
);
|
||||
|
||||
_Objects_Close( &_Message_queue_Information,
|
||||
&the_message_queue->Object );
|
||||
|
||||
_CORE_message_queue_Close(
|
||||
&the_message_queue->message_queue,
|
||||
_Message_queue_MP_Send_object_was_deleted,
|
||||
id,
|
||||
&lock_context
|
||||
);
|
||||
if ( the_message_queue == NULL ) {
|
||||
_Objects_Allocator_unlock();
|
||||
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
if ( _Attributes_Is_global( the_message_queue->attribute_set ) ) {
|
||||
_Objects_MP_Close(
|
||||
&_Message_queue_Information,
|
||||
the_message_queue->Object.id
|
||||
);
|
||||
|
||||
_Message_queue_MP_Send_process_packet(
|
||||
MESSAGE_QUEUE_MP_ANNOUNCE_DELETE,
|
||||
the_message_queue->Object.id,
|
||||
0, /* Not used */
|
||||
0
|
||||
);
|
||||
}
|
||||
#endif
|
||||
_Message_queue_Free( the_message_queue );
|
||||
_Objects_Allocator_unlock();
|
||||
return RTEMS_SUCCESSFUL;
|
||||
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
case OBJECTS_REMOTE:
|
||||
_Objects_Allocator_unlock();
|
||||
if ( _Message_queue_MP_Is_remote( id ) ) {
|
||||
return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
|
||||
}
|
||||
#endif
|
||||
|
||||
case OBJECTS_ERROR:
|
||||
break;
|
||||
return RTEMS_INVALID_ID;
|
||||
}
|
||||
|
||||
_Objects_Allocator_unlock();
|
||||
_CORE_message_queue_Acquire_critical(
|
||||
&the_message_queue->message_queue,
|
||||
&lock_context
|
||||
);
|
||||
|
||||
return RTEMS_INVALID_ID;
|
||||
_Objects_Close( &_Message_queue_Information, &the_message_queue->Object );
|
||||
|
||||
_CORE_message_queue_Close(
|
||||
&the_message_queue->message_queue,
|
||||
_Message_queue_MP_Send_object_was_deleted,
|
||||
id,
|
||||
&lock_context
|
||||
);
|
||||
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
if ( _Attributes_Is_global( the_message_queue->attribute_set ) ) {
|
||||
_Objects_MP_Close(
|
||||
&_Message_queue_Information,
|
||||
the_message_queue->Object.id
|
||||
);
|
||||
|
||||
_Message_queue_MP_Send_process_packet(
|
||||
MESSAGE_QUEUE_MP_ANNOUNCE_DELETE,
|
||||
the_message_queue->Object.id,
|
||||
0, /* Not used */
|
||||
0
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
_Message_queue_Free( the_message_queue );
|
||||
_Objects_Allocator_unlock();
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
@@ -18,79 +18,36 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/chain.h>
|
||||
#include <rtems/score/isr.h>
|
||||
#include <rtems/score/coremsgimpl.h>
|
||||
#include <rtems/score/thread.h>
|
||||
#include <rtems/score/wkspace.h>
|
||||
#include <rtems/rtems/status.h>
|
||||
#include <rtems/rtems/attrimpl.h>
|
||||
#include <rtems/rtems/messageimpl.h>
|
||||
#include <rtems/rtems/options.h>
|
||||
#include <rtems/rtems/support.h>
|
||||
|
||||
/*
|
||||
* rtems_message_queue_flush
|
||||
*
|
||||
* This directive removes all pending messages from a queue and returns
|
||||
* the number of messages removed. If no messages were present then
|
||||
* a count of zero is returned.
|
||||
*
|
||||
* Input parameters:
|
||||
* id - queue id
|
||||
* count - return area for count
|
||||
*
|
||||
* Output parameters:
|
||||
* count - number of messages removed ( 0 = empty queue )
|
||||
* RTEMS_SUCCESSFUL - if successful
|
||||
* error code - if unsuccessful
|
||||
*/
|
||||
|
||||
rtems_status_code rtems_message_queue_flush(
|
||||
rtems_id id,
|
||||
uint32_t *count
|
||||
)
|
||||
{
|
||||
Message_queue_Control *the_message_queue;
|
||||
Objects_Locations location;
|
||||
ISR_lock_Context lock_context;
|
||||
Message_queue_Control *the_message_queue;
|
||||
ISR_lock_Context lock_context;
|
||||
|
||||
if ( !count )
|
||||
if ( count == NULL ) {
|
||||
return RTEMS_INVALID_ADDRESS;
|
||||
}
|
||||
|
||||
the_message_queue = _Message_queue_Get_interrupt_disable(
|
||||
id,
|
||||
&location,
|
||||
&lock_context
|
||||
);
|
||||
switch ( location ) {
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
*count = _CORE_message_queue_Flush(
|
||||
&the_message_queue->message_queue,
|
||||
&lock_context
|
||||
);
|
||||
return RTEMS_SUCCESSFUL;
|
||||
|
||||
if ( the_message_queue == NULL ) {
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
case OBJECTS_REMOTE:
|
||||
_Thread_Executing->Wait.return_argument = count;
|
||||
|
||||
return
|
||||
_Message_queue_MP_Send_request_packet(
|
||||
MESSAGE_QUEUE_MP_FLUSH_REQUEST,
|
||||
id,
|
||||
0, /* buffer not used */
|
||||
0, /* size */
|
||||
0, /* option_set not used */
|
||||
MPCI_DEFAULT_TIMEOUT
|
||||
);
|
||||
_Message_queue_MP_Flush( id, count );
|
||||
#else
|
||||
return RTEMS_INVALID_ID;
|
||||
#endif
|
||||
|
||||
case OBJECTS_ERROR:
|
||||
break;
|
||||
}
|
||||
|
||||
return RTEMS_INVALID_ID;
|
||||
*count = _CORE_message_queue_Flush(
|
||||
&the_message_queue->message_queue,
|
||||
&lock_context
|
||||
);
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
@@ -26,48 +26,33 @@ rtems_status_code rtems_message_queue_get_number_pending(
|
||||
)
|
||||
{
|
||||
Message_queue_Control *the_message_queue;
|
||||
Objects_Locations location;
|
||||
ISR_lock_Context lock_context;
|
||||
|
||||
if ( !count )
|
||||
if ( count == NULL ) {
|
||||
return RTEMS_INVALID_ADDRESS;
|
||||
}
|
||||
|
||||
the_message_queue = _Message_queue_Get_interrupt_disable(
|
||||
id,
|
||||
&location,
|
||||
&lock_context
|
||||
);
|
||||
switch ( location ) {
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
_CORE_message_queue_Acquire_critical(
|
||||
&the_message_queue->message_queue,
|
||||
&lock_context
|
||||
);
|
||||
*count = the_message_queue->message_queue.number_of_pending_messages;
|
||||
_CORE_message_queue_Release(
|
||||
&the_message_queue->message_queue,
|
||||
&lock_context
|
||||
);
|
||||
return RTEMS_SUCCESSFUL;
|
||||
|
||||
if ( the_message_queue == NULL ) {
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
case OBJECTS_REMOTE:
|
||||
_Thread_Get_executing()->Wait.return_argument = count;
|
||||
|
||||
return _Message_queue_MP_Send_request_packet(
|
||||
MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_REQUEST,
|
||||
id,
|
||||
0, /* buffer not used */
|
||||
0, /* size */
|
||||
0, /* option_set not used */
|
||||
MPCI_DEFAULT_TIMEOUT
|
||||
);
|
||||
_Message_queue_MP_Get_number_pending( id, count );
|
||||
#else
|
||||
return RTEMS_INVALID_ID;
|
||||
#endif
|
||||
|
||||
case OBJECTS_ERROR:
|
||||
break;
|
||||
}
|
||||
|
||||
return RTEMS_INVALID_ID;
|
||||
_CORE_message_queue_Acquire_critical(
|
||||
&the_message_queue->message_queue,
|
||||
&lock_context
|
||||
);
|
||||
*count = the_message_queue->message_queue.number_of_pending_messages;
|
||||
_CORE_message_queue_Release(
|
||||
&the_message_queue->message_queue,
|
||||
&lock_context
|
||||
);
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
@@ -18,17 +18,9 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/chain.h>
|
||||
#include <rtems/score/isr.h>
|
||||
#include <rtems/score/coremsgimpl.h>
|
||||
#include <rtems/score/threadimpl.h>
|
||||
#include <rtems/score/wkspace.h>
|
||||
#include <rtems/rtems/status.h>
|
||||
#include <rtems/rtems/attrimpl.h>
|
||||
#include <rtems/rtems/messageimpl.h>
|
||||
#include <rtems/score/threadimpl.h>
|
||||
#include <rtems/rtems/optionsimpl.h>
|
||||
#include <rtems/rtems/support.h>
|
||||
|
||||
THREAD_WAIT_QUEUE_OBJECT_ASSERT(
|
||||
Message_queue_Control,
|
||||
@@ -43,66 +35,48 @@ rtems_status_code rtems_message_queue_receive(
|
||||
rtems_interval timeout
|
||||
)
|
||||
{
|
||||
Message_queue_Control *the_message_queue;
|
||||
Objects_Locations location;
|
||||
bool wait;
|
||||
Thread_Control *executing;
|
||||
ISR_lock_Context lock_context;
|
||||
Message_queue_Control *the_message_queue;
|
||||
ISR_lock_Context lock_context;
|
||||
Thread_Control *executing;
|
||||
|
||||
if ( !buffer )
|
||||
if ( buffer == NULL ) {
|
||||
return RTEMS_INVALID_ADDRESS;
|
||||
}
|
||||
|
||||
if ( !size )
|
||||
if ( size == NULL ) {
|
||||
return RTEMS_INVALID_ADDRESS;
|
||||
}
|
||||
|
||||
the_message_queue = _Message_queue_Get_interrupt_disable(
|
||||
id,
|
||||
&location,
|
||||
&lock_context
|
||||
);
|
||||
switch ( location ) {
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
if ( _Options_Is_no_wait( option_set ) )
|
||||
wait = false;
|
||||
else
|
||||
wait = true;
|
||||
|
||||
_CORE_message_queue_Acquire_critical(
|
||||
&the_message_queue->message_queue,
|
||||
&lock_context
|
||||
);
|
||||
|
||||
executing = _Thread_Executing;
|
||||
_CORE_message_queue_Seize(
|
||||
&the_message_queue->message_queue,
|
||||
executing,
|
||||
the_message_queue->Object.id,
|
||||
buffer,
|
||||
size,
|
||||
wait,
|
||||
timeout,
|
||||
&lock_context
|
||||
);
|
||||
return _Message_queue_Translate_core_message_queue_return_code(
|
||||
executing->Wait.return_code
|
||||
);
|
||||
|
||||
if ( the_message_queue == NULL ) {
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
case OBJECTS_REMOTE:
|
||||
return _Message_queue_MP_Send_request_packet(
|
||||
MESSAGE_QUEUE_MP_RECEIVE_REQUEST,
|
||||
id,
|
||||
buffer,
|
||||
size,
|
||||
option_set,
|
||||
timeout
|
||||
);
|
||||
_Message_queue_MP_Receive( id, buffer, size, option_set, timeout );
|
||||
#else
|
||||
return RTEMS_INVALID_ID;
|
||||
#endif
|
||||
|
||||
case OBJECTS_ERROR:
|
||||
break;
|
||||
}
|
||||
|
||||
return RTEMS_INVALID_ID;
|
||||
_CORE_message_queue_Acquire_critical(
|
||||
&the_message_queue->message_queue,
|
||||
&lock_context
|
||||
);
|
||||
|
||||
executing = _Thread_Executing;
|
||||
_CORE_message_queue_Seize(
|
||||
&the_message_queue->message_queue,
|
||||
executing,
|
||||
the_message_queue->Object.id,
|
||||
buffer,
|
||||
size,
|
||||
!_Options_Is_no_wait( option_set ),
|
||||
timeout,
|
||||
&lock_context
|
||||
);
|
||||
return _Message_queue_Translate_core_message_queue_return_code(
|
||||
executing->Wait.return_code
|
||||
);
|
||||
}
|
||||
|
||||
+31
-54
@@ -18,17 +18,7 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/chain.h>
|
||||
#include <rtems/score/isr.h>
|
||||
#include <rtems/score/coremsgimpl.h>
|
||||
#include <rtems/score/thread.h>
|
||||
#include <rtems/score/wkspace.h>
|
||||
#include <rtems/rtems/status.h>
|
||||
#include <rtems/rtems/attrimpl.h>
|
||||
#include <rtems/rtems/messageimpl.h>
|
||||
#include <rtems/rtems/options.h>
|
||||
#include <rtems/rtems/support.h>
|
||||
|
||||
rtems_status_code rtems_message_queue_send(
|
||||
rtems_id id,
|
||||
@@ -36,59 +26,46 @@ rtems_status_code rtems_message_queue_send(
|
||||
size_t size
|
||||
)
|
||||
{
|
||||
Message_queue_Control *the_message_queue;
|
||||
Objects_Locations location;
|
||||
CORE_message_queue_Status status;
|
||||
ISR_lock_Context lock_context;
|
||||
Message_queue_Control *the_message_queue;
|
||||
ISR_lock_Context lock_context;
|
||||
CORE_message_queue_Status status;
|
||||
|
||||
if ( !buffer )
|
||||
if ( buffer == NULL ) {
|
||||
return RTEMS_INVALID_ADDRESS;
|
||||
}
|
||||
|
||||
the_message_queue = _Message_queue_Get_interrupt_disable(
|
||||
id,
|
||||
&location,
|
||||
&lock_context
|
||||
);
|
||||
switch ( location ) {
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
_CORE_message_queue_Acquire_critical(
|
||||
&the_message_queue->message_queue,
|
||||
&lock_context
|
||||
);
|
||||
status = _CORE_message_queue_Send(
|
||||
&the_message_queue->message_queue,
|
||||
buffer,
|
||||
size,
|
||||
_Message_queue_Core_message_queue_mp_support,
|
||||
id,
|
||||
false, /* sender does not block */
|
||||
0, /* no timeout */
|
||||
&lock_context
|
||||
);
|
||||
|
||||
/*
|
||||
* Since this API does not allow for blocking sends, we can directly
|
||||
* return the returned status.
|
||||
*/
|
||||
|
||||
return _Message_queue_Translate_core_message_queue_return_code(status);
|
||||
|
||||
if ( the_message_queue == NULL ) {
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
case OBJECTS_REMOTE:
|
||||
return _Message_queue_MP_Send_request_packet(
|
||||
MESSAGE_QUEUE_MP_SEND_REQUEST,
|
||||
id,
|
||||
buffer,
|
||||
&size,
|
||||
0, /* option_set */
|
||||
MPCI_DEFAULT_TIMEOUT
|
||||
);
|
||||
break;
|
||||
_Message_queue_MP_Send( id, buffer, size );
|
||||
#else
|
||||
return RTEMS_INVALID_ID;
|
||||
#endif
|
||||
|
||||
case OBJECTS_ERROR:
|
||||
break;
|
||||
}
|
||||
return RTEMS_INVALID_ID;
|
||||
|
||||
_CORE_message_queue_Acquire_critical(
|
||||
&the_message_queue->message_queue,
|
||||
&lock_context
|
||||
);
|
||||
status = _CORE_message_queue_Send(
|
||||
&the_message_queue->message_queue,
|
||||
buffer,
|
||||
size,
|
||||
_Message_queue_Core_message_queue_mp_support,
|
||||
id,
|
||||
false, /* sender does not block */
|
||||
0, /* no timeout */
|
||||
&lock_context
|
||||
);
|
||||
|
||||
/*
|
||||
* Since this API does not allow for blocking sends, we can directly
|
||||
* return the returned status.
|
||||
*/
|
||||
|
||||
return _Message_queue_Translate_core_message_queue_return_code( status );
|
||||
}
|
||||
|
||||
@@ -18,17 +18,7 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/chain.h>
|
||||
#include <rtems/score/isr.h>
|
||||
#include <rtems/score/coremsgimpl.h>
|
||||
#include <rtems/score/thread.h>
|
||||
#include <rtems/score/wkspace.h>
|
||||
#include <rtems/rtems/status.h>
|
||||
#include <rtems/rtems/attrimpl.h>
|
||||
#include <rtems/rtems/messageimpl.h>
|
||||
#include <rtems/rtems/options.h>
|
||||
#include <rtems/rtems/support.h>
|
||||
|
||||
rtems_status_code rtems_message_queue_urgent(
|
||||
rtems_id id,
|
||||
@@ -36,59 +26,46 @@ rtems_status_code rtems_message_queue_urgent(
|
||||
size_t size
|
||||
)
|
||||
{
|
||||
Message_queue_Control *the_message_queue;
|
||||
Objects_Locations location;
|
||||
CORE_message_queue_Status status;
|
||||
ISR_lock_Context lock_context;
|
||||
Message_queue_Control *the_message_queue;
|
||||
ISR_lock_Context lock_context;
|
||||
CORE_message_queue_Status status;
|
||||
|
||||
if ( !buffer )
|
||||
if ( buffer == NULL ) {
|
||||
return RTEMS_INVALID_ADDRESS;
|
||||
}
|
||||
|
||||
the_message_queue = _Message_queue_Get_interrupt_disable(
|
||||
id,
|
||||
&location,
|
||||
&lock_context
|
||||
);
|
||||
switch ( location ) {
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
_CORE_message_queue_Acquire_critical(
|
||||
&the_message_queue->message_queue,
|
||||
&lock_context
|
||||
);
|
||||
status = _CORE_message_queue_Urgent(
|
||||
&the_message_queue->message_queue,
|
||||
buffer,
|
||||
size,
|
||||
_Message_queue_Core_message_queue_mp_support,
|
||||
id,
|
||||
false, /* sender does not block */
|
||||
0, /* no timeout */
|
||||
&lock_context
|
||||
);
|
||||
|
||||
/*
|
||||
* Since this API does not allow for blocking sends, we can directly
|
||||
* return the returned status.
|
||||
*/
|
||||
|
||||
return _Message_queue_Translate_core_message_queue_return_code(status);
|
||||
|
||||
if ( the_message_queue == NULL ) {
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
case OBJECTS_REMOTE:
|
||||
return _Message_queue_MP_Send_request_packet(
|
||||
MESSAGE_QUEUE_MP_URGENT_REQUEST,
|
||||
id,
|
||||
buffer,
|
||||
&size,
|
||||
0, /* option_set */
|
||||
MPCI_DEFAULT_TIMEOUT
|
||||
);
|
||||
_Message_queue_MP_Urgent( id, buffer, size );
|
||||
#else
|
||||
return RTEMS_INVALID_ID;
|
||||
#endif
|
||||
|
||||
case OBJECTS_ERROR:
|
||||
break;
|
||||
}
|
||||
|
||||
return RTEMS_INVALID_ID;
|
||||
_CORE_message_queue_Acquire_critical(
|
||||
&the_message_queue->message_queue,
|
||||
&lock_context
|
||||
);
|
||||
status = _CORE_message_queue_Urgent(
|
||||
&the_message_queue->message_queue,
|
||||
buffer,
|
||||
size,
|
||||
_Message_queue_Core_message_queue_mp_support,
|
||||
id,
|
||||
false, /* sender does not block */
|
||||
0, /* no timeout */
|
||||
&lock_context
|
||||
);
|
||||
|
||||
/*
|
||||
* Since this API does not allow for blocking sends, we can directly
|
||||
* return the returned status.
|
||||
*/
|
||||
|
||||
return _Message_queue_Translate_core_message_queue_return_code( status );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user