dos: vacuous ADV support
authorH. Peter Anvin <hpa@linux.intel.com>
Wed, 23 Jun 2010 00:07:03 +0000 (17:07 -0700)
committerH. Peter Anvin <hpa@linux.intel.com>
Wed, 23 Jun 2010 00:07:03 +0000 (17:07 -0700)
Vacuous ADV support: install an empty ADV.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
dos/Makefile
dos/errno.h
dos/memmove.S [new file with mode: 0644]
dos/string.h
dos/syslinux.c

index d4d20c7..574b65e 100644 (file)
@@ -28,12 +28,13 @@ INCLUDES = -include code16.h -nostdinc -iwithprefix include \
 SRCS     = syslinux.c \
           ../libinstaller/fat.c \
           ../libinstaller/syslxmod.c \
+          ../libinstaller/setadv.c \
           ../libinstaller/bootsect_bin.c \
           ../libinstaller/ldlinux_bin.c \
           ../libinstaller/mbr_bin.c \
            $(wildcard ../libfat/*.c)
 OBJS    = header.o crt0.o $(patsubst %.c,%.o,$(notdir $(SRCS)))
-LIBOBJS         = int2526.o conio.o memcpy.o memset.o  skipatou.o atou.o \
+LIBOBJS         = int2526.o conio.o memcpy.o memset.o memmove.o skipatou.o atou.o \
           malloc.o free.o getsetsl.o \
           argv.o printf.o __divdi3.o __udivmoddi4.o
 
index 30aa046..da733bf 100644 (file)
@@ -1,6 +1,41 @@
 #ifndef ERRNO_H
 #define ERRNO_H
 
+#define        EPERM            1      /* Operation not permitted */
+#define        ENOENT           2      /* No such file or directory */
+#define        ESRCH            3      /* No such process */
+#define        EINTR            4      /* Interrupted system call */
+#define        EIO              5      /* I/O error */
+#define        ENXIO            6      /* No such device or address */
+#define        E2BIG            7      /* Argument list too long */
+#define        ENOEXEC          8      /* Exec format error */
+#define        EBADF            9      /* Bad file number */
+#define        ECHILD          10      /* No child processes */
+#define        EAGAIN          11      /* Try again */
+#define        ENOMEM          12      /* Out of memory */
+#define        EACCES          13      /* Permission denied */
+#define        EFAULT          14      /* Bad address */
+#define        ENOTBLK         15      /* Block device required */
+#define        EBUSY           16      /* Device or resource busy */
+#define        EEXIST          17      /* File exists */
+#define        EXDEV           18      /* Cross-device link */
+#define        ENODEV          19      /* No such device */
+#define        ENOTDIR         20      /* Not a directory */
+#define        EISDIR          21      /* Is a directory */
+#define        EINVAL          22      /* Invalid argument */
+#define        ENFILE          23      /* File table overflow */
+#define        EMFILE          24      /* Too many open files */
+#define        ENOTTY          25      /* Not a typewriter */
+#define        ETXTBSY         26      /* Text file busy */
+#define        EFBIG           27      /* File too large */
+#define        ENOSPC          28      /* No space left on device */
+#define        ESPIPE          29      /* Illegal seek */
+#define        EROFS           30      /* Read-only file system */
+#define        EMLINK          31      /* Too many links */
+#define        EPIPE           32      /* Broken pipe */
+#define        EDOM            33      /* Math argument out of domain of func */
+#define        ERANGE          34      /* Math result not representable */
+
 int errno;
 void perror(const char *);
 
diff --git a/dos/memmove.S b/dos/memmove.S
new file mode 100644 (file)
index 0000000..1ab2cb2
--- /dev/null
@@ -0,0 +1,36 @@
+#
+# memmove.S
+#
+# Simple 16-bit memmove() implementation
+#
+
+       .text
+       .code16gcc
+       .globl memmove
+       .type memmove, @function
+memmove:
+       pushw %di
+       pushw %si
+       movw %ax,%di
+       movw %dx,%si
+       cmpw %si,%di
+       ja 1f
+       # The third argument is already in cx
+       cld
+       rep ; movsb
+2:
+       popw %si
+       popw %di
+       ret
+
+1:     /* si <= di, need reverse copy */
+       add %cx,%di
+       add %cx,%si
+       dec %di
+       dec %si
+       std
+       rep ; movsb
+       cld
+       jmp 2b
+
+       .size memmove,.-memmove
index 8f8c896..5ee829e 100644 (file)
@@ -7,6 +7,7 @@
 
 /* Standard routines */
 #define memcpy(a,b,c)  __builtin_memcpy(a,b,c)
+#define memmove(a,b,c) __builtin_memmove(a,b,c)
 #define memset(a,b,c)  __builtin_memset(a,b,c)
 #define strcpy(a,b)    __builtin_strcpy(a,b)
 #define strlen(a)      __builtin_strlen(a)
index 5dc3483..d83cadc 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "syslinux.h"
 #include "libfat.h"
+#include "setadv.h"
 
 const char *program = "syslinux";      /* Name of program */
 uint16_t dos_version;
@@ -658,6 +659,11 @@ int main(int argc, char *argv[])
        usage();
 
     /*
+     * Create an ADV in memory... this should be smarter.
+     */
+    syslinux_reset_adv(syslinux_adv);
+
+    /*
      * Figure out which drive we're talking to
      */
     dev_fd = (device[0] & ~0x20) - 0x40;
@@ -685,6 +691,7 @@ int main(int argc, char *argv[])
     set_attributes(ldlinux_name, 0);
     fd = creat(ldlinux_name, 0);       /* SYSTEM HIDDEN READONLY */
     write_ldlinux(fd);
+    write_file(fd, syslinux_adv, 2 * ADV_SIZE);
     close(fd);
     set_attributes(ldlinux_name, 0x07);        /* SYSTEM HIDDEN READONLY */