summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhpa <hpa>2004-12-15 19:01:38 +0000
committerhpa <hpa>2004-12-15 19:01:38 +0000
commit701f75fe81968cf2dccbffbf2f09bf2b04ea4ad6 (patch)
tree8fad99a12b46c4dd8d32fceabb8b913bd1b74664
parent5ddecdda2e74520d252dbe50528c3baf1a004992 (diff)
downloadsyslinux-701f75fe81968cf2dccbffbf2f09bf2b04ea4ad6.tar.gz
Simple memset/memcpy implementation
-rw-r--r--dos/Makefile2
-rw-r--r--dos/memcpy.S24
-rw-r--r--dos/memset.S22
-rw-r--r--dos/string.h20
-rw-r--r--dos/syslinux.c6
5 files changed, 54 insertions, 20 deletions
diff --git a/dos/Makefile b/dos/Makefile
index ac75bedf..b46a35f3 100644
--- a/dos/Makefile
+++ b/dos/Makefile
@@ -9,7 +9,7 @@ LDFLAGS = -T com16.ld
SRCS = syslinux.c printf.c conio.c skipatou.c atou.c malloc.c free.c \
../syslxmod.c ../bootsect_bin.c ../ldlinux_bin.c \
$(wildcard ../libfat/*.c)
-OBJS = crt0.o $(patsubst %.c,%.o,$(notdir $(SRCS)))
+OBJS = crt0.o memcpy.o memset.o $(patsubst %.c,%.o,$(notdir $(SRCS)))
.SUFFIXES: .c .o .i .s .S .elf .com
diff --git a/dos/memcpy.S b/dos/memcpy.S
new file mode 100644
index 00000000..f6d4fd2f
--- /dev/null
+++ b/dos/memcpy.S
@@ -0,0 +1,24 @@
+# $Id$
+#
+# memcpy.S
+#
+# Simple 16-bit memcpy() implementation
+#
+
+ .text
+ .code16
+ .globl memcpy
+ .type memcpy, @function
+memcpy:
+ cld
+ pushl %edi
+ pushl %esi
+ movw 12(%esp),%di
+ movw 16(%esp),%si
+ movw 20(%esp),%cx
+ rep ; movsb
+ popl %esi
+ popl %edi
+ ret
+
+ .size memcpy,.-memcpy
diff --git a/dos/memset.S b/dos/memset.S
new file mode 100644
index 00000000..a7f610a3
--- /dev/null
+++ b/dos/memset.S
@@ -0,0 +1,22 @@
+# $Id$
+#
+# memset.S
+#
+# Minimal 16-bit memset() implementation
+#
+
+ .text
+ .code16
+ .globl memset
+ .type memset, @function
+memset:
+ cld
+ pushl %edi
+ movw 8(%esp),%di
+ movb 12(%esp),%al
+ movw 16(%esp),%cx
+ rep ; stosb
+ popl %edi
+ ret
+
+ .size memset,.-memset
diff --git a/dos/string.h b/dos/string.h
index cee8e2e6..44f77dac 100644
--- a/dos/string.h
+++ b/dos/string.h
@@ -6,22 +6,10 @@
#define _STRING_H
/* Standard routines */
-static inline void *memcpy(void *__d, const void *__s, unsigned int __n)
-{
- asm volatile("cld ; rep ; movsb"
- : "+D" (__d), "+S" (__s), "+c" (__n));
- return __d;
-}
-
-static inline void *memset(void *__d, int __c, unsigned int __n)
-{
- asm volatile("cld ; rep ; stosb"
- : "+D" (__d), "+a" (__c), "+c" (__n));
- return __d;
-}
-
-#define strcpy(a,b) __builtin_strcpy(a,b)
-#define strlen(a) __builtin_strlen(a)
+#define memcpy(a,b,c) __builtin_memcpy(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)
/* This only returns true or false */
static inline int memcmp(const void *__m1, const void *__m2, unsigned int __n)
diff --git a/dos/syslinux.c b/dos/syslinux.c
index dbab7bcc..820e1cbc 100644
--- a/dos/syslinux.c
+++ b/dos/syslinux.c
@@ -131,9 +131,9 @@ void set_attributes(const char *file, int attributes)
/*
* Version of the read_device function suitable for libfat
*/
-int libfat_xpread(void *pp, void *buf, size_t secsize, libfat_sector_t sector)
+int libfat_xpread(intptr_t pp, void *buf, size_t secsize, libfat_sector_t sector)
{
- read_device((int)pp, buf, 1, sector);
+ read_device(pp, buf, 1, sector);
return secsize;
}
@@ -208,7 +208,7 @@ int main(int argc, char *argv[])
* this is supposed to be a simple, privileged version
* of the installer.
*/
- fs = libfat_open(libfat_xpread, (void *)dev_fd);
+ fs = libfat_open(libfat_xpread, dev_fd);
ldlinux_cluster = libfat_searchdir(fs, 0, "LDLINUX SYS", NULL);
secp = sectors;
nsectors = 0;