pxe_utils.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. #ifndef __PXE_UTILS_H
  3. #define __PXE_UTILS_H
  4. #include <linux/list.h>
  5. /*
  6. * A note on the pxe file parser.
  7. *
  8. * We're parsing files that use syslinux grammar, which has a few quirks.
  9. * String literals must be recognized based on context - there is no
  10. * quoting or escaping support. There's also nothing to explicitly indicate
  11. * when a label section completes. We deal with that by ending a label
  12. * section whenever we see a line that doesn't include.
  13. *
  14. * As with the syslinux family, this same file format could be reused in the
  15. * future for non pxe purposes. The only action it takes during parsing that
  16. * would throw this off is handling of include files. It assumes we're using
  17. * pxe, and does a tftp download of a file listed as an include file in the
  18. * middle of the parsing operation. That could be handled by refactoring it to
  19. * take a 'include file getter' function.
  20. */
  21. /*
  22. * Describes a single label given in a pxe file.
  23. *
  24. * Create these with the 'label_create' function given below.
  25. *
  26. * name - the name of the menu as given on the 'menu label' line.
  27. * kernel - the path to the kernel file to use for this label.
  28. * append - kernel command line to use when booting this label
  29. * initrd - path to the initrd to use for this label.
  30. * attempted - 0 if we haven't tried to boot this label, 1 if we have.
  31. * localboot - 1 if this label specified 'localboot', 0 otherwise.
  32. * list - lets these form a list, which a pxe_menu struct will hold.
  33. */
  34. struct pxe_label {
  35. char num[4];
  36. char *name;
  37. char *menu;
  38. char *kernel;
  39. char *config;
  40. char *append;
  41. char *initrd;
  42. char *fdt;
  43. char *fdtdir;
  44. char *fdtoverlays;
  45. int ipappend;
  46. int attempted;
  47. int localboot;
  48. int localboot_val;
  49. struct list_head list;
  50. };
  51. /*
  52. * Describes a pxe menu as given via pxe files.
  53. *
  54. * title - the name of the menu as given by a 'menu title' line.
  55. * default_label - the name of the default label, if any.
  56. * bmp - the bmp file name which is displayed in background
  57. * timeout - time in tenths of a second to wait for a user key-press before
  58. * booting the default label.
  59. * prompt - if 0, don't prompt for a choice unless the timeout period is
  60. * interrupted. If 1, always prompt for a choice regardless of
  61. * timeout.
  62. * labels - a list of labels defined for the menu.
  63. */
  64. struct pxe_menu {
  65. char *title;
  66. char *default_label;
  67. char *bmp;
  68. int timeout;
  69. int prompt;
  70. struct list_head labels;
  71. };
  72. extern bool is_pxe;
  73. extern int (*do_getfile)(struct cmd_tbl *cmdtp, const char *file_path,
  74. char *file_addr);
  75. void destroy_pxe_menu(struct pxe_menu *cfg);
  76. int get_pxe_file(struct cmd_tbl *cmdtp, const char *file_path,
  77. unsigned long file_addr);
  78. int get_pxelinux_path(struct cmd_tbl *cmdtp, const char *file,
  79. unsigned long pxefile_addr_r);
  80. void handle_pxe_menu(struct cmd_tbl *cmdtp, struct pxe_menu *cfg);
  81. struct pxe_menu *parse_pxefile(struct cmd_tbl *cmdtp, unsigned long menucfg);
  82. int format_mac_pxe(char *outbuf, size_t outbuf_len);
  83. #endif /* __PXE_UTILS_H */