OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uClinux-2.0.x/] [fs/] [jffs/] [jffs_fm.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/*
2
 * JFFS -- Journalling Flash File System, Linux implementation.
3
 *
4
 * Copyright (C) 1999, 2000  Finn Hakansson, Axis Communications, Inc.
5
 *
6
 * This is free software; you can redistribute it and/or modify it
7
 * under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 2 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * $Id: jffs_fm.h,v 1.1.1.1 2001-09-10 07:44:39 simons Exp $
12
 *
13
 */
14
 
15
#ifndef __LINUX_JFFS_FM_H__
16
#define __LINUX_JFFS_FM_H__
17
 
18
#include <linux/types.h>
19
#include <linux/jffs.h>
20
#include <linux/flash.h>
21
 
22
/* The alignment between two nodes in the flash memory.  */
23
#define JFFS_ALIGN_SIZE 4
24
 
25
/* Run without the buffer cache?  */
26
#define JFFS_FLASH_SHORTCUT 1
27
 
28
/* Mark the on-flash space as obsolete when appropriate.  */
29
#define JFFS_MARK_OBSOLETE 0
30
 
31
/* How many padding bytes should be inserted between two chunks of data
32
   on the flash?  */
33
#define JFFS_GET_PAD_BYTES(size) ((JFFS_ALIGN_SIZE                     \
34
                                  - ((__u32)(size) % JFFS_ALIGN_SIZE)) \
35
                                  % JFFS_ALIGN_SIZE)
36
 
37
/* Is there enough space on the flash?  */
38
#define JFFS_ENOUGH_SPACE(fmc) (((fmc)->flash_size - (fmc)->used_size \
39
                                 - (fmc)->dirty_size) >= (fmc)->min_free_size)
40
 
41
 
42
struct jffs_node_ref
43
{
44
        struct jffs_node *node;
45
        struct jffs_node_ref *next;
46
};
47
 
48
 
49
/* The struct jffs_fm represents a chunk of data in the flash memory.  */
50
struct jffs_fm
51
{
52
        __u32 offset;
53
        __u32 size;
54
        struct jffs_fm *prev;
55
        struct jffs_fm *next;
56
        struct jffs_node_ref *nodes; /* USED if != 0.  */
57
};
58
 
59
struct jffs_fmcontrol
60
{
61
        __u32 flash_start;
62
        __u32 flash_size;
63
        __u32 used_size;
64
        __u32 dirty_size;
65
        __u32 sector_size;
66
        __u32 min_free_size;  /* The minimum free space needed to be able
67
                                 to perform garbage collections.  */
68
        __u32 max_chunk_size; /* The maximum size of a chunk of data.  */
69
        void *flash_part;
70
        __u32 no_call_gc;
71
        struct jffs_control *c;
72
        struct jffs_fm *head;
73
        struct jffs_fm *tail;
74
        struct jffs_fm *head_extra;
75
        struct jffs_fm *tail_extra;
76
};
77
 
78
/* Notice the two members head_extra and tail_extra in the jffs_control
79
   structure above. Those are only used during the scanning of the flash
80
   memory; while the file system is being built. If the data in the flash
81
   memory is organized like
82
 
83
      +----------------+------------------+----------------+
84
      |  USED / DIRTY  |       FREE       |  USED / DIRTY  |
85
      +----------------+------------------+----------------+
86
 
87
   then the scan is split in two parts. The first scanned part of the
88
   flash memory is organized through the members head and tail. The
89
   second scanned part is organized with head_extra and tail_extra. When
90
   the scan is completed, the two lists are merged together. The jffs_fm
91
   struct that head_extra references is the logical beginning of the
92
   flash memory so it will be referenced by the head member.  */
93
 
94
 
95
struct jffs_fmcontrol *jffs_build_begin(struct jffs_control *c, kdev_t dev);
96
void jffs_build_end(struct jffs_fmcontrol *fmc);
97
void jffs_cleanup_fmcontrol(struct jffs_fmcontrol *fmc);
98
 
99
int jffs_fmalloc(struct jffs_fmcontrol *fmc, __u32 size,
100
                 struct jffs_node *node, struct jffs_fm **result);
101
int jffs_fmfree(struct jffs_fmcontrol *fmc, struct jffs_fm *fm,
102
                struct jffs_node *node);
103
 
104
__u32 jffs_free_size1(struct jffs_fmcontrol *fmc);
105
__u32 jffs_free_size2(struct jffs_fmcontrol *fmc);
106
void jffs_sync_erase(struct jffs_fmcontrol *fmc, int erased_size);
107
struct jffs_fm *jffs_cut_node(struct jffs_fmcontrol *fmc, __u32 size);
108
struct jffs_node *jffs_get_oldest_node(struct jffs_fmcontrol *fmc);
109
long jffs_erasable_size(struct jffs_fmcontrol *fmc);
110
struct jffs_fm *jffs_fmalloced(struct jffs_fmcontrol *fmc, __u32 offset,
111
                               __u32 size, struct jffs_node *node);
112
int jffs_add_node(struct jffs_node *node);
113
void jffs_fmfree_partly(struct jffs_fmcontrol *fmc, struct jffs_fm *fm,
114
                        __u32 size);
115
 
116
void jffs_print_fmcontrol(struct jffs_fmcontrol *fmc);
117
void jffs_print_fm(struct jffs_fm *fm);
118
void jffs_print_node_ref(struct jffs_node_ref *ref);
119
 
120
extern int flash_write(unsigned char *ptr, const unsigned char *source,
121
                       unsigned int size);
122
 
123
#endif /* __LINUX_JFFS_FM_H__  */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.