Browse Source

[multiboot] Include argv[0] as part of "command line"

Grub will include the module name as part of the command line, and
some multiboot kernels expect this to be done.
tags/v0.9.8
Michael Brown 15 years ago
parent
commit
822b3b53f4
1 changed files with 6 additions and 5 deletions
  1. 6
    5
      src/arch/i386/image/multiboot.c

+ 6
- 5
src/arch/i386/image/multiboot.c View File

141
 /**
141
 /**
142
  * Add command line in base memory
142
  * Add command line in base memory
143
  *
143
  *
144
+ * @v imgname		Image name
144
  * @v cmdline		Command line
145
  * @v cmdline		Command line
145
  * @ret physaddr	Physical address of command line
146
  * @ret physaddr	Physical address of command line
146
  */
147
  */
147
-physaddr_t multiboot_add_cmdline ( const char *cmdline ) {
148
+physaddr_t multiboot_add_cmdline ( const char *imgname, const char *cmdline ) {
148
 	char *mb_cmdline;
149
 	char *mb_cmdline;
149
 
150
 
150
 	if ( ! cmdline )
151
 	if ( ! cmdline )
155
 	mb_cmdline_offset +=
156
 	mb_cmdline_offset +=
156
 		( snprintf ( mb_cmdline,
157
 		( snprintf ( mb_cmdline,
157
 			     ( sizeof ( mb_cmdlines ) - mb_cmdline_offset ),
158
 			     ( sizeof ( mb_cmdlines ) - mb_cmdline_offset ),
158
-			     "%s", cmdline ) + 1 );
159
+			     "%s %s", imgname, cmdline ) + 1 );
159
 
160
 
160
 	/* Truncate to terminating NUL in buffer if necessary */
161
 	/* Truncate to terminating NUL in buffer if necessary */
161
 	if ( mb_cmdline_offset > sizeof ( mb_cmdlines ) )
162
 	if ( mb_cmdline_offset > sizeof ( mb_cmdlines ) )
210
 			  ( ( count - insert ) * sizeof ( *module ) ) );
211
 			  ( ( count - insert ) * sizeof ( *module ) ) );
211
 		module->mod_start = start;
212
 		module->mod_start = start;
212
 		module->mod_end = end;
213
 		module->mod_end = end;
213
-		module->string =
214
-			multiboot_add_cmdline ( module_image->cmdline );
214
+		module->string = multiboot_add_cmdline ( module_image->name,
215
+						       module_image->cmdline );
215
 		module->reserved = 0;
216
 		module->reserved = 0;
216
 		
217
 		
217
 		/* We promise to page-align modules */
218
 		/* We promise to page-align modules */
269
 	multiboot_build_memmap ( image, &mbinfo, mbmemmap,
270
 	multiboot_build_memmap ( image, &mbinfo, mbmemmap,
270
 				 ( sizeof(mbmemmap) / sizeof(mbmemmap[0]) ) );
271
 				 ( sizeof(mbmemmap) / sizeof(mbmemmap[0]) ) );
271
 	mb_cmdline_offset = 0;
272
 	mb_cmdline_offset = 0;
272
-	mbinfo.cmdline = multiboot_add_cmdline ( image->cmdline );
273
+	mbinfo.cmdline = multiboot_add_cmdline ( image->name, image->cmdline );
273
 	mbinfo.mods_count = multiboot_build_module_list ( image, mbmodules,
274
 	mbinfo.mods_count = multiboot_build_module_list ( image, mbmodules,
274
 				( sizeof(mbmodules) / sizeof(mbmodules[0]) ) );
275
 				( sizeof(mbmodules) / sizeof(mbmodules[0]) ) );
275
 	mbinfo.mods_addr = virt_to_phys ( mbmodules );
276
 	mbinfo.mods_addr = virt_to_phys ( mbmodules );

Loading…
Cancel
Save