ubispl.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* SPDX-License-Identifier: GPL 2.0+ OR BSD-3-Clause */
  2. /*
  3. * Copyright (c) Thomas Gleixner <tglx@linutronix.de>
  4. */
  5. #ifndef __UBOOT_UBISPL_H
  6. #define __UBOOT_UBISPL_H
  7. #define UBI_VOL_NAME_MAX 127
  8. /*
  9. * The following CONFIG options are relevant for UBISPL
  10. *
  11. * #define CONFIG_SPL_UBI_MAX_VOL_LEBS 256
  12. *
  13. * Defines the maximum number of logical erase blocks per loadable
  14. * (static) volume to size the ubispl internal arrays.
  15. *
  16. * #define CONFIG_SPL_UBI_MAX_PEB_SIZE (256*1024)
  17. *
  18. * Defines the maximum physical erase block size to size the fastmap
  19. * buffer for ubispl.
  20. *
  21. * #define CONFIG_SPL_UBI_MAX_PEBS 4096
  22. *
  23. * Define the maximum number of physical erase blocks to size the
  24. * ubispl internal arrays.
  25. *
  26. * #define CONFIG_SPL_UBI_VOL_IDS 8
  27. *
  28. * Defines the maximum number of volumes in which UBISPL is
  29. * interested. Limits the amount of memory for the scan data and
  30. * speeds up the scan process as we simply ignore stuff which we dont
  31. * want to load from the SPL anyway. So the volumes which can be
  32. * loaded in the above example are ids 0 - 7
  33. */
  34. /*
  35. * The struct definition is in drivers/mtd/ubispl/ubispl.h. It does
  36. * not fit into the BSS due to the large buffer requirement of the
  37. * upstream fastmap code. So the caller of ubispl_load_volumes needs
  38. * to hand in a pointer to a free memory area where ubispl will place
  39. * its data. The area is not required to be initialized.
  40. */
  41. struct ubi_scan_info;
  42. typedef int (*ubispl_read_flash)(int pnum, int offset, int len, void *dst);
  43. /**
  44. * struct ubispl_info - description structure for fast ubi scan
  45. * @ubi: Pointer to memory space for ubi scan info structure
  46. * @peb_size: Physical erase block size
  47. * @vid_offset: Offset of the VID header
  48. * @leb_start: Start of the logical erase block, i.e. offset of data
  49. * @peb_count: Number of physical erase blocks in the UBI FLASH area
  50. * aka MTD partition.
  51. * @peb_offset: Offset of PEB0 in the UBI FLASH area (aka MTD partition)
  52. * to the real start of the FLASH in erase blocks.
  53. * @fastmap: Enable fastmap attachment
  54. * @read: Read function to access the flash
  55. */
  56. struct ubispl_info {
  57. struct ubi_scan_info *ubi;
  58. u32 peb_size;
  59. u32 vid_offset;
  60. u32 leb_start;
  61. u32 peb_count;
  62. u32 peb_offset;
  63. int fastmap;
  64. ubispl_read_flash read;
  65. };
  66. /**
  67. * struct ubispl_load - structure to describe a volume to load
  68. * @vol_id: Volume id
  69. * @load_addr: Load address of the volume
  70. */
  71. struct ubispl_load {
  72. int vol_id;
  73. #ifdef CONFIG_SPL_UBI_LOAD_BY_VOLNAME
  74. u32 name_len;
  75. char name[UBI_VOL_NAME_MAX + 1];
  76. #endif
  77. void *load_addr;
  78. };
  79. /**
  80. * ubispl_load_volumes - Scan flash and load volumes
  81. * @info: Pointer to the ubi scan info structure
  82. * @lovls: Pointer to array of volumes to load
  83. * @nrvols: Array size of @lovls
  84. */
  85. int ubispl_load_volumes(struct ubispl_info *info,
  86. struct ubispl_load *lvols, int nrvols);
  87. #endif