Loading initrd over serial line

From: Pavel Machek (pavel@suse.cz)
Date: Tue Aug 08 2000 - 11:41:31 EST


Hi!

This patch should load initrd over serial line. On r38xx it works for
me, but kernel crashes after that and I do not know who to blame. It
needs some ifdefs and it needs making some functions public...

You'll need program that looks for 'X' and sends block of data to use
this.
                                                                Pavel

Index: rd.c
===================================================================
RCS file: /cvsroot/linux-vr/linux/drivers/block/rd.c,v
retrieving revision 1.1.1.8
diff -u -r1.1.1.8 rd.c
--- rd.c 2000/07/10 21:07:31 1.1.1.8
+++ rd.c 2000/08/08 16:33:46
@@ -1,5 +1,5 @@
 /*
- * ramdisk.c - Multiple RAM disk driver - gzip-loading version - v. 0.8 beta.
+ * ramdisk.c - Multiple RAM disk driver - gzip-loading version - v. 0.9
  *
  * (C) Chad Page, Theodore Ts'o, et. al, 1995.
  *
@@ -88,6 +88,7 @@
 
 #ifdef CONFIG_BLK_DEV_INITRD
 static int initrd_users;
+static int read_serial = 0;
 #endif
 #endif
 
@@ -459,6 +460,7 @@
  * ext2
  * romfs
  * gzip
+ * serial
  */
 int __init
 identify_ramdisk_image(kdev_t device, struct file *fp, int start_block)
@@ -499,6 +501,16 @@
                 goto done;
         }
 
+ if ((buf[0] == 'S') && (buf[1] == 'e') && (buf[2] == 'r')) {
+ printk(KERN_NOTICE
+ "RAMDISK: Reading contents from serial\n" );
+ serial_console_write_raw(NULL, "Receive", 7);
+ read_serial = 1;
+ nblocks = 0;
+ goto done;
+ }
+
+
         /* romfs is at block zero too */
         if (romfsb->word0 == ROMSB_WORD0 &&
             romfsb->word1 == ROMSB_WORD1) {
@@ -677,6 +689,7 @@
         kfree(buf);
 
 successful_load:
+ printk("\nRamdisk successfully loaded.\n" );
         invalidate_buffers(device);
         ROOT_DEV = MKDEV(MAJOR_NR, unit);
         if (ROOT_DEVICE_NAME != NULL) strcpy (ROOT_DEVICE_NAME, "rd/0");
@@ -767,7 +780,7 @@
 typedef unsigned short ush;
 typedef unsigned long ulg;
 
-#define INBUFSIZ 4096
+#define INBUFSIZ 0x10000
 #define WSIZE 0x8000 /* window size--must be a power of two, and */
                         /* at least 32K for zip's deflate method */
 
@@ -821,18 +834,34 @@
 {
 }
 
-
 /* ===========================================================================
  * Fill the input buffer. This is called only when the buffer is empty
  * and at least one byte is really needed.
  */
 static int __init fill_inbuf(void)
 {
+ static int counter = 0;
+ unsigned long flags;
+
         if (exit_code) return -1;
-
- insize = crd_infp->f_op->read(crd_infp, inbuf, INBUFSIZ,
- &crd_infp->f_pos);
- if (insize == 0) return -1;
+
+ if (!read_serial) {
+ insize = crd_infp->f_op->read(crd_infp, inbuf, INBUFSIZ,
+ &crd_infp->f_pos);
+ if (insize == 0) return -1;
+ } else {
+ int i;
+ save_and_cli(flags);
+ printk( "\rWaiting for data: %d", counter );
+
+ serial_console_write(NULL, "X", 1);
+ for (i=0; i<INBUFSIZ; i++)
+ inbuf[i] = serial_console_wait_key(NULL);
+ insize = INBUFSIZ;
+ restore_flags(flags);
+ }
+ counter += INBUFSIZ;
+ printk( "\rUncompressing : %d", counter );
 
         inptr = 1;
 

-- 
The best software in life is free (not shareware)!		Pavel
GCM d? s-: !g p?:+ au- a--@ w+ v- C++@ UL+++ L++ N++ E++ W--- M- Y- R+

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Aug 15 2000 - 21:00:17 EST