static void console_late_resume(struct early_suspend *h) { int ret; #ifdef CONFIG_SHLCDC_BOARD char ev[128]; #endif acquire_console_sem(); ret = set_console(orig_fgconsole); #ifdef CONFIG_SHLCDC_BOARD if (!ret) vt_waitactive_queue((void *)ev); #endif release_console_sem(); if (ret) { pr_warning("console_late_resume: Can't set console.\n"); return; } #ifdef CONFIG_SHLCDC_BOARD if (vt_waitactive_wait_dequeue((void *)ev, orig_fgconsole + 1)) #else if (vt_waitactive(orig_fgconsole + 1)) #endif pr_warning("console_late_resume: Can't switch VCs.\n"); }
int pm_prepare_console(void) { orig_loglevel = console_loglevel; console_loglevel = new_loglevel; #ifdef SUSPEND_CONSOLE acquire_console_sem(); orig_fgconsole = fg_console; if (vc_allocate(SUSPEND_CONSOLE)) { /* we can't have a free VC for now. Too bad, * we don't want to mess the screen for now. */ release_console_sem(); return 1; } set_console(SUSPEND_CONSOLE); release_console_sem(); if (vt_waitactive(SUSPEND_CONSOLE)) { pr_debug("Suspend: Can't switch VCs."); return 1; } orig_kmsg = kmsg_redirect; kmsg_redirect = SUSPEND_CONSOLE; #endif return 0; }
static void console_early_suspend(struct early_suspend *h) { #ifdef CONFIG_SHLCDC_BOARD char ev[128]; #endif acquire_console_sem(); orig_fgconsole = fg_console; if (vc_allocate(EARLY_SUSPEND_CONSOLE)) goto err; if (set_console(EARLY_SUSPEND_CONSOLE)) goto err; #ifdef CONFIG_SHLCDC_BOARD vt_waitactive_queue((void *)ev); #endif release_console_sem(); #ifdef CONFIG_SHLCDC_BOARD if (vt_waitactive_wait_dequeue((void *)ev, EARLY_SUSPEND_CONSOLE + 1)) #else if (vt_waitactive(EARLY_SUSPEND_CONSOLE + 1)) #endif pr_warning("console_early_suspend: Can't switch VCs.\n"); return; err: pr_warning("console_early_suspend: Can't set console\n"); release_console_sem(); }
void pm_restore_console(void) { acquire_console_sem(); if (disable_vt_switch) { release_console_sem(); return; } set_console(orig_fgconsole); release_console_sem(); kmsg_redirect = orig_kmsg; }
void pm_restore_console(void) { console_loglevel = orig_loglevel; #ifdef SUSPEND_CONSOLE acquire_console_sem(); set_console(orig_fgconsole); release_console_sem(); kmsg_redirect = orig_kmsg; #endif return; }
static void incr_console(void) { int i; for (i = fg_console+1; i != fg_console; i++) { if (i == MAX_NR_CONSOLES) i = 0; if (vc_cons_allocated(i)) break; } set_console(i); }
static void decr_console(void) { int i; for (i = fg_console-1; i != fg_console; i--) { if (i == -1) i = MAX_NR_CONSOLES-1; if (vc_cons_allocated(i)) break; } set_console(i); }
int main(int argc, char * argv[]) { /* stdin/out/err */ set_console(); /* Hostname */ set_hostname(); if (argc > 1) { char * args = NULL; if (argc > 2) { args = argv[2]; } if (!strcmp(argv[1],"--single")) { return start_options((char *[]){"/bin/compositor","--","/bin/terminal","-Fl",args,NULL}); } else if (!strcmp(argv[1], "--vga")) {
static void console_late_resume(struct early_suspend *h) { int ret; acquire_console_sem(); ret = set_console(orig_fgconsole); release_console_sem(); if (ret) { pr_warning("console_late_resume: Can't set console.\n"); return; } if (vt_waitactive(orig_fgconsole + 1)) pr_warning("console_late_resume: Can't switch VCs.\n"); }
void pm_restore_console(void) { acquire_console_sem(); if (disable_vt_switch) { release_console_sem(); return; } set_console(orig_fgconsole); release_console_sem(); if (vt_waitactive(orig_fgconsole)) { pr_debug("Resume: Can't switch VCs."); return; } kmsg_redirect = orig_kmsg; }
static void console_early_suspend(struct early_suspend *h) { acquire_console_sem(); orig_fgconsole = fg_console; if (vc_allocate(EARLY_SUSPEND_CONSOLE)) goto err; if (set_console(EARLY_SUSPEND_CONSOLE)) goto err; release_console_sem(); if (vt_waitactive(EARLY_SUSPEND_CONSOLE)) pr_warning("console_early_suspend: Can't switch VCs.\n"); return; err: pr_warning("console_early_suspend: Can't set console\n"); release_console_sem(); }
static void console_early_suspend(struct early_suspend *h) { printk("[KENEL] %s, %d \n", __FUNCTION__, __LINE__); acquire_console_sem(); orig_fgconsole = fg_console; if (vc_allocate(EARLY_SUSPEND_CONSOLE)) goto err; if (set_console(EARLY_SUSPEND_CONSOLE)) goto err; release_console_sem(); if (vt_waitactive(EARLY_SUSPEND_CONSOLE + 1)) pr_warning("console_early_suspend: Can't switch VCs.\n"); return; err: pr_warning("console_early_suspend: Can't set console\n"); release_console_sem(); }
int pm_prepare_console(void) { acquire_console_sem(); if (disable_vt_switch) { release_console_sem(); return 0; } orig_fgconsole = fg_console; if (vc_allocate(SUSPEND_CONSOLE)) { /* we can't have a free VC for now. Too bad, * we don't want to mess the screen for now. */ release_console_sem(); return 1; } if (set_console(SUSPEND_CONSOLE)) { /* * We're unable to switch to the SUSPEND_CONSOLE. * Let the calling function know so it can decide * what to do. */ release_console_sem(); return 1; } release_console_sem(); if (vt_waitactive(SUSPEND_CONSOLE)) { pr_debug("Suspend: Can't switch VCs."); return 1; } orig_kmsg = kmsg_redirect; kmsg_redirect = SUSPEND_CONSOLE; return 0; }
static void console_early_suspend(struct early_suspend *h) { printk("%s / acquire_console_sem\n", __func__); acquire_console_sem(); orig_fgconsole = fg_console; printk("%s / alloc\n", __func__); if (vc_allocate(EARLY_SUSPEND_CONSOLE)) goto err; printk("%s / set_console\n", __func__); if (set_console(EARLY_SUSPEND_CONSOLE)) goto err; printk("%s / release_console_sem\n", __func__); release_console_sem(); printk("%s / vt_waitactive\n", __func__); if (vt_waitactive(EARLY_SUSPEND_CONSOLE + 1)) pr_warning("console_early_suspend: Can't switch VCs.\n"); printk("%s / end\n", __func__); return; err: pr_warning("console_early_suspend: Can't set console\n"); release_console_sem(); }
static void set_console(void) { const char* tty; char* split; char line[ 20 ]; const char* try[] = { "tty0", "console", NULL }; /* Try the most common outputs */ int f, i = 0; tty = get_cmdline_val("console",line,sizeof(line)); if (tty != NULL) { split = strchr(tty, ','); if ( split != NULL ) *split = '\0'; } else { // Try a default tty=try[i]; i++; } if (chdir("/dev")) { ERROR("failed to change dir to /dev\n"); return; } while (tty!=NULL) { f = open(tty, O_RDONLY); if (f >= 0) { close(f); break; } tty=try[i]; i++; } if (chdir("/")) ERROR("failed to change dir to /\n"); if (tty != NULL) set_stdio(tty); } static void state_enter(void) { char ubus_cmd[] = "/sbin/ubusd"; switch (state) { case STATE_EARLY: LOG("- early -\n"); watchdog_init(0); hotplug("/etc/hotplug.json"); procd_coldplug(); break; case STATE_UBUS: // try to reopen incase the wdt was not available before coldplug watchdog_init(0); set_stdio("console"); LOG("- ubus -\n"); procd_connect_ubus(); service_start_early("ubus", ubus_cmd); break; case STATE_INIT: LOG("- init -\n"); procd_inittab(); procd_inittab_run("respawn"); procd_inittab_run("askconsole"); procd_inittab_run("askfirst"); procd_inittab_run("sysinit"); // switch to syslog log channel ulog_open(ULOG_SYSLOG, LOG_DAEMON, "procd"); break; case STATE_RUNNING: LOG("- init complete -\n"); break; case STATE_SHUTDOWN: /* Redirect output to the console for the users' benefit */ set_console(); LOG("- shutdown -\n"); procd_inittab_run("shutdown"); sync(); break; case STATE_HALT: // To prevent killed processes from interrupting the sleep signal(SIGCHLD, SIG_IGN); LOG("- SIGTERM processes -\n"); kill(-1, SIGTERM); sync(); sleep(1); LOG("- SIGKILL processes -\n"); kill(-1, SIGKILL); sync(); sleep(1); #ifndef DISABLE_INIT if (reboot_event == RB_POWER_OFF) LOG("- power down -\n"); else LOG("- reboot -\n"); /* Allow time for last message to reach serial console, etc */ sleep(1); /* We have to fork here, since the kernel calls do_exit(EXIT_SUCCESS) * in linux/kernel/sys.c, which can cause the machine to panic when * the init process exits... */ if (!vfork( )) { /* child */ reboot(reboot_event); _exit(EXIT_SUCCESS); } while (1) sleep(1); #else exit(0); #endif break; default: ERROR("Unhandled state %d\n", state); return; }; } void procd_state_next(void) { DEBUG(4, "Change state %d -> %d\n", state, state + 1); state++; state_enter(); } void procd_state_ubus_connect(void) { if (state == STATE_UBUS) procd_state_next(); } void procd_shutdown(int event) { if (state >= STATE_SHUTDOWN) return; DEBUG(2, "Shutting down system with event %x\n", event); reboot_event = event; state = STATE_SHUTDOWN; state_enter(); }
int main(int argc, char **argv) { char *font, *type, *termmode; const char *opts; int dumpmod, dumpopt, opt; int reterr; vt4_mode = is_vt4(); init(); info.size = sizeof(info); if (ioctl(0, CONS_GETINFO, &info) == -1) err(1, "must be on a virtual console"); dumpmod = 0; dumpopt = DUMP_FBF; termmode = NULL; if (vt4_mode) opts = "b:Cc:f:g:h:Hi:M:m:pPr:S:s:T:t:x"; else opts = "b:Cc:df:g:h:Hi:l:LM:m:pPr:S:s:T:t:x"; while ((opt = getopt(argc, argv, opts)) != -1) switch(opt) { case 'b': set_border_color(optarg); break; case 'C': clear_history(); break; case 'c': set_cursor_type(optarg); break; case 'd': if (vt4_mode) break; print_scrnmap(); break; case 'f': type = optarg; font = nextarg(argc, argv, &optind, 'f', 0); if (font == NULL) { type = NULL; font = optarg; } load_font(type, font); break; case 'g': if (sscanf(optarg, "%dx%d", &vesa_cols, &vesa_rows) != 2) { revert(); warnx("incorrect geometry: %s", optarg); usage(); } break; case 'h': set_history(optarg); break; case 'H': dumpopt = DUMP_ALL; break; case 'i': show_info(optarg); break; case 'l': if (vt4_mode) break; load_scrnmap(optarg); break; case 'L': if (vt4_mode) break; load_default_scrnmap(); break; case 'M': set_mouse_char(optarg); break; case 'm': set_mouse(optarg); break; case 'p': dumpmod = DUMP_FMT_RAW; break; case 'P': dumpmod = DUMP_FMT_TXT; break; case 'r': get_reverse_colors(argc, argv, &optind); break; case 'S': set_lockswitch(optarg); break; case 's': set_console(optarg); break; case 'T': if (strcmp(optarg, "xterm") != 0 && strcmp(optarg, "cons25") != 0) usage(); termmode = optarg; break; case 't': set_screensaver_timeout(optarg); break; case 'x': hex = 1; break; default: usage(); } if (dumpmod != 0) dump_screen(dumpmod, dumpopt); reterr = video_mode(argc, argv, &optind); get_normal_colors(argc, argv, &optind); if (optind < argc && !strcmp(argv[optind], "show")) { test_frame(); optind++; } video_mode(argc, argv, &optind); if (termmode != NULL) set_terminal_mode(termmode); get_normal_colors(argc, argv, &optind); if (colors_changed || video_mode_changed) { if (!(new_mode_info.vi_flags & V_INFO_GRAPHICS)) { if ((normal_back_color < 8) && (revers_back_color < 8)) { set_colors(); } else { revert(); errx(1, "bg color for text modes must be < 8"); } } else { set_colors(); } } if ((optind != argc) || (argc == 1)) usage(); return reterr; }
int main(int argc, char **argv) { char *font, *type; int opt; if (argc == 1) usage(); init(); info.size = sizeof(info); if (ioctl(0, CONS_GETINFO, &info) == -1) err(1, "must be on a virtual console"); while((opt = getopt(argc, argv, "b:Cc:df:g:h:i:l:LM:m:pPr:S:s:t:x")) != -1) { switch(opt) { case 'b': set_border_color(optarg); break; case 'C': clear_history(); break; case 'c': set_cursor_type(optarg); break; case 'd': print_scrnmap(); break; case 'f': type = optarg; font = nextarg(argc, argv, &optind, 'f', 0); if (font == NULL) { type = NULL; font = optarg; } load_font(type, font); break; case 'g': if (sscanf(optarg, "%dx%d", &vesa_cols, &vesa_rows) != 2) { revert(); warnx("incorrect geometry: %s", optarg); usage(); } break; case 'h': set_history(optarg); break; case 'i': show_info(optarg); break; case 'l': load_scrnmap(optarg); break; case 'L': load_default_scrnmap(); break; case 'M': set_mouse_char(optarg); break; case 'm': set_mouse(optarg); break; case 'p': dump_screen(DUMP_RAW); break; case 'P': dump_screen(DUMP_TXT); break; case 'r': get_reverse_colors(argc, argv, &optind); break; case 'S': set_lockswitch(optarg); break; case 's': set_console(optarg); break; case 't': set_screensaver_timeout(optarg); break; case 'x': hex = 1; break; default: usage(); } } if (optind < argc && !strcmp(argv[optind], "show")) { test_frame(); optind++; } video_mode(argc, argv, &optind); get_normal_colors(argc, argv, &optind); if (colors_changed || video_mode_changed) { if (!(new_mode_info.vi_flags & V_INFO_GRAPHICS)) { if ((normal_back_color < 8) && (revers_back_color < 8)) { set_colors(); } else { revert(); errx(1, "bg color for text modes must be < 8"); } } else { set_colors(); } } if ((optind != argc) || (argc == 1)) usage(); return 0; }
void enable_mambo_console(void) { prlog(PR_NOTICE, "Enabling Mambo console\n"); set_console(&mambo_con_driver); }
static void do_cons(unsigned char value, char up_flag) { if (up_flag) return; set_console(value); }
int main(int argc, char **argv) { char *font, *type, *termmode; const char *opts; int dumpmod, dumpopt, opt; vt4_mode = is_vt4(); init(); dumpmod = 0; dumpopt = DUMP_FBF; termmode = NULL; if (vt4_mode) opts = "b:Cc:fg:h:Hi:M:m:pPr:S:s:T:t:x"; else opts = "b:Cc:deE:fg:h:Hi:l:LM:m:pPr:S:s:T:t:x"; while ((opt = getopt(argc, argv, opts)) != -1) switch(opt) { case 'b': set_border_color(optarg); break; case 'C': clear_history(); break; case 'c': set_cursor_type(optarg); break; case 'd': if (vt4_mode) break; print_scrnmap(); break; case 'E': if (vt4_mode) break; set_terminal_emulator(optarg); break; case 'e': if (vt4_mode) break; get_terminal_emulators(); break; case 'f': optarg = nextarg(argc, argv, &optind, 'f', 0); if (optarg != NULL) { font = nextarg(argc, argv, &optind, 'f', 0); if (font == NULL) { type = NULL; font = optarg; } else type = optarg; load_font(type, font); } else { if (!vt4_mode) usage(); /* Switch syscons to ROM? */ load_default_vt4font(); } break; case 'g': if (sscanf(optarg, "%dx%d", &vesa_cols, &vesa_rows) != 2) { revert(); warnx("incorrect geometry: %s", optarg); usage(); } break; case 'h': set_history(optarg); break; case 'H': dumpopt = DUMP_ALL; break; case 'i': show_info(optarg); break; case 'l': if (vt4_mode) break; load_scrnmap(optarg); break; case 'L': if (vt4_mode) break; load_default_scrnmap(); break; case 'M': set_mouse_char(optarg); break; case 'm': set_mouse(optarg); break; case 'p': dumpmod = DUMP_FMT_RAW; break; case 'P': dumpmod = DUMP_FMT_TXT; break; case 'r': set_reverse_colors(argc, argv, &optind); break; case 'S': set_lockswitch(optarg); break; case 's': set_console(optarg); break; case 'T': if (strcmp(optarg, "xterm") != 0 && strcmp(optarg, "cons25") != 0) usage(); termmode = optarg; break; case 't': set_screensaver_timeout(optarg); break; case 'x': hex = 1; break; default: usage(); } if (dumpmod != 0) dump_screen(dumpmod, dumpopt); video_mode(argc, argv, &optind); set_normal_colors(argc, argv, &optind); if (optind < argc && !strcmp(argv[optind], "show")) { test_frame(); optind++; } if (termmode != NULL) set_terminal_mode(termmode); if ((optind != argc) || (argc == 1)) usage(); return (0); }
static void lastcons(void) { /* switch to the last used console, ChN */ set_console(last_console); }