include/linux/mtd/map.h

Source file repositories/reference/linux-study-clean/include/linux/mtd/map.h

File Facts

System
Linux kernel
Corpus path
include/linux/mtd/map.h
Extension
.h
Size
13053 bytes
Lines
467
Domain
Core OS
Bucket
Core Kernel Interface
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

struct map_info {
	const char *name;
	unsigned long size;
	resource_size_t phys;
#define NO_XIP (-1UL)

	void __iomem *virt;
	void *cached;

	int swap; /* this mapping's byte-swapping requirement */
	int bankwidth; /* in octets. This isn't necessarily the width
		       of actual bus cycles -- it's the repeat interval
		      in bytes, before you are talking to the first chip again.
		      */

#ifdef CONFIG_MTD_COMPLEX_MAPPINGS
	map_word (*read)(struct map_info *, unsigned long);
	void (*copy_from)(struct map_info *, void *, unsigned long, ssize_t);

	void (*write)(struct map_info *, const map_word, unsigned long);
	void (*copy_to)(struct map_info *, unsigned long, const void *, ssize_t);

	/* We can perhaps put in 'point' and 'unpoint' methods, if we really
	   want to enable XIP for non-linear mappings. Not yet though. */
#endif
	/* It's possible for the map driver to use cached memory in its
	   copy_from implementation (and _only_ with copy_from).  However,
	   when the chip driver knows some flash area has changed contents,
	   it will signal it to the map driver through this routine to let
	   the map driver invalidate the corresponding cache as needed.
	   If there is no cache to care about this can be set to NULL. */
	void (*inval_cache)(struct map_info *, unsigned long, ssize_t);

	/* This will be called with 1 as parameter when the first map user
	 * needs VPP, and called with 0 when the last user exits. The map
	 * core maintains a reference counter, and assumes that VPP is a
	 * global resource applying to all mapped flash chips on the system.
	 */
	void (*set_vpp)(struct map_info *, int);

	unsigned long pfow_base;
	unsigned long map_priv_1;
	unsigned long map_priv_2;
	struct device_node *device_node;
	void *fldrv_priv;
	struct mtd_chip_driver *fldrv;
};

struct mtd_chip_driver {
	struct mtd_info *(*probe)(struct map_info *map);
	void (*destroy)(struct mtd_info *);
	struct module *module;
	char *name;
	struct list_head list;
};

void register_mtd_chip_driver(struct mtd_chip_driver *);
void unregister_mtd_chip_driver(struct mtd_chip_driver *);

struct mtd_info *do_map_probe(const char *name, struct map_info *map);
void map_destroy(struct mtd_info *mtd);

#define ENABLE_VPP(map) do { if (map->set_vpp) map->set_vpp(map, 1); } while (0)
#define DISABLE_VPP(map) do { if (map->set_vpp) map->set_vpp(map, 0); } while (0)

#define INVALIDATE_CACHED_RANGE(map, from, size) \
	do { if (map->inval_cache) map->inval_cache(map, from, size); } while (0)

#define map_word_equal(map, val1, val2)					\
({									\
	int i, ret = 1;							\
	for (i = 0; i < map_words(map); i++)				\
		if ((val1).x[i] != (val2).x[i]) {			\
			ret = 0;					\
			break;						\
		}							\
	ret;								\
})

#define map_word_and(map, val1, val2)					\
({									\
	map_word r;							\
	int i;								\
	for (i = 0; i < map_words(map); i++)				\
		r.x[i] = (val1).x[i] & (val2).x[i];			\
	r;								\
})

#define map_word_clr(map, val1, val2)					\
({									\

Annotation

Implementation Notes