pxe_utils.h 2.9 KB

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