7 * Executable/loadable images
11 #include <gpxe/tables.h>
12 #include <gpxe/list.h>
13 #include <gpxe/uaccess.h>
17 /** Maximum length of a command line */
18 #define CMDLINE_MAX 128
20 /** An executable or loadable image */
24 /** List of registered images */
25 struct list_head list;
27 /** Command line to pass to image */
28 char cmdline[CMDLINE_MAX];
32 /** Length of raw file image */
38 /** Image type, if known */
39 struct image_type *type;
45 /** Image is loaded */
46 #define IMAGE_LOADED 0x0001
48 /** An executable or loadable image type */
50 /** Name of this image type */
53 * Load image into memory
55 * @v image Executable/loadable image
56 * @ret rc Return status code
58 * Load the image into memory. The file image may be
59 * discarded after this call; the method must preserve any
60 * information it may require later (e.g. the execution
61 * address) within the @c image structure.
63 * If the file image is in the correct format, the method must
64 * update @c image->type to point to its own type (unless @c
65 * image->type is already set). This allows the autoloading
66 * code to disambiguate between "this is not my image format"
67 * and "there is something wrong with this image". In
68 * particular, setting @c image->type and then returning an
69 * error will cause image_autoload() to abort and return an
70 * error, rather than continuing to the next image type.
72 int ( * load ) ( struct image *image );
74 * Execute loaded image
76 * @v image Loaded image
77 * @ret rc Return status code
79 int ( * exec ) ( struct image *image );
83 * Multiboot image probe priority
85 * Multiboot images are also valid executables in another format
86 * (e.g. ELF), so we must perform the multiboot probe first.
88 #define PROBE_MULTIBOOT 01
91 * Normal image probe priority
93 #define PROBE_NORMAL 02
96 * PXE image probe priority
98 * PXE images have no signature checks, so will claim all image files.
99 * They must therefore be tried last in the probe order list.
103 /** An executable or loadable image type */
104 #define __image_type( probe_order ) \
105 __table ( struct image_type, image_types, probe_order )
107 extern struct list_head images;
109 /** Iterate over all registered images */
110 #define for_each_image( image ) \
111 list_for_each_entry ( (image), &images, list )
113 extern int register_image ( struct image *image );
114 extern void unregister_image ( struct image *image );
115 struct image * find_image ( const char *name );
116 extern void free_image ( struct image *image );
117 extern int image_load ( struct image *image );
118 extern int image_autoload ( struct image *image );
119 extern int image_exec ( struct image *image );
121 #endif /* _GPXE_IMAGE_H */