|
@@ -0,0 +1,83 @@
|
|
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
|
+ * PXE image format
|
|
23
|
+ *
|
|
24
|
+ */
|
|
25
|
+
|
|
26
|
+#include <gpxe/uaccess.h>
|
|
27
|
+#include <gpxe/image.h>
|
|
28
|
+#include <gpxe/segment.h>
|
|
29
|
+#include <pxe_call.h>
|
|
30
|
+
|
|
31
|
+/** PXE load address segment */
|
|
32
|
+#define PXE_LOAD_SEGMENT 0
|
|
33
|
+
|
|
34
|
+/** PXE load address offset */
|
|
35
|
+#define PXE_LOAD_OFFSET 0x7c00
|
|
36
|
+
|
|
37
|
+struct image_type pxe_image_type __image_type ( PROBE_PXE );
|
|
38
|
+
|
|
39
|
+/**
|
|
40
|
+ * Execute PXE image
|
|
41
|
+ *
|
|
42
|
+ * @v image PXE image
|
|
43
|
+ * @ret rc Return status code
|
|
44
|
+ */
|
|
45
|
+static int pxe_exec ( struct image *image __unused ) {
|
|
46
|
+ return pxe_boot();
|
|
47
|
+}
|
|
48
|
+
|
|
49
|
+/**
|
|
50
|
+ * Load PXE image into memory
|
|
51
|
+ *
|
|
52
|
+ * @v image PXE file
|
|
53
|
+ * @ret rc Return status code
|
|
54
|
+ */
|
|
55
|
+int pxe_load ( struct image *image ) {
|
|
56
|
+ userptr_t buffer = real_to_user ( 0, 0x7c00 );
|
|
57
|
+ size_t filesz = image->len;
|
|
58
|
+ size_t memsz = image->len;
|
|
59
|
+ int rc;
|
|
60
|
+
|
|
61
|
+ /* There are no signature checks for PXE; we will accept anything */
|
|
62
|
+ if ( ! image->type )
|
|
63
|
+ image->type = &pxe_image_type;
|
|
64
|
+
|
|
65
|
+ /* Verify and prepare segment */
|
|
66
|
+ if ( ( rc = prep_segment ( buffer, filesz, memsz ) != 0 ) ) {
|
|
67
|
+ DBG ( "PXE image could not prepare segment: %s\n",
|
|
68
|
+ strerror ( rc ) );
|
|
69
|
+ return rc;
|
|
70
|
+ }
|
|
71
|
+
|
|
72
|
+ /* Copy image to segment */
|
|
73
|
+ memcpy_user ( buffer, 0, image->data, 0, filesz );
|
|
74
|
+
|
|
75
|
+ return 0;
|
|
76
|
+}
|
|
77
|
+
|
|
78
|
+/** PXE image type */
|
|
79
|
+struct image_type pxe_image_type __image_type ( PROBE_PXE ) = {
|
|
80
|
+ .name = "PXE",
|
|
81
|
+ .load = pxe_load,
|
|
82
|
+ .exec = pxe_exec,
|
|
83
|
+};
|