![]() |
|
|||
0001 /* 0002 * MTD partitioning layer definitions 0003 * 0004 * (C) 2000 Nicolas Pitre <nico@fluxnic.net> 0005 * 0006 * This code is GPL 0007 */ 0008 0009 #ifndef MTD_PARTITIONS_H 0010 #define MTD_PARTITIONS_H 0011 0012 #include <linux/types.h> 0013 0014 0015 /* 0016 * Partition definition structure: 0017 * 0018 * An array of struct partition is passed along with a MTD object to 0019 * mtd_device_register() to create them. 0020 * 0021 * For each partition, these fields are available: 0022 * name: string that will be used to label the partition's MTD device. 0023 * types: some partitions can be containers using specific format to describe 0024 * embedded subpartitions / volumes. E.g. many home routers use "firmware" 0025 * partition that contains at least kernel and rootfs. In such case an 0026 * extra parser is needed that will detect these dynamic partitions and 0027 * report them to the MTD subsystem. If set this property stores an array 0028 * of parser names to use when looking for subpartitions. 0029 * size: the partition size; if defined as MTDPART_SIZ_FULL, the partition 0030 * will extend to the end of the master MTD device. 0031 * offset: absolute starting position within the master MTD device; if 0032 * defined as MTDPART_OFS_APPEND, the partition will start where the 0033 * previous one ended; if MTDPART_OFS_NXTBLK, at the next erase block; 0034 * if MTDPART_OFS_RETAIN, consume as much as possible, leaving size 0035 * after the end of partition. 0036 * mask_flags: contains flags that have to be masked (removed) from the 0037 * master MTD flag set for the corresponding MTD partition. 0038 * For example, to force a read-only partition, simply adding 0039 * MTD_WRITEABLE to the mask_flags will do the trick. 0040 * add_flags: contains flags to add to the parent flags 0041 * 0042 * Note: writeable partitions require their size and offset be 0043 * erasesize aligned (e.g. use MTDPART_OFS_NEXTBLK). 0044 */ 0045 0046 struct mtd_partition { 0047 const char *name; /* identifier string */ 0048 const char *const *types; /* names of parsers to use if any */ 0049 uint64_t size; /* partition size */ 0050 uint64_t offset; /* offset within the master MTD space */ 0051 uint32_t mask_flags; /* master MTD flags to mask out for this partition */ 0052 uint32_t add_flags; /* flags to add to the partition */ 0053 struct device_node *of_node; 0054 }; 0055 0056 #define MTDPART_OFS_RETAIN (-3) 0057 #define MTDPART_OFS_NXTBLK (-2) 0058 #define MTDPART_OFS_APPEND (-1) 0059 #define MTDPART_SIZ_FULL (0) 0060 0061 0062 struct mtd_info; 0063 struct device_node; 0064 0065 /** 0066 * struct mtd_part_parser_data - used to pass data to MTD partition parsers. 0067 * @origin: for RedBoot, start address of MTD device 0068 */ 0069 struct mtd_part_parser_data { 0070 unsigned long origin; 0071 }; 0072 0073 0074 /* 0075 * Functions dealing with the various ways of partitioning the space 0076 */ 0077 0078 struct mtd_part_parser { 0079 struct list_head list; 0080 struct module *owner; 0081 const char *name; 0082 const struct of_device_id *of_match_table; 0083 int (*parse_fn)(struct mtd_info *, const struct mtd_partition **, 0084 struct mtd_part_parser_data *); 0085 void (*cleanup)(const struct mtd_partition *pparts, int nr_parts); 0086 }; 0087 0088 /* Container for passing around a set of parsed partitions */ 0089 struct mtd_partitions { 0090 const struct mtd_partition *parts; 0091 int nr_parts; 0092 const struct mtd_part_parser *parser; 0093 }; 0094 0095 extern int __register_mtd_parser(struct mtd_part_parser *parser, 0096 struct module *owner); 0097 #define register_mtd_parser(parser) __register_mtd_parser(parser, THIS_MODULE) 0098 0099 extern void deregister_mtd_parser(struct mtd_part_parser *parser); 0100 0101 /* 0102 * module_mtd_part_parser() - Helper macro for MTD partition parsers that don't 0103 * do anything special in module init/exit. Each driver may only use this macro 0104 * once, and calling it replaces module_init() and module_exit(). 0105 */ 0106 #define module_mtd_part_parser(__mtd_part_parser) \ 0107 module_driver(__mtd_part_parser, register_mtd_parser, \ 0108 deregister_mtd_parser) 0109 0110 int mtd_add_partition(struct mtd_info *master, const char *name, 0111 long long offset, long long length); 0112 int mtd_del_partition(struct mtd_info *master, int partno); 0113 uint64_t mtd_get_device_size(const struct mtd_info *mtd); 0114 0115 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |