Remove stealth whitespace
authorH. Peter Anvin <hpa@zytor.com>
Fri, 17 Mar 2006 17:09:35 +0000 (09:09 -0800)
committerH. Peter Anvin <hpa@zytor.com>
Fri, 17 Mar 2006 17:09:35 +0000 (09:09 -0800)
com32/modules/chain.c
com32/modules/ethersel.c
com32/modules/i386-elf.h
com32/modules/mb_header.h
com32/modules/mb_info.h
com32/modules/mboot.c
com32/modules/menu.c
com32/modules/menu.h
com32/modules/readconfig.c

index 0a52f13..51383cd 100644 (file)
@@ -1,6 +1,6 @@
 #ident "$Id$"
 /* ----------------------------------------------------------------------- *
- *   
+ *
  *   Copyright 2003-2005 H. Peter Anvin - All Rights Reserved
  *
  *   This program is free software; you can redistribute it and/or modify
@@ -45,7 +45,7 @@ int int13_retry(const com32sys_t *inreg, com32sys_t *outreg)
 {
   int retry = 6;               /* Number of retries */
   com32sys_t tmpregs;
-  
+
   if ( !outreg ) outreg = &tmpregs;
 
   while ( retry-- ) {
@@ -98,7 +98,7 @@ int get_disk_params(int disk)
 
   if ( parm.eflags.l & EFLAGS_CF )
     return disk_info.ebios ? 0 : -1;
-  
+
   disk_info.head = parm.edx.b[1]+1;
   disk_info.sect = parm.ecx.b[0] & 0x3f;
   if ( disk_info.sect == 0 ) {
@@ -133,7 +133,7 @@ int read_sector(void *buf, unsigned int lba)
     dapa->off = OFFS(buf);
     dapa->seg = SEG(buf);
     dapa->lba = lba;
-    
+
     inreg.esi.w[0] = OFFS(dapa);
     inreg.ds       = SEG(dapa);
     inreg.edx.b[0] = disk_info.disk;
@@ -166,7 +166,7 @@ int read_sector(void *buf, unsigned int lba)
     inreg.ebx.w[0] = OFFS(buf);
     inreg.es       = SEG(buf);
   }
-  
+
   return int13_retry(&inreg, NULL);
 }
 
@@ -239,21 +239,21 @@ struct part_entry *find_logical_partition(int whichpart, char *table, struct par
     if ( ptab[i].ostype != 0x05 &&
         ptab[i].ostype != 0x0f && ptab[i].ostype != 0x85 )
       continue;                /* Skip empty or data partitions */
-    
+
     if ( !ptab[i].length )
       continue;
-    
+
     /* Adjust the offset to account for the extended partition itself */
     if ( root )
       ptab[i].start_lba += root->start_lba;
-    
+
     /* Sanity check entry: must not extend outside the extended partition.
        This is necessary since some OSes put crap in some entries. */
     if ( root )
       if ( ptab[i].start_lba + ptab[i].length <= root->start_lba ||
           ptab[i].start_lba >= root->start_lba + root->length )
        continue;
-    
+
     /* Process this partition */
     if ( read_sector(table+SECTOR, ptab[i].start_lba) )
       continue;                        /* Read error, must be invalid */
@@ -358,7 +358,7 @@ int main(int argc, char *argv[])
     inreg.esi.w[0] = 0x7be;
     memcpy((char *)0x7be, partinfo, sizeof(*partinfo));
   }
-  
+
   fputs("Booting...\n", stdout);
 
   inreg.eax.w[0] = 0x000d;     /* Clean up and chain boot */
index 39f7185..d4dce9d 100644 (file)
@@ -1,6 +1,6 @@
 #ident "$Id$"
 /* ----------------------------------------------------------------------- *
- *   
+ *
  *   Copyright 2005 H. Peter Anvin - All Rights Reserved
  *
  *   This program is free software; you can redistribute it and/or modify
@@ -23,7 +23,7 @@
  * DEFAULT ethersel.c32
  * # DEV [DID xxxx:yyyy[/mask]] [RID zz-zz] [SID uuuu:vvvv[/mask]] commandline
  * # ...
- * 
+ *
  * DID = PCI device ID
  * RID = Revision ID (range)
  * SID = Subsystem ID
@@ -233,7 +233,7 @@ pciscan(struct match *list)
        a = pci_mkaddr(bus, dev, func, 0);
 
        did = pci_readl(a);
-       
+
        if ( did == 0xffffffff || did == 0xffff0000 ||
             did == 0x0000ffff || did == 0x00000000 )
          continue;
index 7162e3d..04ddf39 100644 (file)
@@ -29,9 +29,9 @@ typedef unsigned long Elf32_Word;
 /* ELF header */
 typedef struct
 {
-  
+
 #define EI_NIDENT 16
-  
+
   /* first four characters are defined below */
 #define EI_MAG0                0
 #define ELFMAG0                0x7f
@@ -41,32 +41,32 @@ typedef struct
 #define ELFMAG2                'L'
 #define EI_MAG3                3
 #define ELFMAG3                'F'
-  
+
 #define EI_CLASS       4       /* data sizes */
 #define ELFCLASS32     1       /* i386 -- up to 32-bit data sizes present */
-  
+
 #define EI_DATA                5       /* data type and ordering */
 #define ELFDATA2LSB    1       /* i386 -- LSB 2's complement */
-  
+
 #define EI_VERSION     6       /* version number.  "e_version" must be the same */
 #define EV_CURRENT      1      /* current version number */
 
 #define EI_OSABI       7       /* operating system/ABI indication */
 #define ELFOSABI_FREEBSD       9
-  
+
 #define EI_ABIVERSION  8       /* ABI version */
-  
+
 #define EI_PAD         9       /* from here in is just padding */
-  
+
 #define EI_BRAND       8       /* start of OS branding (This is
                                   obviously illegal against the ELF
                                   standard.) */
