/** Read in one line of input with initial text provided. * * @param ti Text input * @param istr Initial string * @param dstr Place to save pointer to new string * * @return EOK on success * @return ENOENT if user requested abort * @return EIO if communication with console failed * */ int tinput_read_i(tinput_t *ti, const char *istr, char **dstr) { console_flush(ti->console); if (console_get_size(ti->console, &ti->con_cols, &ti->con_rows) != EOK) return EIO; tinput_set_str(ti, istr); ti->sel_start = 0; ti->done = false; ti->exit_clui = false; if (tinput_display(ti) != EOK) return EIO; while (!ti->done) { console_flush(ti->console); cons_event_t ev; if (!console_get_event(ti->console, &ev)) return EIO; switch (ev.type) { case CEV_KEY: if (ev.ev.key.type == KEY_PRESS) tinput_key_press(ti, &ev.ev.key); else tinput_key_release(ti, &ev.ev.key); break; case CEV_POS: tinput_pos(ti, &ev.ev.pos); break; } } if (ti->exit_clui) return ENOENT; ti->pos = ti->nc; tinput_position_caret(ti); putchar('\n'); char *str = tinput_get_str(ti); if (str_cmp(str, "") != 0) tinput_history_insert(ti, str); ti->hpos = 0; *dstr = str; return EOK; }
static void tinput_display_tail(tinput_t *ti, size_t start, size_t pad) { wchar_t *dbuf = malloc((INPUT_MAX_SIZE + 1) * sizeof(wchar_t)); if (!dbuf) return; size_t sa; size_t sb; tinput_sel_get_bounds(ti, &sa, &sb); tinput_console_set_lpos(ti, ti->text_coord + start); console_set_style(ti->console, STYLE_NORMAL); size_t p = start; if (p < sa) { memcpy(dbuf, ti->buffer + p, (sa - p) * sizeof(wchar_t)); dbuf[sa - p] = '\0'; printf("%ls", dbuf); p = sa; } if (p < sb) { console_flush(ti->console); console_set_style(ti->console, STYLE_SELECTED); memcpy(dbuf, ti->buffer + p, (sb - p) * sizeof(wchar_t)); dbuf[sb - p] = '\0'; printf("%ls", dbuf); p = sb; } console_flush(ti->console); console_set_style(ti->console, STYLE_NORMAL); if (p < ti->nc) { memcpy(dbuf, ti->buffer + p, (ti->nc - p) * sizeof(wchar_t)); dbuf[ti->nc - p] = '\0'; printf("%ls", dbuf); } for (p = 0; p < pad; p++) putchar(' '); console_flush(ti->console); free(dbuf); }
/****************************************************************************** * The SP_MIN main function. Do the platform and PSCI Library setup. Also * initialize the runtime service framework. *****************************************************************************/ void sp_min_main(void) { NOTICE("SP_MIN: %s\n", version_string); NOTICE("SP_MIN: %s\n", build_message); /* Perform the SP_MIN platform setup */ sp_min_platform_setup(); /* Initialize the runtime services e.g. psci */ INFO("SP_MIN: Initializing runtime services\n"); runtime_svc_init(); /* * We are ready to enter the next EL. Prepare entry into the image * corresponding to the desired security state after the next ERET. */ sp_min_prepare_next_image_entry(); /* * Perform any platform specific runtime setup prior to cold boot exit * from SP_MIN. */ sp_min_plat_runtime_setup(); console_flush(); }
static int vincell_devices_init(void) { writel(0, MX53_M4IF_BASE_ADDR + 0xc); console_flush(); imx53_init_lowlevel(1000); clk_set_rate(clk_lookup("nfc_podf"), 66666667); imx53_add_nand(&nand_info); imx51_iim_register_fec_ethaddr(); imx53_add_fec(&fec_info); imx53_add_mmc0(NULL); i2c_register_board_info(0, i2c_devices, ARRAY_SIZE(i2c_devices)); imx53_add_i2c0(NULL); vincell_fec_reset(); armlinux_set_bootparams((void *)0x70000100); armlinux_set_architecture(3297); devfs_add_partition("nand0", SZ_1M, SZ_512K, DEVFS_PARTITION_FIXED, "self_raw"); dev_add_bb_dev("self_raw", "self0"); devfs_add_partition("nand0", SZ_1M + SZ_512K, SZ_512K, DEVFS_PARTITION_FIXED, "env_raw"); dev_add_bb_dev("env_raw", "env0"); imx53_bbu_internal_nand_register_handler("nand", BBU_HANDLER_FLAG_DEFAULT, dcd_entry, sizeof(dcd_entry), 3 * SZ_128K, 0xf8020000); return 0; }
/** * If the PLL settings are in place switch the CPU core frequency to the max. value */ static int pcm038_power_init(void) { uint32_t spctl0; int ret; spctl0 = get_pll_spctl10(); /* PLL registers already set to their final values? */ if (spctl0 == SPCTL0_VAL && MPCTL0 == MPCTL0_VAL) { console_flush(); ret = pmic_power(); if (ret == 0) { /* wait for required power level to run the CPU at 400 MHz */ udelay(100000); CSCR = CSCR_VAL_FINAL; PCDR0 = 0x130410c3; PCDR1 = 0x09030911; /* Clocks have changed. Notify clients */ clock_notifier_call_chain(); } else { printf("Failed to initialize PMIC. Will continue with low CPU speed\n"); } } /* clock gating enable */ GPCR = 0x00050f08; return 0; }
/* Main kernel entry point, called by trampoline */ void start_kernel(start_info_t * start_info) { /* Define hypervisor upcall entry points */ HYPERVISOR_set_callbacks( FLAT_KERNEL_CS, (unsigned long)hypervisor_callback, FLAT_KERNEL_CS, (unsigned long)failsafe_callback); /* Map the shared info page */ HYPERVISOR_update_va_mapping((unsigned long) shared_info, __pte(start_info->shared_info), UVMF_INVLPG); /* Initialise the console */ console_init(start_info); /* Write a message to check that it worked */ console_write("Hello world!\n\r"); console_write("Xen magic string: "); console_write(start_info->magic); console_write("\n\r"); /* Set up the XenStore driver */ xenstore_init(start_info); /* Test the store */ xenstore_test(); /* Flush the console buffer */ console_flush(); /* Exit, since we don't know how to do anything else */ }
static void pane_text_display(void) { int sh_rows, rows; sheet_get_num_rows(&doc.sh, &sh_rows); rows = min(sh_rows - pane.sh_row + 1, pane.rows); /* Draw rows from the sheet. */ console_set_pos(con, 0, 0); pane_row_range_display(0, rows); /* Clear the remaining rows if file is short. */ int i; sysarg_t j; for (i = rows; i < pane.rows; ++i) { console_set_pos(con, 0, i); for (j = 0; j < scr_columns; ++j) putchar(' '); console_flush(con); } pane.rflags |= (REDRAW_STATUS | REDRAW_CARET); pane.rflags &= ~REDRAW_ROW; }
void __assert(const char *file, unsigned int line) { printf("ASSERT: %s:%d\n", file, line); backtrace("assert"); (void)console_flush(); plat_panic_handler(); }
void encoder_progress( lame_global_flags const* gf ) { if (global_ui_config.silent <= 0) { int const frames = lame_get_frameNum(gf); int const frames_diff = frames - global_encoder_progress.last_frame_num; if (global_ui_config.update_interval <= 0) { /* most likely --disptime x not used */ if (frames_diff < 100 && frames_diff != 0) { /* true, most of the time */ return; } global_encoder_progress.last_frame_num = (frames/100)*100; } else { if (frames != 0 && frames != 9) { double const act = GetRealTime(); double const dif = act - global_encoder_progress.last_time; if (dif >= 0 && dif < global_ui_config.update_interval) { return; } } global_encoder_progress.last_time = GetRealTime(); /* from now! disp_time seconds */ } if (global_ui_config.brhist) { brhist_jump_back(); } timestatus(gf); if (global_ui_config.brhist) { brhist_disp(gf); } console_flush(); } }
void decoder_progress(DecoderProgress dp, const mp3data_struct * mp3data, int iread) { addSamples(dp, iread); console_printf("\rFrame#%6i/%-6i %3i kbps", dp->frame_ctr, dp->frames_total, mp3data->bitrate); /* Programmed with a single frame hold delay */ /* Attention: static data */ /* MP2 Playback is still buggy. */ /* "'00' subbands 4-31 in intensity_stereo, bound==4" */ /* is this really intensity_stereo or is it MS stereo? */ if (mp3data->mode == JOINT_STEREO) { int curr = mp3data->mode_ext; int last = dp->last_mode_ext; console_printf(" %s %c", curr & 2 ? last & 2 ? " MS " : "LMSR" : last & 2 ? "LMSR" : "L R", curr & 1 ? last & 1 ? 'I' : 'i' : last & 1 ? 'i' : ' '); dp->last_mode_ext = curr; } else { console_printf(" "); dp->last_mode_ext = 0; } /* console_printf ("%s", Console_IO.str_clreoln ); */ console_printf(" \b\b\b\b\b\b\b\b"); console_flush(); }
static void lnp_console_execute_command(char *out_buffer, int buffer_len, int function_id, char *args) { switch (function_id) { case COMMAND_ID: console_id(out_buffer, buffer_len, args); break; case COMMAND_WRITE: console_write(out_buffer, buffer_len, args); break; case COMMAND_READ: console_read(out_buffer, buffer_len, args); break; case COMMAND_FLUSH: console_flush(out_buffer, buffer_len, args); break; case COMMAND_CONNECTIONS: console_connections(out_buffer, buffer_len, args); break; case COMMAND_HISTORY: console_history(out_buffer, buffer_len, args); break; case COMMAND_CONNECT: console_connect(out_buffer, buffer_len, args); break; case COMMAND_KEYS: console_print_keys(out_buffer, buffer_len, args); break; } }
static bool get_user_decision(bool bdefault, const char *message, ...) { va_list args; va_start(args, message); vprintf(message, args); va_end(args); while (true) { cons_event_t ev; console_flush(con); console_get_event(con, &ev); if (ev.type != CEV_KEY || ev.ev.key.type != KEY_PRESS || (ev.ev.key.mods & (KM_CTRL | KM_ALT)) != 0) { continue; } switch(ev.ev.key.key) { case KC_Y: printf("y\n"); return true; case KC_N: printf("n\n"); return false; case KC_ENTER: printf("%c\n", bdefault ? 'Y' : 'N'); return bdefault; default: break; } } }
int console_putchar(int c) { if (con_cursor >= CON_BUF_SIZE - 1) console_flush(); con_buf[con_cursor++] = (char)c; return c; }
/** * If the PLL settings are in place switch the CPU core frequency to the max. value */ static int pcm038_power_init(void) { uint32_t spctl0 = get_pll_spctl10(); struct mc13xxx *mc13xxx = mc13xxx_get(); /* PLL registers already set to their final values? */ if (spctl0 == SPCTL0_VAL && readl(MX27_CCM_BASE_ADDR + MX27_MPCTL0) == MPCTL0_VAL) { console_flush(); if (mc13xxx) { mc13xxx_reg_write(mc13xxx, MC13783_REG_SWITCHERS(0), MC13783_SWX_VOLTAGE(MC13783_SWX_VOLTAGE_1_450) | MC13783_SWX_VOLTAGE_DVS(MC13783_SWX_VOLTAGE_1_450) | MC13783_SWX_VOLTAGE_STANDBY(MC13783_SWX_VOLTAGE_1_450)); mc13xxx_reg_write(mc13xxx, MC13783_REG_SWITCHERS(4), MC13783_SW1A_MODE(MC13783_SWX_MODE_NO_PULSE_SKIP) | MC13783_SW1A_MODE_STANDBY(MC13783_SWX_MODE_NO_PULSE_SKIP) | MC13783_SW1A_SOFTSTART | MC13783_SW1B_MODE(MC13783_SWX_MODE_NO_PULSE_SKIP) | MC13783_SW1B_MODE_STANDBY(MC13783_SWX_MODE_NO_PULSE_SKIP) | MC13783_SW1B_SOFTSTART | MC13783_SW_PLL_FACTOR(32)); /* Setup VMMC voltage */ if (IS_ENABLED(CONFIG_MCI_IMX)) { u32 val; mc13xxx_reg_read(mc13xxx, MC13783_REG_REG_SETTING(1), &val); /* VMMC1 = 3.00 V */ val &= ~(7 << 6); val |= 6 << 6; mc13xxx_reg_write(mc13xxx, MC13783_REG_REG_SETTING(1), val); mc13xxx_reg_read(mc13xxx, MC13783_REG_REG_MODE(1), &val); /* Enable VMMC1 */ val |= 1 << 18; mc13xxx_reg_write(mc13xxx, MC13783_REG_REG_MODE(1), val); } /* wait for required power level to run the CPU at 400 MHz */ udelay(100000); writel(CSCR_VAL_FINAL, MX27_CCM_BASE_ADDR + MX27_CSCR); writel(0x130410c3, MX27_CCM_BASE_ADDR + MX27_PCDR0); writel(0x09030911, MX27_CCM_BASE_ADDR + MX27_PCDR1); /* Clocks have changed. Notify clients */ clock_notifier_call_chain(); } else { pr_err("Failed to initialize PMIC. Will continue with low CPU speed\n"); } } /* clock gating enable */ writel(0x00050f08, MX27_SYSCTRL_BASE_ADDR + MX27_GPCR); return 0; }
/* * This is a basic implementation. This could be improved. */ void __assert (const char *function, const char *file, unsigned int line, const char *assertion) { tf_printf("ASSERT: %s <%d> : %s\n", function, line, assertion); console_flush(); plat_panic_handler(); }
static void tinput_display_prompt(tinput_t *ti) { tinput_console_set_lpos(ti, ti->prompt_coord); console_set_style(ti->console, STYLE_EMPHASIS); printf("%s", ti->prompt); console_flush(ti->console); console_set_style(ti->console, STYLE_NORMAL); }
inline void battery_charging_image() { unsigned short *dst = mddi_framebuffer(); unsigned short *mod_dst; unsigned short bar_width = 480 * 15; unsigned short bar_height = 15; static unsigned short color = 0x0000; static int update_counter = 0; static int anim_seq = 0; int j = 0; int k = 0; #if 0 //once the battery level proc comm is available at AMSS side then I can use the below if(var == BATT_FULL) {//FILL THE COMPLETE BAR SHOWING THE BATTERY IS FULL while(bar_width--) *dst++ = FGCOLOR; console_flush(); } else #endif if(charger_connected && (++update_counter > BATT_IMG_UPDATE_CYCLE)) { /* Reset update counter */ update_counter = 0; bar_width = (anim_seq + 1) * 120; for (j = 0; j < bar_height; j++) { mod_dst = dst + j * 480; for (k = 0; k < bar_width; k++ ) { *mod_dst++ = color; } } console_flush(); anim_seq++; if (anim_seq > 3) { /* Cycle through battery animation */ anim_seq = 0; color = ~color; } } }
void cprintf(const char *fmt, ...) { va_list ap; va_start(ap, fmt); __xprintf(fmt, ap, (void*) console_putc, 0); va_end(ap); console_flush(); }
void arm_console_runtime_end(void) { (void)console_flush(); #if MULTI_CONSOLE_API (void)console_unregister(&arm_runtime_console.console); #else console_uninit(); #endif /* MULTI_CONSOLE_API */ }
main() { char buf[64]; while (1) { fgets(buf, 64, stdin); console_write_str(buf); console_flush(); } }
void console_up(int n_lines) { #if defined(_WIN32) && !defined(__CYGWIN__) if (Console_IO.Console_file_type != FILE_TYPE_PIPE) { COORD Pos; CONSOLE_SCREEN_BUFFER_INFO CSBI; console_flush(); GetConsoleScreenBufferInfo(Console_IO.Console_Handle, &CSBI); Pos.Y = (SHORT)(CSBI.dwCursorPosition.Y - n_lines); Pos.X = 0; SetConsoleCursorPosition(Console_IO.Console_Handle, Pos); } #else while (n_lines-- > 0) fputs(Console_IO.str_up, Console_IO.Console_fp); console_flush(); #endif }
void console_init(void) { mddi_init(); cmaxx = fb_width / 6; cmaxy = (fb_height-1) / 12; cx = 0; cy = 0; console_clear(); console_flush(); }
/** Display text in the status line. */ static void status_display(char const *str) { console_set_pos(con, 0, scr_rows - 1); console_set_style(con, STYLE_INVERTED); int pos = -(scr_columns - 3); printf(" %*s ", pos, str); console_flush(con); console_set_style(con, STYLE_NORMAL); pane.rflags |= REDRAW_CARET; }
static int do_go(int argc, char *argv[]) { void *addr; int rcode = 1; int fd = -1; int (*func)(int argc, char *argv[]); if (argc < 2) return COMMAND_ERROR_USAGE; if (!isdigit(*argv[1])) { fd = open(argv[1], O_RDONLY); if (fd < 0) { perror("open"); goto out; } addr = memmap(fd, PROT_READ); if (addr == (void *)-1) { perror("memmap"); goto out; } } else addr = (void *)simple_strtoul(argv[1], NULL, 16); printf("## Starting application at 0x%p ...\n", addr); console_flush(); func = addr; shutdown_barebox(); if (do_execute) do_execute(func, argc - 1, &argv[1]); else func(argc - 1, &argv[1]); /* * The application returned. Since we have shutdown barebox and * we know nothing about the state of the cpu/memory we can't * do anything here. */ while (1); out: if (fd > 0) close(fd); return rcode; }
//---------------------------------------------------------------------------- //Routine für die Ausgabe eines Zeichens ueber definierte Devices // void console_write_char(char c) { if ( !console_isinit ) return; #if USE_USART if ( console_mode & CONSOLE_USART ) usart_write_char (c); #endif if ( console_mode & (CONSOLE_TELNET | CONSOLE_SYSLOG) ) { console_tx_buffer[console_tx_counter++] = c; if ( (console_tx_counter >= CONSOLE_TX_BUFFERSIZE - 1) || (c == '\n') ) { // Buffer ist voll oder Zeilenende, absenden console_flush(); } } }
static void levelmessage(unsigned int maxv) { char buff[] = "| . | . | . | . | . | . | . | . | . | . | \r"; static unsigned int max = 0; static unsigned int tmp = 0; buff[tmp] = '+'; tmp = (maxv * 61 + 16384) / (32767 + 16384 / 61); if (tmp > sizeof(buff) - 2) tmp = sizeof(buff) - 2; if (max < tmp) max = tmp; buff[max] = 'x'; buff[tmp] = '#'; console_printf(buff); console_flush(); }
static int eukrea_cpuimx27_late_init(void) { #ifdef CONFIG_I2C_LP3972 struct i2c_client *client; u8 reg[1]; #endif console_flush(); register_device(&fec_dev); #ifdef CONFIG_I2C_LP3972 client = lp3972_get_client(); if (!client) return -ENODEV; reg[0] = 0xa0; i2c_write_reg(client, 0x39, reg, sizeof(reg)); #endif return 0; }
static void levelmessage(unsigned int maxv, int* maxx, int* tmpx) { char buff[] = "| . | . | . | . | . | . | . | . | . | . | \r"; int tmp = *tmpx, max = *maxx; buff[tmp] = '+'; tmp = (maxv * 61 + 16384) / (32767 + 16384 / 61); if (tmp > sizeof(buff) - 2) tmp = sizeof(buff) - 2; if (max < tmp) max = tmp; buff[max] = 'x'; buff[tmp] = '#'; console_printf(buff); console_flush(); *maxx = max; *tmpx = tmp; }
static int imx51_babbage_late_init(void) { if (!of_machine_is_compatible("fsl,imx51-babbage")) return 0; babbage_power_init(); console_flush(); imx51_init_lowlevel(800); clock_notifier_call_chain(); armlinux_set_bootparams((void *)0x90000100); armlinux_set_architecture(MACH_TYPE_MX51_BABBAGE); imx51_bbu_internal_mmc_register_handler("mmc", "/dev/mmc0", BBU_HANDLER_FLAG_DEFAULT, (void *)flash_header_imx51_babbage_start, flash_header_imx51_babbage_end - flash_header_imx51_babbage_start, 0); return 0; }
static void __dead2 rpi3_watchdog_reset(void) { uint32_t rstc; console_flush(); dsbsy(); isb(); mmio_write_32(RPI3_PM_BASE + RPI3_PM_WDOG_OFFSET, RPI3_PM_PASSWORD | RESET_TIMEOUT); rstc = mmio_read_32(RPI3_PM_BASE + RPI3_PM_RSTC_OFFSET); rstc &= ~RPI3_PM_RSTC_WRCFG_MASK; rstc |= RPI3_PM_PASSWORD | RPI3_PM_RSTC_WRCFG_FULL_RESET; mmio_write_32(RPI3_PM_BASE + RPI3_PM_RSTC_OFFSET, rstc); for (;;) { wfi(); } }