|
@@ -0,0 +1,81 @@
|
|
1
|
+/*
|
|
2
|
+ * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
|
|
3
|
+ *
|
|
4
|
+ * This program is free software; you can redistribute it and/or
|
|
5
|
+ * modify it under the terms of the GNU General Public License as
|
|
6
|
+ * published by the Free Software Foundation; either version 2 of the
|
|
7
|
+ * License, or any later version.
|
|
8
|
+ *
|
|
9
|
+ * This program is distributed in the hope that it will be useful, but
|
|
10
|
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
12
|
+ * General Public License for more details.
|
|
13
|
+ *
|
|
14
|
+ * You should have received a copy of the GNU General Public License
|
|
15
|
+ * along with this program; if not, write to the Free Software
|
|
16
|
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
17
|
+ */
|
|
18
|
+
|
|
19
|
+/**
|
|
20
|
+ * @file
|
|
21
|
+ *
|
|
22
|
+ * Linux bzImage image format
|
|
23
|
+ *
|
|
24
|
+ */
|
|
25
|
+
|
|
26
|
+#include <errno.h>
|
|
27
|
+#include <assert.h>
|
|
28
|
+#include <realmode.h>
|
|
29
|
+#include <bzimage.h>
|
|
30
|
+#include <gpxe/uaccess.h>
|
|
31
|
+#include <gpxe/image.h>
|
|
32
|
+#include <gpxe/segment.h>
|
|
33
|
+#include <gpxe/memmap.h>
|
|
34
|
+#include <gpxe/shutdown.h>
|
|
35
|
+
|
|
36
|
+struct image_type bzimage_image_type __image_type ( PROBE_NORMAL );
|
|
37
|
+
|
|
38
|
+/**
|
|
39
|
+ * Execute bzImage image
|
|
40
|
+ *
|
|
41
|
+ * @v image bzImage image
|
|
42
|
+ * @ret rc Return status code
|
|
43
|
+ */
|
|
44
|
+static int bzimage_exec ( struct image *image ) {
|
|
45
|
+}
|
|
46
|
+
|
|
47
|
+/**
|
|
48
|
+ * Load bzImage image into memory
|
|
49
|
+ *
|
|
50
|
+ * @v image bzImage file
|
|
51
|
+ * @ret rc Return status code
|
|
52
|
+ */
|
|
53
|
+int bzimage_load ( struct image *image ) {
|
|
54
|
+ struct bzimage_header bzhdr;
|
|
55
|
+
|
|
56
|
+ /* Sanity check */
|
|
57
|
+ if ( image->len < ( BZHDR_OFFSET + sizeof ( bzhdr ) ) ) {
|
|
58
|
+ DBGC ( image, "BZIMAGE %p too short\n", image );
|
|
59
|
+ return -ENOEXEC;
|
|
60
|
+ }
|
|
61
|
+
|
|
62
|
+ /* Read and verify header */
|
|
63
|
+ copy_from_user ( &bzhdr, image->data, BZHDR_OFFSET, sizeof ( bzhdr ) );
|
|
64
|
+ if ( bzhdr.header != BZIMAGE_SIGNATURE ) {
|
|
65
|
+ DBGC ( image, "BZIMAGE %p not a bzImage\n", image );
|
|
66
|
+ return -ENOEXEC;
|
|
67
|
+ }
|
|
68
|
+
|
|
69
|
+ /* This is a bzImage image, valid or otherwise */
|
|
70
|
+ if ( ! image->type )
|
|
71
|
+ image->type = &bzimage_image_type;
|
|
72
|
+
|
|
73
|
+ return 0;
|
|
74
|
+}
|
|
75
|
+
|
|
76
|
+/** Linux bzImage image type */
|
|
77
|
+struct image_type bzimage_image_type __image_type ( PROBE_NORMAL ) = {
|
|
78
|
+ .name = "bzImage",
|
|
79
|
+ .load = bzimage_load,
|
|
80
|
+ .exec = bzimage_exec,
|
|
81
|
+};
|