#include "config.h"
#endif
-#define _GNU_SOURCE
+#include <assert.h>
#include <errno.h>
#include <getopt.h>
#include <signal.h>
enum opt_value show_help;
const char *log_file;
enum opt_value reset_defaults;
- enum opt_value use_timeout;
enum opt_value show_version;
};
{"help", no_argument, NULL, 'h'},
{"log", required_argument, NULL, 'l'},
{"reset-defaults", no_argument, NULL, 'r'},
- {"timeout", no_argument, NULL, 't'},
{"version", no_argument, NULL, 'V'},
{ NULL, 0, NULL, 0},
};
- static const char short_options[] = "hl:trV";
+ static const char short_options[] = "hl:rV";
static const struct opts default_values = {
.log_file = "/var/log/petitboot/petitboot-nc.log",
};
case 'l':
opts->log_file = optarg;
break;
- case 't':
- opts->use_timeout = opt_yes;
- break;
case 'r':
opts->reset_defaults = opt_yes;
break;
}
/**
- * ps3_kexec_cb - The kexec callback.
+ * ps3_boot_cb - The kexec callback.
*
- * Writes config data to PS3 flash then calls pb_run_kexec().
+ * Writes config data to PS3 flash then calls pb_boot().
* Adds a video mode arg to the kernel command line if needed.
*/
-static int ps3_kexec_cb(struct cui *cui, struct cui_opt_data *cod)
+static int ps3_boot_cb(struct cui *cui, struct cui_opt_data *cod)
{
struct ps3_cui *ps3 = ps3_from_cui(cui);
int result;
int altered_args;
char *orig_args;
- pb_log("%s: %s\n", __func__, cod->name);
+ pb_debug("%s: %s\n", __func__, cod->name);
assert(ps3->cui->current == &ps3->cui->main->scr);
/* Add a default kernel video mode. */
- if (!cod->kd->args) {
+ if (!cod->bd->args) {
altered_args = 1;
orig_args = NULL;
- cod->kd->args = talloc_asprintf(NULL, "video=ps3fb:mode:%u",
+ cod->bd->args = talloc_asprintf(NULL, "video=ps3fb:mode:%u",
(unsigned int)ps3->values.video_mode);
- } else if (!strstr(cod->kd->args, "video=")) {
+ } else if (!strstr(cod->bd->args, "video=")) {
altered_args = 1;
- orig_args = cod->kd->args;
- cod->kd->args = talloc_asprintf(NULL, "%s video=ps3fb:mode:%u",
+ orig_args = cod->bd->args;
+ cod->bd->args = talloc_asprintf(NULL, "%s video=ps3fb:mode:%u",
orig_args, (unsigned int)ps3->values.video_mode);
} else
altered_args = 0;
- result = pb_run_kexec(cod->kd);
+ result = pb_boot(cod->bd, ps3->cui->dry_run);
if (altered_args) {
- talloc_free(cod->kd->args);
- cod->kd->args = orig_args;
+ talloc_free(cod->bd->args);
+ cod->bd->args = orig_args;
}
return result;
}
/**
- * ps3_svm_to_mm_helper - The svm ESC callback.
+ * ps3_svm_to_mm_helper - The svm exit callback.
*/
static void ps3_svm_to_mm_helper(struct pmenu *menu)
return c;
}
-/**
- * ps3_timer_update - Timer callback.
- */
-
-static void ps3_timer_update(struct ui_timer *timer, unsigned int timeout)
-{
- struct ps3_cui *ps3 = ps3_from_cui(cui_from_timer(timer));
-
- //FIXME: make scr:timer.
- // nc_scr_timer_update(&ps3.mm->scr, timeout);
-
- nc_scr_status_printf(&ps3->mm->scr,
- "Welcome to Petitboot (timeout %u sec)", timeout);
-}
-
/**
* ps3_mm_init - Setup the main menu instance.
*/
}
m->hot_key = ps3_hot_key;
- m->on_open = cui_on_open;
+ m->on_new = cui_item_new;
#if defined(DEBUG)
m->scr.frame.title = talloc_strdup(m,
m->scr.frame.title = talloc_strdup(m, "Petitboot PS3");
#endif
m->scr.frame.help = talloc_strdup(m,
- "ESC=exit, Enter=accept, e=edit, o=open");
+ "Enter=accept, e=edit, o=open, x=exit");
m->scr.frame.status = talloc_strdup(m, "Welcome to Petitboot");
i = pmenu_item_init(m, 0, "Boot GameOS");
m->hot_key = ps3_hot_key;
m->scr.frame.title = talloc_strdup(m, "Select PS3 Video Mode");
- m->scr.frame.help = talloc_strdup(m, "ESC=exit, Enter=accept");
+ m->scr.frame.help = talloc_strdup(m, "Enter=accept, x=exit");
i = pmenu_item_init(m, 0, "auto detect");
i->on_execute = ps3_svm_cb;
DBGS("%d\n", signum);
switch (signum) {
- case SIGALRM:
- if (ps3.cui)
- ui_timer_sigalrm(&ps3.cui->timer);
- break;
case SIGWINCH:
if (ps3.cui)
cui_resize(ps3.cui);
int result;
int cui_result;
unsigned int mode;
- FILE *log;
result = opts_parse(&opts, argc, argv);
return EXIT_SUCCESS;
}
- log = fopen(opts.log_file, "a");
- assert(log);
- pb_log_set_stream(log);
+ if (strcmp(opts.log_file, "-")) {
+ FILE *log = fopen(opts.log_file, "a");
+
+ assert(log);
+ pb_log_set_stream(log);
+ } else
+ pb_log_set_stream(stderr);
#if defined(DEBUG)
pb_log_always_flush(1);
if (!result && (ps3.values.video_mode != (uint16_t)mode))
ps3_set_video_mode(ps3.values.video_mode);
- ps3.cui = cui_init(&ps3, ps3_kexec_cb, ps3_sixaxis_map);
+ ps3.cui = cui_init(&ps3, ps3_boot_cb, ps3_sixaxis_map);
if (!ps3.cui)
return EXIT_FAILURE;
ps3.mm = ps3_mm_init(&ps3);
ps3.svm = ps3_svm_init(&ps3);
- if (opts.use_timeout != opt_yes
- || ps3.values.timeout == ps3_timeout_forever)
- ui_timer_disable(&ps3.cui->timer);
- else {
- ps3.cui->timer.update_display = ps3_timer_update;
- ui_timer_init(&ps3.cui->timer, ps3.values.timeout);
- }
-
cui_result = cui_run(ps3.cui, ps3.mm, ps3.values.default_item);
pmenu_delete(ps3.mm);