]>
git.ipfire.org Git - thirdparty/u-boot.git/blob - include/blkmap.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (c) 2023 Addiva Elektronik
4 * Author: Tobias Waldekranz <tobias@waldekranz.com>
13 * struct blkmap - Block map
15 * Data associated with a blkmap.
17 * @label: Human readable name of this blkmap
18 * @blk: Underlying block device
19 * @slices: List of slices associated with this blkmap
24 struct list_head slices
;
28 * blkmap_map_linear() - Map region of other block device
30 * @dev: Blkmap to create the mapping on
31 * @blknr: Start block number of the mapping
32 * @blkcnt: Number of blocks to map
33 * @lblk: The target block device of the mapping
34 * @lblknr: The start block number of the target device
35 * Returns: 0 on success, negative error code on failure
37 int blkmap_map_linear(struct udevice
*dev
, lbaint_t blknr
, lbaint_t blkcnt
,
38 struct udevice
*lblk
, lbaint_t lblknr
);
41 * blkmap_map_mem() - Map region of memory
43 * @dev: Blkmap to create the mapping on
44 * @blknr: Start block number of the mapping
45 * @blkcnt: Number of blocks to map
46 * @addr: The target memory address of the mapping
47 * Returns: 0 on success, negative error code on failure
49 int blkmap_map_mem(struct udevice
*dev
, lbaint_t blknr
, lbaint_t blkcnt
,
53 * blkmap_map_pmem() - Map region of physical memory
55 * Ensures that a valid physical to virtual memory mapping for the
56 * requested region is valid for the lifetime of the mapping, on
57 * architectures that require it (sandbox).
59 * @dev: Blkmap to create the mapping on
60 * @blknr: Start block number of the mapping
61 * @blkcnt: Number of blocks to map
62 * @paddr: The target physical memory address of the mapping
63 * Returns: 0 on success, negative error code on failure
65 int blkmap_map_pmem(struct udevice
*dev
, lbaint_t blknr
, lbaint_t blkcnt
,
70 * blkmap_from_label() - Find blkmap from label
72 * @label: Label of the requested blkmap
73 * Returns: A pointer to the blkmap on success, NULL on failure
75 struct udevice
*blkmap_from_label(const char *label
);
78 * blkmap_create() - Create new blkmap
80 * @label: Label of the new blkmap
81 * @devp: If not NULL, updated with the address of the resulting device
82 * Returns: 0 on success, negative error code on failure
84 int blkmap_create(const char *label
, struct udevice
**devp
);
87 * blkmap_destroy() - Destroy blkmap
89 * @dev: The blkmap to be destroyed
90 * Returns: 0 on success, negative error code on failure
92 int blkmap_destroy(struct udevice
*dev
);
95 * blkmap_create_ramdisk() - Create new ramdisk with blkmap
97 * @label: Label of the new blkmap
98 * @image_addr: Target memory start address of this mapping
99 * @image_size: Target memory size of this mapping
100 * @devp: Updated with the address of the created blkmap device
101 * Returns: 0 on success, negative error code on failure
103 int blkmap_create_ramdisk(const char *label
, ulong image_addr
, ulong image_size
,
104 struct udevice
**devp
);
106 #endif /* _BLKMAP_H */