RTEMS 6.1-rc1
jffs2.h
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/*
4 * Copyright (C) 2013, 2016 embedded brains GmbH & Co. KG
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef RTEMS_JFFS2_H
29#define RTEMS_JFFS2_H
30
31#include <rtems/fs.h>
32#include <sys/param.h>
33#include <sys/ioccom.h>
34#include <zlib.h>
35
36#ifdef __cplusplus
37extern "C" {
38#endif /* __cplusplus */
39
41
191 uint32_t offset,
192 unsigned char *buffer,
193 size_t size_of_buffer
194);
195
210 uint32_t offset,
211 const unsigned char *buffer,
212 size_t size_of_buffer
213);
214
229 uint32_t offset
230);
231
247 uint32_t offset,
248 bool *bad
249);
250
265 uint32_t offset
266);
267
285 uint32_t offset,
286 uint8_t *oobbuf,
287 uint32_t obblen
288);
289
307 uint32_t offset,
308 uint8_t *oobbuf,
309 uint32_t obblen
310);
311
323);
324
336);
337
350);
351
359 uint32_t block_size;
360
367 uint32_t flash_size;
368
375 uint32_t write_size;
376
381
386
391
396
401
406
411
416
423
431
440};
441
443
461 unsigned char *data_in,
462 unsigned char *cdata_out,
463 uint32_t *datalen,
464 uint32_t *cdatalen
465);
466
483 uint16_t comprtype,
484 unsigned char *cdata_in,
485 unsigned char *data_out,
486 uint32_t cdatalen,
487 uint32_t datalen
488);
489
501);
502
511
516
523
527 unsigned char buffer[PAGE_SIZE];
528};
529
535 unsigned char *data_in,
536 unsigned char *cdata_out,
537 uint32_t *datalen,
538 uint32_t *cdatalen
539);
540
546 uint16_t comprtype,
547 unsigned char *cdata_in,
548 unsigned char *data_out,
549 uint32_t cdatalen,
550 uint32_t datalen
551);
552
556typedef struct {
558 z_stream stream;
560
566 unsigned char *data_in,
567 unsigned char *cdata_out,
568 uint32_t *datalen,
569 uint32_t *cdatalen
570);
571
577 uint16_t comprtype,
578 unsigned char *cdata_in,
579 unsigned char *data_out,
580 uint32_t cdatalen,
581 uint32_t datalen
582);
583
589typedef struct {
594
602
618 const void *data
619);
620
626typedef struct {
630 uint32_t flash_size;
631
635 uint32_t flash_blocks;
636
641
647 uint32_t used_size;
648
654 uint32_t dirty_size;
655
661 uint32_t wasted_size;
662
668 uint32_t free_size;
669
675 uint32_t bad_size;
676
682 uint32_t clean_blocks;
683
689 uint32_t dirty_blocks;
690
697
703 uint32_t free_blocks;
704
710 uint32_t bad_blocks;
712
718#define RTEMS_JFFS2_GET_INFO _IOR('F', 1, rtems_jffs2_info)
719
727#define RTEMS_JFFS2_ON_DEMAND_GARBAGE_COLLECTION _IO('F', 2)
728
735#define RTEMS_JFFS2_FORCE_GARBAGE_COLLECTION _IO('F', 3)
736
740#define RTEMS_JFFS2_DELAYED_WRITE_TASK_PRIORITY_DEFAULT 15
741
746typedef struct rtems_jffs2_config {
750
757
760#ifdef __cplusplus
761}
762#endif /* __cplusplus */
763
764#endif /* RTEMS_JFFS2_H */
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:83
int(* rtems_jffs2_flash_erase)(rtems_jffs2_flash_control *self, uint32_t offset)
Flash erase operation.
Definition: jffs2.h:227
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:189
int(* rtems_jffs2_flash_oob_read)(rtems_jffs2_flash_control *self, uint32_t offset, uint8_t *oobbuf, uint32_t obblen)
Flash oob read.
Definition: jffs2.h:305
int(* rtems_jffs2_flash_block_mark_bad)(rtems_jffs2_flash_control *self, uint32_t offset)
Flash bad block mark operation.
Definition: jffs2.h:263
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
uint32_t(* rtems_jffs2_flash_get_oob_size)(rtems_jffs2_flash_control *self)
Flash get oob size.
Definition: jffs2.h:321
int(* rtems_jffs2_flash_oob_write)(rtems_jffs2_flash_control *self, uint32_t offset, uint8_t *oobbuf, uint32_t obblen)
Flash oob write.
Definition: jffs2.h:283
int(* rtems_jffs2_flash_block_is_bad)(rtems_jffs2_flash_control *self, uint32_t offset, bool *bad)
Flash bad block check operation.
Definition: jffs2.h:245
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:459
void(* rtems_jffs2_trigger_garbage_collection)(rtems_jffs2_flash_control *self)
Trigger garbage collection operation.
Definition: jffs2.h:348
struct rtems_jffs2_config rtems_jffs2_config
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
void(* rtems_jffs2_compressor_destroy)(rtems_jffs2_compressor_control *self)
Compressor destroy operation.
Definition: jffs2.h:499
const rtems_jffs2_config jffs2_config
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:1357
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:481
void(* rtems_jffs2_flash_destroy)(rtems_jffs2_flash_control *self)
Flash destroy operation.
Definition: jffs2.h:334
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
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:208
uint32_t rtems_task_priority
This integer type represents task priorities of the Classic API.
Definition: types.h:257
Basic Filesystem Types.
Mount table entry.
Definition: libio.h:1621
JFFS2 compressor control.
Definition: jffs2.h:506
rtems_jffs2_compressor_compress compress
Compress operation.
Definition: jffs2.h:510
rtems_jffs2_compressor_destroy destroy
Compressor destroy operation.
Definition: jffs2.h:522
unsigned char buffer[PAGE_SIZE]
Compression buffer.
Definition: jffs2.h:527
rtems_jffs2_compressor_decompress decompress
Decompress operation.
Definition: jffs2.h:515
ZLIB compressor control structure.
Definition: jffs2.h:556
Definition: jffs2.h:746
rtems_task_priority delayed_write_priority
Definition: jffs2.h:747
JFFS2 flash device control.
Definition: jffs2.h:355
rtems_jffs2_flash_oob_write oob_write
Flash oob bytes write operation.
Definition: jffs2.h:405
rtems_jffs2_trigger_garbage_collection trigger_garbage_collection
Trigger garbage collection operation.
Definition: jffs2.h:439
uint32_t flash_size
The size in bytes of the flash device.
Definition: jffs2.h:367
rtems_jffs2_flash_erase erase
Flash erase operation.
Definition: jffs2.h:390
rtems_jffs2_flash_read read
Read from flash operation.
Definition: jffs2.h:380
uint32_t write_size
The size in bytes of the minimum write size for the flash device.
Definition: jffs2.h:375
rtems_jffs2_flash_block_mark_bad block_mark_bad
Flash bad block mark operation.
Definition: jffs2.h:400
rtems_jffs2_flash_oob_read oob_read
Flash oob bytes read operation.
Definition: jffs2.h:410
rtems_jffs2_flash_block_is_bad block_is_bad
Flash bad block check operation.
Definition: jffs2.h:395
rtems_jffs2_flash_get_oob_size get_oob_size
Flash get oob bytes per page operation.
Definition: jffs2.h:415
rtems_jffs2_flash_destroy destroy
Flash destroy operation.
Definition: jffs2.h:422
rtems_jffs2_flash_write write
Write to flash operation.
Definition: jffs2.h:385
uint32_t block_size
The size in bytes of the erasable unit of the flash device.
Definition: jffs2.h:359
dev_t device_identifier
The device identifier of the flash device.
Definition: jffs2.h:430
JFFS2 filesystem instance information.
Definition: jffs2.h:626
uint32_t flash_block_size
Size of a flash block in bytes.
Definition: jffs2.h:640
uint32_t flash_blocks
Count of flash blocks (erasable units).
Definition: jffs2.h:635
uint32_t dirty_blocks
Count of dirty blocks.
Definition: jffs2.h:689
uint32_t clean_blocks
Count of clean blocks.
Definition: jffs2.h:682
uint32_t bad_blocks
Count of bad blocks.
Definition: jffs2.h:710
uint32_t flash_size
Flash size in bytes.
Definition: jffs2.h:630
uint32_t wasted_size
Wasted size in bytes.
Definition: jffs2.h:661
uint32_t used_size
Used size in bytes.
Definition: jffs2.h:647
uint32_t erasable_blocks
Count of erasable blocks.
Definition: jffs2.h:696
uint32_t free_size
Free size in bytes.
Definition: jffs2.h:668
uint32_t free_blocks
Count of free blocks.
Definition: jffs2.h:703
uint32_t dirty_size
Dirty size in bytes.
Definition: jffs2.h:654
uint32_t bad_size
Bad size in bytes.
Definition: jffs2.h:675
JFFS2 mount options.
Definition: jffs2.h:589
rtems_jffs2_compressor_control * compressor_control
Compressor control.
Definition: jffs2.h:600
rtems_jffs2_flash_control * flash_control
Flash control.
Definition: jffs2.h:593
Definition: zlib.h:170