1/*
2 * Copyright 2016, Data61
3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO)
4 * ABN 41 687 119 230.
5 *
6 * This software may be distributed and modified according to the terms of
7 * the BSD 2-Clause license. Note that NO WARRANTY is provided.
8 * See "LICENSE_BSD2.txt" for details.
9 *
10 * @TAG(D61_BSD)
11 */
12
13/*! @file
14    @brief RefOS sharing library.
15
16    Helper ring buffer library which can be used to implement sharing. For details on how sharing
17    is done on RefOS, please refer to the protocol documentation. Uses a standard ringbuffer
18    implementation.
19
20    Assumes that the sharing has already been set up, and mapped into windows on both processes.
21*/
22
23#ifndef _REFOS_SHARE_H_
24#define _REFOS_SHARE_H_
25
26#include <stddef.h>
27
28#include "refos.h"
29
30/*! @brief Read from a shared buffer.
31    @param dest Buffer in which to store the read data. (output, no ownership)
32    @param len Maximum length of the destination buffer.
33    @param bufVaddr The shared ringbuffer address. (input, no ownership)
34    @param bufSize The shared ringbuffer size.
35    @param start Handle to the associated start address (input, output, no ownership)
36    @param bytesRead The number of bytes that has been successfully read from the shared buffer.
37                     (output, no ownership)
38    @return 0 if success, -1 otherwise.
39 */
40int refos_share_read(char *dest, size_t len, char *bufVaddr, size_t bufSize,
41        unsigned int *start, unsigned int *bytesRead);
42
43/*! @brief Write to a shared buffer.
44    @param src Buffer containing content to write. (input, no ownership)
45    @param len Length of the content source.
46    @param bufVaddr The shared ringbuffer address. (input, no ownership)
47    @param bufSize The shared ringbuffer size.
48    @param end Handle to the associated end address (input, output, no ownership)
49    @return 0 if success, -1 otherwise.
50 */
51int refos_share_write(char *src, size_t len, char *bufVaddr, size_t bufSize,
52        unsigned int *end);
53
54#endif /* _REFOS_SHARE_H_ */
55
56