diff options
Diffstat (limited to 'include/mtd/ubi-user.h')
-rw-r--r-- | include/mtd/ubi-user.h | 161 |
1 files changed, 161 insertions, 0 deletions
diff --git a/include/mtd/ubi-user.h b/include/mtd/ubi-user.h new file mode 100644 index 000000000000..fe06ded0e6b8 --- /dev/null +++ b/include/mtd/ubi-user.h | |||
@@ -0,0 +1,161 @@ | |||
1 | /* | ||
2 | * Copyright (c) International Business Machines Corp., 2006 | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See | ||
12 | * the GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
17 | * | ||
18 | * Author: Artem Bityutskiy (Битюцкий Артём) | ||
19 | */ | ||
20 | |||
21 | #ifndef __UBI_USER_H__ | ||
22 | #define __UBI_USER_H__ | ||
23 | |||
24 | /* | ||
25 | * UBI volume creation | ||
26 | * ~~~~~~~~~~~~~~~~~~~ | ||
27 | * | ||
28 | * UBI volumes are created via the %UBI_IOCMKVOL IOCTL command of UBI character | ||
29 | * device. A &struct ubi_mkvol_req object has to be properly filled and a | ||
30 | * pointer to it has to be passed to the IOCTL. | ||
31 | * | ||
32 | * UBI volume deletion | ||
33 | * ~~~~~~~~~~~~~~~~~~~ | ||
34 | * | ||
35 | * To delete a volume, the %UBI_IOCRMVOL IOCTL command of the UBI character | ||
36 | * device should be used. A pointer to the 32-bit volume ID hast to be passed | ||
37 | * to the IOCTL. | ||
38 | * | ||
39 | * UBI volume re-size | ||
40 | * ~~~~~~~~~~~~~~~~~~ | ||
41 | * | ||
42 | * To re-size a volume, the %UBI_IOCRSVOL IOCTL command of the UBI character | ||
43 | * device should be used. A &struct ubi_rsvol_req object has to be properly | ||
44 | * filled and a pointer to it has to be passed to the IOCTL. | ||
45 | * | ||
46 | * UBI volume update | ||
47 | * ~~~~~~~~~~~~~~~~~ | ||
48 | * | ||
49 | * Volume update should be done via the %UBI_IOCVOLUP IOCTL command of the | ||
50 | * corresponding UBI volume character device. A pointer to a 64-bit update | ||
51 | * size should be passed to the IOCTL. After then, UBI expects user to write | ||
52 | * this number of bytes to the volume character device. The update is finished | ||
53 | * when the claimed number of bytes is passed. So, the volume update sequence | ||
54 | * is something like: | ||
55 | * | ||
56 | * fd = open("/dev/my_volume"); | ||
57 | * ioctl(fd, UBI_IOCVOLUP, &image_size); | ||
58 | * write(fd, buf, image_size); | ||
59 | * close(fd); | ||
60 | */ | ||
61 | |||
62 | /* | ||
63 | * When a new volume is created, users may either specify the volume number they | ||
64 | * want to create or to let UBI automatically assign a volume number using this | ||
65 | * constant. | ||
66 | */ | ||
67 | #define UBI_VOL_NUM_AUTO (-1) | ||
68 | |||
69 | /* Maximum volume name length */ | ||
70 | #define UBI_MAX_VOLUME_NAME 127 | ||
71 | |||
72 | /* IOCTL commands of UBI character devices */ | ||
73 | |||
74 | #define UBI_IOC_MAGIC 'o' | ||
75 | |||
76 | /* Create an UBI volume */ | ||
77 | #define UBI_IOCMKVOL _IOW(UBI_IOC_MAGIC, 0, struct ubi_mkvol_req) | ||
78 | /* Remove an UBI volume */ | ||
79 | #define UBI_IOCRMVOL _IOW(UBI_IOC_MAGIC, 1, int32_t) | ||
80 | /* Re-size an UBI volume */ | ||
81 | #define UBI_IOCRSVOL _IOW(UBI_IOC_MAGIC, 2, struct ubi_rsvol_req) | ||
82 | |||
83 | /* IOCTL commands of UBI volume character devices */ | ||
84 | |||
85 | #define UBI_VOL_IOC_MAGIC 'O' | ||
86 | |||
87 | /* Start UBI volume update */ | ||
88 | #define UBI_IOCVOLUP _IOW(UBI_VOL_IOC_MAGIC, 0, int64_t) | ||
89 | /* An eraseblock erasure command, used for debugging, disabled by default */ | ||
90 | #define UBI_IOCEBER _IOW(UBI_VOL_IOC_MAGIC, 1, int32_t) | ||
91 | |||
92 | /* | ||
93 | * UBI volume type constants. | ||
94 | * | ||
95 | * @UBI_DYNAMIC_VOLUME: dynamic volume | ||
96 | * @UBI_STATIC_VOLUME: static volume | ||
97 | */ | ||
98 | enum { | ||
99 | UBI_DYNAMIC_VOLUME = 3, | ||
100 | UBI_STATIC_VOLUME = 4 | ||
101 | }; | ||
102 | |||
103 | /** | ||
104 | * struct ubi_mkvol_req - volume description data structure used in | ||
105 | * volume creation requests. | ||
106 | * @vol_id: volume number | ||
107 | * @alignment: volume alignment | ||
108 | * @bytes: volume size in bytes | ||
109 | * @vol_type: volume type (%UBI_DYNAMIC_VOLUME or %UBI_STATIC_VOLUME) | ||
110 | * @padding1: reserved for future, not used | ||
111 | * @name_len: volume name length | ||
112 | * @padding2: reserved for future, not used | ||
113 | * @name: volume name | ||
114 | * | ||
115 | * This structure is used by userspace programs when creating new volumes. The | ||
116 | * @used_bytes field is only necessary when creating static volumes. | ||
117 | * | ||
118 | * The @alignment field specifies the required alignment of the volume logical | ||
119 | * eraseblock. This means, that the size of logical eraseblocks will be aligned | ||
120 | * to this number, i.e., | ||
121 | * (UBI device logical eraseblock size) mod (@alignment) = 0. | ||
122 | * | ||
123 | * To put it differently, the logical eraseblock of this volume may be slightly | ||
124 | * shortened in order to make it properly aligned. The alignment has to be | ||
125 | * multiple of the flash minimal input/output unit, or %1 to utilize the entire | ||
126 | * available space of logical eraseblocks. | ||
127 | * | ||
128 | * The @alignment field may be useful, for example, when one wants to maintain | ||
129 | * a block device on top of an UBI volume. In this case, it is desirable to fit | ||
130 | * an integer number of blocks in logical eraseblocks of this UBI volume. With | ||
131 | * alignment it is possible to update this volume using plane UBI volume image | ||
132 | * BLOBs, without caring about how to properly align them. | ||
133 | */ | ||
134 | struct ubi_mkvol_req { | ||
135 | int32_t vol_id; | ||
136 | int32_t alignment; | ||
137 | int64_t bytes; | ||
138 | int8_t vol_type; | ||
139 | int8_t padding1; | ||
140 | int16_t name_len; | ||
141 | int8_t padding2[4]; | ||
142 | char name[UBI_MAX_VOLUME_NAME+1]; | ||
143 | } __attribute__ ((packed)); | ||
144 | |||
145 | /** | ||
146 | * struct ubi_rsvol_req - a data structure used in volume re-size requests. | ||
147 | * @vol_id: ID of the volume to re-size | ||
148 | * @bytes: new size of the volume in bytes | ||
149 | * | ||
150 | * Re-sizing is possible for both dynamic and static volumes. But while dynamic | ||
151 | * volumes may be re-sized arbitrarily, static volumes cannot be made to be | ||
152 | * smaller then the number of bytes they bear. To arbitrarily shrink a static | ||
153 | * volume, it must be wiped out first (by means of volume update operation with | ||
154 | * zero number of bytes). | ||
155 | */ | ||
156 | struct ubi_rsvol_req { | ||
157 | int64_t bytes; | ||
158 | int32_t vol_id; | ||
159 | } __attribute__ ((packed)); | ||
160 | |||
161 | #endif /* __UBI_USER_H__ */ | ||