ppcrcd/yaboot/yaboot.c

sparky cvs at pld-linux.org
Sat Sep 24 01:04:50 CEST 2005


Author: sparky
Date: Sat Sep 24 01:04:43 2005
New Revision: 6405

Modified:
   ppcrcd/yaboot/yaboot.c
Log:
- allow initrd to be split in few parts as OF tftp client supports only
  small files ( < 4MB ? )


Modified: ppcrcd/yaboot/yaboot.c
==============================================================================
--- ppcrcd/yaboot/yaboot.c	(original)
+++ ppcrcd/yaboot/yaboot.c	Sat Sep 24 01:04:43 2005
@@ -174,6 +174,8 @@
 
 static struct first_info *quik_fip = NULL;
 
+unsigned long initrd_size;
+
 int
 yaboot_start (unsigned long r3, unsigned long r4, unsigned long r5)
 {
@@ -560,6 +562,12 @@
      }
      p = cfg_get_strg(label, "initrd-size");
      if (p) {
+	  int len, i;
+          initrd_size = 0;
+	  len = strlen(p);
+	  for (i=0; i<len; i++)
+		  initrd_size = initrd_size * 10 + p[i] - '0';
+	  
 	  strcpy (q, "ramdisk_size=");
 	  strcpy (q + 13, p);
 	  q = strchr (q, 0);
@@ -860,7 +868,6 @@
      int			result;
      static struct boot_param_t	params;
      void		*initrd_base;
-     unsigned long	initrd_size;
      void                *sysmap_base;
      unsigned long	sysmap_size;
      kernel_entry_t      kernel_entry;
@@ -1012,6 +1019,38 @@
 		    params.rd.file=loc;
 	       }
 	       prom_printf("Loading ramdisk...");
+
+	       if ( initrd_size ) {
+		       /* probably multi-file initrd */
+		       char *(part[16]), *sep;
+		       int parts=0, i;
+		       
+		       initrd_base = prom_claim(loadinfo.base+loadinfo.memsize, initrd_size, 0);
+		       prom_printf("size: %d\n", (int)initrd_size);
+		       
+		       // &params.rd - initrd path
+		       part[0] = strdup(params.rd.file);
+		       while (  (sep = strchr(part[parts++], '|' ))  ) {
+			       *sep = '\0';
+			       part[parts] = sep + 1;
+		       }
+		       initrd_more = initrd_base;
+		       for ( i=0; i<parts; i++ ) {
+			       strcpy(params.rd.file, part[i]);
+			       result = open_file(&params.rd, &file);
+	       		       if (result != FILE_ERR_OK) {
+				    prom_printf("%s:%d,", params.rd.dev, params.rd.part);
+				    prom_perror(result, params.rd.file);
+	 		       }
+#define INITRD_MAX 0xF00000
+			       initrd_read = file.fs->read(&file, INITRD_MAX, initrd_more);
+			       initrd_more += initrd_read;
+			       prom_printf("read: %s\n", params.rd.file);
+			       file.fs->close(&file);
+		       }
+		       free(part[0]);
+	       } else {
+	       /* normal behaviour */
 	       result = open_file(&params.rd, &file);
 	       if (result != FILE_ERR_OK) {
 		    prom_printf("%s:%d,", params.rd.dev, params.rd.part);
@@ -1019,17 +1058,12 @@
 	       }
 	       else {
 #define INITRD_CHUNKSIZE 0x200000
-                    /*gunzip_file = file;
-		    gunzip_test_header();*/
-		    
 		    initrd_base = prom_claim(loadinfo.base+loadinfo.memsize, INITRD_CHUNKSIZE, 0);
 		    if (initrd_base == (void *)-1) {
 			 prom_printf("\nClaim failed for initrd memory\n");
 			 initrd_base = 0;
 		    } else {
-			 initrd_size = /*compressed_file ?
-				 gunzip_read(initrd_base, INITRD_CHUNKSIZE) :*/
-				 file.fs->read(&file, INITRD_CHUNKSIZE, initrd_base);
+			 initrd_size = file.fs->read(&file, INITRD_CHUNKSIZE, initrd_base);
 			 prom_printf(".");
 			 if (initrd_size == 0)
 			      initrd_base = 0;
@@ -1042,9 +1076,7 @@
 				   prom_printf("\nClaim failed for initrd memory at %p rc=%p\n",initrd_want,initrd_more);
 				   break;
 			      }
-			      initrd_read = /*compressed_file ?
-				      gunzip_read(initrd_more, INITRD_CHUNKSIZE) :*/
-				      file.fs->read(&file, INITRD_CHUNKSIZE, initrd_more);
+			      initrd_read = file.fs->read(&file, INITRD_CHUNKSIZE, initrd_more);
 			      prom_printf(".");
 			      DEBUG_F("  block at %p rc=%lu\n",initrd_more,initrd_read);
 			      initrd_size += initrd_read;
@@ -1054,6 +1086,7 @@
 		    file.fs->close(&file);
 		    memset(&file, 0, sizeof(file));
 	       }
+	       }
 	       if (initrd_base)
 		    prom_printf("ramdisk loaded at %p, size: %lu Kbytes\n",
 				initrd_base, initrd_size >> 10);



More information about the pld-cvs-commit mailing list