RTEMS: cpukit/include/rtems/rfs/rtems-rfs-buffer.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
rtems-rfs-buffer.h
Go to the documentation of this file.
1
11/*
12 * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
13 *
14 * The license and distribution terms for this file may be
15 * found in the file LICENSE in this distribution or at
16 * http://www.rtems.org/license/LICENSE.
17 */
18
19
20#if !defined (_RTEMS_RFS_BUFFER_H_)
21#define _RTEMS_RFS_BUFFER_H_
22
23#include <errno.h>
24
25#include <rtems/rfs/rtems-rfs-file-system-fwd.h>
26#include <rtems/rfs/rtems-rfs-trace.h>
27
33#if defined (__rtems__)
34#define RTEMS_RFS_USE_LIBBLOCK 1
35#endif
36
40#if RTEMS_RFS_USE_LIBBLOCK
41#include <rtems/bdbuf.h>
42#include <rtems/error.h>
43
44typedef rtems_blkdev_bnum rtems_rfs_buffer_block;
45typedef rtems_bdbuf_buffer rtems_rfs_buffer;
46#define rtems_rfs_buffer_io_request rtems_rfs_buffer_bdbuf_request
47#define rtems_rfs_buffer_io_release rtems_rfs_buffer_bdbuf_release
48
52int rtems_rfs_buffer_bdbuf_request (rtems_rfs_file_system* fs,
53 rtems_rfs_buffer_block block,
54 bool read,
55 rtems_rfs_buffer** buffer);
59int rtems_rfs_buffer_bdbuf_release (rtems_rfs_buffer* handle,
60 bool modified);
61#else /* Device I/O */
62 typedef uint32_t rtems_rfs_buffer_block;
63 typedef struct _rtems_rfs_buffer
64{
65 rtems_chain_node link;
66 rtems_rfs_buffer_block user;
67 void* buffer;
68 size_t size;
69 uint32_t references;
70} rtems_rfs_buffer;
71#define rtems_rfs_buffer_io_request rtems_rfs_buffer_deviceio_request
72#define rtems_rfs_buffer_io_release rtems_rfs_buffer_deviceio_release
73
77 int rtems_rfs_buffer_deviceio_request (rtems_rfs_file_system* fs,
78 rtems_rfs_buffer_block block,
79 bool read,
80 rtems_rfs_buffer* buffer);
84 int rtems_rfs_buffer_deviceio_release (rtems_rfs_buffer* handle,
85 bool modified);
86#endif
87
91 typedef struct rtems_rfs_buffer_handle_t
92{
96 bool dirty;
97
102 rtems_rfs_buffer_block bnum;
103
107 rtems_rfs_buffer* buffer;
108
109} rtems_rfs_buffer_handle;
110
114#define rtems_rfs_buffer_link(_h) (&(_h)->buffer->link)
115
119#define rtems_rfs_buffer_data(_h) ((void*)((_h)->buffer->buffer))
120
124#define rtems_rfs_buffer_size(_h) ((_h)->buffer->size)
125
129#define rtems_rfs_buffer_bnum(_h) ((_h)->bnum)
130
134#define rtems_rfs_buffer_dirty(_h) ((_h)->dirty)
135
139#define rtems_rfs_buffer_handle_has_block(_h) ((_h)->buffer ? true : false)
140
144#define rtems_rfs_buffer_mark_dirty(_h) ((_h)->dirty = true)
145
149#define rtems_rfs_buffer_refs(_h) ((_h)->buffer->references)
150
154#define rtems_rfs_buffer_refs_up(_h) ((_h)->buffer->references += 1)
155
159#define rtems_rfs_buffer_refs_down(_h) ((_h)->buffer->references -= 1)
160
173int rtems_rfs_buffer_handle_request (rtems_rfs_file_system* fs,
174 rtems_rfs_buffer_handle* handle,
175 rtems_rfs_buffer_block block,
176 bool read);
177
189int rtems_rfs_buffer_handle_release (rtems_rfs_file_system* fs,
190 rtems_rfs_buffer_handle* handle);
191
201static inline int
202rtems_rfs_buffer_handle_open (rtems_rfs_file_system* fs,
203 rtems_rfs_buffer_handle* handle)
204{
205 handle->dirty = false;
206 handle->bnum = 0;
207 handle->buffer = NULL;
208 return 0;
209}
210
220static inline int
221rtems_rfs_buffer_handle_close (rtems_rfs_file_system* fs,
222 rtems_rfs_buffer_handle* handle)
223{
224 rtems_rfs_buffer_handle_release (fs, handle);
225 handle->dirty = false;
226 handle->bnum = 0;
227 handle->buffer = NULL;
228 return 0;
229}
230
240int rtems_rfs_buffer_open (const char* name, rtems_rfs_file_system* fs);
241
250int rtems_rfs_buffer_close (rtems_rfs_file_system* fs);
251
260int rtems_rfs_buffer_sync (rtems_rfs_file_system* fs);
261
271int rtems_rfs_buffer_setblksize (rtems_rfs_file_system* fs, uint32_t size);
272
281int rtems_rfs_buffers_release (rtems_rfs_file_system* fs);
282
283#endif
bdbuf.h
Block Device Buffer Management.
NULL
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77
error.h
RTEMS Error Reporting.
rtems_blkdev_bnum
uint32_t rtems_blkdev_bnum
Block device block index type.
Definition: diskdevs.h:45
rtems_rfs_buffer_handle_request
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:79
rtems_rfs_buffers_release
int rtems_rfs_buffers_release(rtems_rfs_file_system *fs)
Definition: rtems-rfs-buffer.c:466
rtems_rfs_buffer_block
uint32_t rtems_rfs_buffer_block
Definition: rtems-rfs-buffer.h:62
rtems_rfs_buffer_deviceio_release
int rtems_rfs_buffer_deviceio_release(rtems_rfs_buffer *handle, bool modified)
rtems_rfs_buffer_handle
struct rtems_rfs_buffer_handle_t rtems_rfs_buffer_handle
rtems_rfs_buffer_handle_release
int rtems_rfs_buffer_handle_release(rtems_rfs_file_system *fs, rtems_rfs_buffer_handle *handle)
Definition: rtems-rfs-buffer.c:201
rtems_rfs_buffer_setblksize
int rtems_rfs_buffer_setblksize(rtems_rfs_file_system *fs, uint32_t size)
Definition: rtems-rfs-buffer.c:414
rtems_rfs_buffer_deviceio_request
int rtems_rfs_buffer_deviceio_request(rtems_rfs_file_system *fs, rtems_rfs_buffer_block block, bool read, rtems_rfs_buffer *buffer)
rtems_rfs_buffer_sync
int rtems_rfs_buffer_sync(rtems_rfs_file_system *fs)
Definition: rtems-rfs-buffer.c:379
rtems_rfs_buffer_close
int rtems_rfs_buffer_close(rtems_rfs_file_system *fs)
Definition: rtems-rfs-buffer.c:350
rtems_rfs_buffer_open
int rtems_rfs_buffer_open(const char *name, rtems_rfs_file_system *fs)
Definition: rtems-rfs-buffer.c:289
rtems-rfs-file-system-fwd.h
RTEMS File Systems Data Forward Declaration.
rtems-rfs-trace.h
Manages the Trace and Debugging Features of the RTEMS RFS File System.
Chain_Node_struct
Definition: chain.h:68
_rtems_rfs_buffer
Definition: rtems-rfs-buffer.h:64
_rtems_rfs_file_system
Definition: rtems-rfs-file-system.h:116
rtems_bdbuf_buffer
Definition: bdbuf.h:309
rtems_rfs_buffer_handle_t
Definition: rtems-rfs-buffer.h:92
rtems_rfs_buffer_handle_t::buffer
rtems_rfs_buffer * buffer
Definition: rtems-rfs-buffer.h:107
rtems_rfs_buffer_handle_t::dirty
bool dirty
Definition: rtems-rfs-buffer.h:96
rtems_rfs_buffer_handle_t::bnum
rtems_rfs_buffer_block bnum
Definition: rtems-rfs-buffer.h:102