bootstd.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Standard U-Boot boot framework
  4. *
  5. * Copyright 2021 Google LLC
  6. * Written by Simon Glass <sjg@chromium.org>
  7. */
  8. #ifndef __bootstd_h
  9. #define __bootstd_h
  10. #include <dm/ofnode_decl.h>
  11. struct udevice;
  12. /**
  13. * struct bootstd_priv - priv data for the bootstd driver
  14. *
  15. * This is attached to the (only) bootstd device, so there is only one instance
  16. * of this struct. It provides overall information about bootdevs and bootflows.
  17. *
  18. * @prefixes: NULL-terminated list of prefixes to use for bootflow filenames,
  19. * e.g. "/", "/boot/"; NULL if none
  20. * @bootdev_order: Order to use for bootdevs (or NULL if none), with each item
  21. * being a bootdev label, e.g. "mmc2", "mmc1" (NULL terminated)
  22. * @env_order: Order as specified by the boot_targets env var (or NULL if none),
  23. * with each item being a bootdev label, e.g. "mmc2", "mmc1" (NULL
  24. * terminated)
  25. * @cur_bootdev: Currently selected bootdev (for commands)
  26. * @cur_bootflow: Currently selected bootflow (for commands)
  27. * @glob_head: Head for the global list of all bootflows across all bootdevs
  28. * @bootmeth_count: Number of bootmeth devices in @bootmeth_order
  29. * @bootmeth_order: List of bootmeth devices to use, in order, NULL-terminated
  30. * @vbe_bootmeth: Currently selected VBE bootmeth, NULL if none
  31. * @theme: Node containing the theme information
  32. * @hunters_used: Bitmask of used hunters, indexed by their position in the
  33. * linker list. The bit is set if the hunter has been used already
  34. */
  35. struct bootstd_priv {
  36. const char **prefixes;
  37. const char **bootdev_order;
  38. const char **env_order;
  39. struct udevice *cur_bootdev;
  40. struct bootflow *cur_bootflow;
  41. struct list_head glob_head;
  42. int bootmeth_count;
  43. struct udevice **bootmeth_order;
  44. struct udevice *vbe_bootmeth;
  45. ofnode theme;
  46. uint hunters_used;
  47. };
  48. /**
  49. * bootstd_get_bootdev_order() - Get the boot-order list
  50. *
  51. * This reads the boot order, e.g. {"mmc0", "mmc2", NULL}
  52. *
  53. * The list is alloced by the bootstd driver so should not be freed. That is the
  54. * reason for all the const stuff in the function signature
  55. *
  56. * @dev: bootstd device
  57. * @okp: returns true if OK, false if out of memory
  58. * Return: list of string pointers, terminated by NULL; or NULL if no boot
  59. * order. Note that this returns NULL in the case of an empty list
  60. */
  61. const char *const *const bootstd_get_bootdev_order(struct udevice *dev,
  62. bool *okp);
  63. /**
  64. * bootstd_get_prefixes() - Get the filename-prefixes list
  65. *
  66. * This reads the prefixes, e.g. {"/", "/boot", NULL}
  67. *
  68. * The list is alloced by the bootstd driver so should not be freed. That is the
  69. * reason for all the const stuff in the function signature
  70. *
  71. * Return: list of string points, terminated by NULL; or NULL if no boot order
  72. */
  73. const char *const *const bootstd_get_prefixes(struct udevice *dev);
  74. /**
  75. * bootstd_get_priv() - Get the (single) state for the bootstd system
  76. *
  77. * The state holds a global list of all bootflows that have been found.
  78. *
  79. * Return: 0 if OK, -ve if the uclass does not exist
  80. */
  81. int bootstd_get_priv(struct bootstd_priv **stdp);
  82. /**
  83. * bootstd_clear_glob() - Clear the global list of bootflows
  84. *
  85. * This removes all bootflows globally and across all bootdevs.
  86. */
  87. void bootstd_clear_glob(void);
  88. #endif