[syslinux] [PATCH] Let MEMDISK honor the quiet append option

Kim Mik kimmik999999 at yahoo.co.uk
Sat Sep 12 15:51:16 PDT 2009


When you add "quiet" to the append line, Syslinux doesn't display the file reading progress anymore.
When you use this option to boot an image with MEMDISK, you still get a lot of text.

==========================
LABEL mydisk
LINUX memdisk
INITRD mydisk.img
APPEND raw quiet
==========================

The following patch makes MEMDISK silent when the quiet keyword is passed to the append line, unless there is a fatal error.
GeekToMe asked about this feature on http://www.boot-land.net/forums/index.php?showtopic=8935&st=40



$ diff -u memdisk.h.old memdisk.h
--- memdisk.h.old    2009-09-12 22:31:11.000000000 +0200
+++ memdisk.h    2009-09-13 00:30:39.000000000 +0200
@@ -134,4 +134,7 @@
 extern void *unzip(void *indata, uint32_t zbytes, uint32_t dbytes,
            uint32_t orig_crc, void *target);
 
+/* Show a lot of output or not */
+bool quiet;
+
 #endif





$ diff -u msetup.c.old msetup.c
--- msetup.c.old    2009-09-12 22:24:59.000000000 +0200
+++ msetup.c    2009-09-13 00:34:24.000000000 +0200
@@ -58,10 +58,10 @@
 
     if (regs.eax.l != 0x534d4150 || copied < 20)
         break;
-
-    printf("e820: %08x%08x %08x%08x %d\n",
-           (uint32_t) (buf->base >> 32), (uint32_t) buf->base,
-           (uint32_t) (buf->len >> 32), (uint32_t) buf->len, buf->type);
+    if (!quiet)
+        printf("e820: %08x%08x %08x%08x %d\n",
+           (uint32_t) (buf->base >> 32), (uint32_t) buf->base,
+           (uint32_t) (buf->len >> 32), (uint32_t) buf->len, buf->type);
 
     insertrange(buf->base, buf->len, buf->type);
     range_count++;
@@ -78,7 +78,8 @@
     memset(&regs, 0, sizeof regs);
     intcall(0x12, &regs, &regs);
     insertrange(0, (uint64_t) ((uint32_t) regs.eax.w[0] << 10), 1);
-    printf(" DOS: %d K\n", regs.eax.w[0]);
+    if (!quiet)
+    printf(" DOS: %d K\n", regs.eax.w[0]);
 }
 
 static inline int get_e801(void)
@@ -101,7 +102,8 @@
             1);
     }
 
-    printf("e801: %04x %04x\n", regs.eax.w[0], regs.ebx.w[0]);
+    if (!quiet)
+        printf("e801: %04x %04x\n", regs.eax.w[0], regs.ebx.w[0]);
     }
 
     return err;
@@ -123,7 +125,8 @@
             1);
     }
 
-    printf("  88: %04x\n", regs.eax.w[0]);
+    if (!quiet)
+        printf("  88: %04x\n", regs.eax.w[0]);
     }
 
     return err;





$ diff -u setup.c.old setup.c
--- setup.c.old    2009-09-12 22:05:37.000000000 +0200
+++ setup.c    2009-09-13 00:39:53.000000000 +0200
@@ -325,8 +325,9 @@
             continue;    /* Can't fit both old and new */
 
         newwhere = (gzwhere - size) & ~(UNZIP_ALIGN - 1);
-        printf("Moving compressed data from 0x%08x to 0x%08x\n",
-               where, newwhere);
+        if (!quiet)
+            printf("Moving compressed data from 0x%08x to 0x%08x\n",
+                   where, newwhere);
 
         memmove((void *)newwhere, (void *)where, size);
         where = newwhere;
@@ -341,8 +342,9 @@
         die("Not enough memory to decompress image (need 0x%08x bytes)\n",
          gzdatasize);
 
-    printf("gzip image: decompressed addr 0x%08x, len 0x%08x: ",
-           target, gzdatasize);
+    if (!quiet)
+        printf("gzip image: decompressed addr 0x%08x, len 0x%08x: ",
+               target, gzdatasize);
 
     *size_p = gzdatasize;
     *where_p = (uint32_t) unzip((void *)(where + offset), zbytes,
@@ -435,7 +437,8 @@
     int i;
     const char *p;
 
-    printf("command line: %s\n", shdr->cmdline);
+    if (!quiet)
+    printf("command line: %s\n", shdr->cmdline);
 
     offset = 0;
     if (CMD_HASDATA(p = getcmditem("offset")) && (v = atou(p)))
@@ -627,14 +630,16 @@
         hd_geometry.type = 0x10;    /* ATAPI floppy, e.g. LS-120 */
     }
 
