aboutsummaryrefslogtreecommitdiffstats
path: root/com32/lib
diff options
context:
space:
mode:
authorFeng Tang <feng.tang@intel.com>2010-07-14 10:57:18 +0800
committerFeng Tang <feng.tang@intel.com>2010-07-20 11:10:04 +0800
commit3400a8754214f4cd69d49d85c0396665d7a6415f (patch)
tree8e6218d779196123eb368b136d91ae55ad2bc418 /com32/lib
parent967eb65904c0de527fccee529187bf0dcb4af989 (diff)
downloadsyslinux-3400a8754214f4cd69d49d85c0396665d7a6415f.tar.gz
syslinux-3400a8754214f4cd69d49d85c0396665d7a6415f.tar.xz
syslinux-3400a8754214f4cd69d49d85c0396665d7a6415f.zip
elflink: add more change as show below
com32/lib/chdir.c com32/lib/getcwd.c com32/lib/getopt.c com32/lib/pci/scan.c com32/lib/sys/farcall.c com32/lib/sys/times.c com32/lib/sys/vesa/background.c com32/lib/sys/vesa/screencpy.c com32/lib/vdprintf.c com32/rosh/rosh.c com32/rosh/rosh.h com32/sysdump/backend.h com32/sysdump/be_tftp.c com32/sysdump/main.c com32/sysdump/memmap.c com32/sysdump/sysdump.h com32/sysdump/vesa.c doc/comboot.txt doc/extlinux.txt doc/gpt.txt doc/memdisk.txt doc/menu.txt doc/syslinux.txt
Diffstat (limited to 'com32/lib')
-rw-r--r--com32/lib/chdir.c10
-rw-r--r--com32/lib/getcwd.c23
-rw-r--r--com32/lib/getopt.c117
-rw-r--r--com32/lib/pci/scan.c8
-rw-r--r--com32/lib/sys/farcall.c15
-rw-r--r--com32/lib/sys/times.c8
-rw-r--r--com32/lib/sys/vesa/background.c4
-rw-r--r--com32/lib/sys/vesa/screencpy.c7
-rw-r--r--com32/lib/vdprintf.c7
9 files changed, 107 insertions, 92 deletions
diff --git a/com32/lib/chdir.c b/com32/lib/chdir.c
index 6a365f3b..00670e35 100644
--- a/com32/lib/chdir.c
+++ b/com32/lib/chdir.c
@@ -6,12 +6,10 @@
#include <stdio.h>
#include <errno.h>
+#include <com32.h>
+#include <syslinux/pmapi.h>
+
int chdir(const char *path)
{
- /* Actually implement something here... */
-
- (void)path;
-
- errno = ENOSYS;
- return -1;
+ return __com32.cs_pm->chdir(path);
}
diff --git a/com32/lib/getcwd.c b/com32/lib/getcwd.c
index 38fae52a..5ce62ec0 100644
--- a/com32/lib/getcwd.c
+++ b/com32/lib/getcwd.c
@@ -2,29 +2,10 @@
* getcwd.c
*/
-#include <syslinux/config.h>
-#include <klibc/compiler.h>
#include <com32.h>
-
-#include <dirent.h>
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
+#include <syslinux/pmapi.h>
char *getcwd(char *buf, size_t size)
{
- static com32sys_t reg;
- char *pwdstr, *ret;
-
- reg.eax.w[0] = 0x001f;
- __intcall(0x22, &reg, &reg);
- pwdstr = MK_PTR(reg.es, reg.ebx.w[0]);
- if ((strlen(pwdstr) < size) && (buf != NULL)) {
- strcpy(buf, pwdstr);
- ret = buf;
- } else {
- ret = NULL;
- errno = ERANGE;
- }
- return ret;
+ return __com32.cs_pm->getcwd(buf, size);
}
diff --git a/com32/lib/getopt.c b/com32/lib/getopt.c
index 5e9b7c63..806735d7 100644
--- a/com32/lib/getopt.c
+++ b/com32/lib/getopt.c
@@ -9,64 +9,89 @@
#include <string.h>
char *optarg;
-int optind = 1;
-int opterr, optopt;
-static const char *__optptr;
+int optind, opterr, optopt;
+static struct getopt_private_state {
+ const char *optptr;
+ const char *last_optstring;
+ char *const *last_argv;
+} pvt;
int getopt(int argc, char *const *argv, const char *optstring)
{
- const char *carg = argv[optind];
- const char *osptr;
- int opt;
+ const char *carg;
+ const char *osptr;
+ int opt;
- /* We don't actually need argc */
- (void)argc;
+ /* getopt() relies on a number of different global state
+ variables, which can make this really confusing if there is
+ more than one use of getopt() in the same program. This
+ attempts to detect that situation by detecting if the
+ "optstring" or "argv" argument have changed since last time
+ we were called; if so, reinitialize the query state. */
- /* First, eliminate all non-option cases */
-
- if (!carg || carg[0] != '-' || !carg[1]) {
- return -1;
- }
+ if (optstring != pvt.last_optstring || argv != pvt.last_argv ||
+ optind < 1 || optind > argc) {
+ /* optind doesn't match the current query */
+ pvt.last_optstring = optstring;
+ pvt.last_argv = argv;
+ optind = 1;
+ pvt.optptr = NULL;
+ }
- if (carg[1] == '-' && !carg[2]) {
- optind++;
- return -1;
- }
+ carg = argv[optind];
- if ((uintptr_t) (__optptr - carg) > (uintptr_t) strlen(carg))
- __optptr = carg + 1; /* Someone frobbed optind, change to new opt. */
+ /* First, eliminate all non-option cases */
- opt = *__optptr++;
+ if (!carg || carg[0] != '-' || !carg[1]) {
+ return -1;
+ }
- if (opt != ':' && (osptr = strchr(optstring, opt))) {
- if (osptr[1] == ':') {
- if (*__optptr) {
- /* Argument-taking option with attached argument */
- optarg = (char *)__optptr;
+ if (carg[1] == '-' && !carg[2]) {
optind++;
- } else {
- /* Argument-taking option with non-attached argument */
- if (argv[optind + 1]) {
- optarg = (char *)argv[optind + 1];
- optind += 2;
+ return -1;
+ }
+
+ if ((uintptr_t) (pvt.optptr - carg) > (uintptr_t) strlen(carg)) {
+ /* Someone frobbed optind, change to new opt. */
+ pvt.optptr = carg + 1;
+ }
+
+ opt = *pvt.optptr++;
+
+ if (opt != ':' && (osptr = strchr(optstring, opt))) {
+ if (osptr[1] == ':') {
+ if (*pvt.optptr) {
+ /* Argument-taking option with attached
+ argument */
+ optarg = (char *)pvt.optptr;
+ optind++;
+ } else {
+ /* Argument-taking option with non-attached
+ argument */
+ if (argv[optind + 1]) {
+ optarg = (char *)argv[optind+1];
+ optind += 2;
+ } else {
+ /* Missing argument */
+ optind++;
+ return (optstring[0] == ':')
+ ? ':' : '?';
+ }
+ }
+ return opt;
} else {
- /* Missing argument */
- return (optstring[0] == ':') ? ':' : '?';
+ /* Non-argument-taking option */
+ /* pvt.optptr will remember the exact position to
+ resume at */
+ if (!*pvt.optptr)
+ optind++;
+ return opt;
}
- }
- return opt;
} else {
- /* Non-argument-taking option */
- /* __optptr will remember the exact position to resume at */
- if (!*__optptr)
- optind++;
- return opt;
+ /* Unknown option */
+ optopt = opt;
+ if (!*pvt.optptr)
+ optind++;
+ return '?';
}
- } else {
- /* Unknown option */
- optopt = opt;
- if (!*__optptr)
- optind++;
- return '?';
- }
}
diff --git a/com32/lib/pci/scan.c b/com32/lib/pci/scan.c
index 65d80157..2577b321 100644
--- a/com32/lib/pci/scan.c
+++ b/com32/lib/pci/scan.c
@@ -676,28 +676,28 @@ int get_module_name_from_alias(struct pci_domain *domain, char *modules_alias_pa
/* Searching for the vendor separator*/
char *temp = strstr(result,"d");
if (temp != NULL) {
- strncpy(vendor_id,result,temp-result);
+ strlcpy(vendor_id,result,temp-result);
result+=strlen(vendor_id)+1;
}
/* Searching for the product separator*/
temp = strstr(result,"sv");
if (temp != NULL) {
- strncpy(product_id,result,temp-result);
+ strlcpy(product_id,result,temp-result);
result+=strlen(product_id)+1;
}
/* Searching for the sub vendor separator*/
temp = strstr(result,"sd");
if (temp != NULL) {
- strncpy(sub_vendor_id,result,temp-result);
+ strlcpy(sub_vendor_id,result,temp-result);
result+=strlen(sub_vendor_id)+1;
}
/* Searching for the sub product separator*/
temp = strstr(result,"bc");
if (temp != NULL) {
- strncpy(sub_product_id,result,temp-result);
+ strlcpy(sub_product_id,result,temp-result);
result+=strlen(sub_product_id)+1;
}
/* That's the module name */
diff --git a/com32/lib/sys/farcall.c b/com32/lib/sys/farcall.c
index 7d195f10..988ee6d2 100644
--- a/com32/lib/sys/farcall.c
+++ b/com32/lib/sys/farcall.c
@@ -4,8 +4,21 @@
#include <com32.h>
+static inline uint32_t eflags(void)
+{
+ uint32_t v;
+
+ asm volatile("pushfl ; popl %0" : "=rm" (v));
+ return v;
+}
+
void __farcall(uint16_t cs, uint16_t ip,
const com32sys_t * ireg, com32sys_t * oreg)
{
- __com32.cs_farcall((cs << 16) + ip, ireg, oreg);
+ com32sys_t xreg = *ireg;
+
+ /* Enable interrupts if and only if they are enabled in the caller */
+ xreg.eflags.l = (xreg.eflags.l & ~EFLAGS_IF) | (eflags() & EFLAGS_IF);
+
+ __com32.cs_farcall((cs << 16) + ip, &xreg, oreg);
}
diff --git a/com32/lib/sys/times.c b/com32/lib/sys/times.c
index 12ed671c..dd063f37 100644
--- a/com32/lib/sys/times.c
+++ b/com32/lib/sys/times.c
@@ -32,13 +32,11 @@
*/
#include <sys/times.h>
-#include <inttypes.h>
+#include <syslinux/pmapi.h>
#include <com32.h>
clock_t times(struct tms * buf)
{
- (void)buf; /* Ignored */
-
- /* Should we get this via INT 1Ah? */
- return *(uint16_t *) 0x46c;
+ (void)buf;
+ return *__com32.cs_pm->ms_timer;
}
diff --git a/com32/lib/sys/vesa/background.c b/com32/lib/sys/vesa/background.c
index 8d732395..93577461 100644
--- a/com32/lib/sys/vesa/background.c
+++ b/com32/lib/sys/vesa/background.c
@@ -34,6 +34,7 @@
#include <sys/stat.h>
#include <minmax.h>
#include <stdbool.h>
+#include <ilog2.h>
#include <syslinux/loadfile.h>
#include "vesa.h"
#include "video.h"
@@ -255,8 +256,7 @@ int vesacon_default_background(void)
z = max(__vesa_info.mi.v_res, __vesa_info.mi.h_res) >> 1;
z = ((z*z) >> 11) - 1;
- asm("bsrl %1,%0" : "=r" (shft) : "rm" (z));
- shft++;
+ shft = ilog2(z) + 1;
for (y = 0, dy = -(__vesa_info.mi.v_res >> 1);
y < __vesa_info.mi.v_res; y++, dy++) {
diff --git a/com32/lib/sys/vesa/screencpy.c b/com32/lib/sys/vesa/screencpy.c
index 9740ea14..32dce9e6 100644
--- a/com32/lib/sys/vesa/screencpy.c
+++ b/com32/lib/sys/vesa/screencpy.c
@@ -30,6 +30,7 @@
#include <klibc/compiler.h>
#include <string.h>
#include <com32.h>
+#include <ilog2.h>
#include "vesa.h"
#include "video.h"
@@ -41,12 +42,6 @@ static struct win_info {
int win_num;
} wi;
-static inline int __constfunc ilog2(unsigned int x)
-{
- asm("bsrl %1,%0" : "=r"(x) : "rm"(x));
- return x;
-}
-
void __vesacon_init_copy_to_screen(void)
{
struct vesa_mode_info *const mi = &__vesa_info.mi;
diff --git a/com32/lib/vdprintf.c b/com32/lib/vdprintf.c
index 330279b3..d74f2782 100644
--- a/com32/lib/vdprintf.c
+++ b/com32/lib/vdprintf.c
@@ -30,7 +30,12 @@ enum serial_port_regs {
MSR = 6,
SCR = 7,
};
-static const uint16_t debug_base = 0x03f8; /* I/O base address */
+
+#ifndef DEBUG_PORT
+# define DEBUG_PORT 0x03f8 /* I/O base address */
+#endif
+
+static const uint16_t debug_base = DEBUG_PORT;
static void debug_putc(char c)
{