Clean up gcc version dependencies, mostly related to asm() statements.
authorhpa <hpa>
Mon, 17 Dec 2001 02:08:56 +0000 (02:08 +0000)
committerhpa <hpa>
Mon, 17 Dec 2001 02:08:56 +0000 (02:08 +0000)
NEWS
gethostip.c
memdisk/Makefile
memdisk/conio.c
memdisk/e820func.c
memdisk/e820test.c
memdisk/msetup.c
memdisk/setup.c
version

diff --git a/NEWS b/NEWS
index e290fe8..b5210fc 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,9 @@
 Starting with 1.47, changes marked with SYSLINUX/PXELINUX/ISOLINUX
 apply to that specific program only; other changes apply to both.
 
+Changes in 1.66:
+       * MEMDISK: Make compile with newer versions of gcc.
+
 Changes in 1.65:
        * ISOLINUX: Support booting disk image files (to boot DOS or
          other non-Linux operating systems), *IF* the BIOS works
index 21131d7..bebcf79 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <netdb.h>
 #include <sys/socket.h>
 #include <unistd.h>
index 9dfa9b6..cdd87d5 100644 (file)
@@ -44,10 +44,10 @@ clean: tidy
        echo '.code16gcc' | cat - $< > $@
 
 %.s: %.S
-       $(CC) -x c $(CFLAGS) -Wp,-traditional -E -o $@ $<
+       $(CC) -x c $(CFLAGS) -traditional -E -o $@ $<
 
 %.s16: %.S16
-       $(CC) -x c $(CFLAGS) -Wp,-traditional -E -o $@ $<
+       $(CC) -x c $(CFLAGS) -traditional -E -o $@ $<
 
 %.s: %.c
        $(CC) $(CFLAGS) -S -o $@ $<
index f1ca699..1efe724 100644 (file)
@@ -30,12 +30,14 @@ int putchar(int ch)
                 ::: "eax", "ebx", "ecx", "edx",
                 "esi", "edi", "ebp");
   }
-
-  asm volatile("movw $0x0007,%%bx ; "
-              "int $0x10"
-              :: "a" ((uint16_t)(0x0e00|(ch&0xff)))
-              : "eax", "ebx", "ecx", "edx",
-              "esi", "edi", "ebp");
+  
+  {
+    uint16_t ax = 0x0e00|(ch&0xff);
+    asm volatile("movw $0x0007,%%bx ; "
+                "int $0x10"
+                : "+a" (ax)
+                :: "ebx", "ecx", "edx", "esi", "edi", "ebp");
+  }
 
   return ch;
 }
index 3087d33..57ab0fc 100644 (file)
@@ -28,10 +28,14 @@ int nranges;
 
 void e820map_init(void)
 {
+  struct e820range *rp = ranges;
+  unsigned int rdw = sizeof(ranges) >> 2;
   nranges = 1;
-  asm volatile("cld ; rep ; stosl %0,%%es:(%1)"
-              :: "a" (0), "D" (ranges), "c" (sizeof(ranges) >> 2)
-              : "edi", "ecx");
+  
+  asm volatile("cld ; rep ; stosl %2,%%es:(%0)"
+              : "+D" (rp), "+c" (rdw)
+              : "a" (0)
+              : "memory");
   ranges[1].type = -1;
 }
 
index 2d8be07..2d10a35 100644 (file)
@@ -18,6 +18,7 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <inttypes.h>
 #include "e820.h"
 
index d5036d8..f9ed071 100644 (file)
@@ -33,23 +33,25 @@ static inline int get_e820(void)
   uint32_t lastptr = 0;
   uint32_t copied;
   int range_count = 0;
