It is a non blocking implementation for just a single writer (producer) and reader (consumer) and, under such a constraint, it can be a specific substitute for RTAI mailboxes. There are other constraints that must be satisfied, so it cannot be a general substitute for the more flexible RTAI mailboxes. In fact it provides just functions corresponding to RTAI mailboxes non blocking atomic send/receive of messages, i.e. the equivalents of rt_mbx_send_if and rt_mbx_receive_if. Moreover the circular buffer size must be >= to the largest message to be sent/received. At least the double of the largest message to be sent/received is strongly recommended. Thus sending/receiving a message either succeeds of fails. However thanks to the use of shared memory it should be more efficient than mailboxes in atomic exchanges of messages from kernel to user space. So it is a good candidate for supporting drivers development.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Definition in file rtai_scb.h.
Include dependency graph for rtai_scb.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Defines | |
#define | SCB ((void *)(scb)) |
#define | SIZE ((volatile int *)scb)[-3] |
#define | FBYTE ((volatile int *)scb)[-2] |
#define | LBYTE ((volatile int *)scb)[-1] |
#define | HDRSIZ (3*sizeof(int)) |
#define | RTAI_SCB_PROTO RTAI_PROTO |
Functions | |
RTAI_SCB_PROTO (void *, rt_scb_init,(unsigned long name, int size, unsigned long suprt)) | |
Allocate and initialize a shared memory circular buffer. | |
RTAI_SCB_PROTO (void, rt_scb_reset,(void *scb)) | |
Reset a shared memory circular buffer. | |
RTAI_SCB_PROTO (int, rt_scb_delete,(unsigned long name)) | |
Free a shared memory circular buffer. | |
RTAI_SCB_PROTO (int, rt_scb_avbs,(void *scb)) | |
Get the number of bytes avaiable in a shared memory circular buffer. | |
RTAI_SCB_PROTO (int, rt_scb_bytes,(void *scb)) | |
Get the number of bytes avaiable in a shared memory circular buffer. | |
RTAI_SCB_PROTO (int, rt_scb_frbs,(void *scb)) | |
Get the number of free bytes pace in a shared memory circular buffer. | |
RTAI_SCB_PROTO (int, rt_scb_get,(void *scb, void *msg, int msg_size)) | |
Gets (receives) a message, only if the whole message can be passed all at once. | |
RTAI_SCB_PROTO (int, rt_scb_evdrp,(void *scb, void *msg, int msg_size)) | |
eavedrops a message. | |
RTAI_SCB_PROTO (int, rt_scb_put,(void *scb, void *msg, int msg_size)) | |
Puts (sends) a message, only if the whole message can be passed all at once. | |
RTAI_SCB_PROTO (int, rt_scb_ovrwr,(void *scb, void *msg, int msg_size)) |
#define FBYTE ((volatile int *)scb)[-2] |
#define HDRSIZ (3*sizeof(int)) |
#define LBYTE ((volatile int *)scb)[-1] |
#define RTAI_SCB_PROTO RTAI_PROTO |
Definition at line 60 of file rtai_scb.h.
#define SCB ((void *)(scb)) |
#define SIZE ((volatile int *)scb)[-3] |
RTAI_SCB_PROTO | ( | int | , | |
rt_scb_ovrwr | , | |||
(void *scb, void *msg, int msg_size) | ||||
) |
RTAI_SCB_PROTO | ( | int | , | |
rt_scb_put | , | |||
(void *scb, void *msg, int msg_size) | ||||
) |
Puts (sends) a message, only if the whole message can be passed all at once.
rt_scb_put tries to atomically send the message msg of msg_size bytes to the shared memory circular buffer scb. It returns immediately and the caller is never blocked.
Definition at line 296 of file rtai_scb.h.
RTAI_SCB_PROTO | ( | int | , | |
rt_scb_evdrp | , | |||
(void *scb, void *msg, int msg_size) | ||||
) |
eavedrops a message.
rt_scb_evdrp atomically spies the message msg of msg_size bytes from the shared memory circular buffer scb. It returns immediately and the caller is never blocked. It is like rt_scb_get but leaves the message in the shared memory circular buffer.
Definition at line 268 of file rtai_scb.h.
RTAI_SCB_PROTO | ( | int | , | |
rt_scb_get | , | |||
(void *scb, void *msg, int msg_size) | ||||
) |
Gets (receives) a message, only if the whole message can be passed all at once.
rt_scb_get tries to atomically receive the message msg of msg_size bytes from the shared memory circular buffer scb. It returns immediately and the caller is never blocked.
Definition at line 238 of file rtai_scb.h.
RTAI_SCB_PROTO | ( | int | , | |
rt_scb_frbs | , | |||
(void *scb) | ||||
) |
Get the number of free bytes pace in a shared memory circular buffer.
For internal use only.
rt_scb_frbs is used to get the number of free bytes space avaiable in a shared memory circular buffer.
scb | is the pointer handle returned when the buffer was initted. |
Definition at line 220 of file rtai_scb.h.
RTAI_SCB_PROTO | ( | int | , | |
rt_scb_bytes | , | |||
(void *scb) | ||||
) |
Get the number of bytes avaiable in a shared memory circular buffer.
For internal use only.
rt_scb_bytes is used to get the number of bytes avaiable in a shared memory circular buffer; legacy alias for rt_scb_avbs.
scb | is the pointer handle returned when the buffer was initted. |
Definition at line 201 of file rtai_scb.h.
RTAI_SCB_PROTO | ( | int | , | |
rt_scb_avbs | , | |||
(void *scb) | ||||
) |
Get the number of bytes avaiable in a shared memory circular buffer.
For internal use only.
rt_scb_avbs is used to get the number of bytes avaiable in a shared memory circular buffer.
scb | is the pointer handle returned when the buffer was initted. |
Definition at line 181 of file rtai_scb.h.
RTAI_SCB_PROTO | ( | int | , | |
rt_scb_delete | , | |||
(unsigned long name) | ||||
) |
Free a shared memory circular buffer.
For internal use only.
rt_scb_delete is used to release a previously allocated shared memory circular buffer.
name | is the unsigned long identifier used when the buffer was allocated; |
Definition at line 162 of file rtai_scb.h.
References rt_shm_free().
Here is the call graph for this function:
RTAI_SCB_PROTO | ( | void | , | |
rt_scb_reset | , | |||
(void *scb) | ||||
) |
Reset a shared memory circular buffer.
For internal use only.
rt_scb_reset reinitializes a shared memory circular buffer.
scb | is the pointer returned when the buffer was initted. |
Definition at line 134 of file rtai_scb.h.
RTAI_SCB_PROTO | ( | void * | , | |
rt_scb_init | , | |||
(unsigned long name, int size, unsigned long suprt) | ||||
) |
Allocate and initialize a shared memory circular buffer.
For internal use only.
rt_scb_init is used to allocate and/or initialize a shared memory circular buffer.
name | is an unsigned long identifier; | |
size | is the size of the circular buffer. | |
suprt | is the kernel allocation method to be used, it can be:
|
Definition at line 105 of file rtai_scb.h.
References atomic_cmpxchg(), HDRSIZ, and rt_shm_alloc.
Here is the call graph for this function: