Index: preploader/Makefile
diff -c preploader/Makefile:1.1.1.3 preploader/Makefile:1.2
*** preploader/Makefile:1.1.1.3	Wed Jan 20 09:45:40 1999
--- preploader/Makefile	Wed Jan 20 14:26:39 1999
***************
*** 59,68 ****
  
  #OBJECTS += vreset.o kbd.o
  
! zImage: $(OBJECTS) $(IMAGES) $(SIZES) ppcboot.lds
  	ld -o zImage $(OBJECTS) -b binary $(IMAGES) -T ppcboot.lds \
  	--defsym _vmlinux_size=`cut -f 1 <.vmlinux.size` -Map zImage.map
  
  # The 2 objcopy are quite ugly, but for now it was the simplest solution
  # since the flags to expand the bss do not work on a binary output format.
  # It would be better to know where the bss is and clear it in the bootloader,
--- 59,72 ----
  
  #OBJECTS += vreset.o kbd.o
  
! zImage: $(OBJECTS) $(IMAGES) $(SIZES) ppcboot.lds prepctl
  	ld -o zImage $(OBJECTS) -b binary $(IMAGES) -T ppcboot.lds \
  	--defsym _vmlinux_size=`cut -f 1 <.vmlinux.size` -Map zImage.map
  
+ prepctl: prepctl.c
+ 	$(CC) -O -o $@ $<
+ 
+ 
  # The 2 objcopy are quite ugly, but for now it was the simplest solution
  # since the flags to expand the bss do not work on a binary output format.
  # It would be better to know where the bss is and clear it in the bootloader,
Index: preploader/bootdata.h
diff -c /dev/null preploader/bootdata.h:1.1
*** /dev/null	Wed Jan 20 14:54:39 1999
--- preploader/bootdata.h	Wed Jan 20 14:27:27 1999
***************
*** 0 ****
--- 1,3 ----
+ #define MAGIC1_CMDLINE 0xe08ed9f7
+ #define MAGIC2_CMDLINE 0x3c0b8c88
+ 
Index: preploader/bootldr.h
diff -c preploader/bootldr.h:1.1.1.3 preploader/bootldr.h:1.2
*** preploader/bootldr.h:1.1.1.3	Wed Jan 20 09:45:19 1999
--- preploader/bootldr.h	Wed Jan 20 14:26:41 1999
***************
*** 73,78 ****
--- 73,81 ----
   * functions who have to access the .got2 sections (this increases the 
   * size of the prologue in every function).
   */
+ 
+ #include "bootdata.h"
+ 
  typedef struct _boot_data {
  	RESIDUAL *residual;
  	void *load_address;
***************
*** 95,101 ****
  	const struct console_io *console_functions;
  	opaque * console_private;
  	u_long ticks_per_ms;
! 	char cmd_line[256];
  } boot_data;
  
  register boot_data *bd __asm__("r13");
--- 98,106 ----
  	const struct console_io *console_functions;
  	opaque * console_private;
  	u_long ticks_per_ms;
!   unsigned long magic1;
!   char cmd_line[256];
!   unsigned long magic2;
  } boot_data;
  
  register boot_data *bd __asm__("r13");
Index: preploader/misc.c
diff -c preploader/misc.c:1.1.1.3 preploader/misc.c:1.2
*** preploader/misc.c:1.1.1.3	Wed Jan 20 09:45:33 1999
--- preploader/misc.c	Wed Jan 20 14:26:43 1999
***************
*** 48,54 ****
  		  &vacuum_console_functions,
  		  &console_private,
  		  1000000,	/* Decrementer ticks per ms (true for 601) */
! 		  "console=ttyS0"	
  		 };
  
  void exit()
--- 48,54 ----
  		  &vacuum_console_functions,
  		  &console_private,
  		  1000000,	/* Decrementer ticks per ms (true for 601) */
!                   MAGIC1_CMDLINE, "console=ttyS0" ,MAGIC2_CMDLINE
  		 };
  
  void exit()
***************
*** 70,75 ****
--- 70,88 ----
  	return dst;
  }
  
+ int strcmp(const char *p1,const char *p2) {
+   int vs1,vs2;
+   const unsigned char *s1 = p1;
+   const unsigned char *s2 = p2;
+   do {
+     vs1 = *s1++;
+     vs2 = *s2++;
+     if (vs1 != vs2)
+       return vs1 - vs2;
+   } while (vs1 && vs2);
+   return 0;
+ }
+ 
  void hang(const char *s, u_long x, ctxt *p) {
  	u_long *r1;
  #ifdef DEBUG
***************
*** 291,297 ****
  		} else {
  			select_console(&vga_console_setup);
  			/* Remove the kernel serial console parameter */
! 			bd->cmd_line[0]='\0';
  		}
  	} else if (!err) {
  		select_console(&serial_console_setup);
--- 304,311 ----
  		} else {
  			select_console(&vga_console_setup);
  			/* Remove the kernel serial console parameter */
!                         if (strcmp(bd->cmd_line,"console=ttyS0") == 0)
!                           bd->cmd_line[0]='\0';
  		}
  	} else if (!err) {
  		select_console(&serial_console_setup);
Index: preploader/prepctl.c
diff -c /dev/null preploader/prepctl.c:1.1
*** /dev/null	Wed Jan 20 14:54:40 1999
--- preploader/prepctl.c	Wed Jan 20 14:27:30 1999
***************
*** 0 ****
--- 1,64 ----
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ #include "bootdata.h"
+ 
+ #define NBINT 4096
+ #define CMDLENGTH (256/sizeof(int))
+ 
+ int main(int argc,char*argv[])
+ {
+   char buf[256];
+   static unsigned int data[NBINT*2];
+   FILE *f;
+   long pos;
+ 
+   if (argc < 2) {
+     fprintf(stderr,"usage:prepctl <zImage-file> [new command line]\n");
+     exit(1);
+   }
+   f = fopen(argv[1],argc > 2 ? "r+": "r");
+   if (!f) {
+     fprintf(stderr,"cannot open file %s\n",argv[1]);
+     perror("erreur:");
+     exit(1);
+   }
+   
+   while (1) { 
+     int i;
+     pos = ftell(f);
+     if (fread(data,sizeof(data[0]),NBINT,f) <= 0)
+       break;
+     for (i=0;i<NBINT;i++) {
+       if (data[i] == MAGIC1_CMDLINE) {
+         if (i+1+CMDLENGTH < NBINT || fread(data+NBINT,sizeof(data[0]),NBINT,f) >= i+1+CMDLENGTH-NBINT) {
+           char *p = (char*)(data+i+1);
+           int j;
+           if (data[i+1+CMDLENGTH] != MAGIC2_CMDLINE) {
+             fprintf(stderr,"ERROR:found magic1 but no magic2\n");
+             exit(1);
+           }
+           printf("current cmdline=%s\n",p);
+           if (argc <= 2)
+             return 0;
+           p[0] = 0;
+           for (j=2;j<argc;j++) {
+             strcat(p,argv[j]);
+             strcat(p," ");
+           }
+           printf("writing new cmdline=%s\n",p);
+           fflush(f);
+           fseek(f,pos,SEEK_SET);
+           if (fwrite(data,sizeof(data[0]),i+1+CMDLENGTH,f) != i+1+CMDLENGTH) {
+             perror("writing new cmd line\n");
+             exit(1);
+           }
+           return 0;
+         }
+       }
+     }
+   }
+   fprintf(stderr,"magic1 number not found in image\n");
+   return 0;
+ }