-    if ((size - hd_geometry.offset) & 0x1ff) {
-    puts("MEMDISK: Image has fractional end sector\n");
-    }
-    if (sectors % (hd_geometry.h * hd_geometry.s)) {
-    puts("MEMDISK: Image seems to have fractional end cylinder\n");
-    }
-    if ((hd_geometry.c * hd_geometry.h * hd_geometry.s) > sectors) {
-    puts("MEMDISK: Image appears to be truncated\n");
+    if (!quiet) {
+    if ((size - hd_geometry.offset) & 0x1ff) {
+        puts("MEMDISK: Image has fractional end sector\n");
+    }
+    if (sectors % (hd_geometry.h * hd_geometry.s)) {
+        puts("MEMDISK: Image seems to have fractional end cylinder\n");
+    }
+    if ((hd_geometry.c * hd_geometry.h * hd_geometry.s) > sectors) {
+        puts("MEMDISK: Image appears to be truncated\n");
+    }
     }
 
     return &hd_geometry;
@@ -782,8 +787,14 @@
     memcpy(&rm_args, rm_args_ptr, sizeof rm_args);
     sti();            /* ... then interrupts are safe */
 
+    if (getcmditem("quiet") != CMD_NOTFOUND)
+    quiet = true;
+    else
+    quiet = false;
+
     /* Show signs of life */
-    printf("%s  %s\n", memdisk_version, copyright);
+    if (!quiet)
+    printf("%s  %s\n", memdisk_version, copyright);
 
     if (!shdr->ramdisk_image || !shdr->ramdisk_size)
     die("MEMDISK: No ramdisk image specified!\n");
@@ -795,7 +806,9 @@
     get_mem();            /* Query BIOS for memory map */
     parse_mem();        /* Parse memory map */
 
-    printf("Ramdisk at 0x%08x, length 0x%08x\n", ramdisk_image, ramdisk_size);
+    if (!quiet)
+    printf("Ramdisk at 0x%08x, length 0x%08x\n", ramdisk_image,
+           ramdisk_size);
 
     unzip_if_needed(&ramdisk_image, &ramdisk_size);
 
@@ -868,7 +881,8 @@
     pptr->configflags |= CONFIG_SAFEINT;
     }
 
-    printf("Disk is %s%d, %u%s K, C/H/S = %u/%u/%u (%s/%s), EDD %s, %s\n",
+    if (!quiet) {
+    printf("Disk is %s%d, %u%s K, C/H/S = %u/%u/%u (%s/%s), EDD %s, %s\n",
        (geometry->driveno & 0x80) ? "hd" : "fd",
        geometry->driveno & 0x7f,
        geometry->sectors >> 1,
@@ -878,25 +892,26 @@
        do_edd ? "on" : "off",
        pptr->configflags & CONFIG_READONLY ? "ro" : "rw");
 
-    puts("Using ");
-    switch (pptr->configflags & CONFIG_MODEMASK) {
-    case 0:
-    puts("standard INT 15h");
-    break;
-    case CONFIG_SAFEINT:
-    puts("safe INT 15h");
-    break;
-    case CONFIG_RAW:
-    puts("raw");
-    break;
-    case CONFIG_RAW | CONFIG_BIGRAW:
-    puts("big real mode raw");
-    break;
-    default:
-    printf("unknown %#x", pptr->configflags & CONFIG_MODEMASK);
-    break;
+    puts("Using ");
+    switch (pptr->configflags & CONFIG_MODEMASK) {
+    case 0:
+        puts("standard INT 15h");
+        break;
+    case CONFIG_SAFEINT:
+        puts("safe INT 15h");
+        break;
+    case CONFIG_RAW:
+        puts("raw");
+        break;
+    case CONFIG_RAW | CONFIG_BIGRAW:
+        puts("big real mode raw");
+        break;
+    default:
+        printf("unknown %#x", pptr->configflags & CONFIG_MODEMASK);
+        break;
+    }
+    puts(" access to high memory\n");
     }
-    puts(" access to high memory\n");
 
     /* Set up a drive parameter table */
     if (geometry->driveno & 0x80) {
@@ -956,10 +971,12 @@
     total_size += cmdline_len;        /* Command line */
     stack_len = stack_needed();
     total_size += stack_len;        /* Stack */
-    printf("Code %u, meminfo %u, cmdline %u, stack %u\n",
-       hptr->total_size, e820_len, cmdline_len, stack_len);
-    printf("Total size needed = %u bytes, allocating %uK\n",
-       total_size, (total_size + 0x3ff) >> 10);
+    if (!quiet) {
+    printf("Code %u, meminfo %u, cmdline %u, stack %u\n",
+           hptr->total_size, e820_len, cmdline_len, stack_len);
+    printf("Total size needed = %u bytes, allocating %uK\n",
+           total_size, (total_size + 0x3ff) >> 10);
+    }
 
     if (total_size > dos_mem)
     die("MEMDISK: Insufficient low memory\n");
@@ -967,8 +984,9 @@
     driveraddr = stddosmem - total_size;
     driveraddr &= ~0x3FF;
 
-    printf("Old dos memory at 0x%05x (map says 0x%05x), loading at 0x%05x\n",
-       stddosmem, dos_mem, driveraddr);
+    if (!quiet)
+    printf("Old dos memory at 0x%05x (map says 0x%05x), loading at 0x%05x\n",
+           stddosmem, dos_mem, driveraddr);
 
     /* Reserve this range of memory */
     wrz_16(BIOS_BASEMEM, driveraddr >> 10);
@@ -985,8 +1003,9 @@
     pptr->memint1588 = low_mem >> 10;
     }
 
-    printf("1588: 0x%04x  15E801: 0x%04x 0x%04x\n",
-       pptr->memint1588, pptr->mem1mb, pptr->mem16mb);
+    if (!quiet)
+    printf("1588: 0x%04x  15E801: 0x%04x 0x%04x\n",
+           pptr->memint1588, pptr->mem1mb, pptr->mem16mb);
 
     driverseg = driveraddr >> 4;
     driverptr = driverseg << 16;
@@ -1007,7 +1026,8 @@
 
     if (getcmditem("nopass") != CMD_NOTFOUND) {
     /* nopass specified - we're the only drive by definition */
-    printf("nopass specified - we're the only drive\n");
+    if (!quiet)
+        printf("nopass specified - we're the only drive\n");
     bios_drives = 0;
     pptr->drivecnt = 0;
     pptr->oldint13 = driverptr + hptr->iret_offs;
@@ -1023,12 +1043,14 @@
     /* Note: per suggestion from the Interrupt List, consider
        INT 13 08 to have failed if the sector count in CL is zero. */
     if ((regs.eflags.l & 1) || !(regs.ecx.b[0] & 0x3f)) {
-        printf("INT 13 08: Failure, assuming this is the only drive\n");
+        if (!quiet)
+        printf("INT 13 08: Failure, assuming this is the only drive\n");
         pptr->drivecnt = 0;
         no_bpt = 1;
     } else {
-        printf("INT 13 08: Success, count = %u, BPT = %04x:%04x\n",
-           regs.edx.b[0], regs.es, regs.edi.w[0]);
+        if (!quiet)
+        printf("INT 13 08: Success, count = %u, BPT = %04x:%04x\n",
+               regs.edx.b[0], regs.es, regs.edi.w[0]);
         pptr->drivecnt = regs.edx.b[0];
         no_bpt = !(regs.es | regs.edi.w[0]);
     }
@@ -1046,8 +1068,9 @@
     }
 
     if (pptr->drivecnt > bios_drives) {
-        printf("BIOS equipment byte says count = %d, go with that\n",
-           bios_drives);
+        if (!quiet)
+        printf("BIOS equipment byte says count = %d, go with that\n",
+               bios_drives);
         pptr->drivecnt = bios_drives;
     }
     }
@@ -1111,16 +1134,18 @@
     }
 
     /* Install the interrupt handlers */
