RTEMS: cpukit/include/rtems/jffs2.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
jffs2.h
1/*
2 * Copyright (c) 2013, 2016 embedded brains GmbH. All rights reserved.
3 *
4 * embedded brains GmbH
5 * Dornierstr. 4
6 * 82178 Puchheim
7 * Germany
8 * <rtems@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#ifndef RTEMS_JFFS2_H
16#define RTEMS_JFFS2_H
17
18#include <rtems/fs.h>
19#include <sys/param.h>
20#include <sys/ioccom.h>
21#include <zlib.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif /* __cplusplus */
26
27typedef struct rtems_jffs2_flash_control rtems_jffs2_flash_control;
28
176 typedef int (*rtems_jffs2_flash_read)(
177 rtems_jffs2_flash_control *self,
178 uint32_t offset,
179 unsigned char *buffer,
180 size_t size_of_buffer
181);
182
195 typedef int (*rtems_jffs2_flash_write)(
196 rtems_jffs2_flash_control *self,
197 uint32_t offset,
198 const unsigned char *buffer,
199 size_t size_of_buffer
200);
201
214 typedef int (*rtems_jffs2_flash_erase)(
215 rtems_jffs2_flash_control *self,
216 uint32_t offset
217);
218
228 typedef void (*rtems_jffs2_flash_destroy)(
229 rtems_jffs2_flash_control *self
230);
231
242 typedef void (*rtems_jffs2_trigger_garbage_collection)(
243 rtems_jffs2_flash_control *self
244);
245
249 struct rtems_jffs2_flash_control {
253 uint32_t block_size;
254
261 uint32_t flash_size;
262
266 rtems_jffs2_flash_read read;
267
271 rtems_jffs2_flash_write write;
272
276 rtems_jffs2_flash_erase erase;
277
283 rtems_jffs2_flash_destroy destroy;
284
291 dev_t device_identifier;
292
300 rtems_jffs2_trigger_garbage_collection trigger_garbage_collection;
301};
302
303typedef struct rtems_jffs2_compressor_control rtems_jffs2_compressor_control;
304
320 typedef uint16_t (*rtems_jffs2_compressor_compress)(
321 rtems_jffs2_compressor_control *self,
322 unsigned char *data_in,
323 unsigned char *cdata_out,
324 uint32_t *datalen,
325 uint32_t *cdatalen
326);
327
342 typedef int (*rtems_jffs2_compressor_decompress)(
343 rtems_jffs2_compressor_control *self,
344 uint16_t comprtype,
345 unsigned char *cdata_in,
346 unsigned char *data_out,
347 uint32_t cdatalen,
348 uint32_t datalen
349);
350
360 typedef void (*rtems_jffs2_compressor_destroy)(
361 rtems_jffs2_compressor_control *self
362);
363
367 struct rtems_jffs2_compressor_control {
371 rtems_jffs2_compressor_compress compress;
372
376 rtems_jffs2_compressor_decompress decompress;
377
383 rtems_jffs2_compressor_destroy destroy;
384
388 unsigned char buffer[PAGE_SIZE];
389};
390
394uint16_t rtems_jffs2_compressor_rtime_compress(
395 rtems_jffs2_compressor_control *self,
396 unsigned char *data_in,
397 unsigned char *cdata_out,
398 uint32_t *datalen,
399 uint32_t *cdatalen
400);
401
405int rtems_jffs2_compressor_rtime_decompress(
406 rtems_jffs2_compressor_control *self,
407 uint16_t comprtype,
408 unsigned char *cdata_in,
409 unsigned char *data_out,
410 uint32_t cdatalen,
411 uint32_t datalen
412);
413
417 typedef struct {
418 rtems_jffs2_compressor_control super;
419 z_stream stream;
420} rtems_jffs2_compressor_zlib_control;
421
425uint16_t rtems_jffs2_compressor_zlib_compress(
426 rtems_jffs2_compressor_control *self,
427 unsigned char *data_in,
428 unsigned char *cdata_out,
429 uint32_t *datalen,
430 uint32_t *cdatalen
431);
432
436int rtems_jffs2_compressor_zlib_decompress(
437 rtems_jffs2_compressor_control *self,
438 uint16_t comprtype,
439 unsigned char *cdata_in,
440 unsigned char *data_out,
441 uint32_t cdatalen,
442 uint32_t datalen
443);
444
450 typedef struct {
454 rtems_jffs2_flash_control *flash_control;
455
461 rtems_jffs2_compressor_control *compressor_control;
462} rtems_jffs2_mount_data;
463
477int rtems_jffs2_initialize(
478 rtems_filesystem_mount_table_entry_t *mt_entry,
479 const void *data
480);
481
487 typedef struct {
491 uint32_t flash_size;
492
496 uint32_t flash_blocks;
497
501 uint32_t flash_block_size;
502
508 uint32_t used_size;
509
515 uint32_t dirty_size;
516
522 uint32_t wasted_size;
523
529 uint32_t free_size;
530
536 uint32_t bad_size;
537
543 uint32_t clean_blocks;
544
550 uint32_t dirty_blocks;
551
557 uint32_t erasable_blocks;
558
564 uint32_t free_blocks;
565
571 uint32_t bad_blocks;
572} rtems_jffs2_info;
573
579#define RTEMS_JFFS2_GET_INFO _IOR('F', 1, rtems_jffs2_info)
580
588#define RTEMS_JFFS2_ON_DEMAND_GARBAGE_COLLECTION _IO('F', 2)
589
596#define RTEMS_JFFS2_FORCE_GARBAGE_COLLECTION _IO('F', 3)
597
600#ifdef __cplusplus
601}
602#endif /* __cplusplus */
603
604#endif /* RTEMS_JFFS2_H */
rtems_jffs2_compressor_rtime_decompress
int rtems_jffs2_compressor_rtime_decompress(rtems_jffs2_compressor_control *self, uint16_t comprtype, unsigned char *cdata_in, unsigned char *data_out, uint32_t cdatalen, uint32_t datalen)
RTIME compressor decompress operation.
Definition: compr_rtime.c:80
rtems_jffs2_flash_erase
int(* rtems_jffs2_flash_erase)(rtems_jffs2_flash_control *self, uint32_t offset)
Flash erase operation.
Definition: jffs2.h:214
rtems_jffs2_flash_read
int(* rtems_jffs2_flash_read)(rtems_jffs2_flash_control *self, uint32_t offset, unsigned char *buffer, size_t size_of_buffer)
Read from flash operation.
Definition: jffs2.h:176
rtems_jffs2_compressor_rtime_compress
uint16_t rtems_jffs2_compressor_rtime_compress(rtems_jffs2_compressor_control *self, unsigned char *data_in, unsigned char *cdata_out, uint32_t *datalen, uint32_t *cdatalen)
RTIME compressor compress operation.
Definition: compr_rtime.c:33
rtems_jffs2_compressor_compress
uint16_t(* rtems_jffs2_compressor_compress)(rtems_jffs2_compressor_control *self, unsigned char *data_in, unsigned char *cdata_out, uint32_t *datalen, uint32_t *cdatalen)
Compress operation.
Definition: jffs2.h:320
rtems_jffs2_trigger_garbage_collection
void(* rtems_jffs2_trigger_garbage_collection)(rtems_jffs2_flash_control *self)
Trigger garbage collection operation.
Definition: jffs2.h:242
rtems_jffs2_compressor_zlib_compress
uint16_t rtems_jffs2_compressor_zlib_compress(rtems_jffs2_compressor_control *self, unsigned char *data_in, unsigned char *cdata_out, uint32_t *datalen, uint32_t *cdatalen)
ZLIB compressor compress operation.
Definition: compr_zlib.c:46
rtems_jffs2_compressor_destroy
void(* rtems_jffs2_compressor_destroy)(rtems_jffs2_compressor_control *self)
Compressor destroy operation.
Definition: jffs2.h:360
rtems_jffs2_initialize
int rtems_jffs2_initialize(rtems_filesystem_mount_table_entry_t *mt_entry, const void *data)
Initialization handler of the JFFS2 file system.
Definition: fs-rtems.c:1216
rtems_jffs2_compressor_decompress
int(* rtems_jffs2_compressor_decompress)(rtems_jffs2_compressor_control *self, uint16_t comprtype, unsigned char *cdata_in, unsigned char *data_out, uint32_t cdatalen, uint32_t datalen)
Decompress operation.
Definition: jffs2.h:342
rtems_jffs2_flash_destroy
void(* rtems_jffs2_flash_destroy)(rtems_jffs2_flash_control *self)
Flash destroy operation.
Definition: jffs2.h:228
rtems_jffs2_compressor_zlib_decompress
int rtems_jffs2_compressor_zlib_decompress(rtems_jffs2_compressor_control *self, uint16_t comprtype, unsigned char *cdata_in, unsigned char *data_out, uint32_t cdatalen, uint32_t datalen)
ZLIB compressor decompress operation.
Definition: compr_zlib.c:121
rtems_jffs2_flash_write
int(* rtems_jffs2_flash_write)(rtems_jffs2_flash_control *self, uint32_t offset, const unsigned char *buffer, size_t size_of_buffer)
Write to flash operation.
Definition: jffs2.h:195
fs.h
Basic Filesystem Types.
rtems_filesystem_mount_table_entry_tt
Mount table entry.
Definition: libio.h:1604
rtems_jffs2_compressor_control
JFFS2 compressor control.
Definition: jffs2.h:367
rtems_jffs2_compressor_control::compress
rtems_jffs2_compressor_compress compress
Compress operation.
Definition: jffs2.h:371
rtems_jffs2_compressor_control::destroy
rtems_jffs2_compressor_destroy destroy
Compressor destroy operation.
Definition: jffs2.h:383
rtems_jffs2_compressor_control::buffer
unsigned char buffer[PAGE_SIZE]
Compression buffer.
Definition: jffs2.h:388
rtems_jffs2_compressor_control::decompress
rtems_jffs2_compressor_decompress decompress
Decompress operation.
Definition: jffs2.h:376
rtems_jffs2_compressor_zlib_control
ZLIB compressor control structure.
Definition: jffs2.h:417
rtems_jffs2_flash_control
JFFS2 flash device control.
Definition: jffs2.h:249
rtems_jffs2_flash_control::trigger_garbage_collection
rtems_jffs2_trigger_garbage_collection trigger_garbage_collection
Trigger garbage collection operation.
Definition: jffs2.h:300
rtems_jffs2_flash_control::flash_size
uint32_t flash_size
The size in bytes of the flash device.
Definition: jffs2.h:261
rtems_jffs2_flash_control::erase
rtems_jffs2_flash_erase erase
Flash erase operation.
Definition: jffs2.h:276
rtems_jffs2_flash_control::read
rtems_jffs2_flash_read read
Read from flash operation.
Definition: jffs2.h:266
rtems_jffs2_flash_control::destroy
rtems_jffs2_flash_destroy destroy
Flash destroy operation.
Definition: jffs2.h:283
rtems_jffs2_flash_control::write
rtems_jffs2_flash_write write
Write to flash operation.
Definition: jffs2.h:271
rtems_jffs2_flash_control::block_size
uint32_t block_size
The size in bytes of the erasable unit of the flash device.
Definition: jffs2.h:253
rtems_jffs2_flash_control::device_identifier
dev_t device_identifier
The device identifier of the flash device.
Definition: jffs2.h:291
rtems_jffs2_info
JFFS2 filesystem instance information.
Definition: jffs2.h:487
rtems_jffs2_info::flash_block_size
uint32_t flash_block_size
Size of a flash block in bytes.
Definition: jffs2.h:501
rtems_jffs2_info::flash_blocks
uint32_t flash_blocks
Count of flash blocks (erasable units).
Definition: jffs2.h:496
rtems_jffs2_info::dirty_blocks
uint32_t dirty_blocks
Count of dirty blocks.
Definition: jffs2.h:550
rtems_jffs2_info::clean_blocks
uint32_t clean_blocks
Count of clean blocks.
Definition: jffs2.h:543
rtems_jffs2_info::bad_blocks
uint32_t bad_blocks
Count of bad blocks.
Definition: jffs2.h:571
rtems_jffs2_info::flash_size
uint32_t flash_size
Flash size in bytes.
Definition: jffs2.h:491
rtems_jffs2_info::wasted_size
uint32_t wasted_size
Wasted size in bytes.
Definition: jffs2.h:522
rtems_jffs2_info::used_size
uint32_t used_size
Used size in bytes.
Definition: jffs2.h:508
rtems_jffs2_info::erasable_blocks
uint32_t erasable_blocks
Count of erasable blocks.
Definition: jffs2.h:557
rtems_jffs2_info::free_size
uint32_t free_size
Free size in bytes.
Definition: jffs2.h:529
rtems_jffs2_info::free_blocks
uint32_t free_blocks
Count of free blocks.
Definition: jffs2.h:564
rtems_jffs2_info::dirty_size
uint32_t dirty_size
Dirty size in bytes.
Definition: jffs2.h:515
rtems_jffs2_info::bad_size
uint32_t bad_size
Bad size in bytes.
Definition: jffs2.h:536
rtems_jffs2_mount_data
JFFS2 mount options.
Definition: jffs2.h:450
rtems_jffs2_mount_data::compressor_control
rtems_jffs2_compressor_control * compressor_control
Compressor control.
Definition: jffs2.h:461
rtems_jffs2_mount_data::flash_control
rtems_jffs2_flash_control * flash_control
Flash control.
Definition: jffs2.h:454
z_stream_s
Definition: zlib.h:170