From 1e443fbc6ff358a1ce5559263957cbb4c4f92cec Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Fri, 28 Mar 2008 22:10:01 -0700 Subject: [PATCH] Add stpcpy() and implement version/derivative queries Add stpcpy(), and actually implement syslinux_version() and syslinux_derivative_info(). --- com32/include/string.h | 1 + com32/lib/Makefile | 5 +++-- com32/lib/stpcpy.c | 23 ++++++++++++++++++++++ com32/lib/syslinux/dsinfo.c | 47 ++++++++++++++++++++++++++++++++++++++++++++ com32/lib/syslinux/version.c | 46 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 com32/lib/stpcpy.c create mode 100644 com32/lib/syslinux/dsinfo.c create mode 100644 com32/lib/syslinux/version.c diff --git a/com32/include/string.h b/com32/include/string.h index 6592372..af9792b 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 6c08c22..adc3660 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 0000000..85fc49d --- /dev/null +++ b/com32/lib/stpcpy.c @@ -0,0 +1,23 @@ +/* + * stpcpy.c + * + * stpcpy() + */ + +#include + +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 0000000..6d77a0d --- /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 +#include +#include + +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, ®, ®); + + __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 0000000..2131fa0 --- /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 +#include +#include + +struct syslinux_version __syslinux_version; + +void __constructor __syslinux_get_version(void) +{ + static com32sys_t reg; + + reg.eax.w[0] = 0x0001; + __intcall(0x22, ®, ®); + + __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]); +} -- 2.7.4