diff options
author | David Woodhouse <dwmw2@infradead.org> | 2008-02-03 06:07:40 -0500 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2008-02-03 06:07:40 -0500 |
commit | 6208e77e7fa9e69f399fddc55b1cf9527fbde599 (patch) | |
tree | f69fd4ed2e5101a442f14d6657b26e6e92fe72e5 /include | |
parent | 5eb91034f3d825f43b3c8ace7b69f94752b7deda (diff) | |
parent | 6dc4a8717fadd47103b5015cc678c75afda43ae0 (diff) |
Merge git://git.infradead.org/~dedekind/ubi-2.6
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/mtd/ubi.h | 17 | ||||
-rw-r--r-- | include/mtd/ubi-header.h | 47 | ||||
-rw-r--r-- | include/mtd/ubi-user.h | 51 |
3 files changed, 91 insertions, 24 deletions
diff --git a/include/linux/mtd/ubi.h b/include/linux/mtd/ubi.h index c4abe0351225..f71201d0f3e7 100644 --- a/include/linux/mtd/ubi.h +++ b/include/linux/mtd/ubi.h | |||
@@ -26,23 +26,6 @@ | |||
26 | #include <mtd/ubi-user.h> | 26 | #include <mtd/ubi-user.h> |
27 | 27 | ||
28 | /* | 28 | /* |
29 | * UBI data type hint constants. | ||
30 | * | ||
31 | * UBI_LONGTERM: long-term data | ||
32 | * UBI_SHORTTERM: short-term data | ||
33 | * UBI_UNKNOWN: data persistence is unknown | ||
34 | * | ||
35 | * These constants are used when data is written to UBI volumes in order to | ||
36 | * help the UBI wear-leveling unit to find more appropriate physical | ||
37 | * eraseblocks. | ||
38 | */ | ||
39 | enum { | ||
40 | UBI_LONGTERM = 1, | ||
41 | UBI_SHORTTERM, | ||
42 | UBI_UNKNOWN | ||
43 | }; | ||
44 | |||
45 | /* | ||
46 | * enum ubi_open_mode - UBI volume open mode constants. | 29 | * enum ubi_open_mode - UBI volume open mode constants. |
47 | * | 30 | * |
48 | * UBI_READONLY: read-only mode | 31 | * UBI_READONLY: read-only mode |
diff --git a/include/mtd/ubi-header.h b/include/mtd/ubi-header.h index 74efa7763479..292f916ea564 100644 --- a/include/mtd/ubi-header.h +++ b/include/mtd/ubi-header.h | |||
@@ -58,6 +58,43 @@ enum { | |||
58 | }; | 58 | }; |
59 | 59 | ||
60 | /* | 60 | /* |
61 | * Volume flags used in the volume table record. | ||
62 | * | ||
63 | * @UBI_VTBL_AUTORESIZE_FLG: auto-resize this volume | ||
64 | * | ||
65 | * %UBI_VTBL_AUTORESIZE_FLG flag can be set only for one volume in the volume | ||
66 | * table. UBI automatically re-sizes the volume which has this flag and makes | ||
67 | * the volume to be of largest possible size. This means that if after the | ||
68 | * initialization UBI finds out that there are available physical eraseblocks | ||
69 | * present on the device, it automatically appends all of them to the volume | ||
70 | * (the physical eraseblocks reserved for bad eraseblocks handling and other | ||
71 | * reserved physical eraseblocks are not taken). So, if there is a volume with | ||
72 | * the %UBI_VTBL_AUTORESIZE_FLG flag set, the amount of available logical | ||
73 | * eraseblocks will be zero after UBI is loaded, because all of them will be | ||
74 | * reserved for this volume. Note, the %UBI_VTBL_AUTORESIZE_FLG bit is cleared | ||
75 | * after the volume had been initialized. | ||
76 | * | ||
77 | * The auto-resize feature is useful for device production purposes. For | ||
78 | * example, different NAND flash chips may have different amount of initial bad | ||
79 | * eraseblocks, depending of particular chip instance. Manufacturers of NAND | ||
80 | * chips usually guarantee that the amount of initial bad eraseblocks does not | ||
81 | * exceed certain percent, e.g. 2%. When one creates an UBI image which will be | ||
82 | * flashed to the end devices in production, he does not know the exact amount | ||
83 | * of good physical eraseblocks the NAND chip on the device will have, but this | ||
84 | * number is required to calculate the volume sized and put them to the volume | ||
85 | * table of the UBI image. In this case, one of the volumes (e.g., the one | ||
86 | * which will store the root file system) is marked as "auto-resizable", and | ||
87 | * UBI will adjust its size on the first boot if needed. | ||
88 | * | ||
89 | * Note, first UBI reserves some amount of physical eraseblocks for bad | ||
90 | * eraseblock handling, and then re-sizes the volume, not vice-versa. This | ||
91 | * means that the pool of reserved physical eraseblocks will always be present. | ||
92 | */ | ||
93 | enum { | ||
94 | UBI_VTBL_AUTORESIZE_FLG = 0x01, | ||
95 | }; | ||
96 | |||
97 | /* | ||
61 | * Compatibility constants used by internal volumes. | 98 | * Compatibility constants used by internal volumes. |
62 | * | 99 | * |
63 | * @UBI_COMPAT_DELETE: delete this internal volume before anything is written | 100 | * @UBI_COMPAT_DELETE: delete this internal volume before anything is written |
@@ -262,7 +299,9 @@ struct ubi_vid_hdr { | |||
262 | 299 | ||
263 | /* The layout volume contains the volume table */ | 300 | /* The layout volume contains the volume table */ |
264 | 301 | ||
265 | #define UBI_LAYOUT_VOL_ID UBI_INTERNAL_VOL_START | 302 | #define UBI_LAYOUT_VOLUME_ID UBI_INTERNAL_VOL_START |
303 | #define UBI_LAYOUT_VOLUME_TYPE UBI_VID_DYNAMIC | ||
304 | #define UBI_LAYOUT_VOLUME_ALIGN 1 | ||
266 | #define UBI_LAYOUT_VOLUME_EBS 2 | 305 | #define UBI_LAYOUT_VOLUME_EBS 2 |
267 | #define UBI_LAYOUT_VOLUME_NAME "layout volume" | 306 | #define UBI_LAYOUT_VOLUME_NAME "layout volume" |
268 | #define UBI_LAYOUT_VOLUME_COMPAT UBI_COMPAT_REJECT | 307 | #define UBI_LAYOUT_VOLUME_COMPAT UBI_COMPAT_REJECT |
@@ -289,7 +328,8 @@ struct ubi_vid_hdr { | |||
289 | * @upd_marker: if volume update was started but not finished | 328 | * @upd_marker: if volume update was started but not finished |
290 | * @name_len: volume name length | 329 | * @name_len: volume name length |
291 | * @name: the volume name | 330 | * @name: the volume name |
292 | * @padding2: reserved, zeroes | 331 | * @flags: volume flags (%UBI_VTBL_AUTORESIZE_FLG) |
332 | * @padding: reserved, zeroes | ||
293 | * @crc: a CRC32 checksum of the record | 333 | * @crc: a CRC32 checksum of the record |
294 | * | 334 | * |
295 | * The volume table records are stored in the volume table, which is stored in | 335 | * The volume table records are stored in the volume table, which is stored in |
@@ -324,7 +364,8 @@ struct ubi_vtbl_record { | |||
324 | __u8 upd_marker; | 364 | __u8 upd_marker; |
325 | __be16 name_len; | 365 | __be16 name_len; |
326 | __u8 name[UBI_VOL_NAME_MAX+1]; | 366 | __u8 name[UBI_VOL_NAME_MAX+1]; |
327 | __u8 padding2[24]; | 367 | __u8 flags; |
368 | __u8 padding[23]; | ||
328 | __be32 crc; | 369 | __be32 crc; |
329 | } __attribute__ ((packed)); | 370 | } __attribute__ ((packed)); |
330 | 371 | ||
diff --git a/include/mtd/ubi-user.h b/include/mtd/ubi-user.h index 4d184a7f80a8..a7421f130cc0 100644 --- a/include/mtd/ubi-user.h +++ b/include/mtd/ubi-user.h | |||
@@ -63,7 +63,7 @@ | |||
63 | * | 63 | * |
64 | * Volume update should be done via the %UBI_IOCVOLUP IOCTL command of the | 64 | * Volume update should be done via the %UBI_IOCVOLUP IOCTL command of the |
65 | * corresponding UBI volume character device. A pointer to a 64-bit update | 65 | * corresponding UBI volume character device. A pointer to a 64-bit update |
66 | * size should be passed to the IOCTL. After then, UBI expects user to write | 66 | * size should be passed to the IOCTL. After this, UBI expects user to write |
67 | * this number of bytes to the volume character device. The update is finished | 67 | * this number of bytes to the volume character device. The update is finished |
68 | * when the claimed number of bytes is passed. So, the volume update sequence | 68 | * when the claimed number of bytes is passed. So, the volume update sequence |
69 | * is something like: | 69 | * is something like: |
@@ -72,6 +72,15 @@ | |||
72 | * ioctl(fd, UBI_IOCVOLUP, &image_size); | 72 | * ioctl(fd, UBI_IOCVOLUP, &image_size); |
73 | * write(fd, buf, image_size); | 73 | * write(fd, buf, image_size); |
74 | * close(fd); | 74 | * close(fd); |
75 | * | ||
76 | * Atomic eraseblock change | ||
77 | * ~~~~~~~~~~~~~~~~~~~~~~~~ | ||
78 | * | ||
79 | * Atomic eraseblock change operation is done via the %UBI_IOCEBCH IOCTL | ||
80 | * command of the corresponding UBI volume character device. A pointer to | ||
81 | * &struct ubi_leb_change_req has to be passed to the IOCTL. Then the user is | ||
82 | * expected to write the requested amount of bytes. This is similar to the | ||
83 | * "volume update" IOCTL. | ||
75 | */ | 84 | */ |
76 | 85 | ||
77 | /* | 86 | /* |
@@ -113,11 +122,30 @@ | |||
113 | #define UBI_IOCVOLUP _IOW(UBI_VOL_IOC_MAGIC, 0, int64_t) | 122 | #define UBI_IOCVOLUP _IOW(UBI_VOL_IOC_MAGIC, 0, int64_t) |
114 | /* An eraseblock erasure command, used for debugging, disabled by default */ | 123 | /* An eraseblock erasure command, used for debugging, disabled by default */ |
115 | #define UBI_IOCEBER _IOW(UBI_VOL_IOC_MAGIC, 1, int32_t) | 124 | #define UBI_IOCEBER _IOW(UBI_VOL_IOC_MAGIC, 1, int32_t) |
125 | /* An atomic eraseblock change command */ | ||
126 | #define UBI_IOCEBCH _IOW(UBI_VOL_IOC_MAGIC, 2, int32_t) | ||
116 | 127 | ||
117 | /* Maximum MTD device name length supported by UBI */ | 128 | /* Maximum MTD device name length supported by UBI */ |
118 | #define MAX_UBI_MTD_NAME_LEN 127 | 129 | #define MAX_UBI_MTD_NAME_LEN 127 |
119 | 130 | ||
120 | /* | 131 | /* |
132 | * UBI data type hint constants. | ||
133 | * | ||
134 | * UBI_LONGTERM: long-term data | ||
135 | * UBI_SHORTTERM: short-term data | ||
136 | * UBI_UNKNOWN: data persistence is unknown | ||
137 | * | ||
138 | * These constants are used when data is written to UBI volumes in order to | ||
139 | * help the UBI wear-leveling unit to find more appropriate physical | ||
140 | * eraseblocks. | ||
141 | */ | ||
142 | enum { | ||
143 | UBI_LONGTERM = 1, | ||
144 | UBI_SHORTTERM = 2, | ||
145 | UBI_UNKNOWN = 3, | ||
146 | }; | ||
147 | |||
148 | /* | ||
121 | * UBI volume type constants. | 149 | * UBI volume type constants. |
122 | * | 150 | * |
123 | * @UBI_DYNAMIC_VOLUME: dynamic volume | 151 | * @UBI_DYNAMIC_VOLUME: dynamic volume |
@@ -125,7 +153,7 @@ | |||
125 | */ | 153 | */ |
126 | enum { | 154 | enum { |
127 | UBI_DYNAMIC_VOLUME = 3, | 155 | UBI_DYNAMIC_VOLUME = 3, |
128 | UBI_STATIC_VOLUME = 4, | 156 | UBI_STATIC_VOLUME = 4, |
129 | }; | 157 | }; |
130 | 158 | ||
131 | /** | 159 | /** |
@@ -137,7 +165,7 @@ enum { | |||
137 | * | 165 | * |
138 | * This data structure is used to specify MTD device UBI has to attach and the | 166 | * This data structure is used to specify MTD device UBI has to attach and the |
139 | * parameters it has to use. The number which should be assigned to the new UBI | 167 | * parameters it has to use. The number which should be assigned to the new UBI |
140 | * device is passed in @ubi_num. UBI may automatically assing the number if | 168 | * device is passed in @ubi_num. UBI may automatically assign the number if |
141 | * @UBI_DEV_NUM_AUTO is passed. In this case, the device number is returned in | 169 | * @UBI_DEV_NUM_AUTO is passed. In this case, the device number is returned in |
142 | * @ubi_num. | 170 | * @ubi_num. |
143 | * | 171 | * |
@@ -176,7 +204,7 @@ struct ubi_attach_req { | |||
176 | * @padding2: reserved for future, not used, has to be zeroed | 204 | * @padding2: reserved for future, not used, has to be zeroed |
177 | * @name: volume name | 205 | * @name: volume name |
178 | * | 206 | * |
179 | * This structure is used by userspace programs when creating new volumes. The | 207 | * This structure is used by user-space programs when creating new volumes. The |
180 | * @used_bytes field is only necessary when creating static volumes. | 208 | * @used_bytes field is only necessary when creating static volumes. |
181 | * | 209 | * |
182 | * The @alignment field specifies the required alignment of the volume logical | 210 | * The @alignment field specifies the required alignment of the volume logical |
@@ -222,4 +250,19 @@ struct ubi_rsvol_req { | |||
222 | int32_t vol_id; | 250 | int32_t vol_id; |
223 | } __attribute__ ((packed)); | 251 | } __attribute__ ((packed)); |
224 | 252 | ||
253 | /** | ||
254 | * struct ubi_leb_change_req - a data structure used in atomic logical | ||
255 | * eraseblock change requests. | ||
256 | * @lnum: logical eraseblock number to change | ||
257 | * @bytes: how many bytes will be written to the logical eraseblock | ||
258 | * @dtype: data type (%UBI_LONGTERM, %UBI_SHORTTERM, %UBI_UNKNOWN) | ||
259 | * @padding: reserved for future, not used, has to be zeroed | ||
260 | */ | ||
261 | struct ubi_leb_change_req { | ||
262 | int32_t lnum; | ||
263 | int32_t bytes; | ||
264 | uint8_t dtype; | ||
265 | uint8_t padding[7]; | ||
266 | } __attribute__ ((packed)); | ||
267 | |||
225 | #endif /* __UBI_USER_H__ */ | 268 | #endif /* __UBI_USER_H__ */ |