Tobias Waldekranz | 4f76dd3 | 2023-02-16 16:33:49 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
| 2 | /* |
| 3 | * Copyright (c) 2023 Addiva Elektronik |
| 4 | * Author: Tobias Waldekranz <tobias@waldekranz.com> |
| 5 | */ |
| 6 | |
| 7 | #ifndef _BLKMAP_H |
| 8 | #define _BLKMAP_H |
| 9 | |
| 10 | /** |
Tobias Waldekranz | f7241a4 | 2023-02-16 16:33:51 +0100 | [diff] [blame] | 11 | * blkmap_map_linear() - Map region of other block device |
| 12 | * |
| 13 | * @dev: Blkmap to create the mapping on |
| 14 | * @blknr: Start block number of the mapping |
| 15 | * @blkcnt: Number of blocks to map |
| 16 | * @lblk: The target block device of the mapping |
| 17 | * @lblknr: The start block number of the target device |
| 18 | * Returns: 0 on success, negative error code on failure |
| 19 | */ |
| 20 | int blkmap_map_linear(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, |
| 21 | struct udevice *lblk, lbaint_t lblknr); |
| 22 | |
| 23 | /** |
Tobias Waldekranz | 5f7f822 | 2023-02-16 16:33:50 +0100 | [diff] [blame] | 24 | * blkmap_map_mem() - Map region of memory |
| 25 | * |
| 26 | * @dev: Blkmap to create the mapping on |
| 27 | * @blknr: Start block number of the mapping |
| 28 | * @blkcnt: Number of blocks to map |
| 29 | * @addr: The target memory address of the mapping |
| 30 | * Returns: 0 on success, negative error code on failure |
| 31 | */ |
| 32 | int blkmap_map_mem(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, |
| 33 | void *addr); |
| 34 | |
| 35 | /** |
| 36 | * blkmap_map_pmem() - Map region of physical memory |
| 37 | * |
| 38 | * Ensures that a valid physical to virtual memory mapping for the |
| 39 | * requested region is valid for the lifetime of the mapping, on |
| 40 | * architectures that require it (sandbox). |
| 41 | * |
| 42 | * @dev: Blkmap to create the mapping on |
| 43 | * @blknr: Start block number of the mapping |
| 44 | * @blkcnt: Number of blocks to map |
| 45 | * @paddr: The target physical memory address of the mapping |
| 46 | * Returns: 0 on success, negative error code on failure |
| 47 | */ |
| 48 | int blkmap_map_pmem(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, |
| 49 | phys_addr_t paddr); |
| 50 | |
| 51 | |
| 52 | /** |
Tobias Waldekranz | 4f76dd3 | 2023-02-16 16:33:49 +0100 | [diff] [blame] | 53 | * blkmap_from_label() - Find blkmap from label |
| 54 | * |
| 55 | * @label: Label of the requested blkmap |
| 56 | * Returns: A pointer to the blkmap on success, NULL on failure |
| 57 | */ |
| 58 | struct udevice *blkmap_from_label(const char *label); |
| 59 | |
| 60 | /** |
| 61 | * blkmap_create() - Create new blkmap |
| 62 | * |
| 63 | * @label: Label of the new blkmap |
| 64 | * @devp: If not NULL, updated with the address of the resulting device |
| 65 | * Returns: 0 on success, negative error code on failure |
| 66 | */ |
| 67 | int blkmap_create(const char *label, struct udevice **devp); |
| 68 | |
| 69 | /** |
| 70 | * blkmap_destroy() - Destroy blkmap |
| 71 | * |
| 72 | * @dev: The blkmap to be destroyed |
| 73 | * Returns: 0 on success, negative error code on failure |
| 74 | */ |
| 75 | int blkmap_destroy(struct udevice *dev); |
| 76 | |
| 77 | #endif /* _BLKMAP_H */ |