pxe_utils.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. char *fdtoverlays;
  44. int ipappend;
  45. int attempted;
  46. int localboot;
  47. int localboot_val;
  48. struct list_head list;
  49. };
  50. /*
  51. * Describes a pxe menu as given via pxe files.
  52. *
  53. * title - the name of the menu as given by a 'menu title' line.
  54. * default_label - the name of the default label, if any.
  55. * bmp - the bmp file name which is displayed in background
  56. * timeout - time in tenths of a second to wait for a user key-press before
  57. * booting the default label.
  58. * prompt - if 0, don't prompt for a choice unless the timeout period is
  59. * interrupted. If 1, always prompt for a choice regardless of
  60. * timeout.
  61. * labels - a list of labels defined for the menu.
  62. */
  63. struct pxe_menu {
  64. char *title;
  65. char *default_label;
  66. char *bmp;
  67. int timeout;
  68. int prompt;
  69. struct list_head labels;
  70. };
  71. extern bool is_pxe;
  72. extern int (*do_getfile)(struct cmd_tbl *cmdtp, const char *file_path,
  73. char *file_addr);
  74. void destroy_pxe_menu(struct pxe_menu *cfg);
  75. int get_pxe_file(struct cmd_tbl *cmdtp, const char *file_path,
  76. unsigned long file_addr);
  77. int get_pxelinux_path(struct cmd_tbl *cmdtp, const char *file,
  78. unsigned long pxefile_addr_r);
  79. void handle_pxe_menu(struct cmd_tbl *cmdtp, struct pxe_menu *cfg);
  80. struct pxe_menu *parse_pxefile(struct cmd_tbl *cmdtp, unsigned long menucfg);
  81. int format_mac_pxe(char *outbuf, size_t outbuf_len);
  82. #endif /* __PXE_UTILS_H */