2 * qi-bootmenu - A kexec based bootloader with an elementary based GUI
4 * Copyright (c) 2009-2010 Marc Andre Tanner <mat@brain-dump.org>
6 * qi-bootmenu shares the basic idea with kexecboot which is written by:
8 * Copyright (c) 2008-2009 Yuri Bushmelev <jay4mail@gmail.com>
9 * Copyright (c) 2008 Thomas Kunze <thommycheck@gmx.de>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2, or (at your option)
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
29 #include <Ecore_Evas.h>
31 #define countof(arr) (sizeof(arr) / sizeof((arr)[0]))
32 #define sstrlen(str) (sizeof(str) - 1)
34 static void eprint(const char *errstr
, ...);
37 #define debug(format, args...)
42 #define RGB(r, g, b) r,g,b
55 void(*callback
)(void*, Evas
*, Evas_Object
*, void *);
60 static void boot_nand(void *data
, Evas
*evas
, Evas_Object
*obj
, void *event
);
61 static void poweroff(void *data
, Evas
*evas
, Evas_Object
*obj
, void *event
);
63 /* drawing related stuff */
64 static Ecore_Evas
*ee
;
69 void(*show
)(Eina_List
*systems
);
70 void(*select
)(Evas_Object
*item
);
71 void(*deselect
)(Evas_Object
*item
);
72 void(*error
)(const char *errstr
, va_list ap
);
75 /* functions available to gui modules */
76 static void gui_bootitem_clicked(void *data
, Evas
*evas
, Evas_Object
*item
, void *event
);
77 static void gui_show_error(const char *errstr
, ...);
81 /* will be used to search the kernel as in {u,z}Image-$MACHINE.bin */
82 static const char *machine
= DEFAULT_MACHINE
;
84 /* if no option is passed in then use the first entry */
85 static Gui
*gui
= &guis
[0];
90 static void eprint(const char *errstr
, ...) {
93 vfprintf(stderr
, errstr
, ap
);
98 eprint("usage: qi-bootmenu [-d] [-m ...] [-i ...]\n");
102 int main(int argc
, char **argv
) {
104 Eina_List
*dev_ignore
= NULL
; /* partitions to ignore */
112 for (arg
= 1; arg
< argc
; arg
++) {
113 if (argv
[arg
][0] != '-')
116 switch (argv
[arg
][1]) {
123 machine
= argv
[++arg
];
128 dev_ignore
= eina_list_append(dev_ignore
, argv
[++arg
]);
131 for (g
= 0; g
< countof(guis
); g
++) {
132 if (argv
[arg
][1] == guis
[g
].option
)
141 diagnostics(dev_ignore
);
146 eprint("Couldn't init GUI\n");
150 /* search for system images to boot and display them */
151 gui
->show(scan_system(dev_ignore
));
153 debug("entering main loop\n");
155 ecore_main_loop_begin();