RTEMS  5.1
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 
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 
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 
52 int rtems_rfs_buffer_bdbuf_request (rtems_rfs_file_system* fs,
54  bool read,
55  rtems_rfs_buffer** buffer);
59 int 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;
67  void* buffer;
68  size_t size;
69  uint32_t references;
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 
79  bool read,
80  rtems_rfs_buffer* buffer);
85  bool modified);
86 #endif
87 
92 {
96  bool dirty;
97 
103 
108 
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 
174  rtems_rfs_buffer_handle* handle,
176  bool read);
177 
190  rtems_rfs_buffer_handle* handle);
191 
201 static inline int
202 rtems_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 
220 static inline int
221 rtems_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 
240 int rtems_rfs_buffer_open (const char* name, rtems_rfs_file_system* fs);
241 
251 
261 
272 
282 
283 #endif
int rtems_rfs_buffer_deviceio_release(rtems_rfs_buffer *handle, bool modified)
Definition: chain.h:68
ssize_t read(int fd, void *buffer, size_t count)
Definition: read.c:27
uint32_t rtems_blkdev_bnum
Block device block index type.
Definition: diskdevs.h:45
int rtems_rfs_buffer_close(rtems_rfs_file_system *fs)
Definition: rtems-rfs-buffer.c:350
int rtems_rfs_buffer_sync(rtems_rfs_file_system *fs)
Definition: rtems-rfs-buffer.c:379
Definition: rtems-rfs-file-system.h:123
uint32_t rtems_rfs_buffer_block
Definition: rtems-rfs-buffer.h:62
int rtems_rfs_buffer_setblksize(rtems_rfs_file_system *fs, uint32_t size)
Definition: rtems-rfs-buffer.c:414
RTEMS Error Reporting.
rtems_rfs_buffer * buffer
Definition: rtems-rfs-buffer.h:107
int rtems_rfs_buffer_handle_release(rtems_rfs_file_system *fs, rtems_rfs_buffer_handle *handle)
Definition: rtems-rfs-buffer.c:201
bool dirty
Definition: rtems-rfs-buffer.h:96
Manages the Trace and Debugging Features of the RTEMS RFS File System.
int rtems_rfs_buffer_deviceio_request(rtems_rfs_file_system *fs, rtems_rfs_buffer_block block, bool read, rtems_rfs_buffer *buffer)
struct rtems_rfs_buffer_handle_t rtems_rfs_buffer_handle
Definition: bdbuf.h:308
int rtems_rfs_buffer_open(const char *name, rtems_rfs_file_system *fs)
Definition: rtems-rfs-buffer.c:289
Definition: rtems-rfs-buffer.h:63
Definition: rtems-rfs-buffer.h:91
RTEMS File Systems Data Forward Declaration.
rtems_rfs_buffer_block bnum
Definition: rtems-rfs-buffer.h:102
int rtems_rfs_buffers_release(rtems_rfs_file_system *fs)
Definition: rtems-rfs-buffer.c:466
unsigned size
Definition: tte.h:74
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
Block Device Buffer Management.
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77