aboutsummaryrefslogtreecommitdiffstats
path: root/com32
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2013-06-17 11:57:29 +0100
committerMatt Fleming <matt.fleming@intel.com>2013-06-17 11:57:29 +0100
commita0bb1928c8652aada30243089c53754ddd9b99df (patch)
tree5fd177bf495f80b51d323a7d7ebf76e8650e65c4 /com32
parent97bff28959e9deed6b78dd7df974797476683006 (diff)
parent022cdd1d56512e8759e8374c10a7420201db93c0 (diff)
downloadsyslinux-a0bb1928c8652aada30243089c53754ddd9b99df.tar.gz
syslinux-a0bb1928c8652aada30243089c53754ddd9b99df.tar.xz
syslinux-a0bb1928c8652aada30243089c53754ddd9b99df.zip
Merge tag 'syslinux-5.11-pre2' into firmware
syslinux-5.11-pre2 Conflicts: core/elflink/load_env32.c version
Diffstat (limited to 'com32')
-rw-r--r--com32/elflink/ldlinux/cli.c2
-rw-r--r--com32/elflink/ldlinux/readconfig.c85
-rw-r--r--com32/lib/sys/module/common.c36
-rw-r--r--com32/lib/syslinux/load_linux.c49
4 files changed, 96 insertions, 76 deletions
diff --git a/com32/elflink/ldlinux/cli.c b/com32/elflink/ldlinux/cli.c
index b85357b2..7c4f14c6 100644
--- a/com32/elflink/ldlinux/cli.c
+++ b/com32/elflink/ldlinux/cli.c
@@ -168,7 +168,7 @@ const char *edit_cmdline(const char *input, int top /*, int width */ ,
prev_len = max(len, prev_len);
/* Redraw the command line */
- printf("\033[?7l\033[?25l");
+ printf("\033[?25l");
printf("\033[1G%s ", input);
x = strlen(input);
diff --git a/com32/elflink/ldlinux/readconfig.c b/com32/elflink/ldlinux/readconfig.c
index 9d50c2f3..d6e34bda 100644
--- a/com32/elflink/ldlinux/readconfig.c
+++ b/com32/elflink/ldlinux/readconfig.c
@@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------- *
*
* Copyright 2004-2009 H. Peter Anvin - All Rights Reserved
- * Copyright 2009 Intel Corporation; author: H. Peter Anvin
+ * Copyright 2009-2013 Intel Corporation; author: H. Peter Anvin
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -759,7 +759,6 @@ static uint8_t SerialNotice = 1;
#define DEFAULT_BAUD 9600
#define BAUD_DIVISOR 115200
-#define serial_base 0x0400
extern void sirq_cleanup_nowipe(void);
extern void sirq_install(void);
@@ -771,6 +770,46 @@ extern void loadkeys(char *);
extern char syslinux_banner[];
extern char copyright_str[];
+/*
+ * PATH-based lookup
+ *
+ * Each entry in the PATH directive is separated by a colon, e.g.
+ *
+ * PATH /bar:/bin/foo:/baz/bar/bin
+ */
+static int parse_path(char *p)
+{
+ struct path_entry *entry;
+ const char *str;
+
+ while (*p) {
+ char *c = p;
+
+ /* Find the next directory */
+ while (*c && *c != ':')
+ c++;
+
+ str = refstrndup(p, c - p);
+ if (!str)
+ goto bail;
+
+ entry = path_add(str);
+ refstr_put(str);
+
+ if (!entry)
+ goto bail;
+
+ if (!*c++)
+ break;
+ p = c;
+ }
+
+ return 0;
+
+bail:
+ return -1;
+}
+
static void parse_config_file(FILE * f)
{
char line[MAX_LINE], *p, *ep, ch;
@@ -1185,16 +1224,9 @@ do_include:
refstr_put(filename);
} else if (looking_at(p, "kbdmap")) {
const char *filename;
- char *dst = KernelName;
- size_t len = FILENAME_MAX - 1;
-
- filename = refstrdup(skipspace(p + 4));
-
- while (len-- && not_whitespace(*filename))
- *dst++ = *filename++;
- *dst = '\0';
- loadkeys(KernelName);
+ filename = refstrdup(skipspace(p + 6));
+ loadkeys(filename);
refstr_put(filename);
}
/*
@@ -1280,16 +1312,7 @@ do_include:
baud &= 0xffff;
BaudDivisor = baud;
- /*
- * If port > 3 then port is I/O addr
- */
- if (port <= 3) {
- /* Get the I/O port from the BIOS */
- port <<= 1;
- port = *(volatile uint16_t *)serial_base;
- }
-
-
+ port = get_serial_port(port);
SerialPort = port;
/*
@@ -1347,24 +1370,8 @@ do_include:
} else if (looking_at(p, "say")) {
printf("%s\n", p+4);
} else if (looking_at(p, "path")) {
- /* PATH-based lookup */
- const char *new_path;
- char *_p;
- size_t len, new_len;
-
- new_path = refstrdup(skipspace(p + 4));
- len = strlen(PATH);
- new_len = strlen(new_path);
- _p = malloc(len + new_len + 2);
- if (_p) {
- strncpy(_p, PATH, len);
- _p[len++] = ':';
- strncpy(_p + len, new_path, new_len);
- _p[len + new_len] = '\0';
- free(PATH);
- PATH = _p;
- } else
- printf("Failed to realloc PATH\n");
+ if (parse_path(skipspace(p + 4)))
+ printf("Failed to parse PATH\n");
} else if (looking_at(p, "sendcookies")) {
const union syslinux_derivative_info *sdi;
diff --git a/com32/lib/sys/module/common.c b/com32/lib/sys/module/common.c
index 4c83789e..a589f24f 100644
--- a/com32/lib/sys/module/common.c
+++ b/com32/lib/sys/module/common.c
@@ -59,40 +59,28 @@ void print_elf_symbols(struct elf_module *module) {
FILE *findpath(char *name)
{
+ struct path_entry *entry;
char path[FILENAME_MAX];
FILE *f;
- char *p, *n;
- int i;
f = fopen(name, "rb"); /* for full path */
if (f)
return f;
- p = PATH;
-again:
- i = 0;
- while (*p && *p != ':' && i < FILENAME_MAX - 1) {
- path[i++] = *p++;
- }
-
- if (*p == ':')
- p++;
+ list_for_each_entry(entry, &PATH, list) {
+ bool slash = false;
- /* Ensure we have a '/' separator */
- if (path[i] != '/' && i < FILENAME_MAX - 1)
- path[i++] = '/';
+ /* Ensure we have a '/' separator */
+ if (entry->str[strlen(entry->str) - 1] != '/')
+ slash = true;
- n = name;
- while (*n && i < FILENAME_MAX - 1)
- path[i++] = *n++;
- path[i] = '\0';
+ snprintf(path, sizeof(path), "%s%s%s",
+ entry->str, slash ? "/" : "", name);
- f = fopen(path, "rb");
- if (f)
- return f;
-
- if (p >= PATH && p < PATH + strlen(PATH))
- goto again;
+ f = fopen(path, "rb");
+ if (f)
+ return f;
+ }
return NULL;
}
diff --git a/com32/lib/syslinux/load_linux.c b/com32/lib/syslinux/load_linux.c
index aea03058..f6e03f76 100644
--- a/com32/lib/syslinux/load_linux.c
+++ b/com32/lib/syslinux/load_linux.c
@@ -146,6 +146,7 @@ int bios_boot_linux(void *kernel_buf, size_t kernel_size,
cmdline_size = strlen(cmdline) + 1;
+ errno = EINVAL;
if (kernel_size < 2 * 512)
goto bail;
@@ -249,8 +250,10 @@ int bios_boot_linux(void *kernel_buf, size_t kernel_size,
/* Get the memory map */
mmap = syslinux_memory_map(); /* Memory map for shuffle_boot */
amap = syslinux_dup_memmap(mmap); /* Keep track of available memory */
- if (!mmap || !amap)
+ if (!mmap || !amap) {
+ errno = ENOMEM;
goto bail;
+ }
dprintf("Initial memory map:\n");
syslinux_dump_memmap(mmap);
@@ -260,8 +263,10 @@ int bios_boot_linux(void *kernel_buf, size_t kernel_size,
it's unavailable to the boot loader, which probably has already touched
some of it), or just in the amap? */
if (memlimit)
- if (syslinux_add_memmap(&amap, memlimit, -memlimit, SMT_RESERVED))
+ if (syslinux_add_memmap(&amap, memlimit, -memlimit, SMT_RESERVED)) {
+ errno = ENOMEM;
goto bail;
+ }
/* Place the kernel in memory */
@@ -342,18 +347,24 @@ int bios_boot_linux(void *kernel_buf, size_t kernel_size,
real_mode_size))
goto bail;
if (syslinux_add_memmap
- (&amap, real_mode_base, cmdline_offset + cmdline_size, SMT_ALLOC))
+ (&amap, real_mode_base, cmdline_offset + cmdline_size, SMT_ALLOC)) {
+ errno = ENOMEM;
goto bail;
+ }
/* Zero region between real mode code and cmdline */
if (syslinux_add_memmap(&mmap, real_mode_base + real_mode_size,
- cmdline_offset - real_mode_size, SMT_ZERO))
+ cmdline_offset - real_mode_size, SMT_ZERO)) {
+ errno = ENOMEM;
goto bail;
+ }
/* Command line */
if (syslinux_add_movelist(&fraglist, real_mode_base + cmdline_offset,
- (addr_t) cmdline, cmdline_size))
+ (addr_t) cmdline, cmdline_size)) {
+ errno = ENOMEM;
goto bail;
+ }
if (hdr.version >= 0x0202) {
whdr->cmd_line_ptr = real_mode_base + cmdline_offset;
} else {
@@ -369,11 +380,15 @@ int bios_boot_linux(void *kernel_buf, size_t kernel_size,
if (prot_mode_size) {
if (syslinux_add_movelist(&fraglist, prot_mode_base,
(addr_t) kernel_buf + real_mode_size,
- prot_mode_size))
+ prot_mode_size)) {
+ errno = ENOMEM;
goto bail;
+ }
if (syslinux_add_memmap(&amap, prot_mode_base, prot_mode_size,
- SMT_ALLOC))
+ SMT_ALLOC)) {
+ errno = ENOMEM;
goto bail;
+ }
}
/* Figure out the size of the initramfs, and where to put it.
@@ -399,11 +414,15 @@ int bios_boot_linux(void *kernel_buf, size_t kernel_size,
whdr->ramdisk_image = best_addr;
whdr->ramdisk_size = irf_size;
- if (syslinux_add_memmap(&amap, best_addr, irf_size, SMT_ALLOC))
+ if (syslinux_add_memmap(&amap, best_addr, irf_size, SMT_ALLOC)) {
+ errno = ENOMEM;
goto bail;
+ }
- if (map_initramfs(&fraglist, &mmap, initramfs, best_addr))
+ if (map_initramfs(&fraglist, &mmap, initramfs, best_addr)) {
+ errno = ENOMEM;
goto bail;
+ }
}
}
@@ -439,14 +458,20 @@ int bios_boot_linux(void *kernel_buf, size_t kernel_size,
*prev_ptr = best_addr;
prev_ptr = &sdp->hdr.next;
- if (syslinux_add_memmap(&amap, best_addr, size, SMT_ALLOC))
+ if (syslinux_add_memmap(&amap, best_addr, size, SMT_ALLOC)) {
+ errno = ENOMEM;
goto bail;
+ }
if (syslinux_add_movelist(&fraglist, best_addr,
- (addr_t)&sdp->hdr, sizeof sdp->hdr))
+ (addr_t)&sdp->hdr, sizeof sdp->hdr)) {
+ errno = ENOMEM;
goto bail;
+ }
if (syslinux_add_movelist(&fraglist, best_addr + sizeof sdp->hdr,
- (addr_t)sdp->data, sdp->hdr.len))
+ (addr_t)sdp->data, sdp->hdr.len)) {
+ errno = ENOMEM;
goto bail;
+ }
}
}