-  
+  uint32_t eax, edx;
+
   do {
+    copied = sizeof(buf);
+    eax = 0x0000e820;
+    edx = 0x534d4150;
+    
     asm volatile("int $0x15 ; "
-                "jc 1f ; "
-                "cmpl $0x534d4150, %%eax ; "
-                "je 2f\n"
-                "1:\n\t"
+                "jnc 1f ; "
                 "xorl %0,%0\n"
-                "2:"
-                : "=c" (copied), "+b" (lastptr)
-                : "a" (0x0000e820), "d" (0x534d4150),
-                "c" (sizeof(buf)), "D" (&buf)
-                : "eax", "edx", "esi", "edi", "ebp");
-
-    if ( copied < 20 )
+                "1:"
+                : "+c" (copied), "+b" (lastptr),
+                "+a" (eax), "+d" (edx)
+                : "D" (&buf)
+                : "esi", "ebp");
+    
+    if ( eax != 0x534d4150 || copied < 20 )
       break;
-
+    
     insertrange(buf.base, buf.len, buf.type);
     range_count++;
 
index 2ab5b98..e72f4b6 100644 (file)
@@ -151,10 +151,14 @@ static void high_bcopy(uint32_t dst, uint32_t src, uint16_t len)
   high_mover.dst2  = dst >> 16;
   high_mover.dst3  = dst >> 24;
 
-  asm volatile("pushfl ; movb $0x87,%%ah ; int $0x15 ; popfl"
+  asm volatile("pushal ; "
+              "pushfl ; "
+              "movb $0x87,%%ah ; "
+              "int $0x15 ; "
+              "popfl ; "
+              "popal"
               :: "S" (&high_mover), "c" (len >> 1)
-              : "eax", "ebx", "ecx", "edx",
-              "ebp", "esi", "edi", "memory");
+              : "memory");
 }
 
 #define LOWSEG 0x0800          /* Should match init.S16 */
@@ -594,21 +598,22 @@ uint32_t setup(void)
   }
 
   /* Copy driver followed by E820 table */
-  asm volatile("pushw %%es ; "
+  asm volatile("pushal ; "
+              "pushw %%es ; "
               "movw %0,%%es ; "
               "cld ; "
               "rep ; movsl %%ds:(%%si), %%es:(%%di) ; "
               "movw %1,%%cx ; "
               "movw %2,%%si ; "
               "rep ; movsl %%ds:(%%si), %%es:(%%di) ; "
-              "popw %%es"
+              "popw %%es ; "
+              "popal"
               :: "r" (driverseg),
               "r" ((uint16_t)((nranges+1)*3)), /* 3 dwords/range */
               "r" ((uint16_t)&ranges),
               "c" (bin_size >> 2),
               "S" (&_binary_memdisk_bin_start),
-              "D" (0)
-              : "esi", "edi", "ecx");
+              "D" (0));
 
   /* Install the interrupt handlers */
   {
@@ -644,7 +649,9 @@ uint32_t setup(void)
   }
 
   /* Reboot into the new "disk" */
-  asm volatile("pushw %%es ; "
+  asm volatile("pushl %%ebp ; "
+              "pushl %%edx ; "
+              "pushw %%es ; "
               "xorw %%cx,%%cx ; "
               "movw %%cx,%%es ; "
               "incw %%cx ; "
@@ -652,10 +659,12 @@ uint32_t setup(void)
               "movw $0x7c00,%%bx ; "
               "int $0x13 ; "
               "popw %%es ; "
-              "setc %0 "
+              "popl %%edx ; "
+              "popl %%ebp ; "
+              "setc %0"
               : "=rm" (status), "=a" (exitcode)
               : "d" ((uint16_t)geometry->driveno)
-              : "ebx", "ecx", "edx", "esi", "edi", "ebp");
+              : "ecx", "ebx", "esi", "edi");
 
   if ( status ) {
     puts("MEMDISK: Failed to load new boot sector\n");
diff --git a/version b/version
index 5b6cd6b..9cf4011 100644 (file)
--- a/version
+++ b/version
@@ -1 +1 @@
-1.65
+1.66