unsetenv("boot_initrd");
unsetenv("boot_dtb");
unsetenv("boot_args");
- unsetenv("boot_tty");
+ unsetenv("boot_console");
setenv("boot_image", task->local_image, 1);
if (task->local_initrd)
setenv("boot_dtb", task->local_dtb, 1);
if (task->args)
setenv("boot_args", task->args, 1);
- if (task->boot_tty)
- setenv("boot_tty", task->boot_tty, 1);
+ if (task->boot_console)
+ setenv("boot_console", task->boot_console, 1);
}
static int hook_filter(const struct dirent *dirent)
boot_task->args = NULL;
}
- if (cmd && cmd->tty)
- boot_task->boot_tty = talloc_strdup(boot_task, cmd->tty);
+ if (cmd && cmd->console)
+ boot_task->boot_console = talloc_strdup(boot_task, cmd->console);
else {
config = config_get();
- boot_task->boot_tty = config ? config->boot_tty : NULL;
+ boot_task->boot_console = config ? config->boot_console : NULL;
}
if (boot_task->verify_signature || boot_task->decrypt_files) {
char *local_initrd_override;
char *local_dtb_override;
const char *args;
- const char *boot_tty;
+ const char *boot_console;
boot_status_fn status_fn;
void *status_arg;
bool dry_run;
val = get_param(platform, "petitboot,tty");
if (val)
- config->boot_tty = talloc_strdup(config, val);
+ config->boot_console = talloc_strdup(config, val);
}
static char *iface_config_str(void *ctx, struct interface_config *config)
val = config->allow_writes ? "true" : "false";
update_string_config(platform, "petitboot,write?", val);
- val = config->boot_tty ?: "";
+ val = config->boot_console ?: "";
update_string_config(platform, "petitboot,tty", val);
update_network_config(platform, config);
struct stat sbuf;
char *fsp_prop = NULL;
- config->n_tty = 2;
- config->tty_list = talloc_array(config, char *, config->n_tty);
- if (!config->tty_list)
+ config->n_consoles = 2;
+ config->consoles = talloc_array(config, char *, config->n_consoles);
+ if (!config->consoles)
goto err;
- config->tty_list[0] = talloc_asprintf(config->tty_list,
+ config->consoles[0] = talloc_asprintf(config->consoles,
"/dev/hvc0 [IPMI / Serial]");
- config->tty_list[1] = talloc_asprintf(config->tty_list,
+ config->consoles[1] = talloc_asprintf(config->consoles,
"/dev/tty1 [VGA]");
fsp_prop = talloc_asprintf(config, "%sfsps", devtree_dir);
if (stat(fsp_prop, &sbuf) == 0) {
/* FSP based machines also have a separate serial console */
- config->tty_list = talloc_realloc(config, config->tty_list,
- char *, config->n_tty + 1);
- if (!config->tty_list)
+ config->consoles = talloc_realloc(config, config->consoles,
+ char *, config->n_consoles + 1);
+ if (!config->consoles)
goto err;
- config->tty_list[config->n_tty++] = talloc_asprintf(
- config->tty_list,
+ config->consoles[config->n_consoles++] = talloc_asprintf(
+ config->consoles,
"/dev/hvc1 [Serial]");
}
return;
err:
- config->n_tty = 0;
- pb_log("Failed to allocate memory for tty_list\n");
+ config->n_consoles = 0;
+ pb_log("Failed to allocate memory for consoles\n");
}
static int load_config(struct platform *p, struct config *config)
config->allow_writes ? "yes" : "no");
pb_log(" Default UI to boot on: %s\n",
- config->boot_tty ?: "none set");
+ config->boot_console ?: "none set");
pb_log(" language: %s\n", config->lang ?: "");
config->allow_writes = true;
config->disable_snapshots = false;
- config->n_tty = 0;
- config->tty_list = NULL;
- config->boot_tty = NULL;
+ config->n_consoles = 0;
+ config->consoles = NULL;
+ config->boot_console = NULL;
config->n_autoboot_opts = 2;
config->autoboot_opts = talloc_array(config, struct autoboot_option,
dest->allow_writes = src->allow_writes;
- dest->n_tty = src->n_tty;
- if (src->tty_list)
- dest->tty_list = talloc_array(dest, char *, src->n_tty);
- for (i = 0; i < src->n_tty && src->n_tty; i++)
- dest->tty_list[i] = talloc_strdup(dest->tty_list,
- src->tty_list[i]);
-
- if (src->boot_tty)
- dest->boot_tty = talloc_strdup(dest, src->boot_tty);
+ dest->n_consoles = src->n_consoles;
+ if (src->consoles)
+ dest->consoles = talloc_array(dest, char *, src->n_consoles);
+ for (i = 0; i < src->n_consoles && src->n_consoles; i++)
+ dest->consoles[i] = talloc_strdup(dest->consoles,
+ src->consoles[i]);
+
+ if (src->boot_console)
+ dest->boot_console = talloc_strdup(dest, src->boot_console);
if (src->lang && strlen(src->lang))
dest->lang = talloc_strdup(dest, src->lang);
4 + optional_strlen(boot->dtb_file) +
4 + optional_strlen(boot->boot_args) +
4 + optional_strlen(boot->args_sig_file) +
- 4 + optional_strlen(boot->tty);
+ 4 + optional_strlen(boot->console);
}
int pb_protocol_boot_status_len(const struct boot_status *status)
len += 4; /* allow_writes */
- len += 4; /* n_tty */
- for (i = 0; i < config->n_tty; i++)
- len += 4 + optional_strlen(config->tty_list[i]);
+ len += 4; /* n_consoles */
+ for (i = 0; i < config->n_consoles; i++)
+ len += 4 + optional_strlen(config->consoles[i]);
- len += 4 + optional_strlen(config->boot_tty);
+ len += 4 + optional_strlen(config->boot_console);
len += 4 + optional_strlen(config->lang);
pos += pb_protocol_serialise_string(pos, boot->dtb_file);
pos += pb_protocol_serialise_string(pos, boot->boot_args);
pos += pb_protocol_serialise_string(pos, boot->args_sig_file);
- pos += pb_protocol_serialise_string(pos, boot->tty);
+ pos += pb_protocol_serialise_string(pos, boot->console);
assert(pos <= buf + buf_len);
(void)buf_len;
*(uint32_t *)pos = config->allow_writes;
pos += 4;
- *(uint32_t *)pos = __cpu_to_be32(config->n_tty);
+ *(uint32_t *)pos = __cpu_to_be32(config->n_consoles);
pos += 4;
- for (i = 0; i < config->n_tty; i++)
- pos += pb_protocol_serialise_string(pos, config->tty_list[i]);
+ for (i = 0; i < config->n_consoles; i++)
+ pos += pb_protocol_serialise_string(pos, config->consoles[i]);
- pos += pb_protocol_serialise_string(pos, config->boot_tty);
+ pos += pb_protocol_serialise_string(pos, config->boot_console);
pos += pb_protocol_serialise_string(pos, config->lang);
if (read_string(cmd, &pos, &len, &cmd->args_sig_file))
goto out;
- if (read_string(cmd, &pos, &len, &cmd->tty))
+ if (read_string(cmd, &pos, &len, &cmd->console))
goto out;
rc = 0;
goto out;
config->allow_writes = !!tmp;
- if (read_u32(&pos, &len, &config->n_tty))
+ if (read_u32(&pos, &len, &config->n_consoles))
goto out;
- config->tty_list = talloc_array(config, char *, config->n_tty);
- for (i = 0; i < config->n_tty; i++) {
- if (read_string(config->tty_list, &pos, &len, &str))
+ config->consoles = talloc_array(config, char *, config->n_consoles);
+ for (i = 0; i < config->n_consoles; i++) {
+ if (read_string(config->consoles, &pos, &len, &str))
goto out;
- config->tty_list[i] = str;
+ config->consoles[i] = str;
}
if (read_string(config, &pos, &len, &str))
goto out;
- config->boot_tty = str;
+ config->boot_console = str;
if (read_string(config, &pos, &len, &str))
goto out;
char *dtb_file;
char *boot_args;
char *args_sig_file;
- char *tty;
+ char *console;
};
struct boot_status {
bool allow_writes;
- char *boot_tty;
+ char *boot_console;
char *lang;
/* not user-settable */
- unsigned int n_tty;
- char **tty_list;
+ unsigned int n_consoles;
+ char **consoles;
bool disable_snapshots;
bool safe_mode;
bool debug;
command->dtb_file = data->dtb;
command->boot_args = data->args;
command->args_sig_file = data->args_sig_file;
- command->tty = ttyname(STDIN_FILENO);
+ command->console = ttyname(STDIN_FILENO);
}
int discover_client_boot(struct discover_client *client,
#include "nc-config.h"
#include "nc-widgets.h"
-#define N_FIELDS 43
+#define N_FIELDS 44
extern struct help_text config_help_text;
struct nc_widget_label *allow_write_l;
struct nc_widget_select *allow_write_f;
- struct nc_widget_label *boot_tty_l;
- struct nc_widget_select *boot_tty_f;
- struct nc_widget_label *current_tty_l;
+ struct nc_widget_label *boot_console_l;
+ struct nc_widget_select *boot_console_f;
+ struct nc_widget_label *current_console_l;
struct nc_widget_label *net_override_l;
struct nc_widget_label *safe_mode;
bool allow_write, autoboot;
char *str, *end;
struct config *config;
- int i, n_boot_opts, rc, idx;
- unsigned int *order, tty;
+ int i, n_boot_opts, rc;
+ unsigned int *order, idx;
char mac[20];
config = config_copy(screen, screen->cui->config);
if (allow_write != config->allow_writes)
config->allow_writes = allow_write;
- if (config->n_tty) {
- tty = widget_select_get_value(screen->widgets.boot_tty_f);
- if (!config->boot_tty) {
- config->boot_tty = talloc_strdup(config,
- config->tty_list[tty]);
- } else if (strncmp(config->boot_tty, config->tty_list[tty],
- strlen(config->boot_tty)) != 0) {
- talloc_free(config->boot_tty);
- config->boot_tty = talloc_strdup(config,
- config->tty_list[tty]);
+ if (config->n_consoles) {
+ idx = widget_select_get_value(screen->widgets.boot_console_f);
+ if (!config->boot_console) {
+ config->boot_console = talloc_strdup(config,
+ config->consoles[idx]);
+ } else if (strncmp(config->boot_console, config->consoles[idx],
+ strlen(config->boot_console)) != 0) {
+ talloc_free(config->boot_console);
+ config->boot_console = talloc_strdup(config,
+ config->consoles[idx]);
}
}
y += 1;
- if (widget_height(widget_select_base(screen->widgets.boot_tty_f))) {
- layout_pair(screen, y, screen->widgets.boot_tty_l,
- widget_select_base(screen->widgets.boot_tty_f));
- y += widget_height(widget_select_base(screen->widgets.boot_tty_f));
- widget_move(widget_label_base(screen->widgets.current_tty_l),
+ if (widget_height(widget_select_base(screen->widgets.boot_console_f))) {
+ layout_pair(screen, y, screen->widgets.boot_console_l,
+ widget_select_base(screen->widgets.boot_console_f));
+ y += widget_height(widget_select_base(screen->widgets.boot_console_f));
+ widget_move(widget_label_base(screen->widgets.current_console_l),
y, screen->field_x);
y += 2;
} else {
widget_set_visible(widget_label_base(
- screen->widgets.boot_tty_l), false);
+ screen->widgets.boot_console_l), false);
widget_set_visible(widget_select_base(
- screen->widgets.boot_tty_f), false);
+ screen->widgets.boot_console_f), false);
widget_set_visible(widget_label_base(
- screen->widgets.current_tty_l), false);
+ screen->widgets.current_console_l), false);
}
if (screen->net_override) {
_("Allow bootloader scripts to modify disks"),
config->allow_writes);
- screen->widgets.boot_tty_l = widget_new_label(set, 0, 0,
- _("Default tty:"));
- screen->widgets.boot_tty_f = widget_new_select(set, 0, 0,
+ screen->widgets.boot_console_l = widget_new_label(set, 0, 0,
+ _("Boot console:"));
+ screen->widgets.boot_console_f = widget_new_select(set, 0, 0,
COLS - screen->field_x - 1);
- for (i = 0; i < config->n_tty; i++){
- found = config->boot_tty &&
- strncmp(config->boot_tty, config->tty_list[i],
- strlen(config->boot_tty)) == 0;
- widget_select_add_option(screen->widgets.boot_tty_f, i,
- config->tty_list[i], found);
+ for (i = 0; i < config->n_consoles; i++){
+ found = config->boot_console &&
+ strncmp(config->boot_console, config->consoles[i],
+ strlen(config->boot_console)) == 0;
+ widget_select_add_option(screen->widgets.boot_console_f, i,
+ config->consoles[i], found);
}
tty = talloc_asprintf(screen, _("Current interface: %s"),
ttyname(STDIN_FILENO));
- screen->widgets.current_tty_l = widget_new_label(set, 0 , 0, tty);
+ screen->widgets.current_console_l = widget_new_label(set, 0 , 0, tty);
screen->widgets.ok_b = widget_new_button(set, 0, 0, 10, _("OK"),
ok_click, screen);
static int set_stdout(struct offb_ctx *ctx)
{
- const char *boot_tty, *ptr;
+ const char *boot_console, *ptr;
long unsigned int termno;
const fdt32_t *prop;
int node, prop_len;
char *stdout_path;
- boot_tty = getenv("boot_tty");
- if (!boot_tty) {
- fprintf(stderr, "boot_tty not set, using default stdout for boot\n");
+ boot_console = getenv("boot_console");
+ if (!boot_console) {
+ fprintf(stderr, "boot_console not set, using default stdout for boot\n");
return 0;
}
- if (strstr(boot_tty, "tty") != NULL) {
- fprintf(stderr, "TTY recognised: %s\n", boot_tty);
+ if (strstr(boot_console, "tty") != NULL) {
+ fprintf(stderr, "TTY recognised: %s\n", boot_console);
stdout_path = get_vga_path(ctx);
} else {
- ptr = strstr(boot_tty, "hvc");
+ ptr = strstr(boot_console, "hvc");
if (!ptr || strlen(ptr) <= strlen("hvc")) {
- fprintf(stderr, "Unrecognised console: %s\n", boot_tty);
+ fprintf(stderr, "Unrecognised console: %s\n",
+ boot_console);
return 0;
}
ptr += strlen("hvc");
errno = 0;
termno = strtoul(ptr, NULL, 0);
if (errno) {
- fprintf(stderr, "Couldn't parse termno from %s\n", boot_tty);
+ fprintf(stderr, "Couldn't parse termno from %s\n",
+ boot_console);
return 0;
}
- fprintf(stderr, "HVC recognised: %s\n", boot_tty);
+ fprintf(stderr, "HVC recognised: %s\n", boot_console);
stdout_path = get_hvc_path(ctx, termno);
}
if (!stdout_path) {
- fprintf(stderr, "Couldn't parse %s into a path\n", boot_tty);
+ fprintf(stderr, "Couldn't parse %s into a path\n",
+ boot_console);
return -1;
}