ソースを参照

Place command-line inline, to save on memory allocation hassles.

tags/v0.9.3
Michael Brown 17年前
コミット
9debfed07a
2個のファイルの変更16行の追加8行の削除
  1. 4
    7
      src/arch/i386/image/multiboot.c
  2. 12
    1
      src/include/gpxe/image.h

+ 4
- 7
src/arch/i386/image/multiboot.c ファイルの表示

@@ -119,8 +119,7 @@ multiboot_build_module_list ( struct image *image,
119 119
 		module->mod_start = user_to_phys ( module_image->data, 0 );
120 120
 		module->mod_end = user_to_phys ( module_image->data,
121 121
 						 module_image->len );
122
-		if ( image->cmdline )
123
-			module->string = virt_to_phys ( image->cmdline );
122
+		module->string = virt_to_phys ( image->cmdline );
124 123
 
125 124
 		/* We promise to page-align modules, so at least check */
126 125
 		assert ( ( module->mod_start & 0xfff ) == 0 );
@@ -154,11 +153,9 @@ static int multiboot_exec ( struct image *image ) {
154 153
 	mbinfo.mmap_addr = virt_to_phys ( &mbmemmap[0].base_addr );
155 154
 	mbinfo.flags |= ( MBI_FLAG_MEM | MBI_FLAG_MMAP );
156 155
 
157
-	/* Set command line, if present */
158
-	if ( image->cmdline ) {
159
-		mbinfo.cmdline = virt_to_phys ( image->cmdline );
160
-		mbinfo.flags |= MBI_FLAG_CMDLINE;
161
-	}
156
+	/* Set command line */
157
+	mbinfo.cmdline = virt_to_phys ( image->cmdline );
158
+	mbinfo.flags |= MBI_FLAG_CMDLINE;
162 159
 
163 160
 	/* Construct module list */
164 161
 	num_modules = multiboot_build_module_list ( image, NULL );

+ 12
- 1
src/include/gpxe/image.h ファイルの表示

@@ -14,6 +14,9 @@
14 14
 
15 15
 struct image_type;
16 16
 
17
+/** Maximum length of a command line */
18
+#define CMDLINE_MAX 128
19
+
17 20
 /** An executable or loadable image */
18 21
 struct image {
19 22
 	/** Name */
@@ -22,12 +25,20 @@ struct image {
22 25
 	struct list_head list;
23 26
 
24 27
 	/** Command line to pass to image */
25
-	const char *cmdline;
28
+	char cmdline[CMDLINE_MAX];
26 29
 
27 30
 	/** Raw file image */
28 31
 	userptr_t data;
29 32
 	/** Length of raw file image */
30 33
 	size_t len;
34
+	/**
35
+	 * Free raw file image
36
+	 *
37
+	 * @v data		Raw file image
38
+	 *
39
+	 * Call this method before freeing up the @c struct @c image.
40
+	 */
41
+	void ( * free ) ( userptr_t data );
31 42
 
32 43
 	/** Entry point */
33 44
 	physaddr_t entry;

読み込み中…
キャンセル
保存