global: Migrate CONFIG_STACKBASE to CFG
[platform/kernel/u-boot.git] / include / pxe_utils.h
index 6681442..1e5e842 100644 (file)
  * Create these with the 'label_create' function given below.
  *
  * name - the name of the menu as given on the 'menu label' line.
+ * kernel_label - the kernel label, including FIT config if present.
  * kernel - the path to the kernel file to use for this label.
  * append - kernel command line to use when booting this label
  * initrd - path to the initrd to use for this label.
  * attempted - 0 if we haven't tried to boot this label, 1 if we have.
  * localboot - 1 if this label specified 'localboot', 0 otherwise.
+ * kaslrseed - 1 if generate kaslrseed from hw_rng
  * list - lets these form a list, which a pxe_menu struct will hold.
  */
 struct pxe_label {
        char num[4];
        char *name;
        char *menu;
+       char *kernel_label;
        char *kernel;
        char *config;
        char *append;
@@ -50,6 +53,7 @@ struct pxe_label {
        int attempted;
        int localboot;
        int localboot_val;
+       int kaslrseed;
        struct list_head list;
 };
 
@@ -77,7 +81,7 @@ struct pxe_menu {
 
 struct pxe_context;
 typedef int (*pxe_getfile_func)(struct pxe_context *ctx, const char *file_path,
-                               char *file_addr);
+                               char *file_addr, ulong *filesizep);
 
 /**
  * struct pxe_context - context information for PXE parsing
@@ -86,6 +90,9 @@ typedef int (*pxe_getfile_func)(struct pxe_context *ctx, const char *file_path,
  * @getfile: Function called by PXE to read a file
  * @userdata: Data the caller requires for @getfile
  * @allow_abs_path: true to allow absolute paths
+ * @bootdir: Directory that files are loaded from ("" if no directory). This is
+ *     allocated
+ * @pxe_file_size: Size of the PXE file
  */
 struct pxe_context {
        struct cmd_tbl *cmdtp;
@@ -96,12 +103,15 @@ struct pxe_context {
         * @file_path: Path to the file
         * @file_addr: String containing the hex address to put the file in
         *      memory
+        * @filesizep: Returns the file size in bytes
         * Return 0 if OK, -ve on error
         */
        pxe_getfile_func getfile;
 
        void *userdata;
        bool allow_abs_path;
+       char *bootdir;
+       ulong pxe_file_size;
 };
 
 /**
@@ -197,9 +207,51 @@ int format_mac_pxe(char *outbuf, size_t outbuf_len);
  * @getfile: Function to call to read a file
  * @userdata: Data the caller requires for @getfile - stored in ctx->userdata
  * @allow_abs_path: true to allow absolute paths
+ * @bootfile: Bootfile whose directory loaded files are relative to, NULL if
+ *     none
+ * Return: 0 if OK, -ENOMEM if out of memory, -E2BIG if bootfile is larger than
+ *     MAX_TFTP_PATH_LEN bytes
  */
-void pxe_setup_ctx(struct pxe_context *ctx, struct cmd_tbl *cmdtp,
-                  pxe_getfile_func getfile, void *userdata,
-                  bool allow_abs_path);
+int pxe_setup_ctx(struct pxe_context *ctx, struct cmd_tbl *cmdtp,
+                 pxe_getfile_func getfile, void *userdata,
+                 bool allow_abs_path, const char *bootfile);
+
+/**
+ * pxe_destroy_ctx() - Destroy a PXE context
+ *
+ * @ctx: Context to destroy
+ */
+void pxe_destroy_ctx(struct pxe_context *ctx);
+
+/**
+ * pxe_process() - Process a PXE file through to boot
+ *
+ * @ctx: PXE context created with pxe_setup_ctx()
+ * @pxefile_addr_r: Address to load file
+ * @prompt: Force a prompt for the user
+ */
+int pxe_process(struct pxe_context *ctx, ulong pxefile_addr_r, bool prompt);
+
+/**
+ * pxe_get_file_size() - Read the value of the 'filesize' environment variable
+ *
+ * @sizep: Place to put the value
+ * Return: 0 if OK, -ENOENT if no such variable, -EINVAL if format is invalid
+ */
+int pxe_get_file_size(ulong *sizep);
+
+/**
+ * pxe_get() - Get the PXE file from the server
+ *
+ * This tries various filenames to obtain a PXE file
+ *
+ * @pxefile_addr_r: Address to put file
+ * @bootdirp: Returns the boot filename, or NULL if none. This is the 'bootfile'
+ *     option provided by the DHCP server. If none, returns NULL. For example,
+ *     "rpi/info", which indicates that all files should be fetched from the
+ *     "rpi/" subdirectory
+ * @sizep: Size of the PXE file (not bootfile)
+ */
+int pxe_get(ulong pxefile_addr_r, char **bootdirp, ulong *sizep);
 
 #endif /* __PXE_UTILS_H */