diff options
Diffstat (limited to 'include/mtd/ubi-user.h')
-rw-r--r-- | include/mtd/ubi-user.h | 132 |
1 files changed, 110 insertions, 22 deletions
diff --git a/include/mtd/ubi-user.h b/include/mtd/ubi-user.h index 2dc2eb2b8e22..296efae3525e 100644 --- a/include/mtd/ubi-user.h +++ b/include/mtd/ubi-user.h | |||
@@ -40,37 +40,37 @@ | |||
40 | * UBI volume creation | 40 | * UBI volume creation |
41 | * ~~~~~~~~~~~~~~~~~~~ | 41 | * ~~~~~~~~~~~~~~~~~~~ |
42 | * | 42 | * |
43 | * UBI volumes are created via the %UBI_IOCMKVOL IOCTL command of UBI character | 43 | * UBI volumes are created via the %UBI_IOCMKVOL ioctl command of UBI character |
44 | * device. A &struct ubi_mkvol_req object has to be properly filled and a | 44 | * device. A &struct ubi_mkvol_req object has to be properly filled and a |
45 | * pointer to it has to be passed to the IOCTL. | 45 | * pointer to it has to be passed to the ioctl. |
46 | * | 46 | * |
47 | * UBI volume deletion | 47 | * UBI volume deletion |
48 | * ~~~~~~~~~~~~~~~~~~~ | 48 | * ~~~~~~~~~~~~~~~~~~~ |
49 | * | 49 | * |
50 | * To delete a volume, the %UBI_IOCRMVOL IOCTL command of the UBI character | 50 | * To delete a volume, the %UBI_IOCRMVOL ioctl command of the UBI character |
51 | * device should be used. A pointer to the 32-bit volume ID hast to be passed | 51 | * device should be used. A pointer to the 32-bit volume ID hast to be passed |
52 | * to the IOCTL. | 52 | * to the ioctl. |
53 | * | 53 | * |
54 | * UBI volume re-size | 54 | * UBI volume re-size |
55 | * ~~~~~~~~~~~~~~~~~~ | 55 | * ~~~~~~~~~~~~~~~~~~ |
56 | * | 56 | * |
57 | * To re-size a volume, the %UBI_IOCRSVOL IOCTL command of the UBI character | 57 | * To re-size a volume, the %UBI_IOCRSVOL ioctl command of the UBI character |
58 | * device should be used. A &struct ubi_rsvol_req object has to be properly | 58 | * device should be used. A &struct ubi_rsvol_req object has to be properly |
59 | * filled and a pointer to it has to be passed to the IOCTL. | 59 | * filled and a pointer to it has to be passed to the ioctl. |
60 | * | 60 | * |
61 | * UBI volumes re-name | 61 | * UBI volumes re-name |
62 | * ~~~~~~~~~~~~~~~~~~~ | 62 | * ~~~~~~~~~~~~~~~~~~~ |
63 | * | 63 | * |
64 | * To re-name several volumes atomically at one go, the %UBI_IOCRNVOL command | 64 | * To re-name several volumes atomically at one go, the %UBI_IOCRNVOL command |
65 | * of the UBI character device should be used. A &struct ubi_rnvol_req object | 65 | * of the UBI character device should be used. A &struct ubi_rnvol_req object |
66 | * has to be properly filled and a pointer to it has to be passed to the IOCTL. | 66 | * has to be properly filled and a pointer to it has to be passed to the ioctl. |
67 | * | 67 | * |
68 | * UBI volume update | 68 | * UBI volume update |
69 | * ~~~~~~~~~~~~~~~~~ | 69 | * ~~~~~~~~~~~~~~~~~ |
70 | * | 70 | * |
71 | * Volume update should be done via the %UBI_IOCVOLUP IOCTL command of the | 71 | * Volume update should be done via the %UBI_IOCVOLUP ioctl command of the |
72 | * corresponding UBI volume character device. A pointer to a 64-bit update | 72 | * corresponding UBI volume character device. A pointer to a 64-bit update |
73 | * size should be passed to the IOCTL. After this, UBI expects user to write | 73 | * size should be passed to the ioctl. After this, UBI expects user to write |
74 | * this number of bytes to the volume character device. The update is finished | 74 | * this number of bytes to the volume character device. The update is finished |
75 | * when the claimed number of bytes is passed. So, the volume update sequence | 75 | * when the claimed number of bytes is passed. So, the volume update sequence |
76 | * is something like: | 76 | * is something like: |
@@ -80,14 +80,58 @@ | |||
80 | * write(fd, buf, image_size); | 80 | * write(fd, buf, image_size); |
81 | * close(fd); | 81 | * close(fd); |
82 | * | 82 | * |
83 | * Atomic eraseblock change | 83 | * Logical eraseblock erase |
84 | * ~~~~~~~~~~~~~~~~~~~~~~~~ | 84 | * ~~~~~~~~~~~~~~~~~~~~~~~~ |
85 | * | 85 | * |
86 | * Atomic eraseblock change operation is done via the %UBI_IOCEBCH IOCTL | 86 | * To erase a logical eraseblock, the %UBI_IOCEBER ioctl command of the |
87 | * command of the corresponding UBI volume character device. A pointer to | 87 | * corresponding UBI volume character device should be used. This command |
88 | * &struct ubi_leb_change_req has to be passed to the IOCTL. Then the user is | 88 | * unmaps the requested logical eraseblock, makes sure the corresponding |
89 | * expected to write the requested amount of bytes. This is similar to the | 89 | * physical eraseblock is successfully erased, and returns. |
90 | * "volume update" IOCTL. | 90 | * |
91 | * Atomic logical eraseblock change | ||
92 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
93 | * | ||
94 | * Atomic logical eraseblock change operation is called using the %UBI_IOCEBCH | ||
95 | * ioctl command of the corresponding UBI volume character device. A pointer to | ||
96 | * a &struct ubi_leb_change_req object has to be passed to the ioctl. Then the | ||
97 | * user is expected to write the requested amount of bytes (similarly to what | ||
98 | * should be done in case of the "volume update" ioctl). | ||
99 | * | ||
100 | * Logical eraseblock map | ||
101 | * ~~~~~~~~~~~~~~~~~~~~~ | ||
102 | * | ||
103 | * To map a logical eraseblock to a physical eraseblock, the %UBI_IOCEBMAP | ||
104 | * ioctl command should be used. A pointer to a &struct ubi_map_req object is | ||
105 | * expected to be passed. The ioctl maps the requested logical eraseblock to | ||
106 | * a physical eraseblock and returns. Only non-mapped logical eraseblocks can | ||
107 | * be mapped. If the logical eraseblock specified in the request is already | ||
108 | * mapped to a physical eraseblock, the ioctl fails and returns error. | ||
109 | * | ||
110 | * Logical eraseblock unmap | ||
111 | * ~~~~~~~~~~~~~~~~~~~~~~~~ | ||
112 | * | ||
113 | * To unmap a logical eraseblock to a physical eraseblock, the %UBI_IOCEBUNMAP | ||
114 | * ioctl command should be used. The ioctl unmaps the logical eraseblocks, | ||
115 | * schedules corresponding physical eraseblock for erasure, and returns. Unlike | ||
116 | * the "LEB erase" command, it does not wait for the physical eraseblock being | ||
117 | * erased. Note, the side effect of this is that if an unclean reboot happens | ||
118 | * after the unmap ioctl returns, you may find the LEB mapped again to the same | ||
119 | * physical eraseblock after the UBI is run again. | ||
120 | * | ||
121 | * Check if logical eraseblock is mapped | ||
122 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
123 | * | ||
124 | * To check if a logical eraseblock is mapped to a physical eraseblock, the | ||
125 | * %UBI_IOCEBISMAP ioctl command should be used. It returns %0 if the LEB is | ||
126 | * not mapped, and %1 if it is mapped. | ||
127 | * | ||
128 | * Set an UBI volume property | ||
129 | * ~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
130 | * | ||
131 | * To set an UBI volume property the %UBI_IOCSETPROP ioctl command should be | ||
132 | * used. A pointer to a &struct ubi_set_prop_req object is expected to be | ||
133 | * passed. The object describes which property should be set, and to which value | ||
134 | * it should be set. | ||
91 | */ | 135 | */ |
92 | 136 | ||
93 | /* | 137 | /* |
@@ -101,7 +145,7 @@ | |||
101 | /* Maximum volume name length */ | 145 | /* Maximum volume name length */ |
102 | #define UBI_MAX_VOLUME_NAME 127 | 146 | #define UBI_MAX_VOLUME_NAME 127 |
103 | 147 | ||
104 | /* IOCTL commands of UBI character devices */ | 148 | /* ioctl commands of UBI character devices */ |
105 | 149 | ||
106 | #define UBI_IOC_MAGIC 'o' | 150 | #define UBI_IOC_MAGIC 'o' |
107 | 151 | ||
@@ -114,7 +158,7 @@ | |||
114 | /* Re-name volumes */ | 158 | /* Re-name volumes */ |
115 | #define UBI_IOCRNVOL _IOW(UBI_IOC_MAGIC, 3, struct ubi_rnvol_req) | 159 | #define UBI_IOCRNVOL _IOW(UBI_IOC_MAGIC, 3, struct ubi_rnvol_req) |
116 | 160 | ||
117 | /* IOCTL commands of the UBI control character device */ | 161 | /* ioctl commands of the UBI control character device */ |
118 | 162 | ||
119 | #define UBI_CTRL_IOC_MAGIC 'o' | 163 | #define UBI_CTRL_IOC_MAGIC 'o' |
120 | 164 | ||
@@ -123,16 +167,24 @@ | |||
123 | /* Detach an MTD device */ | 167 | /* Detach an MTD device */ |
124 | #define UBI_IOCDET _IOW(UBI_CTRL_IOC_MAGIC, 65, int32_t) | 168 | #define UBI_IOCDET _IOW(UBI_CTRL_IOC_MAGIC, 65, int32_t) |
125 | 169 | ||
126 | /* IOCTL commands of UBI volume character devices */ | 170 | /* ioctl commands of UBI volume character devices */ |
127 | 171 | ||
128 | #define UBI_VOL_IOC_MAGIC 'O' | 172 | #define UBI_VOL_IOC_MAGIC 'O' |
129 | 173 | ||
130 | /* Start UBI volume update */ | 174 | /* Start UBI volume update */ |
131 | #define UBI_IOCVOLUP _IOW(UBI_VOL_IOC_MAGIC, 0, int64_t) | 175 | #define UBI_IOCVOLUP _IOW(UBI_VOL_IOC_MAGIC, 0, int64_t) |
132 | /* An eraseblock erasure command, used for debugging, disabled by default */ | 176 | /* LEB erasure command, used for debugging, disabled by default */ |
133 | #define UBI_IOCEBER _IOW(UBI_VOL_IOC_MAGIC, 1, int32_t) | 177 | #define UBI_IOCEBER _IOW(UBI_VOL_IOC_MAGIC, 1, int32_t) |
134 | /* An atomic eraseblock change command */ | 178 | /* Atomic LEB change command */ |
135 | #define UBI_IOCEBCH _IOW(UBI_VOL_IOC_MAGIC, 2, int32_t) | 179 | #define UBI_IOCEBCH _IOW(UBI_VOL_IOC_MAGIC, 2, int32_t) |
180 | /* Map LEB command */ | ||
181 | #define UBI_IOCEBMAP _IOW(UBI_VOL_IOC_MAGIC, 3, struct ubi_map_req) | ||
182 | /* Unmap LEB command */ | ||
183 | #define UBI_IOCEBUNMAP _IOW(UBI_VOL_IOC_MAGIC, 4, int32_t) | ||
184 | /* Check if LEB is mapped command */ | ||
185 | #define UBI_IOCEBISMAP _IOR(UBI_VOL_IOC_MAGIC, 5, int32_t) | ||
186 | /* Set an UBI volume property */ | ||
187 | #define UBI_IOCSETPROP _IOW(UBI_VOL_IOC_MAGIC, 6, struct ubi_set_prop_req) | ||
136 | 188 | ||
137 | /* Maximum MTD device name length supported by UBI */ | 189 | /* Maximum MTD device name length supported by UBI */ |
138 | #define MAX_UBI_MTD_NAME_LEN 127 | 190 | #define MAX_UBI_MTD_NAME_LEN 127 |
@@ -168,6 +220,16 @@ enum { | |||
168 | UBI_STATIC_VOLUME = 4, | 220 | UBI_STATIC_VOLUME = 4, |
169 | }; | 221 | }; |
170 | 222 | ||
223 | /* | ||
224 | * UBI set property ioctl constants | ||
225 | * | ||
226 | * @UBI_PROP_DIRECT_WRITE: allow / disallow user to directly write and | ||
227 | * erase individual eraseblocks on dynamic volumes | ||
228 | */ | ||
229 | enum { | ||
230 | UBI_PROP_DIRECT_WRITE = 1, | ||
231 | }; | ||
232 | |||
171 | /** | 233 | /** |
172 | * struct ubi_attach_req - attach MTD device request. | 234 | * struct ubi_attach_req - attach MTD device request. |
173 | * @ubi_num: UBI device number to create | 235 | * @ubi_num: UBI device number to create |
@@ -305,8 +367,8 @@ struct ubi_rnvol_req { | |||
305 | } __attribute__ ((packed)); | 367 | } __attribute__ ((packed)); |
306 | 368 | ||
307 | /** | 369 | /** |
308 | * struct ubi_leb_change_req - a data structure used in atomic logical | 370 | * struct ubi_leb_change_req - a data structure used in atomic LEB change |
309 | * eraseblock change requests. | 371 | * requests. |
310 | * @lnum: logical eraseblock number to change | 372 | * @lnum: logical eraseblock number to change |
311 | * @bytes: how many bytes will be written to the logical eraseblock | 373 | * @bytes: how many bytes will be written to the logical eraseblock |
312 | * @dtype: data type (%UBI_LONGTERM, %UBI_SHORTTERM, %UBI_UNKNOWN) | 374 | * @dtype: data type (%UBI_LONGTERM, %UBI_SHORTTERM, %UBI_UNKNOWN) |
@@ -319,4 +381,30 @@ struct ubi_leb_change_req { | |||
319 | int8_t padding[7]; | 381 | int8_t padding[7]; |
320 | } __attribute__ ((packed)); | 382 | } __attribute__ ((packed)); |
321 | 383 | ||
384 | /** | ||
385 | * struct ubi_map_req - a data structure used in map LEB requests. | ||
386 | * @lnum: logical eraseblock number to unmap | ||
387 | * @dtype: data type (%UBI_LONGTERM, %UBI_SHORTTERM, %UBI_UNKNOWN) | ||
388 | * @padding: reserved for future, not used, has to be zeroed | ||
389 | */ | ||
390 | struct ubi_map_req { | ||
391 | int32_t lnum; | ||
392 | int8_t dtype; | ||
393 | int8_t padding[3]; | ||
394 | } __attribute__ ((packed)); | ||
395 | |||
396 | |||
397 | /** | ||
398 | * struct ubi_set_prop_req - a data structure used to set an ubi volume | ||
399 | * property. | ||
400 | * @property: property to set (%UBI_PROP_DIRECT_WRITE) | ||
401 | * @padding: reserved for future, not used, has to be zeroed | ||
402 | * @value: value to set | ||
403 | */ | ||
404 | struct ubi_set_prop_req { | ||
405 | uint8_t property; | ||
406 | uint8_t padding[7]; | ||
407 | uint64_t value; | ||
408 | } __attribute__ ((packed)); | ||
409 | |||
322 | #endif /* __UBI_USER_H__ */ | 410 | #endif /* __UBI_USER_H__ */ |