-  
+
   unsigned char e_ident[EI_NIDENT];    /* basic identification block */
-  
+
 #define ET_EXEC                2       /* we only care about executable types */
   Elf32_Half e_type;           /* file types */
-  
+
 #define EM_386         3       /* i386 -- obviously use this one */
   Elf32_Half e_machine;        /* machine types */
   Elf32_Word e_version;        /* use same as "EI_VERSION" above */
@@ -79,7 +79,7 @@ typedef struct
   Elf32_Half e_phnum;          /* number of entries in program header */
   Elf32_Half e_shentsize;      /* section header entry size */
   Elf32_Half e_shnum;          /* number of entries in section header */
-  
+
 #define SHN_UNDEF       0
 #define SHN_LORESERVE   0xff00
 #define SHN_LOPROC      0xff00
index 2193457..4215323 100644 (file)
@@ -25,17 +25,17 @@ struct multiboot_header
 {
   /* Must be MULTIBOOT_MAGIC - see below.  */
   unsigned magic;
-  
+
   /* Feature flags - see below.  */
   unsigned flags;
-  
+
   /*
    * Checksum
    *
    * The above fields plus this one must equal 0 mod 2^32.
    */
   unsigned checksum;
-  
+
   /* These are only valid if MULTIBOOT_AOUT_KLUDGE is set.  */
   unsigned header_addr;
   unsigned load_addr;
index fb37f10..91a1392 100644 (file)
@@ -26,10 +26,10 @@ struct mod_list
   /* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */
   unsigned long mod_start;
   unsigned long mod_end;
-  
+
   /* Module command line */
   unsigned long cmdline;
-  
+
   /* padding to take it to 16 bytes (must be zero) */
   unsigned long pad;
 };
@@ -48,7 +48,7 @@ struct AddrRangeDesc
   unsigned long long BaseAddr;
   unsigned long long Length;
   unsigned long Type;
-  
+
   /* unspecified optional padding... */
 };
 
