summaryrefslogtreecommitdiffstats
path: root/src/include/gpxe/image.h
blob: 65f7e7643a53b722877297af1d8319fb5a3c35aa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef _GPXE_IMAGE_H
#define _GPXE_IMAGE_H

/**
 * @file
 *
 * Executable/loadable image formats
 *
 */

#include <gpxe/tables.h>

/** An executable or loadable image */
struct image {
	/** Raw file image */
	userptr_t data;
	/** Length of raw file image */
	size_t len;

	/** Execute method
	 *
	 * Filled in by the image loader.  If NULL, then the image
	 * cannot be executed.
	 */
	int ( * execute ) ( struct image *image );
	/** Entry point */
	physaddr_t entry;

	/** Command line to pass to image */
	const char *cmdline;
};

/** An executable or loadable image type */
struct image_type {
	/** Name of this image type */
	char *name;
	/** Load image into memory
	 *
	 * @v image		Executable/loadable image
	 * @ret rc		Return status code
	 *
	 * Load the image into memory.  The file image may be
	 * discarded after this call; the method must preserve any
	 * information it may require later (e.g. the execution
	 * address) within the @c image structure.
	 *
	 * The method should return -ENOEXEC if and only if the image
	 * is not in the correct format.  Other errors will be
	 * interpreted as "I claim this image format, but there's
	 * something wrong with it that makes it unloadable".  In
	 * particular, returning -ENOEXEC will cause the image probing
	 * code to try the next available image type, while returning
	 * any other error will terminate image probing.
	 */
	int ( * load ) ( struct image *image );
};

/** An executable or loadable image type */
#define __image_type __table ( struct image_type, image_types, 01 )

/**
 * An unverifiable executable or loadable image type
 *
 * This should be used to mark image types for which there are no
 * signature or other checks that can be used to verify the validity
 * of the image (such as PXE images).  These will then be tried last
 * in the list of image types.
 */
#define __default_image_type __table ( struct image_type, image_types, 02 )

#endif /* _GPXE_IMAGE_H */