blob: 80d3d5c54e08e1a19212ac7f1b25e2a00ab2b337 (
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
#include "dev.h"
#include <gpxe/buffer.h>
#include <console.h>
#if 0
static struct image images[0] __image_start;
static struct image images_end[0] __image_end;
/*
* Print all images
*
*/
void print_images ( void ) {
struct image *image;
for ( image = images ; image < images_end ; image++ ) {
printf ( "%s ", image->name );
}
}
/*
* Identify the image format
*
*/
static struct image * identify_image ( physaddr_t start, physaddr_t len,
void **context ) {
struct image *image;
for ( image = images ; image < images_end ; image++ ) {
if ( image->probe ( start, len, context ) )
return image;
}
return NULL;
}
/*
* Load an image into memory at a location determined by the image
* format
*
*/
int autoload ( struct dev *dev, struct image **image, void **context ) {
struct buffer buffer;
int rc = 0;
/* Prepare the load buffer */
if ( ! init_load_buffer ( &buffer ) ) {
DBG ( "IMAGE could not initialise load buffer\n" );
goto out;
}
/* Load the image into the load buffer */
if ( ! load ( dev, &buffer ) ) {
DBG ( "IMAGE could not load image\n" );
goto out_free;
}
/* Shrink the load buffer */
trim_load_buffer ( &buffer );
/* Identify the image type */
*image = identify_image ( buffer.start, buffer.fill, context );
if ( ! *image ) {
DBG ( "IMAGE could not identify image type\n" );
goto out_free;
}
/* Move the image into the target location */
if ( ! (*image)->load ( buffer.start, buffer.fill, *context ) ) {
DBG ( "IMAGE could not move to target location\n" );
goto out_free;
}
/* Return success */
rc = 1;
out_free:
/* Free the load buffer */
done_load_buffer ( &buffer );
out:
return rc;
}
#endif
|