@@ -107,21 +107,21 @@ struct multiboot_info
 {
   /* MultiBoot info version number */
   unsigned long flags;
-  
+
   /* Available memory from BIOS */
   unsigned long mem_lower;
   unsigned long mem_upper;
-  
+
   /* "root" partition */
   unsigned long boot_device;
-  
+
   /* Kernel command line */
   unsigned long cmdline;
-  
+
   /* Boot-Module list */
   unsigned long mods_count;
   unsigned long mods_addr;
-  
+
   union
   {
     struct
@@ -133,7 +133,7 @@ struct multiboot_info
       unsigned long pad;
     }
     a;
-    
+
     struct
     {
       /* (ELF) Kernel section header table */
@@ -145,18 +145,18 @@ struct multiboot_info
     e;
   }
   syms;
-  
+
   /* Memory Mapping buffer */
   unsigned long mmap_length;
   unsigned long mmap_addr;
-  
+
   /* Drive Info buffer */
   unsigned long drives_length;
   unsigned long drives_addr;
-  
+
   /* ROM configuration table */
   unsigned long config_table;
-  
+
   /* Boot Loader Name */
   unsigned long boot_loader_name;
 
index 0fe8299..74afaa5 100644 (file)
@@ -2,7 +2,7 @@
  *  mboot.c
  *
  *  Loader for Multiboot-compliant kernels and modules.
- * 
+ *
  *  Copyright (C) 2005 Tim Deegan <Tim.Deegan@cl.cam.ac.uk>
  *  Parts based on GNU GRUB, Copyright (C) 2000  Free Software Foundation, Inc.
  *  Parts based on SYSLINUX, Copyright (C) 1994-2005  H. Peter Anvin.
@@ -22,7 +22,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  *  02111-1307, USA.
- * 
+ *
  */
 
 
@@ -97,7 +97,7 @@ static const char module_separator[] = "---";
  */
 
 static void __constructor check_version(void)
-    /* Check the SYSLINUX version.  Docs say we should be OK from v2.08, 
+    /* Check the SYSLINUX version.  Docs say we should be OK from v2.08,
      * but in fact we crash on anything below v2.12 (when libc came in). */
 {
     com32sys_t regs_in, regs_out;
@@ -125,13 +125,13 @@ static void __constructor grab_memory(void)
     /* Runs before init_memory_arena() (com32/lib/malloc.c) to let
      * the malloc() code know how much space it's allowed to use.
      * We don't use malloc() directly, but some of the library code
-     * does (zlib, for example). */ 
-{ 
+     * does (zlib, for example). */
+{
     /* Find the stack pointer */
     register char * sp;
     asm volatile("movl %%esp, %0" : "=r" (sp));
 
-    /* Initialize the allocation of *run-time* memory: don't let ourselves 
+    /* Initialize the allocation of *run-time* memory: don't let ourselves
      * overwrite the stack during the relocation later. */
     max_run_addr = (size_t) sp - (MALLOC_SIZE + STACK_SIZE);
 
@@ -139,12 +139,12 @@ static void __constructor grab_memory(void)
      * above __mem_end and below the stack.  We will load files starting
      * at the old __mem_end and working towards the new one, and allocate
      * section descriptors at the top of that area, working down. */
-    next_load_addr = __mem_end; 
+    next_load_addr = __mem_end;
     section_addr = sp - (MALLOC_SIZE + STACK_SIZE);
     section_count = 0;
 
     /* But be careful not to move it the wrong direction if memory is
-     * tight.  Instead we'll fail more gracefully later, when we try to 
+     * tight.  Instead we'll fail more gracefully later, when we try to
      * load a file and find that next_load_addr > section_addr. */
     __mem_end = MAX(section_addr, next_load_addr);
 }
@@ -156,7 +156,7 @@ static void __constructor grab_memory(void)
  *  Run-time memory map functions: allocating and recording allocations.
  */
 
-static int cmp_sections(const void *a, const void *b) 
+static int cmp_sections(const void *a, const void *b)
     /* For sorting section descriptors by destination address */
 {
     const section_t *sa = a;
@@ -176,7 +176,7 @@ static void add_section(size_t dest, char *src, size_t size)
     printf("SECTION: %#8.8x --> %#8.8x (%#x)\n", (size_t) src, dest, size);
 #endif
 
-    section_addr -= sizeof (section_t); 
+    section_addr -= sizeof (section_t);
     if (section_addr < next_load_addr) {
         printf("Fatal: out of memory allocating section descriptor.\n");
         exit(1);
@@ -187,13 +187,13 @@ static void add_section(size_t dest, char *src, size_t size)
     sec->src = src;
     sec->dest = dest;
     sec->size = size;
-    
+
     /* Keep the list sorted */
     qsort(sec, section_count, sizeof (section_t), cmp_sections);
 }
 
 
-static size_t place_low_section(size_t size, size_t align) 
+static size_t place_low_section(size_t size, size_t align)
     /* Find a space in the run-time memory map, below 640K */
 {
     int i;
@@ -216,7 +216,7 @@ static size_t place_low_section(size_t size, size_t align)
 }
 
 
-static size_t place_module_section(size_t size, size_t align) 
+static size_t place_module_section(size_t size, size_t align)
     /* Find a space in the run-time memory map for this module. */
 {
     /* Ideally we'd run through the sections looking for a free space
@@ -224,7 +224,7 @@ static size_t place_module_section(size_t size, size_t align)
      * assume that the bootloader has loaded all the modules
      * consecutively, above the kernel.  So, what we actually do is
      * keep a pointer to the highest address allocated so far, and
-     * always allocate modules there. */ 
+     * always allocate modules there. */
 
     size_t start = next_mod_run_addr;
     start = (start + (align-1)) & ~(align-1);
@@ -268,7 +268,7 @@ static void place_kernel_section(size_t start, size_t size)
         printf("Fatal: kernel (%#8.8x+%#x) runs into the memory hole.\n",
                start, size);
         exit(1);
-    }   
+    }
     if (start < MIN_RUN_ADDR) {
         /* Loads too low */
         printf("Fatal: kernel load address (%#8.8x) is too low (<%#8.8x).\n",
@@ -282,8 +282,8 @@ static void place_kernel_section(size_t start, size_t size)
 }
 
 
-static void reorder_sections(void) 
-    /* Reorders sections into a safe order, where no relocation 
+static void reorder_sections(void)
+    /* Reorders sections into a safe order, where no relocation
      * overwrites the source of a later one.  */
 {
     section_t *secs = (section_t *) section_addr;
@@ -293,8 +293,8 @@ static void reorder_sections(void)
 #ifdef DEBUG
     printf("Relocations:\n");
     for (i = 0; i < section_count ; i++) {
-        printf("    %#8.8x --> %#8.8x (%#x)\n", 
-               (size_t)secs[i].src, secs[i].dest, secs[i].size); 
+        printf("    %#8.8x --> %#8.8x (%#x)\n",
+               (size_t)secs[i].src, secs[i].dest, secs[i].size);
     }
 #endif
 
@@ -303,7 +303,7 @@ static void reorder_sections(void)
     scan_again:
         for (j = i + 1 ; j < section_count; j++) {
             if (secs[j].src != NULL
-                && secs[i].dest + secs[i].size > (size_t) secs[j].src 
+                && secs[i].dest + secs[i].size > (size_t) secs[j].src
                 && secs[i].dest < (size_t) secs[j].src + secs[j].size) {
                 /* Would overwrite the source of the later move */
                 if (++tries > section_count) {
@@ -323,8 +323,8 @@ static void reorder_sections(void)
 #ifdef DEBUG
     printf("Relocations:\n");
     for (i = 0; i < section_count ; i++) {
-        printf("    %#8.8x --> %#8.8x (%#x)\n", 
-               (size_t)secs[i].src, secs[i].dest, secs[i].size); 
+        printf("    %#8.8x --> %#8.8x (%#x)\n",
+               (size_t)secs[i].src, secs[i].dest, secs[i].size);
     }
 #endif
 }
@@ -339,7 +339,7 @@ static void init_mmap(struct multiboot_info *mbi)
     size_t mem_lower, mem_upper, run_addr, mmap_size;
     register size_t sp;
 
-    /* Default values for mem_lower and mem_upper in case the BIOS won't 
+    /* Default values for mem_lower and mem_upper in case the BIOS won't
      * tell us: 640K, and all memory up to the stack. */
     asm volatile("movl %%esp, %0" : "=r" (sp));
     mem_upper = (sp - MEM_HOLE_END) / 1024;
@@ -348,7 +348,7 @@ static void init_mmap(struct multiboot_info *mbi)
 #ifdef DEBUG
     printf("Requesting memory map from BIOS:\n");
 #endif
-    
+
     /* Ask the BIOS for the full memory map of the machine.  We'll
      * build it in Multiboot format (i.e. with size fields) in the
      * bounce buffer, and then allocate some high memory to keep it in
@@ -356,13 +356,13 @@ static void init_mmap(struct multiboot_info *mbi)
     e820 = __com32.cs_bounce;
     e820_slots = 0;
     regs_out.ebx.l = 0;
-    
-    while(((void *)(e820 + 1)) < __com32.cs_bounce + __com32.cs_bounce_size) 
+
+    while(((void *)(e820 + 1)) < __com32.cs_bounce + __com32.cs_bounce_size)
     {
         memset(e820, 0, sizeof (*e820));
         memset(&regs_in, 0, sizeof regs_in);
         e820->size = sizeof(*e820) - sizeof(e820->size);
-      
+
         /* Ask the BIOS to fill in this descriptor */
         regs_in.eax.l = 0xe820;         /* "Get system memory map" */
         regs_in.ebx.l = regs_out.ebx.l; /* Continuation value from last call */
@@ -371,32 +371,32 @@ static void init_mmap(struct multiboot_info *mbi)
         regs_in.es = SEG(&e820->BaseAddr);
         regs_in.edi.w[0] = OFFS(&e820->BaseAddr);
         __intcall(0x15, &regs_in, &regs_out);
-        
+
         if ((regs_out.eflags.l & EFLAGS_CF) != 0 && regs_out.ebx.l != 0)
             break;  /* End of map */
 
         if (((regs_out.eflags.l & EFLAGS_CF) != 0 && regs_out.ebx.l == 0)
             || (regs_out.eax.l != 0x534d4150))
-        {           
+        {
             /* Error */
-            printf("Error %x reading E820 memory map: %s.\n", 
+            printf("Error %x reading E820 memory map: %s.\n",
                    (int) regs_out.eax.b[0],
                    (regs_out.eax.b[0] == 0x80) ? "invalid command" :
                    (regs_out.eax.b[0] == 0x86) ? "not supported" :
                    "unknown error");
             break;
-        } 
+        }
 
         /* Success */
 #ifdef DEBUG
-        printf("    %#16.16Lx -- %#16.16Lx : ", 
+        printf("    %#16.16Lx -- %#16.16Lx : ",
                e820->BaseAddr, e820->BaseAddr + e820->Length);
         switch (e820->Type) {
-        case 1: printf("Available\n"); break; 
-        case 2: printf("Reserved\n"); break; 
-        case 3: printf("ACPI Reclaim\n"); break; 
-        case 4: printf("ACPI NVS\n"); break; 
-        default: printf("? (Reserved)\n"); break; 
+        case 1: printf("Available\n"); break;
+        case 2: printf("Reserved\n"); break;
+        case 3: printf("ACPI Reclaim\n"); break;
+        case 4: printf("ACPI NVS\n"); break;
+        default: printf("? (Reserved)\n"); break;
         }
 #endif
 
@@ -408,12 +408,12 @@ static void init_mmap(struct multiboot_info *mbi)
             }
         }
 
-        /* Move to next slot */ 
+        /* Move to next slot */
         e820++;
         e820_slots++;
-        
+
         /* Done? */
-        if (regs_out.ebx.l == 0) 
+        if (regs_out.ebx.l == 0)
             break;
     }
 
@@ -421,11 +421,11 @@ static void init_mmap(struct multiboot_info *mbi)
     mbi->flags |= MB_INFO_MEMORY;
     mbi->mem_lower = mem_lower;
     mbi->mem_upper = mem_upper;
-    
+
     /* Record the full memory map in the MBI */
     if (e820_slots != 0) {
         mmap_size = e820_slots * sizeof(*e820);
-        /* Where will it live at run time? */ 
+        /* Where will it live at run time? */
         run_addr = place_low_section(mmap_size, 1);
         if (run_addr == 0) {
             printf("Fatal: can't find space for the e820 mmap.\n");
@@ -456,14 +456,14 @@ static void init_mmap(struct multiboot_info *mbi)
  *  Code for loading and parsing files.
  */
 
-static void load_file(char *filename, char **startp, size_t *sizep) 
+static void load_file(char *filename, char **startp, size_t *sizep)
     /* Load a file into memory.  Returns where it is and how big via
      * startp and sizep */
 {
     gzFile fp;
     char *start;
     int bsize;
-    
+
     printf("Loading %s.", filename);
 
     start = next_load_addr;
@@ -475,7 +475,7 @@ static void load_file(char *filename, char **startp, size_t *sizep)
         printf("\nFatal: cannot open %s\n", filename);
         exit(1);
     }
-    
+
     while (next_load_addr + LOAD_CHUNK <= section_addr) {
         bsize = gzread(fp, next_load_addr, LOAD_CHUNK);
         printf("%s",".");
@@ -485,13 +485,13 @@ static void load_file(char *filename, char **startp, size_t *sizep)
             gzclose(fp);
             exit(1);
         }
-      
+
         next_load_addr += bsize;
         sizep[0] += bsize;
 
         if (bsize < LOAD_CHUNK) {
             printf("%s","\n");
-            gzclose(fp);        
+            gzclose(fp);
             return;
         }
     }
@@ -503,16 +503,16 @@ static void load_file(char *filename, char **startp, size_t *sizep)
     } else {
         bsize = 0;
     }
-    
+
     if (bsize < 0) {
         gzclose(fp);
         printf("\nFatal: read error in %s\n", filename);
         exit(1);
     }
-    
+
     next_load_addr += bsize;
     sizep[0] += bsize;
-    
+
     if (!gzeof(fp)) {
         gzclose(fp);
         printf("\nFatal: out of memory reading %s\n", filename);
@@ -525,7 +525,7 @@ static void load_file(char *filename, char **startp, size_t *sizep)
 }
 
 
-static size_t load_kernel(struct multiboot_info *mbi, char *cmdline) 
+static size_t load_kernel(struct multiboot_info *mbi, char *cmdline)
     /* Load a multiboot/elf32 kernel and allocate run-time memory for it.
      * Returns the kernel's entry address.  */
 {
@@ -536,7 +536,7 @@ static size_t load_kernel(struct multiboot_info *mbi, char *cmdline)
     size_t seg_size, bss_size;                     /* How big it is */
     size_t run_addr, run_size;            /* Where it should be put */
     size_t shdr_run_addr;
-    char *p; 
+    char *p;
     Elf32_Ehdr *ehdr;
     Elf32_Phdr *phdr;
     Elf32_Shdr *shdr;
@@ -544,13 +544,13 @@ static size_t load_kernel(struct multiboot_info *mbi, char *cmdline)
 
     printf("Kernel: %s\n", cmdline);
 
-    load_addr = 0; 
+    load_addr = 0;
     load_size = 0;
-    p = strchr(cmdline, ' '); 
+    p = strchr(cmdline, ' ');
     if (p != NULL) *p = 0;
     load_file(cmdline, &load_addr, &load_size);
     if (load_size < 12) {
-        printf("Fatal: %s is too short to be a multiboot kernel.", 
+        printf("Fatal: %s is too short to be a multiboot kernel.",
                cmdline);
         exit(1);
     }
@@ -561,7 +561,7 @@ static size_t load_kernel(struct multiboot_info *mbi, char *cmdline)
     for (i = 0; i <= MIN(load_size - 12, MULTIBOOT_SEARCH - 12); i += 4)
     {
         mbh = (struct multiboot_header *)(load_addr + i);
-        if (mbh->magic != MULTIBOOT_MAGIC 
+        if (mbh->magic != MULTIBOOT_MAGIC
             || ((mbh->magic+mbh->flags+mbh->checksum) & 0xffffffff))
         {
             /* Not a multiboot header */
@@ -570,7 +570,7 @@ static size_t load_kernel(struct multiboot_info *mbi, char *cmdline)
         if (mbh->flags & (MULTIBOOT_UNSUPPORTED | MULTIBOOT_VIDEO_MODE)) {
             /* Requires options we don't support */
             printf("Fatal: Kernel requires multiboot options "
-                   "that I don't support: %#x.\n", 
+                   "that I don't support: %#x.\n",
                    mbh->flags & (MULTIBOOT_UNSUPPORTED|MULTIBOOT_VIDEO_MODE));
             exit(1);
         }
@@ -589,35 +589,35 @@ static size_t load_kernel(struct multiboot_info *mbi, char *cmdline)
 
             /* How much code is there? */
             run_addr = mbh->load_addr;
-            if (mbh->load_end_addr != 0) 
+            if (mbh->load_end_addr != 0)
                 seg_size = mbh->load_end_addr - mbh->load_addr;
-            else 
+            else
                 seg_size = load_size - (seg_addr - load_addr);
 
-            /* How much memory will it take up? */ 
+            /* How much memory will it take up? */
             if (mbh->bss_end_addr != 0)
                 run_size = mbh->bss_end_addr - mbh->load_addr;
             else
                 run_size = seg_size;
-            
+
             if (seg_size > run_size) {
-                printf("Fatal: can't put %i bytes of kernel into %i bytes " 
+                printf("Fatal: can't put %i bytes of kernel into %i bytes "
                        "of memory.\n", seg_size, run_size);
                 exit(1);
             }
             if (seg_addr + seg_size > load_addr + load_size) {
-                printf("Fatal: multiboot load segment runs off the " 
+                printf("Fatal: multiboot load segment runs off the "
                        "end of the file.\n");
                 exit(1);
             }
 
             /* Does it fit where it wants to be? */
             place_kernel_section(run_addr, run_size);
-            
+
             /* Put it on the relocation list */
             if (seg_size < run_size) {
                 /* Set up the kernel BSS too */
-                if (seg_size > 0) 
+                if (seg_size > 0)
                     add_section(run_addr, seg_addr, seg_size);
                 bss_size = run_size - seg_size;
                 add_section(run_addr + seg_size, NULL, bss_size);
@@ -625,15 +625,15 @@ static size_t load_kernel(struct multiboot_info *mbi, char *cmdline)
                 /* No BSS */
                 add_section(run_addr, seg_addr, run_size);
             }
-            
+
             /* Done. */
             return mbh->entry_addr;
-            
+
         } else {
-          
-            /* Now look for an ELF32 header */    
+
+            /* Now look for an ELF32 header */
             ehdr = (Elf32_Ehdr *)load_addr;
-            if (*(unsigned long *)ehdr != 0x464c457f 
+            if (*(unsigned long *)ehdr != 0x464c457f
                 || ehdr->e_ident[EI_DATA] != ELFDATA2LSB
                 || ehdr->e_ident[EI_CLASS] != ELFCLASS32
                 || ehdr->e_machine != EM_386)
@@ -655,7 +655,7 @@ static size_t load_kernel(struct multiboot_info *mbi, char *cmdline)
             printf("Using ELF header.\n");
 #endif
 
-            if (ehdr->e_type != ET_EXEC 
+            if (ehdr->e_type != ET_EXEC
                 || ehdr->e_version != EV_CURRENT
                 || ehdr->e_phentsize != sizeof (Elf32_Phdr)) {
                 printf("Warning: funny-looking ELF header.\n");
@@ -667,15 +667,15 @@ static size_t load_kernel(struct multiboot_info *mbi, char *cmdline)
 
                 /* How much is in this segment? */
                 run_size = phdr[i].p_memsz;
-                if (phdr[i].p_type != PT_LOAD) 
+                if (phdr[i].p_type != PT_LOAD)
                     seg_size = 0;
-                else 
+                else
                     seg_size = (size_t)phdr[i].p_filesz;
-                
+
                 /* Where is it in the loaded file? */
                 seg_addr = load_addr + phdr[i].p_offset;
                 if (seg_addr + seg_size > load_addr + load_size) {
-                    printf("Fatal: ELF load segment runs off the " 
+                    printf("Fatal: ELF load segment runs off the "
                            "end of the file.\n");
                     exit(1);
                 }
@@ -690,7 +690,7 @@ static size_t load_kernel(struct multiboot_info *mbi, char *cmdline)
                 /* Put it on the relocation list */
                 if (seg_size < run_size) {
                     /* Set up the kernel BSS too */
-                    if (seg_size > 0) 
+                    if (seg_size > 0)
                         add_section(run_addr, seg_addr, seg_size);
                     bss_size = run_size - seg_size;
                     add_section(run_addr + seg_size, NULL, bss_size);
@@ -699,7 +699,7 @@ static size_t load_kernel(struct multiboot_info *mbi, char *cmdline)
                     add_section(run_addr, seg_addr, run_size);
                 }
             }
-         
+
             if (ehdr->e_shoff != 0) {
 #ifdef DEBUG
                 printf("Loading ELF section table.\n");
@@ -709,7 +709,7 @@ static size_t load_kernel(struct multiboot_info *mbi, char *cmdline)
 
                 /* Section Header Table size */
                 run_size = ehdr->e_shentsize * ehdr->e_shnum;
-                shdr_run_addr = place_module_section(run_size, 0x1000); 
+                shdr_run_addr = place_module_section(run_size, 0x1000);
                 if (shdr_run_addr == 0) {
                     printf("Warning: Not enough memory to load the "
                            "section table.\n");
@@ -719,23 +719,23 @@ static size_t load_kernel(struct multiboot_info *mbi, char *cmdline)
 
                 /* Load section tables not loaded thru program segments */
                 for (i = 0; i < ehdr->e_shnum; i++) {
-                   /* This case is when this section is already included in 
+                   /* This case is when this section is already included in
                     * program header or it's 0 size, so no need to load */
                    if (shdr[i].sh_addr != 0 || !shdr[i].sh_size)
                        continue;
 
                    if (shdr[i].sh_addralign == 0)
                        shdr[i].sh_addralign = 1;
-                   
-                   run_addr = place_module_section(shdr[i].sh_size, 
-                                                   shdr[i].sh_addralign); 
+
+                   run_addr = place_module_section(shdr[i].sh_size,
+                                                   shdr[i].sh_addralign);
                    if (run_addr == 0) {
                        printf("Warning: Not enough memory to load "
                               "section %d.\n", i);
                        return ehdr->e_entry;
                    }
                    shdr[i].sh_addr = run_addr;
-                   add_section(run_addr, 
+                   add_section(run_addr,
                                (void*) (shdr[i].sh_offset + load_addr),
                                shdr[i].sh_size);
                 }
@@ -747,10 +747,10 @@ static size_t load_kernel(struct multiboot_info *mbi, char *cmdline)
                 mbi->syms.e.addr = shdr_run_addr;
 #ifdef DEBUG
                 printf("Section information: shnum: %lu, entSize: %lu, "
-                       "shstrndx: %lu, addr: 0x%lx\n", 
-                       mbi->syms.e.num, mbi->syms.e.size, 
+                       "shstrndx: %lu, addr: 0x%lx\n",
+                       mbi->syms.e.num, mbi->syms.e.size,
                        mbi->syms.e.shndx, mbi->syms.e.addr);
-#endif                    
+#endif
             }
 
             /* Done! */
@@ -765,17 +765,17 @@ static size_t load_kernel(struct multiboot_info *mbi, char *cmdline)
 
 
 
-static void load_module(struct mod_list *mod, char *cmdline) 
+static void load_module(struct mod_list *mod, char *cmdline)
     /* Load a multiboot module and allocate a memory area for it */
 {
     char *load_addr, *p;
     size_t load_size, run_addr;
-    
+
     printf("Module: %s\n", cmdline);
 
-    load_addr = 0; 
+    load_addr = 0;
     load_size = 0;
-    p = strchr(cmdline, ' '); 
+    p = strchr(cmdline, ' ');
     if (p != NULL) *p = 0;
     load_file(cmdline, &load_addr, &load_size);
     if (p != NULL) *p = ' ';
@@ -787,7 +787,7 @@ static void load_module(struct mod_list *mod, char *cmdline)
         exit(1);
     }
     add_section(run_addr, load_addr, load_size);
-    
+
     /* Remember where we put it */
     mod->mod_start = run_addr;
     mod->mod_end = run_addr + load_size;
@@ -805,7 +805,7 @@ static void load_module(struct mod_list *mod, char *cmdline)
  *  Code for shuffling sections into place and booting the new kernel
  */
 
-static void trampoline_start(section_t *secs, int sec_count, 
+static void trampoline_start(section_t *secs, int sec_count,
                              size_t mbi_run_addr, size_t entry)
     /* Final shuffle-and-boot code.  Running on the stack; no external code
      * or data can be relied on. */
@@ -845,12 +845,12 @@ static void trampoline_start(section_t *secs, int sec_count,
             char *q = (char *) secs[i].dest;
             size_t n = secs[i].size;
             if ( q < p ) {
-                asm volatile("cld ; rep ; movsb" 
+                asm volatile("cld ; rep ; movsb"
                              : "+c" (n), "+S" (p), "+D" (q));
             } else {
                 p += (n-1);
                 q += (n-1);
-                asm volatile("std ; rep ; movsb" 
+                asm volatile("std ; rep ; movsb"
                              : "+c" (n), "+S" (p), "+D" (q));
             }
         }
@@ -866,26 +866,26 @@ static void trampoline_start(section_t *secs, int sec_count,
          * ESP is the kernels' problem.
          * GDTR is the kernel's problem.
          * CS is already a 32-bit, 0--4G code segments.
-         * DS, ES, FS and GS are already 32-bit, 0--4G data segments. 
+         * DS, ES, FS and GS are already 32-bit, 0--4G data segments.
          * EBX must point to the MBI: */
 
-        "movl %0, %%ebx;" 
-    
+        "movl %0, %%ebx;"
+
         /* EAX must be the Multiboot magic number. */
 
         "movl $0x2badb002, %%eax;"
 
         /* Start the kernel. */
 
-        "jmp *%1" 
+        "jmp *%1"
 
-        : : "m" (mbi_run_addr), "r" (entry));    
+        : : "m" (mbi_run_addr), "r" (entry));
 
 }
 static void trampoline_end(void) {}
 
 
-static void boot(size_t mbi_run_addr, size_t entry) 
+static void boot(size_t mbi_run_addr, size_t entry)
     /* Tidy up SYSLINUX, shuffle memory and boot the kernel */
 {
     com32sys_t regs;
@@ -901,7 +901,7 @@ static void boot(size_t mbi_run_addr, size_t entry)
      * safe because it's not the source or the destination of any
      * copies, and there'll be no more library calls after the copy. */
 
-    tr_sections = ((section_t *) section_addr) + section_count; 
+    tr_sections = ((section_t *) section_addr) + section_count;
     trampoline = (void *) (tr_sections + section_count);
     trampoline_size = (void *)&trampoline_end - (void *)&trampoline_start;
 
@@ -917,7 +917,7 @@ static void boot(size_t mbi_run_addr, size_t entry)
 
     memmove(tr_sections, section_addr, section_count * sizeof (section_t));
     memmove(trampoline, trampoline_start, trampoline_size);
-      
+
     /* Tell SYSLINUX to clean up */
     memset(&regs, 0, sizeof regs);
     regs.eax.l = 0x000c; /* "Perform final cleanup" */
@@ -960,17 +960,17 @@ int main(int argc, char **argv)
 #endif
 
     /* How much space will the MBI need? */
-    modules = 0; 
+    modules = 0;
     mbi_size = sizeof(struct multiboot_info) + strlen(version_string) + 5;
     for (i = 1 ; i < argc ; i++) {
         if (!strcmp(argv[i], module_separator)) {
-            modules++; 
+            modules++;
             mbi_size += sizeof(struct mod_list) + 1;
         } else {
             mbi_size += strlen(argv[i]) + 1;
         }
     }
-    
+
     /* Allocate space in the load buffer for the MBI, all the command
      * lines, and all the module details. */
     mbi = (struct multiboot_info *)next_load_addr;
@@ -1028,10 +1028,10 @@ int main(int argc, char **argv)
         load_module(&(modp[i]), (char *)(modp[i].cmdline + mbi_reloc_offset));
     }
     boot(mbi_run_addr, entry);
-    
+
     return 1;
 }
 
-/* 
+/*
  *  EOF
  */
index 54aaf54..bd9a363 100644 (file)
@@ -1,6 +1,6 @@
 #ident "$Id$"
 /* ----------------------------------------------------------------------- *
- *   
+ *
  *   Copyright 2004-2006 H. Peter Anvin - All Rights Reserved
  *
  *   This program is free software; you can redistribute it and/or modify
@@ -154,11 +154,11 @@ static void
 draw_row(int y, int sel, int top, int sbtop, int sbbot)
 {
   int i = (y-4)+top;
-  
+
   printf("\033[%d;%dH%s\016x\017%s ",
         y, MARGIN+1, menu_attrib->border,
         (i == sel) ? menu_attrib->sel : menu_attrib->unsel);
-  
+
   if ( i >= nentries ) {
     fputs(pad_line("", 0, WIDTH-2*MARGIN-4), stdout);
   } else {
@@ -225,11 +225,11 @@ static int mygetkey(clock_t timeout)
   for (;;) {
     tto = min(totaltimeout, INT_MAX);
     to = timeout ? min(tto, timeout) : tto;
-    
+
     t0 = times(NULL);
     key = get_key(stdin, to);
     t = times(NULL) - t0;
-    
+
     if ( totaltimeout <= t )
       longjmp(timeout_jump, 1);
 
@@ -241,7 +241,7 @@ static int mygetkey(clock_t timeout)
     if ( timeout ) {
       if ( timeout <= t )
        return KEY_NONE;
-      
+
       timeout -= t;
     }
   }
@@ -260,7 +260,7 @@ ask_passwd(const char *menu_entry)
         menu_attrib->pwdborder);
   for ( x = 2 ; x <= WIDTH-2*PASSWD_MARGIN-1 ; x++ )
     putchar('q');
-  
+
   printf("k\033[%d;%dHx", PASSWD_ROW+1, PASSWD_MARGIN+1);
   for ( x = 2 ; x <= WIDTH-2*PASSWD_MARGIN-1 ; x++ )
     putchar(' ');
@@ -268,7 +268,7 @@ ask_passwd(const char *menu_entry)
   printf("x\033[%d;%dHm", PASSWD_ROW+2, PASSWD_MARGIN+1);
   for ( x = 2 ; x <= WIDTH-2*PASSWD_MARGIN-1 ; x++ )
     putchar('q');
-  
+
   printf("j\017\033[%d;%dH%s %s \033[%d;%dH%s",
         PASSWD_ROW, (WIDTH-((int)sizeof(title)+1))/2,
         menu_attrib->pwdheader, title,
@@ -323,7 +323,7 @@ ask_passwd(const char *menu_entry)
     return 0;                  /* No password entered */
 
   *p = '\0';
-      
+
   return (menu_master_passwd && passwd_compare(menu_master_passwd, user_passwd))
     || (menu_entry && passwd_compare(menu_entry, user_passwd));
 }
@@ -334,31 +334,31 @@ draw_menu(int sel, int top, int edit_line)
 {
   int x, y;
   int sbtop = 0, sbbot = 0;
-  
+
   if ( nentries > MENU_ROWS ) {
     int sblen = MENU_ROWS*MENU_ROWS/nentries;
     sbtop = (MENU_ROWS-sblen+1)*top/(nentries-MENU_ROWS+1);
     sbbot = sbtop + sblen - 1;
-    
+
     sbtop += 4;  sbbot += 4;   /* Starting row of scrollbar */
   }
-  
+
   printf("\033[1;%dH%s\016l", MARGIN+1, menu_attrib->border);
   for ( x = 2 ; x <= WIDTH-2*MARGIN-1 ; x++ )
     putchar('q');
-  
+
   printf("k\033[2;%dH%sx\017%s %s %s\016x",
         MARGIN+1,
         menu_attrib->border,
         menu_attrib->title,
         pad_line(menu_title, 1, WIDTH-2*MARGIN-4),
         menu_attrib->border);
-  
+
   printf("\033[3;%dH%st", MARGIN+1, menu_attrib->border);
   for ( x = 2 ; x <= WIDTH-2*MARGIN-1 ; x++ )
     putchar('q');
   fputs("u\017", stdout);
-  
+
   for ( y = 4 ; y < 4+MENU_ROWS ; y++ )
     draw_row(y, sel, top, sbtop, sbbot);
 
@@ -433,7 +433,7 @@ edit_cmdline(char *input, int top)
       }
       break;
 
-    case KEY_CTRL('D'):        
+    case KEY_CTRL('D'):
     case KEY_DELETE:
       if ( cursor < len ) {
        memmove(cmdline+cursor, cmdline+cursor+1, len-cursor);
@@ -638,7 +638,7 @@ run_menu(void)
       if ( key_timeout ) {
        if ( timeout_left <= this_timeout )
          longjmp(timeout_jump, 1);
-       
+
        timeout_left -= this_timeout;
       }
       break;
@@ -730,7 +730,7 @@ run_menu(void)
          /* Erase [Tab] message */
          printf("\033[%d;1H%s\033[K", TABMSG_ROW, menu_attrib->screen);
        }
-       
+
        if ( ok ) {
          cmdline = edit_cmdline(menu_entries[entry].cmdline, top);
          done = !!cmdline;
@@ -746,7 +746,7 @@ run_menu(void)
        done = 1;
        clear = 1;
        key_timeout = 0;
-       
+
        draw_row(entry-top+4, -1, top, 0, 0);
 
        if ( menu_master_passwd )
@@ -790,11 +790,11 @@ execute(const char *cmdline)
     *q++ = *p++;
   }
   *q++ = '\0';
-  
+
   args = q;
   while ( *p && my_isspace(*p) )
     p++;
-  
+
   strcpy(q, p);
 
   if ( !strcmp(kernel, ".localboot") ) {
index 59247df..0589c7a 100644 (file)
@@ -1,6 +1,6 @@
 #ident "$Id$"
 /* ----------------------------------------------------------------------- *
- *   
+ *
  *   Copyright 2004-2005 H. Peter Anvin - All Rights Reserved
  *
  *   This program is free software; you can redistribute it and/or modify
index 4fb5b07..82b663b 100644 (file)
@@ -1,6 +1,6 @@
 #ident "$Id$"
 /* ----------------------------------------------------------------------- *
- *   
+ *
  *   Copyright 2004-2006 H. Peter Anvin - All Rights Reserved
  *
  *   This program is free software; you can redistribute it and/or modify
@@ -45,7 +45,7 @@ struct menu_entry *menu_hotkeys[256];
                       __p; })
 
 const char *ipappends[32];
-                      
+
 static void
 get_ipappend(void)
 {
@@ -74,7 +74,7 @@ get_config(void)
 {
 #ifdef __COM32__
   static com32sys_t r;
-  
+
   r.eax.w[0] = 0x000E;
   __intcall(0x22, &r, &r);
 
@@ -83,7 +83,7 @@ get_config(void)
   return "syslinux.cfg";       /* Dummy default name */
 #endif
 }
-  
+
 #define MAX_LINE 512
 
 static char *
@@ -91,7 +91,7 @@ skipspace(char *p)
 {
   while ( *p && my_isspace(*p) )
     p++;
-  
+
   return p;
 }
 
@@ -209,7 +209,7 @@ unlabel(char *str)
       q = malloc(strlen(me->cmdline) + strlen(p) + 1);
       strcpy(q, me->cmdline);
       strcat(q, p);
-      
+
       free(str);
 
       return q;
@@ -247,7 +247,7 @@ void parse_config(const char *filename)
 
     if ( looking_at(p, "menu") ) {
       p = skipspace(p+4);
-      
+
       if ( looking_at(p, "title") ) {
        menu_title = strdup(skipspace(p+5));
       } else if ( looking_at(p, "label") ) {
@@ -311,10 +311,10 @@ void parse_config(const char *filename)
       ld.append = strdup(skipspace(p+9));
     }
   }
-  
+
   record(&ld, append);
   fclose(f);
-  
+
   if ( ontimeout )
     ontimeout = unlabel(ontimeout);
 }