bootm.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * (C) Copyright 2000-2009
  4. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. */
  6. #ifndef _BOOTM_H
  7. #define _BOOTM_H
  8. #include <image.h>
  9. struct cmd_tbl;
  10. #define BOOTM_ERR_RESET (-1)
  11. #define BOOTM_ERR_OVERLAP (-2)
  12. #define BOOTM_ERR_UNIMPLEMENTED (-3)
  13. /*
  14. * Continue booting an OS image; caller already has:
  15. * - copied image header to global variable `header'
  16. * - checked header magic number, checksums (both header & image),
  17. * - verified image architecture (PPC) and type (KERNEL or MULTI),
  18. * - loaded (first part of) image to header load address,
  19. * - disabled interrupts.
  20. *
  21. * @flag: Flags indicating what to do (BOOTM_STATE_...)
  22. * @argc: Number of arguments. Note that the arguments are shifted down
  23. * so that 0 is the first argument not processed by U-Boot, and
  24. * argc is adjusted accordingly. This avoids confusion as to how
  25. * many arguments are available for the OS.
  26. * @images: Pointers to os/initrd/fdt
  27. * Return: 1 on error. On success the OS boots so this function does
  28. * not return.
  29. */
  30. typedef int boot_os_fn(int flag, int argc, char *const argv[],
  31. bootm_headers_t *images);
  32. extern boot_os_fn do_bootm_linux;
  33. extern boot_os_fn do_bootm_vxworks;
  34. int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
  35. boot_os_fn *bootm_os_get_boot_func(int os);
  36. #if defined(CONFIG_FIT_SIGNATURE)
  37. int bootm_host_load_images(const void *fit, int cfg_noffset);
  38. #endif
  39. int boot_selected_os(int argc, char *const argv[], int state,
  40. bootm_headers_t *images, boot_os_fn *boot_fn);
  41. ulong bootm_disable_interrupts(void);
  42. /* This is a special function used by booti/bootz */
  43. int bootm_find_images(int flag, int argc, char *const argv[], ulong start,
  44. ulong size);
  45. int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int argc,
  46. char *const argv[], int states, bootm_headers_t *images,
  47. int boot_progress);
  48. void arch_preboot_os(void);
  49. /*
  50. * boards should define this to disable devices when EFI exits from boot
  51. * services.
  52. *
  53. * TODO(sjg@chromium.org>): Update this to use driver model's device_remove().
  54. */
  55. void board_quiesce_devices(void);
  56. /**
  57. * switch_to_non_secure_mode() - switch to non-secure mode
  58. */
  59. void switch_to_non_secure_mode(void);
  60. /* Flags to control bootm_process_cmdline() */
  61. enum bootm_cmdline_t {
  62. BOOTM_CL_SILENT = 1 << 0, /* Do silent console processing */
  63. BOOTM_CL_SUBST = 1 << 1, /* Do substitution */
  64. BOOTM_CL_ALL = 3, /* All substitutions */
  65. };
  66. /**
  67. * arch_preboot_os() - arch specific configuration before booting
  68. */
  69. void arch_preboot_os(void);
  70. /**
  71. * board_preboot_os() - board specific configuration before booting
  72. */
  73. void board_preboot_os(void);
  74. /*
  75. * bootm_process_cmdline() - Process fix-ups for the command line
  76. *
  77. * This handles:
  78. *
  79. * - making Linux boot silently if requested ('silent_linux' envvar)
  80. * - performing substitutions in the command line ('bootargs_subst' envvar)
  81. *
  82. * @maxlen must provide enough space for the string being processed plus the
  83. * resulting string
  84. *
  85. * @buf: buffer holding commandline string to adjust
  86. * @maxlen: Maximum length of buffer at @buf (including \0)
  87. * @flags: Flags to control what happens (see bootm_cmdline_t)
  88. * Return: 0 if OK, -ENOMEM if out of memory, -ENOSPC if the commandline is too
  89. * long
  90. */
  91. int bootm_process_cmdline(char *buf, int maxlen, int flags);
  92. /**
  93. * bootm_process_cmdline_env() - Process fix-ups for the command line
  94. *
  95. * Updates the 'bootargs' envvar as required. This handles:
  96. *
  97. * - making Linux boot silently if requested ('silent_linux' envvar)
  98. * - performing substitutions in the command line ('bootargs_subst' envvar)
  99. *
  100. * @flags: Flags to control what happens (see bootm_cmdline_t)
  101. * Return: 0 if OK, -ENOMEM if out of memory
  102. */
  103. int bootm_process_cmdline_env(int flags);
  104. #endif