-    printf("old: int13 = %08x  int15 = %08x  int1e = %08x\n",
-       rdz_32(BIOS_INT13), rdz_32(BIOS_INT15), rdz_32(BIOS_INT1E));
+    if (!quiet)
+    printf("old: int13 = %08x  int15 = %08x  int1e = %08x\n",
+           rdz_32(BIOS_INT13), rdz_32(BIOS_INT15), rdz_32(BIOS_INT1E));
 
     wrz_32(BIOS_INT13, driverptr + hptr->int13_offs);
     wrz_32(BIOS_INT15, driverptr + hptr->int15_offs);
     if (pptr->dpt_ptr)
     wrz_32(BIOS_INT1E, driverptr + pptr->dpt_ptr);
 
-    printf("new: int13 = %08x  int15 = %08x  int1e = %08x\n",
-       rdz_32(BIOS_INT13), rdz_32(BIOS_INT15), rdz_32(BIOS_INT1E));
+    if (!quiet)
+    printf("new: int13 = %08x  int15 = %08x  int1e = %08x\n",
+           rdz_32(BIOS_INT13), rdz_32(BIOS_INT15), rdz_32(BIOS_INT1E));
 
     /* Figure out entry point */
     if (!boot_seg) {
@@ -1141,17 +1166,20 @@
     relocate_rm_code(rm_base);
 
     /* Reboot into the new "disk" */
-    puts("Loading boot sector... ");
+    if (!quiet)
+    puts("Loading boot sector... ");
 
     memcpy((void *)boot_base, (char *)pptr->diskbuf + boot_lba*512, boot_len);
 
     if (getcmditem("pause") != CMD_NOTFOUND) {
-    puts("press any key to boot... ");
+    puts("\n  Press any key to boot... ");
     regs.eax.w[0] = 0;
     intcall(0x16, &regs, NULL);
+    puts("\n");
     }
 
-    puts("booting...\n");
+    if (!quiet)
+    puts("booting...\n");
 
     /* On return the assembly code will jump to the boot vector */
     shdr->esdi = pnp_install_check();






$ diff -u unzip.c.old unzip.c
--- unzip.c.old    2009-09-12 22:24:43.000000000 +0200
+++ unzip.c    2009-09-13 00:34:40.000000000 +0200
@@ -383,7 +383,8 @@
     if (orig_crc != CRC_VALUE)
     error("crc error");
 
-    puts("ok\n");
+    if (!quiet)
+    puts("ok\n");
 
     return target;
 }


      




More information about the Syslinux mailing list