summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-03-28 22:10:01 -0700
committerH. Peter Anvin <hpa@zytor.com>2008-03-28 22:19:12 -0700
commit1e443fbc6ff358a1ce5559263957cbb4c4f92cec (patch)
treea3d1526497714267476670f8d9ccc35c4b704f39
parentbbb8f15936b851e6a0ef6f7bb2c95197bff35994 (diff)
downloadsyslinux-1e443fbc6ff358a1ce5559263957cbb4c4f92cec.tar.gz
Add stpcpy() and implement version/derivative queries
Add stpcpy(), and actually implement syslinux_version() and syslinux_derivative_info().
-rw-r--r--com32/include/string.h1
-rw-r--r--com32/lib/Makefile5
-rw-r--r--com32/lib/stpcpy.c23
-rw-r--r--com32/lib/syslinux/dsinfo.c47
-rw-r--r--com32/lib/syslinux/version.c46
5 files changed, 120 insertions, 2 deletions
diff --git a/com32/include/string.h b/com32/include/string.h
index 65923723..af9792b6 100644
--- a/com32/include/string.h
+++ b/com32/include/string.h
@@ -33,6 +33,7 @@ __extern char *strncat(char *, const char *, size_t);
__extern size_t strlcat(char *, const char *, size_t);
__extern int strncmp(const char *, const char *, size_t);
__extern char *strncpy(char *, const char *, size_t);
+__extern char *stpcpy(char *, const char *);
__extern char *stpncpy(char *, const char *, size_t);
__extern size_t strlcpy(char *, const char *, size_t);
__extern char *strpbrk(const char *, const char *);
diff --git a/com32/lib/Makefile b/com32/lib/Makefile
index 6c08c221..adc36605 100644
--- a/com32/lib/Makefile
+++ b/com32/lib/Makefile
@@ -13,7 +13,8 @@ LIBOBJS = \
sprintf.o srand48.o sscanf.o stack.o strcasecmp.o strcat.o \
strchr.o strcmp.o strcpy.o strdup.o strerror.o strlen.o \
strnlen.o \
- strncasecmp.o strncat.o strncmp.o strncpy.o stpncpy.o strndup.o \
+ strncasecmp.o strncat.o strncmp.o strncpy.o strndup.o \
+ stpcpy.o stpncpy.o \
strntoimax.o strntoumax.o strrchr.o strsep.o strspn.o strstr.o \
strtoimax.o strtok.o strtol.o strtoll.o strtoul.o strtoull.o \
strtoumax.o vfprintf.o vprintf.o vsnprintf.o vsprintf.o \
@@ -72,7 +73,7 @@ LIBOBJS = \
\
syslinux/idle.o syslinux/reboot.o \
syslinux/features.o syslinux/config.o syslinux/serial.o \
- syslinux/ipappend.o \
+ syslinux/ipappend.o syslinux/dsinfo.o syslinux/version.o \
\
syslinux/addlist.o syslinux/freelist.o syslinux/memmap.o \
syslinux/movebits.o syslinux/shuffle.o syslinux/shuffle_pm.o \
diff --git a/com32/lib/stpcpy.c b/com32/lib/stpcpy.c
new file mode 100644
index 00000000..85fc49d3
--- /dev/null
+++ b/com32/lib/stpcpy.c
@@ -0,0 +1,23 @@
+/*
+ * stpcpy.c
+ *
+ * stpcpy()
+ */
+
+#include <string.h>
+
+char *stpcpy(char *dst, const char *src)
+{
+ char *q = dst;
+ const char *p = src;
+ char ch;
+
+ for (;;) {
+ *q = ch = *p++;
+ if ( !ch )
+ break;
+ q++;
+ }
+
+ return q;
+}
diff --git a/com32/lib/syslinux/dsinfo.c b/com32/lib/syslinux/dsinfo.c
new file mode 100644
index 00000000..6d77a0de
--- /dev/null
+++ b/com32/lib/syslinux/dsinfo.c
@@ -0,0 +1,47 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2008 H. Peter Anvin - All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall
+ * be included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * ----------------------------------------------------------------------- */
+
+#include <syslinux/config.h>
+#include <klibc/compiler.h>
+#include <com32.h>
+
+union syslinux_derivative_info __syslinux_derivative_info;
+
+void __constructor __syslinux_get_derivative_info(void)
+{
+ static com32sys_t reg;
+
+ reg.eax.w[0] = 0x000A;
+ __intcall(0x22, &reg, &reg);
+
+ __syslinux_derivative_info.r.ax = reg.eax.w[0];
+ __syslinux_derivative_info.r.cx = reg.ecx.w[0];
+ __syslinux_derivative_info.r.dx = reg.edx.w[0];
+ __syslinux_derivative_info.r.esbx = MK_PTR(reg.es, reg.ebx.w[0]);
+ __syslinux_derivative_info.r.fssi = MK_PTR(reg.fs, reg.esi.w[0]);
+ __syslinux_derivative_info.r.gsdi = MK_PTR(reg.gs, reg.edi.w[0]);
+}
diff --git a/com32/lib/syslinux/version.c b/com32/lib/syslinux/version.c
new file mode 100644
index 00000000..2131fa04
--- /dev/null
+++ b/com32/lib/syslinux/version.c
@@ -0,0 +1,46 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2008 H. Peter Anvin - All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall
+ * be included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * ----------------------------------------------------------------------- */
+
+#include <syslinux/config.h>
+#include <klibc/compiler.h>
+#include <com32.h>
+
+struct syslinux_version __syslinux_version;
+
+void __constructor __syslinux_get_version(void)
+{
+ static com32sys_t reg;
+
+ reg.eax.w[0] = 0x0001;
+ __intcall(0x22, &reg, &reg);
+
+ __syslinux_version.version = reg.ecx.w[0];
+ __syslinux_version.max_api = reg.eax.w[0];
+ __syslinux_version.filesystem = reg.edx.b[0];
+ __syslinux_version.version_string = MK_PTR(reg.es, reg.esi.w[0]);
+ __syslinux_version.copyright_string = MK_PTR(reg.es, reg.edi.w[0]);
+}