ldlinux: Add localboot support
authorMatt Fleming <matt.fleming@linux.intel.com>
Tue, 24 May 2011 10:54:10 +0000 (11:54 +0100)
committerMatt Fleming <matt.fleming@linux.intel.com>
Tue, 24 May 2011 11:01:08 +0000 (12:01 +0100)
Add a few tweaks to enable ldlinux to localboot a hard disk. Most of
the support was already there, there were just a few bug fixes in
execute().

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
com32/elflink/ldlinux/execute.c
com32/elflink/ldlinux/ldlinux.c

index a00a5b1..635e327 100644 (file)
@@ -134,7 +134,7 @@ void execute(const char *cmdline, enum kernel_type type)
                argv[argc] = NULL;
                module_load_dependencies(kernel, "modules.dep");
                spawn_load(kernel, argc, argv);
-       } else if (type <= KT_KERNEL) {
+       } else if (type == KT_KERNEL) {
                /* Need add one item for kernel load, as we don't use
                * the assembly runkernel.inc any more */
                new_linux_kernel(kernel, cmdline);
@@ -148,14 +148,15 @@ void execute(const char *cmdline, enum kernel_type type)
                if (type == KT_LOCALBOOT) {
                        ireg.eax.w[0] = 0x0014; /* Local boot */
                        ireg.edx.w[0] = strtoul(kernel, NULL, 0);
+               } else {
+                       ireg.eax.w[0] = 0x0016; /* Run kernel image */
+                       ireg.esi.w[0] = OFFS(kernel);
+                       ireg.ds = SEG(kernel);
+                       ireg.ebx.w[0] = OFFS(args);
+                       ireg.es = SEG(args);
+                       ireg.edx.l = type - KT_KERNEL;
+                       /* ireg.ecx.l    = 0; *//* We do ipappend "manually" */
                }
-               ireg.eax.w[0] = 0x0016; /* Run kernel image */
-               ireg.esi.w[0] = OFFS(kernel);
-               ireg.ds = SEG(kernel);
-               ireg.ebx.w[0] = OFFS(args);
-               ireg.es = SEG(args);
-               ireg.edx.l = type - KT_KERNEL;
-               /* ireg.ecx.l    = 0; *//* We do ipappend "manually" */
 
                __intcall(0x22, &ireg, NULL);
        }
index 9ba1aeb..67f38c0 100644 (file)
@@ -27,8 +27,13 @@ static void load_kernel(const char *kernel)
        /* Virtual kernel? */
        me = find_label(kernel);
        if (me) {
-               /* XXX we don't handle LOCALBOOT yet */
-               execute(me->cmdline, KT_KERNEL);
+               enum kernel_type type = KT_KERNEL;
+
+               /* cmdline contains type specifier */
+               if (me->cmdline[0] == '.')
+                       type = KT_NONE;
+
+               execute(me->cmdline, type);
                /* We shouldn't return */
                goto bad_kernel;
        }