void run_ramstage(void) { struct prog ramstage = PROG_INIT(ASSET_RAMSTAGE, CONFIG_CBFS_PREFIX "/ramstage"); /* Only x86 systems currently take the same firmware path on resume. */ if (IS_ENABLED(CONFIG_ARCH_X86) && IS_ENABLED(CONFIG_EARLY_CBMEM_INIT)) run_ramstage_from_resume(romstage_handoff_find_or_add(), &ramstage); if (prog_locate(&ramstage)) goto fail; timestamp_add_now(TS_START_COPYRAM); if (IS_ENABLED(CONFIG_RELOCATABLE_RAMSTAGE)) { if (load_relocatable_ramstage(&ramstage)) goto fail; } else if (cbfs_prog_stage_load(&ramstage)) goto fail; stage_cache_add(STAGE_RAMSTAGE, &ramstage); timestamp_add_now(TS_END_COPYRAM); prog_run(&ramstage); fail: die("Ramstage was not loaded!\n"); }
/*! The main function. */ void job_on_the_field(struct programs_t *progs, struct debug_t *debug, struct tm *tm_clock) { if (flag_get(progs, FL_LED)) led_set(GREEN, ON); if (flag_get(progs, FL_LOG)) { debug_print_P(PSTR("Executing programs at "), debug); date(debug); } prog_run(progs, tm_clock, debug); if (prog_alarm(progs)) { if (flag_get(progs, FL_LED)) led_set(RED, BLINK); if (flag_get(progs, FL_LOG)) debug_print_P(PSTR("ALARM! queue run skipped!\n"), debug); } else { if (flag_get(progs, FL_LOG)) { debug_print_P(PSTR("Run queue at "), debug); date(debug); } queue_run(progs, tm_clock, debug); } /* print the temperature updated * from the prog_run call */ if (flag_get(progs, FL_LOG)) temperature_print(progs, debug); led_set(GREEN, OFF); }
static void run_ramstage_from_resume(struct romstage_handoff *handoff, struct prog *ramstage) { if (handoff != NULL && handoff->s3_resume) { /* Load the cached ramstage to runtime location. */ load_cached_ramstage(handoff, ramstage); if (prog_entry(ramstage) != NULL) { printk(BIOS_DEBUG, "Jumping to image.\n"); prog_run(ramstage); } } }
static void vboot_prepare(void) { int run_verification; run_verification = verification_should_run(); if (run_verification) { verstage_main(); car_set_var(vboot_executed, 1); } else if (verstage_should_load()) { struct cbfsf file; struct prog verstage = PROG_INIT(PROG_VERSTAGE, CONFIG_CBFS_PREFIX "/verstage"); printk(BIOS_DEBUG, "VBOOT: Loading verstage.\n"); /* load verstage from RO */ if (cbfs_boot_locate(&file, prog_name(&verstage), NULL)) die("failed to load verstage"); cbfs_file_data(prog_rdev(&verstage), &file); if (cbfs_prog_stage_load(&verstage)) die("failed to load verstage"); /* verify and select a slot */ prog_run(&verstage); /* This is not actually possible to hit this condition at * runtime, but this provides a hint to the compiler for dead * code elimination below. */ if (!IS_ENABLED(CONFIG_RETURN_FROM_VERSTAGE)) return; car_set_var(vboot_executed, 1); } /* * Fill in vboot cbmem objects before moving to ramstage so all * downstream users have access to vboot results. This path only * applies to platforms employing VBOOT_DYNAMIC_WORK_BUFFER because * cbmem comes online prior to vboot verification taking place. For * other platforms the vboot cbmem objects are initialized when * cbmem comes online. */ if (ENV_ROMSTAGE && IS_ENABLED(CONFIG_VBOOT_DYNAMIC_WORK_BUFFER)) { vb2_store_selected_region(); vboot_fill_handoff(); } }
static void load_ramstage(const struct prog_loader_ops *ops, struct romstage_handoff *handoff, struct prog *ramstage) { timestamp_add_now(TS_START_COPYRAM); if (ops->prepare(ramstage)) return; cache_loaded_ramstage(handoff, ramstage); timestamp_add_now(TS_END_COPYRAM); prog_run(ramstage); }
void payload_run(void) { struct prog *payload = &global_payload; /* Reset to booting from this image as late as possible */ boot_successful(); printk(BIOS_DEBUG, "Jumping to boot code at %p(%p)\n", prog_entry(payload), prog_entry_arg(payload)); post_code(POST_ENTER_ELF_BOOT); timestamp_add_now(TS_SELFBOOT_JUMP); /* Before we go off to run the payload, see if * we stayed within our bounds. */ checkstack(_estack, 0); prog_run(payload); }
void run_romstage(void) { struct prog romstage = PROG_INIT(ASSET_ROMSTAGE, CONFIG_CBFS_PREFIX "/romstage"); if (prog_locate(&romstage)) goto fail; timestamp_add_now(TS_START_COPYROM); if (cbfs_prog_stage_load(&romstage)) goto fail; timestamp_add_now(TS_END_COPYROM); prog_run(&romstage); fail: if (IS_ENABLED(CONFIG_BOOTBLOCK_CONSOLE)) die("Couldn't load romstage.\n"); halt(); }
static void vboot_prepare(void) { if (verification_should_run()) { /* Note: this path is not used for VBOOT_RETURN_FROM_VERSTAGE */ verstage_main(); car_set_var(vboot_executed, 1); vb2_save_recovery_reason_vbnv(); /* * Avoid double memory retrain when the EC is running RW code * and a recovery request came in through an EC host event. The * double retrain happens because the EC won't be rebooted * until kernel verification notices the EC isn't running RO * code which is after memory training. Therefore, reboot the * EC after we've saved the potential recovery request so it's * not lost. Lastly, only perform this sequence on x86 * platforms since those are the ones that currently do a * costly memory training in recovery mode. */ if (IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC) && IS_ENABLED(CONFIG_ARCH_X86)) google_chromeec_early_init(); } else if (verstage_should_load()) { struct cbfsf file; struct prog verstage = PROG_INIT(PROG_VERSTAGE, CONFIG_CBFS_PREFIX "/verstage"); printk(BIOS_DEBUG, "VBOOT: Loading verstage.\n"); /* load verstage from RO */ if (cbfs_boot_locate(&file, prog_name(&verstage), NULL)) die("failed to load verstage"); cbfs_file_data(prog_rdev(&verstage), &file); if (cbfs_prog_stage_load(&verstage)) die("failed to load verstage"); /* verify and select a slot */ prog_run(&verstage); /* This is not actually possible to hit this condition at * runtime, but this provides a hint to the compiler for dead * code elimination below. */ if (!IS_ENABLED(CONFIG_VBOOT_RETURN_FROM_VERSTAGE)) return; car_set_var(vboot_executed, 1); } /* * Fill in vboot cbmem objects before moving to ramstage so all * downstream users have access to vboot results. This path only * applies to platforms employing VBOOT_STARTS_IN_ROMSTAGE because * cbmem comes online prior to vboot verification taking place. For * other platforms the vboot cbmem objects are initialized when * cbmem comes online. */ if (ENV_ROMSTAGE && IS_ENABLED(CONFIG_VBOOT_STARTS_IN_ROMSTAGE)) { vb2_store_selected_region(); vboot_fill_handoff(); } }