diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2007-12-18 11:22:16 -0500 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2007-12-26 12:15:17 -0500 |
commit | 9b79cc0f84edecceb04b806b9014fcec1306c34d (patch) | |
tree | badf70fe3267064b11d2673ad724a6bd038671cb /include/mtd | |
parent | dd38fccfbc77e12417512c38508a5283ea79a375 (diff) |
UBI: introduce attach ioctls
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'include/mtd')
-rw-r--r-- | include/mtd/ubi-user.h | 80 |
1 files changed, 72 insertions, 8 deletions
diff --git a/include/mtd/ubi-user.h b/include/mtd/ubi-user.h index fe06ded0e6b8..4d184a7f80a8 100644 --- a/include/mtd/ubi-user.h +++ b/include/mtd/ubi-user.h | |||
@@ -22,6 +22,21 @@ | |||
22 | #define __UBI_USER_H__ | 22 | #define __UBI_USER_H__ |
23 | 23 | ||
24 | /* | 24 | /* |
25 | * UBI device creation (the same as MTD device attachment) | ||
26 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
27 | * | ||
28 | * MTD devices may be attached using %UBI_IOCATT ioctl command of the UBI | ||
29 | * control device. The caller has to properly fill and pass | ||
30 | * &struct ubi_attach_req object - UBI will attach the MTD device specified in | ||
31 | * the request and return the newly created UBI device number as the ioctl | ||
32 | * return value. | ||
33 | * | ||
34 | * UBI device deletion (the same as MTD device detachment) | ||
35 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
36 | * | ||
37 | * An UBI device maybe deleted with %UBI_IOCDET ioctl command of the UBI | ||
38 | * control device. | ||
39 | * | ||
25 | * UBI volume creation | 40 | * UBI volume creation |
26 | * ~~~~~~~~~~~~~~~~~~~ | 41 | * ~~~~~~~~~~~~~~~~~~~ |
27 | * | 42 | * |
@@ -60,11 +75,12 @@ | |||
60 | */ | 75 | */ |
61 | 76 | ||
62 | /* | 77 | /* |
63 | * When a new volume is created, users may either specify the volume number they | 78 | * When a new UBI volume or UBI device is created, users may either specify the |
64 | * want to create or to let UBI automatically assign a volume number using this | 79 | * volume/device number they want to create or to let UBI automatically assign |
65 | * constant. | 80 | * the number using these constants. |
66 | */ | 81 | */ |
67 | #define UBI_VOL_NUM_AUTO (-1) | 82 | #define UBI_VOL_NUM_AUTO (-1) |
83 | #define UBI_DEV_NUM_AUTO (-1) | ||
68 | 84 | ||
69 | /* Maximum volume name length */ | 85 | /* Maximum volume name length */ |
70 | #define UBI_MAX_VOLUME_NAME 127 | 86 | #define UBI_MAX_VOLUME_NAME 127 |
@@ -80,6 +96,15 @@ | |||
80 | /* Re-size an UBI volume */ | 96 | /* Re-size an UBI volume */ |
81 | #define UBI_IOCRSVOL _IOW(UBI_IOC_MAGIC, 2, struct ubi_rsvol_req) | 97 | #define UBI_IOCRSVOL _IOW(UBI_IOC_MAGIC, 2, struct ubi_rsvol_req) |
82 | 98 | ||
99 | /* IOCTL commands of the UBI control character device */ | ||
100 | |||
101 | #define UBI_CTRL_IOC_MAGIC 'o' | ||
102 | |||
103 | /* Attach an MTD device */ | ||
104 | #define UBI_IOCATT _IOW(UBI_CTRL_IOC_MAGIC, 64, struct ubi_attach_req) | ||
105 | /* Detach an MTD device */ | ||
106 | #define UBI_IOCDET _IOW(UBI_CTRL_IOC_MAGIC, 65, int32_t) | ||
107 | |||
83 | /* IOCTL commands of UBI volume character devices */ | 108 | /* IOCTL commands of UBI volume character devices */ |
84 | 109 | ||
85 | #define UBI_VOL_IOC_MAGIC 'O' | 110 | #define UBI_VOL_IOC_MAGIC 'O' |
@@ -89,6 +114,9 @@ | |||
89 | /* An eraseblock erasure command, used for debugging, disabled by default */ | 114 | /* An eraseblock erasure command, used for debugging, disabled by default */ |
90 | #define UBI_IOCEBER _IOW(UBI_VOL_IOC_MAGIC, 1, int32_t) | 115 | #define UBI_IOCEBER _IOW(UBI_VOL_IOC_MAGIC, 1, int32_t) |
91 | 116 | ||
117 | /* Maximum MTD device name length supported by UBI */ | ||
118 | #define MAX_UBI_MTD_NAME_LEN 127 | ||
119 | |||
92 | /* | 120 | /* |
93 | * UBI volume type constants. | 121 | * UBI volume type constants. |
94 | * | 122 | * |
@@ -97,19 +125,55 @@ | |||
97 | */ | 125 | */ |
98 | enum { | 126 | enum { |
99 | UBI_DYNAMIC_VOLUME = 3, | 127 | UBI_DYNAMIC_VOLUME = 3, |
100 | UBI_STATIC_VOLUME = 4 | 128 | UBI_STATIC_VOLUME = 4, |
129 | }; | ||
130 | |||
131 | /** | ||
132 | * struct ubi_attach_req - attach MTD device request. | ||
133 | * @ubi_num: UBI device number to create | ||
134 | * @mtd_num: MTD device number to attach | ||
135 | * @vid_hdr_offset: VID header offset (use defaults if %0) | ||
136 | * @padding: reserved for future, not used, has to be zeroed | ||
137 | * | ||
138 | * 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 | ||
140 | * device is passed in @ubi_num. UBI may automatically assing the number if | ||
141 | * @UBI_DEV_NUM_AUTO is passed. In this case, the device number is returned in | ||
142 | * @ubi_num. | ||
143 | * | ||
144 | * Most applications should pass %0 in @vid_hdr_offset to make UBI use default | ||
145 | * offset of the VID header within physical eraseblocks. The default offset is | ||
146 | * the next min. I/O unit after the EC header. For example, it will be offset | ||
147 | * 512 in case of a 512 bytes page NAND flash with no sub-page support. Or | ||
148 | * it will be 512 in case of a 2KiB page NAND flash with 4 512-byte sub-pages. | ||
149 | * | ||
150 | * But in rare cases, if this optimizes things, the VID header may be placed to | ||
151 | * a different offset. For example, the boot-loader might do things faster if the | ||
152 | * VID header sits at the end of the first 2KiB NAND page with 4 sub-pages. As | ||
153 | * the boot-loader would not normally need to read EC headers (unless it needs | ||
154 | * UBI in RW mode), it might be faster to calculate ECC. This is weird example, | ||
155 | * but it real-life example. So, in this example, @vid_hdr_offer would be | ||
156 | * 2KiB-64 bytes = 1984. Note, that this position is not even 512-bytes | ||
157 | * aligned, which is OK, as UBI is clever enough to realize this is 4th sub-page | ||
158 | * of the first page and add needed padding. | ||
159 | */ | ||
160 | struct ubi_attach_req { | ||
161 | int32_t ubi_num; | ||
162 | int32_t mtd_num; | ||
163 | int32_t vid_hdr_offset; | ||
164 | uint8_t padding[12]; | ||
101 | }; | 165 | }; |
102 | 166 | ||
103 | /** | 167 | /** |
104 | * struct ubi_mkvol_req - volume description data structure used in | 168 | * struct ubi_mkvol_req - volume description data structure used in |
105 | * volume creation requests. | 169 | * volume creation requests. |
106 | * @vol_id: volume number | 170 | * @vol_id: volume number |
107 | * @alignment: volume alignment | 171 | * @alignment: volume alignment |
108 | * @bytes: volume size in bytes | 172 | * @bytes: volume size in bytes |
109 | * @vol_type: volume type (%UBI_DYNAMIC_VOLUME or %UBI_STATIC_VOLUME) | 173 | * @vol_type: volume type (%UBI_DYNAMIC_VOLUME or %UBI_STATIC_VOLUME) |
110 | * @padding1: reserved for future, not used | 174 | * @padding1: reserved for future, not used, has to be zeroed |
111 | * @name_len: volume name length | 175 | * @name_len: volume name length |
112 | * @padding2: reserved for future, not used | 176 | * @padding2: reserved for future, not used, has to be zeroed |
113 | * @name: volume name | 177 | * @name: volume name |
114 | * | 178 | * |
115 | * This structure is used by userspace programs when creating new volumes. The | 179 | * This structure is used by userspace programs when creating new volumes. The |
@@ -139,7 +203,7 @@ struct ubi_mkvol_req { | |||
139 | int8_t padding1; | 203 | int8_t padding1; |
140 | int16_t name_len; | 204 | int16_t name_len; |
141 | int8_t padding2[4]; | 205 | int8_t padding2[4]; |
142 | char name[UBI_MAX_VOLUME_NAME+1]; | 206 | char name[UBI_MAX_VOLUME_NAME + 1]; |
143 | } __attribute__ ((packed)); | 207 | } __attribute__ ((packed)); |
144 | 208 | ||
145 | /** | 209 | /** |