blkmap.h 2.3 KB

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