buildrom. only set up for olpc right now.
[buildrom.git] / buildrom-devel / buildrom / packages / kexec-boot-loader / kexec-only.patch
blob6e1258c61f8055e64943c69b07c045247a5ca631
1 Index: kexec-boot-loader.old/Makefile
2 ===================================================================
3 --- kexec-boot-loader.old.orig/Makefile 2006-05-31 10:52:30.000000000 -0600
4 +++ kexec-boot-loader.old/Makefile 2006-07-24 17:36:40.000000000 -0600
5 @@ -11,7 +11,7 @@
7 UCLIBCLIBS = $(UCLIBCPATH)/usr/lib/crt1.o $(UCLIBCPATH)/usr/lib/libc.a
9 -FILES = main.o mount.o ui.o nand.o usb.o $(KEXEC_FILES)
10 +FILES = main.o $(KEXEC_FILES)
12 olpc-boot-loader: $(FILES)
13 $(CC) -Xlinker $(LDFLAGS) -nostdlib -o $@ $(FILES) $(UCLIBCLIBS)
14 Index: kexec-boot-loader.old/main.c
15 ===================================================================
16 --- kexec-boot-loader.old.orig/main.c 2006-05-31 14:45:18.000000000 -0600
17 +++ kexec-boot-loader.old/main.c 2006-07-24 17:37:05.000000000 -0600
18 @@ -1,67 +1,49 @@
19 #include <stdio.h>
20 #include <sys/mount.h>
21 +#include <sys/stat.h>
22 +#include <fcntl.h>
23 +#include <unistd.h>
24 #include <errno.h>
25 #include "ui.h"
26 #include "mount.h"
29 -static char def_kernel_file[] = "bzImage";
30 -char *kernel_file = def_kernel_file;
32 -static char def_kernel_cmdline[] = "root=/dev/ram rw";
33 -char *kernel_cmdline = def_kernel_cmdline;
35 -char *initrd_file = NULL;
37 -char mntpoint[] = "/mntpoint";
39 -int mount_proc(void)
41 - return do_mount(0, "/proc", "proc");
42 +void no(char *err, char *what) {
43 + print("no %s, %s\n", err, what);
44 + exit(1);
47 -int main (void)
48 +int stat_file(char *file)
50 - int ret;
51 + struct stat st;
52 + int ret, saved_errno;
54 - print("Kexec boot loader\n\n");
55 + ret = stat(file, &st);
56 + if (ret) {
57 + saved_errno = errno;
58 + print("failure to stat file at %s - errno=%d\n",
59 + file, saved_errno);
60 + }
61 + return ret;
64 - mount_proc();
66 - create_mountpath(mntpoint);
67 +int main (int argc, char *argv[])
69 + int ret;
71 - do {
72 - ret = startup();
73 - } while (1);
74 + char *kernel = argv[1], *cmd = argv[2], *init = argv[3];
76 - /* never return, we only get outside of this by booting
77 - * another kernel.
78 - */
80 + printf("argc is %d, argv[1] %s, argv[2] %s, argv[3] %s\n", argc, argv[1], argv[2], argv[3]);
82 -int startup(void)
84 - int opt;
85 - char c;
86 + if (stat_file(kernel))
87 + no("kernel", kernel);
89 - print("Select option:\n");
90 + ret = my_load(cmd, kernel, init);
91 + if (ret)
92 + no("load", "failed");
94 - print("1 - boot from NAND flash (JFFS2)\n");
95 - print("2 - boot from USB device (EXT2)\n");
96 + ret = my_exec();
97 + if (ret)
98 + no("exec", "failed");
100 - scanf("%1d", &opt);
102 - select_options();
104 - switch(opt) {
105 - case 1:
106 - return load_exec_nand_image(kernel_file, kernel_cmdline,
107 - initrd_file);
108 - case 2:
109 - return load_exec_usb_image(kernel_file, kernel_cmdline,
110 - initrd_file);
111 - default:
112 - print("unsupported option!\n");
113 - return 1;