Hi, here's a first (draft) implementation for having multiple LinuxBIOS payloads in one image, which will be executed one after the other.
This is part of my GЅoC project work; it's needed for lbmenu, the LinuxBIOS runtime config tool. More details in the patch. Uwe. -- http://www.hermann-uwe.de | http://www.holsham-traders.de http://www.crazy-hacks.org | http://www.unmaintained-free-software.org
Add (draft) support for multiple LinuxBIOS payloads.
The current implementation has the following limitations:
- Payload files must be named 'payload[0-9]', i.e. payload0, payload1, etc.
Actually, you can specify the prefix (e.g. 'payload') via Kconfig.
- All payload files must be in the same target directory (which can be
specified via Kconfig).
- The maximum number of payloads is 10 (arbitrary limit, could be more).
- The payloads are executed in order, i.e. first payload0 is executed.
When that is done and returns control to LinuxBIOS, payload1 is
executed next, then payload2 etc. etc.
If any of the payloads does not return, well, control will never be
returned to LinuxBIOS and thus all other payloads will never be executed.
This patch is required for lbmenu, the LinuxBIOS runtime config menu.
Usually you would make lbmenu the first payload. Then lbmenu will be
invoked, it'll wait a few seconds for you to press a certain key (e.g. ESC)
and then enter the actual LinuxBIOS runtime config menu.
When quitting lbmenu (or when the timeout expires), control will be returned
to LinuxBIOS which will then execute the "next" payload, which can be GRUB2
or FILO or some other payload which does the "real" work...
Signed-off-by: Uwe Hermann <[EMAIL PROTECTED]>
Index: Kconfig
===================================================================
--- Kconfig (Revision 468)
+++ Kconfig (Arbeitskopie)
@@ -95,33 +95,60 @@
default PAYLOAD_NONE
config PAYLOAD_ELF
- bool "An ELF executable payload file"
+ bool "One or more ELF executable payload file(s)"
help
- Select this option if you have a payload image (an ELF file)
+ Select this option if you have one or more payload images (ELF files)
which LinuxBIOS should run as soon as the basic hardware
initialization is completed.
- You will be able to specify the location and file name of the
- payload image later.
+ You will be able to specify the location and base filenames of the
+ payload images later.
config PAYLOAD_NONE
- bool "No payload"
+ bool "No payloads"
help
Select this option if you want to create an "empty" LinuxBIOS
ROM image for a certain mainboard, i.e. a LinuxBIOS ROM image
- which does not yet contain a payload.
+ which does not yet contain any payloads.
For such an image to be useful, you have to use the 'lar' tool
- to add a payload to the ROM image later.
+ to add one or more payloads to the ROM image later.
endchoice
-config PAYLOAD_FILE
- string "Payload path and filename"
+config PAYLOAD_DIRECTORY
+ string "Payload directory"
depends PAYLOAD_ELF
- default "payload.elf"
+ default "."
help
- The path and filename of the ELF executable file to use as payload.
+ The location (directory) where the LinuxBIOS build process
+ shall find the payload files you want to use.
+ Do _not_ add any trailing slash to the path/directory.
+
+ The default location is the current directory.
+
+config PAYLOAD_BASE_FILENAME
+ string "Payload base filename"
+ depends PAYLOAD_ELF
+ default "payload"
+ help
+ The base filename of the ELF executable file(s) to use as payloads.
+
+ A LinuxBIOS image can contain multiple payloads which are
+ executed one after the other. If the first payload has quit,
+ control is returned to LinuxBIOS, which will run the next payload.
+
+ The payload name determines the order in which payloads are
+ executed. Say the payload base name is 'payload', then the
+ LinuxBIOS build process will add all files starting with payload
+ to the resulting LinuxBIOS image, e.g. payload0, payload1, etc.
+
+ When run, LinuxBIOS will first execute payload0, then payload1,
+ and so on.
+
+ If one of the payloads never quits, LinuxBIOS will never gain
+ control again and cannot run the remaining payloads.
+
endmenu
Index: arch/x86/stage1.c
===================================================================
--- arch/x86/stage1.c (Revision 468)
+++ arch/x86/stage1.c (Arbeitskopie)
@@ -27,6 +27,8 @@
#include <mc146818rtc.h>
#include <post_code.h>
+#include <string.h>
+
#define UNCOMPRESS_AREA 0x60000
/* these prototypes should go into headers */
@@ -54,9 +56,10 @@
*/
void __attribute__((stdcall)) stage1_main(u32 bist)
{
- int ret;
+ int i, ret;
struct mem_file archive, result;
int elfboot_mem(struct lb_memory *mem, void *where, int size);
+ char filename[40];
/* we can't statically init this hack. */
unsigned char faker[64];
@@ -143,22 +146,22 @@
printk(BIOS_DEBUG, "Stage2 code done.\n");
- ret = find_file(&archive, "normal/payload", &result);
- if (ret) {
- printk(BIOS_ERR, "No such file '%s'.\n", "normal/payload");
- die("FATAL: No payload found.\n");
- }
- ret = copy_file(&archive, "normal/payload", (void *)UNCOMPRESS_AREA);
- if (ret) {
- printk(BIOS_ERR, "'%s' found, but could not load it.\n", "normal/payload");
- die("FATAL: No usable payload found.\n");
- }
+ #define MAX_PAYLOADS 10
+ for (i = 0; i < MAX_PAYLOADS; i++) {
+ sprintf((char *)&filename, "normal/payload%d", i);
- ret = elfboot_mem(mem, (void *)UNCOMPRESS_AREA, result.reallen);
+ ret = find_file(&archive, filename, &result);
+ if (ret)
+ printk(BIOS_DEBUG, "Payload '%s' not found. Skipping.\n", filename);
- printk(BIOS_ERR, "elfboot_mem returns %d\n", ret);
+ ret = copy_file(&archive, filename, (void *)UNCOMPRESS_AREA);
+ if (ret)
+ printk(BIOS_DEBUG, "Payload '%s' found, but could not be loaded. Skipping.\n", filename);
- die ("FATAL: Last stage returned to LinuxBIOS.\n");
+ ret = elfboot_mem(mem, (void *)UNCOMPRESS_AREA, result.reallen);
+ printk(BIOS_DEBUG, "Payload '%s' returned with status %d\n",
+ filename, ret);
+ }
+
+ die ("FATAL: Last payload returned to LinuxBIOS.\n");
}
-
-
Index: arch/x86/Makefile
===================================================================
--- arch/x86/Makefile (Revision 468)
+++ arch/x86/Makefile (Arbeitskopie)
@@ -38,7 +38,7 @@
LARFILES := nocompress:normal/initram normal/stage2 nocompress:normal/option_table
ifneq ($(CONFIG_PAYLOAD_NONE),y)
-LARFILES += normal/payload
+LARFILES += normal/payload[0-9]
endif
DECOMPRESSORS :=
@@ -67,14 +67,8 @@
ifeq ($(CONFIG_PAYLOAD_NONE),y)
$(Q)printf " PAYLOAD none (as specified by user)\n"
else
- $(Q)# TODO: Print sth. other than $(CONFIG_PAYLOAD_FILE) if compressed.
- $(Q)if [ -r $(CONFIG_PAYLOAD_FILE) ]; then \
- printf " PAYLOAD $(CONFIG_PAYLOAD_FILE)\n"; \
- cp $(CONFIG_PAYLOAD_FILE) $(obj)/lar.tmp/normal/payload; \
- else \
- printf "Error: payload file '$(CONFIG_PAYLOAD_FILE)' not found.\n"; \
- exit 1; \
- fi
+ $(Q)printf " PAYLOAD $(CONFIG_PAYLOAD_DIRECTORY)/$(CONFIG_PAYLOAD_BASE_FILENAME)*\n"
+ $(Q)cp $(CONFIG_PAYLOAD_DIRECTORY)/$(CONFIG_PAYLOAD_BASE_FILENAME)[0-9] $(obj)/lar.tmp/normal;
endif
$(Q)printf " LAR $(subst $(shell pwd)/,,$(@))\n"
$(Q)cd $(obj)/lar.tmp && ../util/lar/lar $(COMPRESSFLAG) -c \
signature.asc
Description: Digital signature
-- linuxbios mailing list [email protected] http://www.linuxbios.org/mailman/listinfo/linuxbios
