RTEMS 6.1-rc4
Loading...
Searching...
No Matches
rtems-rfs-buffer.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
13/*
14 * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 */
37
38
39#if !defined (_RTEMS_RFS_BUFFER_H_)
40#define _RTEMS_RFS_BUFFER_H_
41
42#include <errno.h>
43
46
52#if defined (__rtems__)
53#define RTEMS_RFS_USE_LIBBLOCK 1
54#endif
55
59#if RTEMS_RFS_USE_LIBBLOCK
60#include <rtems/bdbuf.h>
61#include <rtems/error.h>
62
65#define rtems_rfs_buffer_io_request rtems_rfs_buffer_bdbuf_request
66#define rtems_rfs_buffer_io_release rtems_rfs_buffer_bdbuf_release
67
71int rtems_rfs_buffer_bdbuf_request (rtems_rfs_file_system* fs,
73 bool read,
74 rtems_rfs_buffer** buffer);
78int rtems_rfs_buffer_bdbuf_release (rtems_rfs_buffer* handle,
79 bool modified);
80#else /* Device I/O */
81typedef uint32_t rtems_rfs_buffer_block;
82typedef struct _rtems_rfs_buffer
83{
86 void* buffer;
87 size_t size;
88 uint32_t references;
90#define rtems_rfs_buffer_io_request rtems_rfs_buffer_deviceio_request
91#define rtems_rfs_buffer_io_release rtems_rfs_buffer_deviceio_release
92
98 bool read,
99 rtems_rfs_buffer* buffer);
104 bool modified);
105#endif
106
111{
115 bool dirty;
116
122
127
129
133#define rtems_rfs_buffer_link(_h) (&(_h)->buffer->link)
134
138#define rtems_rfs_buffer_data(_h) ((void*)((_h)->buffer->buffer))
139
143#define rtems_rfs_buffer_size(_h) ((_h)->buffer->size)
144
148#define rtems_rfs_buffer_bnum(_h) ((_h)->bnum)
149
153#define rtems_rfs_buffer_dirty(_h) ((_h)->dirty)
154
158#define rtems_rfs_buffer_handle_has_block(_h) ((_h)->buffer ? true : false)
159
163#define rtems_rfs_buffer_mark_dirty(_h) ((_h)->dirty = true)
164
168#define rtems_rfs_buffer_refs(_h) ((_h)->buffer->references)
169
173#define rtems_rfs_buffer_refs_up(_h) ((_h)->buffer->references += 1)
174
178#define rtems_rfs_buffer_refs_down(_h) ((_h)->buffer->references -= 1)
179
195 bool read);
196
210
220static inline int
221rtems_rfs_buffer_handle_open (rtems_rfs_file_system* fs,
223{
224 handle->dirty = false;
225 handle->bnum = 0;
226 handle->buffer = NULL;
227 return 0;
228}
229
239static inline int
240rtems_rfs_buffer_handle_close (rtems_rfs_file_system* fs,
242{
244 handle->dirty = false;
245 handle->bnum = 0;
246 handle->buffer = NULL;
247 return 0;
248}
249
259int rtems_rfs_buffer_open (const char* name, rtems_rfs_file_system* fs);
260
270
280
291
301
302#endif
Block Device Buffer Management.
RTEMS Error Reporting.
uint32_t rtems_blkdev_bnum
Block device block index type.
Definition: diskdevs.h:45
int rtems_rfs_buffer_handle_request(rtems_rfs_file_system *fs, rtems_rfs_buffer_handle *handle, rtems_rfs_buffer_block block, bool read)
Definition: rtems-rfs-buffer.c:98
int rtems_rfs_buffers_release(rtems_rfs_file_system *fs)
Definition: rtems-rfs-buffer.c:485
uint32_t rtems_rfs_buffer_block
Definition: rtems-rfs-buffer.h:81
int rtems_rfs_buffer_deviceio_release(rtems_rfs_buffer *handle, bool modified)
struct rtems_rfs_buffer_handle_t rtems_rfs_buffer_handle
int rtems_rfs_buffer_handle_release(rtems_rfs_file_system *fs, rtems_rfs_buffer_handle *handle)
Definition: rtems-rfs-buffer.c:220
int rtems_rfs_buffer_setblksize(rtems_rfs_file_system *fs, uint32_t size)
Definition: rtems-rfs-buffer.c:433
int rtems_rfs_buffer_deviceio_request(rtems_rfs_file_system *fs, rtems_rfs_buffer_block block, bool read, rtems_rfs_buffer *buffer)
int rtems_rfs_buffer_sync(rtems_rfs_file_system *fs)
Definition: rtems-rfs-buffer.c:398
int rtems_rfs_buffer_close(rtems_rfs_file_system *fs)
Definition: rtems-rfs-buffer.c:369
int rtems_rfs_buffer_open(const char *name, rtems_rfs_file_system *fs)
Definition: rtems-rfs-buffer.c:308
RTEMS File Systems Data Forward Declaration.
Manages the Trace and Debugging Features of the RTEMS RFS File System.
This structure represents a chain node.
Definition: chain.h:78
Definition: rtems-rfs-buffer.h:83
Definition: rtems-rfs-file-system.h:135
Definition: bdbuf.h:309
Definition: rtems-rfs-buffer.h:111
rtems_rfs_buffer * buffer
Definition: rtems-rfs-buffer.h:126
bool dirty
Definition: rtems-rfs-buffer.h:115
rtems_rfs_buffer_block bnum
Definition: rtems-rfs-buffer.h:121