aboutsummaryrefslogtreecommitdiffstats
path: root/com32/elflink/ldlinux
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2012-07-11 13:12:33 +0100
committerMatt Fleming <matt.fleming@intel.com>2012-07-20 10:20:18 +0100
commitb93e6bc9bdafc9fa2dc8709dc97fa5e598c7e94d (patch)
tree27def756e27efd3f398f53d97ecfe2f80fb31ba8 /com32/elflink/ldlinux
parentc2d3f65790c15efed66e6ba3a6e4c08836070889 (diff)
downloadsyslinux-b93e6bc9bdafc9fa2dc8709dc97fa5e598c7e94d.tar.gz
syslinux-b93e6bc9bdafc9fa2dc8709dc97fa5e598c7e94d.tar.xz
syslinux-b93e6bc9bdafc9fa2dc8709dc97fa5e598c7e94d.zip
ldlinux: Stop using the internal KT_* image types
The KT_* image types were never meant to be used outside of com32/menu, so use the external image types from syslinux/boot.h Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Diffstat (limited to 'com32/elflink/ldlinux')
-rw-r--r--com32/elflink/ldlinux/chainboot.c5
-rw-r--r--com32/elflink/ldlinux/execute.c52
-rw-r--r--com32/elflink/ldlinux/ldlinux.c41
-rw-r--r--com32/elflink/ldlinux/readconfig.c16
4 files changed, 64 insertions, 50 deletions
diff --git a/com32/elflink/ldlinux/chainboot.c b/com32/elflink/ldlinux/chainboot.c
index c1efadfe..4a4a2e1a 100644
--- a/com32/elflink/ldlinux/chainboot.c
+++ b/com32/elflink/ldlinux/chainboot.c
@@ -30,11 +30,12 @@
#include "localboot.h"
#include "bios.h"
+#include <syslinux/boot.h>
#include <syslinux/bootrm.h>
#include <syslinux/movebits.h>
#include <syslinux/config.h>
-void chainboot_file(const char *file, enum kernel_type type)
+void chainboot_file(const char *file, uint32_t type)
{
uint8_t keeppxe = 0;
const union syslinux_derivative_info *sdi;
@@ -97,7 +98,7 @@ void chainboot_file(const char *file, enum kernel_type type)
* superblock.
*/
if (sdi->c.filesystem == SYSLINUX_FS_SYSLINUX &&
- type == KT_BSS && this_fs->fs_ops->copy_super(buf))
+ type == IMAGE_TYPE_BSS && this_fs->fs_ops->copy_super(buf))
goto bail;
if (sdi->c.filesystem == SYSLINUX_FS_PXELINUX) {
diff --git a/com32/elflink/ldlinux/execute.c b/com32/elflink/ldlinux/execute.c
index 5d128cbb..77d268c8 100644
--- a/com32/elflink/ldlinux/execute.c
+++ b/com32/elflink/ldlinux/execute.c
@@ -28,29 +28,28 @@
#include <syslinux/bootrm.h>
#include <syslinux/movebits.h>
#include <syslinux/config.h>
-
-/* Must match enum kernel_type */
-const char *const kernel_types[] = {
- "none",
- "localboot",
- "kernel",
- "linux",
- "boot",
- "bss",
- "pxe",
- "fdimage",
- "comboot",
- "com32",
- "config",
- NULL
+#include <syslinux/boot.h>
+
+const struct image_types image_boot_types[] = {
+ { "localboot", IMAGE_TYPE_LOCALBOOT },
+ { "kernel", IMAGE_TYPE_KERNEL },
+ { "linux", IMAGE_TYPE_LINUX },
+ { "boot", IMAGE_TYPE_BOOT },
+ { "bss", IMAGE_TYPE_BSS },
+ { "pxe", IMAGE_TYPE_PXE },
+ { "fdimage", IMAGE_TYPE_FDIMAGE },
+ { "comboot", IMAGE_TYPE_COMBOOT },
+ { "com32", IMAGE_TYPE_COM32 },
+ { "config", IMAGE_TYPE_CONFIG },
+ { NULL, 0 },
};
extern int create_args_and_load(char *);
-void execute(const char *cmdline, enum kernel_type type)
+void execute(const char *cmdline, uint32_t type)
{
- const char *p, *const *pp;
const char *kernel, *args;
+ const char *p;
com32sys_t ireg;
char *q;
@@ -79,22 +78,22 @@ void execute(const char *cmdline, enum kernel_type type)
dprintf("kernel is %s, args = %s type = %d \n", kernel, args, type);
- if (kernel[0] == '.' && type == KT_NONE) {
+ if (kernel[0] == '.') {
/* It might be a type specifier */
- enum kernel_type type = KT_NONE;
- for (pp = kernel_types; *pp; pp++, type++) {
- if (!strcmp(kernel + 1, *pp)) {
+ const struct image_types *t;
+ for (t = image_boot_types; t->name; t++) {
+ if (!strcmp(kernel + 1, t->name)) {
/* Strip the type specifier and retry */
- execute(p, type);
+ execute(p, t->type);
return;
}
}
}
- if (type == KT_COM32) {
+ if (type == IMAGE_TYPE_COM32) {
/* new entry for elf format c32 */
create_args_and_load((char *)cmdline);
- } else if (type == KT_CONFIG) {
+ } else if (type == IMAGE_TYPE_CONFIG) {
char *argv[] = { "ldlinux.c32", NULL };
/* kernel contains the config file name */
@@ -105,9 +104,10 @@ void execute(const char *cmdline, enum kernel_type type)
mangle_name(config_cwd, args);
start_ldlinux(argv);
- } else if (type == KT_LOCALBOOT) {
+ } else if (type == IMAGE_TYPE_LOCALBOOT) {
local_boot(strtoul(kernel, NULL, 0));
- } else if (type == KT_PXE || type == KT_BSS || type == KT_BOOT) {
+ } else if (type == IMAGE_TYPE_PXE || type == IMAGE_TYPE_BSS ||
+ type == IMAGE_TYPE_BOOT) {
chainboot_file(kernel, type);
} else {
/* Need add one item for kernel load, as we don't use
diff --git a/com32/elflink/ldlinux/ldlinux.c b/com32/elflink/ldlinux/ldlinux.c
index f56f2c06..8879d2a0 100644
--- a/com32/elflink/ldlinux/ldlinux.c
+++ b/com32/elflink/ldlinux/ldlinux.c
@@ -11,6 +11,7 @@
#include "menu.h"
#include "config.h"
#include "syslinux/adv.h"
+#include "syslinux/boot.h"
#include <sys/module.h>
@@ -20,15 +21,15 @@ struct file_ext {
};
static const struct file_ext file_extensions[] = {
- { ".com", KT_COMBOOT },
- { ".cbt", KT_COMBOOT },
- { ".c32", KT_COM32 },
- { ".img", KT_FDIMAGE },
- { ".bss", KT_BSS },
- { ".bin", KT_BOOT },
- { ".bs", KT_BOOT },
- { ".0", KT_PXE },
- { NULL, KT_NONE },
+ { ".com", IMAGE_TYPE_COMBOOT },
+ { ".cbt", IMAGE_TYPE_COMBOOT },
+ { ".c32", IMAGE_TYPE_COM32 },
+ { ".img", IMAGE_TYPE_FDIMAGE },
+ { ".bss", IMAGE_TYPE_BSS },
+ { ".bin", IMAGE_TYPE_BOOT },
+ { ".bs", IMAGE_TYPE_BOOT },
+ { ".0", IMAGE_TYPE_PXE },
+ { NULL, 0 },
};
/*
@@ -45,7 +46,7 @@ static inline const char *find_command(const char *str)
return p;
}
-enum kernel_type parse_kernel_type(const char *kernel)
+uint32_t parse_image_type(const char *kernel)
{
const struct file_ext *ext;
const char *p;
@@ -62,8 +63,8 @@ enum kernel_type parse_kernel_type(const char *kernel)
return ext->type;
}
- /* use KT_KERNEL as default */
- return KT_KERNEL;
+ /* use IMAGE_TYPE_KERNEL as default */
+ return IMAGE_TYPE_KERNEL;
}
/*
@@ -139,9 +140,9 @@ static const char *apply_extension(const char *kernel, const char *ext)
static void load_kernel(const char *command_line)
{
struct menu_entry *me;
- enum kernel_type type;
const char *cmdline;
const char *kernel;
+ uint32_t type;
kernel = strdup(command_line);
if (!kernel)
@@ -150,11 +151,7 @@ static void load_kernel(const char *command_line)
/* Virtual kernel? */
me = find_label(kernel);
if (me) {
- type = parse_kernel_type(me->cmdline);
-
- /* cmdline contains type specifier */
- if (me->cmdline[0] == '.')
- type = KT_NONE;
+ type = parse_image_type(me->cmdline);
execute(me->cmdline, type);
/* We shouldn't return */
@@ -170,8 +167,8 @@ static void load_kernel(const char *command_line)
*p = '\0';
}
- type = parse_kernel_type(kernel);
- if (type == KT_KERNEL) {
+ type = parse_image_type(kernel);
+ if (type == IMAGE_TYPE_KERNEL) {
const char *ext;
/*
@@ -189,7 +186,7 @@ static void load_kernel(const char *command_line)
free((void *)kernel);
kernel = k;
- type = parse_kernel_type(kernel);
+ type = parse_image_type(kernel);
}
}
@@ -204,7 +201,7 @@ bad_kernel:
*/
if (onerrorlen) {
rsprintf(&cmdline, "%s %s", onerror, default_cmd);
- execute(cmdline, KT_COM32);
+ execute(cmdline, IMAGE_TYPE_COM32);
}
}
diff --git a/com32/elflink/ldlinux/readconfig.c b/com32/elflink/ldlinux/readconfig.c
index 1a8434c3..1db397a1 100644
--- a/com32/elflink/ldlinux/readconfig.c
+++ b/com32/elflink/ldlinux/readconfig.c
@@ -52,6 +52,22 @@ const struct menu_parameter mparm[NPARAMS] = {
[P_HIDDEN_ROW] = {"hiddenrow", -2},
};
+/* Must match enum kernel_type */
+static const char *const kernel_types[] = {
+ "none",
+ "localboot",
+ "kernel",
+ "linux",
+ "boot",
+ "bss",
+ "pxe",
+ "fdimage",
+ "comboot",
+ "com32",
+ "config",
+ NULL
+};
+
short uappendlen = 0; //bytes in append= command
short ontimeoutlen = 0; //bytes in ontimeout command
short onerrorlen = 0; //bytes in onerror command