void file_query_posix_( file_info_t * const info ) { struct stat statbuf; char const * const pathstr = object_str( info->name ); char const * const pathspec = *pathstr ? pathstr : "."; if ( stat( pathspec, &statbuf ) < 0 ) { info->is_file = 0; info->is_dir = 0; info->exists = 0; timestamp_clear( &info->time ); } else { info->is_file = statbuf.st_mode & S_IFREG ? 1 : 0; info->is_dir = statbuf.st_mode & S_IFDIR ? 1 : 0; info->exists = 1; #if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200809 #if defined(OS_MACOSX) timestamp_init( &info->time, statbuf.st_mtimespec.tv_sec, statbuf.st_mtimespec.tv_nsec ); #else timestamp_init( &info->time, statbuf.st_mtim.tv_sec, statbuf.st_mtim.tv_nsec ); #endif #else timestamp_init( &info->time, statbuf.st_mtime, 0 ); #endif } }
void ntp_init(struct ntp *ntp, struct sclock *clock) { ntp->sc = clock; timestamp_init(&(ntp->t1)); timestamp_init(&(ntp->t2)); timestamp_init(&(ntp->t3)); timestamp_init(&(ntp->t4)); }
void file_supported_fmt_resolution( timestamp * const t ) { #if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200809 timestamp_init( t, 0, 1 ); #else /* The current implementation does not support file modification timestamp * resolution of less than one second. */ timestamp_init( t, 1, 0 ); #endif }
/* C code entry point for the boot block */ void bootblock_main(const uint64_t reg_x0, const uint64_t reg_pc) { uint64_t base_timestamp = 0; init_timer(); if (IS_ENABLED(CONFIG_COLLECT_TIMESTAMPS)) base_timestamp = timestamp_get(); /* Initialize timestamps if we have TIMESTAMP region in memlayout.ld. */ if (IS_ENABLED(CONFIG_COLLECT_TIMESTAMPS) && _timestamp_size > 0) timestamp_init(base_timestamp); bootblock_soc_early_init(); bootblock_mainboard_early_init(); if (IS_ENABLED(CONFIG_BOOTBLOCK_CONSOLE)) { console_init(); exception_init(); if (reg_x0) printk(BIOS_ERR, "BOOTBLOCK: RST Boot Failure Code %lld\n", reg_x0); } bootblock_soc_init(); bootblock_mainboard_init(); run_romstage(); }
file_info_t * file_query( OBJECT * const path ) { /* FIXME: Add tracking for disappearing files (i.e. those that can not be * detected by stat() even though they had been detected successfully * before) and see how they should be handled in the rest of Boost Jam code. * Possibly allow Jamfiles to specify some files as 'volatile' which would * make Boost Jam avoid caching information about those files and instead * ask the OS about them every time. * * FIXME: Consider returning a clear file_info() result here if * file_query_() fails. Should simplify the caller side error checking and * the caller still can and needs to detect whether the file has not been * successfully detected by the OS, i.e. whether the file_query() call * failed. */ file_info_t * const ff = file_info( path ); if ( timestamp_empty( &ff->time ) ) { if ( file_query_( ff ) < 0 ) return 0; /* Set the path's timestamp to 1 in case it is 0 or undetected to avoid * confusion with non-existing paths. */ if ( timestamp_empty( &ff->time ) ) timestamp_init( &ff->time, 1, 0 ); } return ff; }
void romstage_init(void) { void *entry; #if CONFIG_COLLECT_TIMESTAMPS uint64_t start_romstage_time; uint64_t before_dram_time; uint64_t after_dram_time; uint64_t base_time = timestamp_get(); start_romstage_time = timestamp_get(); #endif rkclk_set_pll(); console_init(); #if CONFIG_COLLECT_TIMESTAMPS before_dram_time = timestamp_get(); #endif dram_main(); #if CONFIG_COLLECT_TIMESTAMPS after_dram_time = timestamp_get(); #endif udelay(100); cbmem_initialize_empty(); #if CONFIG_COLLECT_TIMESTAMPS timestamp_init(base_time); timestamp_add(TS_START_ROMSTAGE, start_romstage_time ); timestamp_add(TS_BEFORE_INITRAM, before_dram_time ); timestamp_add(TS_AFTER_INITRAM, after_dram_time ); #endif entry = cbfs_load_stage(CBFS_DEFAULT_MEDIA, "fallback/coreboot_ram"); #if CONFIG_COLLECT_TIMESTAMPS timestamp_add_now(TS_END_ROMSTAGE); #endif stage_exit(entry); }
void file_supported_fmt_resolution( timestamp * const t ) { /* The current implementation does not support file modification timestamp * resolution of less than one second. */ timestamp_init( t, 1, 0 ); }
/** @internal * @brief Calculates the RTT of the host with SSH channel operations, and * returns the average of the calculated RTT. * @param[in] session active SSH session to test. * @param[out] average average RTT in milliseconds. * @returns 0 on success, -1 if there is an error. */ int benchmarks_ssh_latency(ssh_session session, float *average){ float times[3]; struct timestamp_struct ts; int i; ssh_channel channel; channel=ssh_channel_new(session); if(channel==NULL) goto error; if(ssh_channel_open_session(channel)==SSH_ERROR) goto error; for(i=0;i<3;++i){ timestamp_init(&ts); if(ssh_channel_request_env(channel,"TEST","test")==SSH_ERROR && ssh_get_error_code(session)==SSH_FATAL) goto error; times[i]=elapsed_time(&ts); } ssh_channel_close(channel); ssh_channel_free(channel); channel=NULL; printf("Times : %f ms ; %f ms ; %f ms\n", times[0], times[1], times[2]); *average=(times[0]+times[1]+times[2])/3; return 0; error: fprintf(stderr,"Error calculating SSH latency : %s\n",ssh_get_error(session)); if(channel) ssh_channel_free(channel); return -1; }
file_info_t * file_query( OBJECT * const path ) { /* FIXME: Add tracking for disappearing files (i.e. those that can not be * detected by stat() even though they had been detected successfully * before) and see how they should be handled in the rest of Boost Jam code. * Possibly allow Jamfiles to specify some files as 'volatile' which would * make Boost Jam avoid caching information about those files and instead * ask the OS about them every time. */ int found; file_info_t * const ff = file_info( path, &found ); if ( !found ) { file_query_( ff ); if ( ff->exists ) { /* Set the path's timestamp to 1 in case it is 0 or undetected to avoid * confusion with non-existing paths. */ if ( timestamp_empty( &ff->time ) ) timestamp_init( &ff->time, 1, 0 ); } } if ( !ff->exists ) { return 0; } return ff; }
char loop(struct rtimer* t, void *ptr){ PT_BEGIN(&pt); uint8_t packet[TIMESTAMP_BIT]; int packet_len = 0; sclock_init(&sclk, TYPE_CLOCK); ntp_init(&ntp, &sclk); static struct timestamp second; timestamp_init(&second); second.sec = 1; while(1) { sclock_etimer_set(&sclk, &et, &second); PT_YIELD_UNTIL(&pt,etimer_expired(&et)); leds_invert(LEDS_RED); #if REQUEST packet_len = ntp_make_request(&ntp, packet); packetbuf_copyfrom(packet, packet_len); abc_send(&abc); #endif } PT_END(&pt); }
void main(void) { extern struct mem_timings mem_timings; int is_resume = (get_wakeup_state() != IS_NOT_WAKEUP); int power_init_failed; exynos5420_config_smp(); power_init_failed = setup_power(is_resume); timestamp_init(timestamp_get()); timestamp_add_now(TS_START_ROMSTAGE); /* Clock must be initialized before console_init, otherwise you may need * to re-initialize serial console drivers again. */ system_clock_init(); exynos_pinmux_uart3(); console_init(); exception_init(); if (power_init_failed) die("Failed to intialize power.\n"); /* re-initialize PMIC I2C channel after (re-)setting system clocks */ i2c_init(PMIC_I2C_BUS, 1000000, 0x00); /* 1MHz */ timestamp_add_now(TS_BEFORE_INITRAM); setup_memory(&mem_timings, is_resume); timestamp_add_now(TS_AFTER_INITRAM); primitive_mem_test(); trustzone_init(); if (is_resume) { wakeup(); } setup_gpio(); setup_ec(); simple_spi_test(); /* Set SPI (primary CBFS media) clock to 50MHz. */ /* if this is uncommented SPI will not work correctly. */ clock_set_rate(PERIPH_ID_SPI1, 50000000); exynos_pinmux_spi1(); simple_spi_test(); cbmem_initialize_empty(); simple_spi_test(); timestamp_add_now(TS_END_ROMSTAGE); run_ramstage(); }
void stopwatch_stop(struct stopwatch *timer, const struct timestamp *now) { if ((STOPWATCH_ACTIVE(timer))) { timestamp_add(&timer->total, now); timestamp_sub(&timer->total, &timer->start); timestamp_init(&timer->start); } else { //DEBUG_ONLY(NONFATAL("Stopping inactive stopwatch.")); } }
int arch_cpu_init(void) { int ret = get_coreboot_info(&lib_sysinfo); if (ret != 0) { printf("Failed to parse coreboot tables.\n"); return ret; } timestamp_init(); return x86_cpu_init_f(); }
void timestamp_current( timestamp * const t ) { #ifdef OS_NT /* GetSystemTimeAsFileTime()'s resolution seems to be about 15 ms on Windows * XP and under a millisecond on Windows 7. */ FILETIME ft; GetSystemTimeAsFileTime( &ft ); timestamp_from_filetime( t, &ft ); #else /* OS_NT */ timestamp_init( t, time( 0 ), 0 ); #endif /* OS_NT */ }
static void collect_archive_content_big( int fd, file_archive_info_t * const archive ) { struct fl_hdr_big fl_hdr; struct { struct ar_hdr_big hdr; char pad[ 256 ]; } ar_hdr ; char buf[ MAXJPATH ]; long long offset; const char * path = object_str( archive->file->name ); if ( read( fd, (char *)&fl_hdr, FL_HSZ_BIG ) != FL_HSZ_BIG ) return; sscanf( fl_hdr.fl_fstmoff, "%lld", &offset ); if ( DEBUG_BINDSCAN ) out_printf( "scan archive %s\n", path ); while ( offset > 0 && lseek( fd, offset, 0 ) >= 0 && read( fd, &ar_hdr, sizeof( ar_hdr ) ) >= sizeof( ar_hdr.hdr ) ) { long lar_date; int lar_namlen; sscanf( ar_hdr.hdr.ar_namlen, "%d" , &lar_namlen ); sscanf( ar_hdr.hdr.ar_date , "%ld" , &lar_date ); sscanf( ar_hdr.hdr.ar_nxtmem, "%lld", &offset ); if ( !lar_namlen ) continue; ar_hdr.hdr._ar_name.ar_name[ lar_namlen ] = '\0'; sprintf( buf, "%s", ar_hdr.hdr._ar_name.ar_name ); if ( strcmp( buf, "") != 0 ) { file_info_t * member = 0; archive->members = filelist_push_back( archive->members, object_new( buf ) ); member = filelist_back( archive->members ); member->is_file = 1; member->is_dir = 0; member->exists = 0; timestamp_init( &member->time, (time_t)lar_date, 0 ); } } }
static void plugin_init(OhmPlugin *plugin) { OHM_DEBUG_INIT(playback); client_init(plugin); media_init(plugin); pbreq_init(plugin); sm_init(plugin); dbusif_init(plugin); dresif_init(plugin); fsif_init(plugin); timestamp_init(); }
static void __attribute__((noinline)) romstage(void) { timestamp_init(0); timestamp_add_now(TS_START_ROMSTAGE); console_init(); exception_init(); sdram_init(get_sdram_config()); /* used for MMU and CBMEM setup, in MB */ u32 dram_start_mb = (uintptr_t)_dram/MiB; u32 dram_end_mb = sdram_max_addressable_mb(); u32 dram_size_mb = dram_end_mb - dram_start_mb; configure_l2_cache(); mmu_init(); /* Device memory below DRAM is uncached. */ mmu_config_range(0, dram_start_mb, DCACHE_OFF); /* SRAM is cached. MMU code will round size up to page size. */ mmu_config_range((uintptr_t)_sram/MiB, div_round_up(_sram_size, MiB), DCACHE_WRITEBACK); /* DRAM is cached. */ mmu_config_range(dram_start_mb, dram_size_mb, DCACHE_WRITEBACK); /* A window for DMA is uncached. */ mmu_config_range((uintptr_t)_dma_coherent/MiB, _dma_coherent_size/MiB, DCACHE_OFF); /* The space above DRAM is uncached. */ if (dram_end_mb < 4096) mmu_config_range(dram_end_mb, 4096 - dram_end_mb, DCACHE_OFF); mmu_disable_range(0, 1); dcache_mmu_enable(); /* * A watchdog reset only resets part of the system so it ends up in * a funny state. If that happens, we need to reset the whole machine. */ if (power_reset_status() == POWER_RESET_WATCHDOG) { printk(BIOS_INFO, "Watchdog reset detected, rebooting.\n"); hard_reset(); } /* FIXME: this may require coordination with moving timestamps */ cbmem_initialize_empty(); early_mainboard_init(); run_ramstage(); }
void main(void) { #if CONFIG_COLLECT_TIMESTAMPS uint64_t start_romstage_time; uint64_t before_dram_time; uint64_t after_dram_time; uint64_t base_time = timestamp_get(); start_romstage_time = timestamp_get(); #endif console_init(); configure_l2ctlr(); tsadc_init(); /* vdd_log 1200mv is enough for ddr run 666Mhz */ regulate_vdd_log(1200); #if CONFIG_COLLECT_TIMESTAMPS before_dram_time = timestamp_get(); #endif sdram_init(get_sdram_config()); #if CONFIG_COLLECT_TIMESTAMPS after_dram_time = timestamp_get(); #endif /* Now that DRAM is up, add mappings for it and DMA coherency buffer. */ mmu_config_range((uintptr_t)_dram/MiB, sdram_size_mb(), DCACHE_WRITEBACK); mmu_config_range((uintptr_t)_dma_coherent/MiB, _dma_coherent_size/MiB, DCACHE_OFF); cbmem_initialize_empty(); #if CONFIG_COLLECT_TIMESTAMPS timestamp_init(base_time); timestamp_add(TS_START_ROMSTAGE, start_romstage_time); timestamp_add(TS_BEFORE_INITRAM, before_dram_time); timestamp_add(TS_AFTER_INITRAM, after_dram_time); timestamp_add_now(TS_END_ROMSTAGE); #endif #if IS_ENABLED(CONFIG_VBOOT_VERIFY_FIRMWARE) void *entry = vboot2_load_ramstage(); if (entry != NULL) stage_exit(entry); #endif run_ramstage(); }
int file_query_posix_( file_info_t * const info ) { struct stat statbuf; char const * const pathstr = object_str( info->name ); char const * const pathspec = *pathstr ? pathstr : "."; assert( timestamp_empty( &info->time ) ); if ( stat( pathspec, &statbuf ) < 0 ) return -1; info->is_file = statbuf.st_mode & S_IFREG ? 1 : 0; info->is_dir = statbuf.st_mode & S_IFDIR ? 1 : 0; timestamp_init( &info->time, statbuf.st_mtime, 0 ); return 0; }
void bootblock_soc_init(void) { timestamp_init(timestamp_get()); rkclk_init(); mmu_init(); /* Start with a clean slate. */ mmu_config_range(0, 4096, DCACHE_OFF); /* SRAM is tightly wedged between registers, need to use subtables. Map * write-through as equivalent for non-cacheable without XN on A17. */ mmu_config_range_kb((uintptr_t)_sram/KiB, _sram_size/KiB, DCACHE_WRITETHROUGH); dcache_mmu_enable(); rkclk_configure_crypto(148500*KHz); }
void main(void) { init_timer(); if (IS_ENABLED(CONFIG_HAS_PRECBMEM_TIMESTAMP_REGION)) timestamp_init(timestamp_get()); bootblock_mainboard_early_init(); #if CONFIG_BOOTBLOCK_CONSOLE console_init(); exception_init(); #endif bootblock_soc_init(); bootblock_mainboard_init(); run_romstage(); }
static void frametimes_init_base(GH_frametimes *ft) { /* get the base timestamp */ if (ft->mode > GH_FRAMETIME_NONE) { GH_timestamp base; unsigned int i; GH_frametime *last=&ft->frametime[ft->num_results * ft->num_timestamps]; timestamp_init(&base); timestamp_set(&base, &last[0], ft->mode); timestamp_set(&base, &last[0], ft->mode); for (i=1; i<ft->num_timestamps; i++) { last[i]=last[0]; } timestamp_cleanup(&base); } }
void main(void) { struct mem_timings *mem; int is_resume = (get_wakeup_state() != IS_NOT_WAKEUP); timestamp_init(timestamp_get()); timestamp_add_now(TS_START_ROMSTAGE); /* Clock must be initialized before console_init, otherwise you may need * to re-initialize serial console drivers again. */ mem = setup_clock(); console_init(); exception_init(); setup_power(is_resume); timestamp_add_now(TS_BEFORE_INITRAM); setup_memory(mem, is_resume); timestamp_add_now(TS_AFTER_INITRAM); /* This needs to happen on normal boots and on resume. */ trustzone_init(); if (is_resume) { wakeup(); } setup_gpio(); setup_graphics(); /* Set SPI (primary CBFS media) clock to 50MHz and configure pinmux. */ exynos_pinmux_spi1(); clock_set_rate(PERIPH_ID_SPI1, 50000000); cbmem_initialize_empty(); timestamp_add_now(TS_END_ROMSTAGE); run_ramstage(); }
void timestamp_from_filetime( timestamp * const t, FILETIME const * const ft ) { /* Seconds between 1.1.1601 and 1.1.1970 */ static __int64 const secs_between_epochs = 11644473600; /* We can not simply cast and dereference a FILETIME, since it might not be * aligned properly. __int64 type variables are expected to be aligned to an * 8 byte boundary while FILETIME structures may be aligned to any 4 byte * boundary. Using an incorrectly aligned __int64 variable may cause a * performance penalty on some platforms or even exceptions on others * (documented on MSDN). */ __int64 in; memcpy( &in, ft, sizeof( in ) ); /* FILETIME resolution: 100ns. */ timestamp_init( t, (time_t)( ( in / 10000000 ) - secs_between_epochs ), (int)( in % 10000000 ) * 100 ); }
asmlinkage void bootblock_main_with_timestamp(uint64_t base_timestamp) { /* Initialize timestamps if we have TIMESTAMP region in memlayout.ld. */ if (IS_ENABLED(CONFIG_COLLECT_TIMESTAMPS) && _timestamp_size > 0) timestamp_init(base_timestamp); cmos_post_init(); bootblock_soc_early_init(); bootblock_mainboard_early_init(); if (IS_ENABLED(CONFIG_BOOTBLOCK_CONSOLE)) { console_init(); exception_init(); } bootblock_soc_init(); bootblock_mainboard_init(); run_romstage(); }
void * asmlinkage romstage_main(unsigned long bist) { int cbmem_was_initted; /* init_timer(); */ post_code(0x05); i82801ix_early_init(); console_init(); /* Halt if there was a built in self test failure */ report_bist_failure(bist); cbmem_was_initted = !cbmem_recovery(0); timestamp_init(timestamp_get()); timestamp_add_now(TS_START_ROMSTAGE); /* Emulation uses fixed low stack during ramstage. */ return NULL; }
void main(unsigned long bist) { int cbmem_was_initted; /* init_timer(); */ post_code(0x05); console_init(); /* Halt if there was a built in self test failure */ report_bist_failure(bist); //print_pci_devices(); //dump_pci_devices(); cbmem_was_initted = !cbmem_recovery(0); timestamp_init(timestamp_get()); timestamp_add_now(TS_START_ROMSTAGE); }
void file_query_posix_( file_info_t * const info ) { struct stat statbuf; char const * const pathstr = object_str( info->name ); char const * const pathspec = *pathstr ? pathstr : "."; if ( stat( pathspec, &statbuf ) < 0 ) { info->is_file = 0; info->is_dir = 0; info->exists = 0; timestamp_clear( &info->time ); } else { info->is_file = statbuf.st_mode & S_IFREG ? 1 : 0; info->is_dir = statbuf.st_mode & S_IFDIR ? 1 : 0; info->exists = 1; timestamp_init( &info->time, statbuf.st_mtime, 0 ); } }
/* Entry from cache-as-ram.inc. */ void * asmlinkage romstage_main(unsigned long bist, uint32_t tsc_low, uint32_t tsc_hi) { struct romstage_params rp = { .bist = bist, .mrc_params = NULL, }; /* Save initial timestamp from bootblock. */ timestamp_init((((uint64_t)tsc_hi) << 32) | (uint64_t)tsc_low); /* Save romstage begin */ timestamp_add_now(TS_START_ROMSTAGE); program_base_addresses(); tco_disable(); byt_config_com1_and_enable(); console_init(); spi_init(); set_max_freq(); punit_init(); gfx_init(); #if CONFIG_EC_GOOGLE_CHROMEEC /* Ensure the EC is in the right mode for recovery */ google_chromeec_early_init(); #endif /* Call into mainboard. */ mainboard_romstage_entry(&rp); return setup_stack_and_mttrs(); }
void mainboard_romstage_entry(unsigned long bist) { // ch0 ch1 const u8 spd_addrmap[4] = { 0x50, 0, 0x52, 0 }; u8 boot_path = 0; u8 s3_resume; timestamp_init(get_initial_timestamp()); timestamp_add_now(TS_START_ROMSTAGE); /* Set southbridge and Super I/O GPIOs. */ ich7_enable_lpc(); mb_lpc_setup(); console_init(); report_bist_failure(bist); enable_smbus(); x4x_early_init(); s3_resume = southbridge_detect_s3_resume(); if (s3_resume) boot_path = BOOT_PATH_RESUME; if (MCHBAR32(PMSTS_MCHBAR) & PMSTS_WARM_RESET) boot_path = BOOT_PATH_WARM_RESET; printk(BIOS_DEBUG, "Initializing memory\n"); timestamp_add_now(TS_BEFORE_INITRAM); sdram_initialize(boot_path, spd_addrmap); timestamp_add_now(TS_AFTER_INITRAM); quick_ram_check(); printk(BIOS_DEBUG, "Memory initialized\n"); x4x_late_init(s3_resume); printk(BIOS_DEBUG, "x4x late init complete\n"); }