int main(void) { time_t the_time; struct tm *tm_time; struct tm unknown_time = { /* sec, min, hour, mday, mon, year, wday, yday, isdst */ 40, 30, 2, 1, 8, 98, 0, 259, 0, }; time (&the_time); /* 取目前原始時間 */ printf (" current raw time is %ld\n", the_time); tm_time = gmtime (&the_time); /* 轉換原始時間至GMT分解時 */ printf (" gmtime gives: \n"); report_time (tm_time); tm_time = localtime (&the_time); /* 轉換原始時間至本機時 */ printf (" localtime gives: \n"); report_time (tm_time); /* 轉換一個用分解時表示的不存在的日期至原始時間 */ the_time = mktime (&unknown_time); if ( the_time <0 ) printf ("ERROR: mktime() call failed\n"); else { printf (" after calling mktime:\n"); printf (" time = %ld\n", the_time); report_time (&unknown_time); printf (" weekday: %s yearday: %d\n", wday[unknown_time.tm_wday], unknown_time.tm_yday); } }
void test_des_encrypt() { int n; int nt=10000; int i; byte key[8]={0x5b,0x5a,0x57,0x67,0x6a,0x56,0x67,0x6e}; byte inex[8]={0x67,0x5a,0x69,0x67,0x5e,0x5a,0x6b,0x5a}; byte outex[8]={0x97,0x4a,0xff,0xbf,0x86,0x02,0x2d,0x1f}; byte in[8]; byte out[8]; // testlagrangeRoy(); for(i=0;i<8;i++) in[i]=inex[i]; int dt,base=0; printf("Without countermeasure, plain: "); dt=run_des(in,out,key,nt); base=dt; report_time(dt,nt,base,0); check_ciphertext(out,outex,8); printf("Without countermeasure, Carlet: "); runalgo(des_encrypt_carlet,in,out,key,outex,8,nt,base); for(n=3;n<=13;n+=2) { printf("n=%d\n",n); printf(" With Carlet (RV13) countermeasure: "); init_randcount(); dt=run_des_share(in,out,key,n,&polyRoy_share,nt); // &polygen_share report_time(dt,nt,base,get_randcount()); check_ciphertext(out,outex,8); printf(" With Carlet (CRV14) countermeasure: "); init_randcount(); dt=run_des_share(in,out,key,n,&polyCRV_share,nt); report_time(dt,nt,base,get_randcount()); check_ciphertext(out,outex,8); printf(" With randomized table: "); init_randcount(); dt=run_des_share(in,out,key,n,&sbox_htable_word,nt); report_time(dt,nt,base,get_randcount()); check_ciphertext(out,outex,8); } }
int do_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { const int target_argc = argc - 1; int retval = 0; unsigned long int cycles = 0; cmd_tbl_t *target_cmdtp = NULL; if (argc == 1) { printf("no command provided\n"); return 1; } /* parse command */ target_cmdtp = find_cmd(argv[1]); if (!target_cmdtp) { printf("command not found: %s\n", argv[1]); return 1; } if (target_argc > target_cmdtp->maxargs) { printf("maxarags exceeded: %d > %d\n", target_argc, target_cmdtp->maxargs); return 1; } /* run the command and report run time */ cycles = get_timer_masked(); retval = target_cmdtp->cmd(target_cmdtp, 0, target_argc, argv + 1); cycles = get_timer_masked() - cycles; putc('\n'); report_time(cycles); return retval; }
int main() { int n; int nt=100; int i; byte keyex[16]={0x2b,0x7e,0x15,0x16,0x28,0xae,0xd2,0xa6,0xab,0xf7,0x15,0x88,0x09,0xcf,0x4f,0x3c}; byte inex[16]={0x32,0x43,0xf6,0xa8,0x88,0x5a,0x30,0x8d,0x31,0x31,0x98,0xa2,0xe0,0x37,0x07,0x34}; byte outex[16]={0x39,0x25,0x84,0x1d,0x02,0xdc,0x09,0xfb,0xdc,0x11,0x85,0x97,0x19,0x6a,0x0b,0x32}; byte in[16],out[16]; byte key[16]; printMes("in",inex); printMes("key",keyex); for(i=0;i<16;i++) key[i]=keyex[i]; for(i=0;i<16;i++) in[i]=inex[i]; double dt,base; printf("Without countermeasure, plain: "); dt=run_aes(in,out,key,nt); base=dt; check_ciphertext(out,outex,16); report_time(dt,nt,base); printf("Without countermeasure, RP: "); runalgo(&aes_rp,in,out,key,outex,16,nt,base); for(n=3;n<=9;n+=2) { printf("n=%d\n",n); printf(" With RP countermeasure: "); dt=run_aes_share(in,out,key,n,&subbyte_rp_share,nt); report_time(dt,nt,base); check_ciphertext(out,outex,16); printf(" With randomized table : "); dt=run_aes_share(in,out,key,n,&subbyte_htable_word,nt); report_time(dt,nt,base); check_ciphertext(out,outex,16); } }
static int do_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { ulong cycles = 0; int retval = 0; if (argc == 1) return cmd_usage(cmdtp); retval = run_command_and_time_it(0, argc - 1, argv + 1, &cycles); report_time(cycles); return retval; }
int main(int argc, char **argv) { gettimeofday(&t[0], NULL); read_from_stdin(); gettimeofday(&t[5], NULL); find_best_prices(); gettimeofday(&t[6], NULL); print_best_prices(); gettimeofday(&t[7], NULL); report_branch(); report_time(); return 0; }
static int do_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { ulong cycles = 0; int retval = 0; int repeatable; if (argc == 1) return CMD_RET_USAGE; retval = cmd_process(0, argc - 1, argv + 1, &repeatable, &cycles); report_time(cycles); return retval; }
static void handle_sighup(void) { char *t; syslog(LOG_DEBUG,"Sighup"); mf_sighup = 0; t = report_time(c_starttime,time(NULL)); syslog(LOG_INFO,"%s",t); syslog(LOG_INFO,"tuples: %10lu",(unsigned long)g_poolnum); syslog(LOG_INFO,"greylisted: %10lu",(unsigned long)g_greylisted); syslog(LOG_INFO,"whitelisted: %10lu",(unsigned long)g_whitelisted); syslog(LOG_INFO,"greylist expired: %10lu",(unsigned long)g_greylist_expired); syslog(LOG_INFO,"whitelist expired: %10lu",(unsigned long)g_whitelist_expired); free(t); }
int runalgo(void (*algo)(byte *,byte *,byte *),byte *in,byte *out,byte *key,byte *outex,int nbyte,int nt,int base) { int i; clock_t start,end; int dt; start=clock(); for(i=0;i<nt;i++) algo(in,out,key); end=clock(); dt=(int) (end-start); if (base==0) base=dt; report_time(dt,nt,base); check_ciphertext(out,outex,nbyte); return dt; }
static void load_gen(int fd) { int *buf; unsigned pkts=0; unsigned i=0; unsigned max_recvd=0; buf = malloc(BUFSIZE); if (backlog) { set_nonblocking(fd); } start_timer(); while (1) { int n; buf[0] = htonl(recv_size); buf[1] = i++; write(fd, buf, send_size); n = read(fd, buf, BUFSIZE); if (n == recv_size) { pkts++; if (buf[1] > max_recvd) max_recvd = buf[1]; if (max_recvd > i) max_recvd = i; } if (backlog && i - max_recvd >= backlog) { fd_set fds; struct timeval tv; tv.tv_sec = 0; tv.tv_usec = 1; FD_ZERO(&fds); FD_SET(fd, &fds); select(fd+1, &fds, NULL, NULL, &tv); } if (end_timer() > 1.0) { report_time(pkts*(recv_size+send_size)); start_timer(); pkts=0; } } }
static int compact_matches(struct sorthash_t *obarray, const int hashcount) /* compact the hash list by removing obvious uniques */ { struct sorthash_t *mp, *np; /* * To reduce the size of the in-core working set, we do a a * pre-elimination of duplicates based on hash key alone, in * linear time. This may leave in the array hashes that all * point to the same tree. We'll discard those in the next * phase. This costs less time than one might think; without it, * the clique detector in the next phase would have to do an * extra SORTHASHCMP per array slot to detect clique boundaries. Net * cost of this optimization is thus *one* SORTHASHCMP per entry. * The benefit is that it kicks lots of shreds out, reducing the * total working set at the time we build match lists. The idea * here is to avoid swapping, because typical data sets are so * large that handling them can easily kick the VM into * thrashing. * * The technique: first mark... */ if (SORTHASHCMP(obarray, obarray+1)) obarray[0].hash.flags = INTERNAL_FLAG; for (np = obarray+1; np < obarray + hashcount-1; np++) if (SORTHASHCMP(np, np-1) && SORTHASHCMP(np, np+1)) np->hash.flags = INTERNAL_FLAG; if (SORTHASHCMP(obarray+hashcount-2, obarray+hashcount-1)) obarray[hashcount-1].hash.flags = INTERNAL_FLAG; /* ...then sweep. */ for (mp = np = obarray; np < obarray + hashcount; np++) if (np->hash.flags != INTERNAL_FLAG) *mp++ = *np; /* now we get to reduce the memory footprint */ report_time("Compaction reduced %d shreds to %d", hashcount, mp - obarray); return (mp - obarray); }
static void prvTimeManageTask( void *pvParameters ) { configASSERT( ( ( unsigned long ) pvParameters ) == TIME_MANAGE_PARAMETER ); minute_count = 0; report_timeout = 60; // Produce a time report once every 60 minutes. /* @non-terminating@ */ for( ;; ) { if (rtc_triggered_a2()) { rtc_get(&time); minute_count++; if(minute_count == report_timeout) report_time(); update_absolute_time(); broadcast_minute(); rtc_reset_a2(); } exec_commands(); } }
int merge_compare(struct sorthash_t *obarray, int hashcount) /* report our results (header portion) */ { struct match_t *match, *copy; int matchcount; hashcount = compact_matches(obarray, hashcount); obarray = (struct sorthash_t *)realloc(obarray, sizeof(struct sorthash_t)*hashcount); matchcount = hashcount; hitlist = reduce_matches(obarray, &matchcount); if (debug) dump_array("After removing uniques.\n", obarray, hashcount); report_time("%d range groups after removing unique hashes", matchcount); mergecount = collapse_ranges(hitlist, matchcount); /* * Here's where we do significance filtering. As a side effect, * compact the match list in order to cut the n log n qsort time */ for (copy = match = hitlist; match < hitlist + matchcount; match++) if (match->nmatches > 0 && copy < match) { int i, flags = 0, maxsize = 0; for (i=0; i < match->nmatches; i++) { struct sorthash_t *rp = match->matches+i; int matchsize = rp->hash.end - rp->hash.start + 1; if (matchsize >= maxsize) maxsize = matchsize; /* * This odd-looking bit of logic, deals with an * annoying edge case. Sometimes we'll get boilerplate C * stuff in both a C and a text file. To cope, propagate * insignificance -- if we know from one context that a * particular span of text is not interesting, declare it * uninteresting everywhere. */ flags |= rp->hash.flags; } /* * Filter for sigificance right at the last minute. The * point of doing it this way is to allow significance bits to * propagate through range merges. */ if (maxsize >= minsize && (nofilter || !(flags & INSIGNIFICANT))) *copy++ = *match; } mergecount = (copy - hitlist); /* sort everything so the report looks neat */ qsort(hitlist, mergecount, sizeof(struct match_t), sortmatch); if (debug) dump_array("After merging ranges.\n", obarray, hashcount); report_time("%d range groups after merging", mergecount); return(mergecount); }
int main(int argc, char **argv) { int iterations; struct rusage endUsage; struct rusage startUsage; /* * getenv() on the existing environment. */ getrusage(RUSAGE_SELF, &startUsage); /* Iterate over setting variable. */ for (iterations = 0; iterations < MaxIterations; iterations++) if (getenv(name) == NULL) err(EXIT_FAILURE, "getenv(name)"); getrusage(RUSAGE_SELF, &endUsage); report_time("getenv(name)", &startUsage.ru_utime, &endUsage.ru_utime); /* * setenv() a variable with a large value. */ getrusage(RUSAGE_SELF, &startUsage); /* Iterate over setting variable. */ for (iterations = 0; iterations < MaxIterations; iterations++) if (setenv(name, value1, 1) == -1) err(EXIT_FAILURE, "setenv(name, value1, 1)"); getrusage(RUSAGE_SELF, &endUsage); report_time("setenv(name, value1, 1)", &startUsage.ru_utime, &endUsage.ru_utime); /* * getenv() the new variable on the new environment. */ getrusage(RUSAGE_SELF, &startUsage); /* Iterate over setting variable. */ for (iterations = 0; iterations < MaxIterations; iterations++) /* Set large value to variable. */ if (getenv(name) == NULL) err(EXIT_FAILURE, "getenv(name)"); getrusage(RUSAGE_SELF, &endUsage); report_time("getenv(name)", &startUsage.ru_utime, &endUsage.ru_utime); /* * getenv() a different variable on the new environment. */ getrusage(RUSAGE_SELF, &startUsage); /* Iterate over setting variable. */ for (iterations = 0; iterations < MaxIterations; iterations++) /* Set large value to variable. */ if (getenv(name2) == NULL) err(EXIT_FAILURE, "getenv(name2)"); getrusage(RUSAGE_SELF, &endUsage); report_time("getenv(name2)", &startUsage.ru_utime, &endUsage.ru_utime); /* * setenv() a variable with a small value. */ getrusage(RUSAGE_SELF, &startUsage); /* Iterate over setting variable. */ for (iterations = 0; iterations < MaxIterations; iterations++) if (setenv(name, value2, 1) == -1) err(EXIT_FAILURE, "setenv(name, value2, 1)"); getrusage(RUSAGE_SELF, &endUsage); report_time("setenv(name, value2, 1)", &startUsage.ru_utime, &endUsage.ru_utime); /* * getenv() a different variable on the new environment. */ getrusage(RUSAGE_SELF, &startUsage); /* Iterate over setting variable. */ for (iterations = 0; iterations < MaxIterations; iterations++) /* Set large value to variable. */ if (getenv(name2) == NULL) err(EXIT_FAILURE, "getenv(name)"); getrusage(RUSAGE_SELF, &endUsage); report_time("getenv(name)", &startUsage.ru_utime, &endUsage.ru_utime); /* * getenv() a different variable on the new environment. */ getrusage(RUSAGE_SELF, &startUsage); /* Iterate over setting variable. */ for (iterations = 0; iterations < MaxIterations; iterations++) /* Set large value to variable. */ if (getenv(name2) == NULL) err(EXIT_FAILURE, "getenv(name2)"); getrusage(RUSAGE_SELF, &endUsage); report_time("getenv(name2)", &startUsage.ru_utime, &endUsage.ru_utime); /* * putenv() a variable with a small value. */ getrusage(RUSAGE_SELF, &startUsage); /* Iterate over setting variable. */ for (iterations = 0; iterations < MaxIterations; iterations++) if (putenv(nameValuePair) == -1) err(EXIT_FAILURE, "putenv(nameValuePair)"); getrusage(RUSAGE_SELF, &endUsage); report_time("putenv(nameValuePair)", &startUsage.ru_utime, &endUsage.ru_utime); exit(EXIT_SUCCESS); }
TEST(Mem, random_uniform) { int seed = 1; int c1 = 437; int c2 = 0; int c3 = 0xDECAFBAD; int n = 544357; int status = 0; double max_err = 0.0, avg_err = 0.0; oskar_Mem* v_cpu_f = oskar_mem_create(OSKAR_SINGLE, OSKAR_CPU, n, &status); oskar_Mem* v_gpu_f = oskar_mem_create(OSKAR_SINGLE, OSKAR_GPU, n, &status); oskar_Mem* v_cpu_d = oskar_mem_create(OSKAR_DOUBLE, OSKAR_CPU, n, &status); oskar_Mem* v_gpu_d = oskar_mem_create(OSKAR_DOUBLE, OSKAR_GPU, n, &status); oskar_Timer* tmr = oskar_timer_create(OSKAR_TIMER_CUDA); // Run in single precision. oskar_timer_start(tmr); oskar_mem_random_uniform(v_cpu_f, seed, c1, c2, c3, &status); report_time(n, "uniform", "single", "CPU", oskar_timer_elapsed(tmr)); ASSERT_EQ(0, status) << oskar_get_error_string(status); oskar_timer_start(tmr); oskar_mem_random_uniform(v_gpu_f, seed, c1, c2, c3, &status); report_time(n, "uniform", "single", "GPU", oskar_timer_elapsed(tmr)); ASSERT_EQ(0, status) << oskar_get_error_string(status); // Check consistency between CPU and GPU results. oskar_mem_evaluate_relative_error(v_gpu_f, v_cpu_f, 0, &max_err, &avg_err, 0, &status); EXPECT_LT(max_err, 1e-5); EXPECT_LT(avg_err, 1e-5); // Run in double precision. oskar_timer_start(tmr); oskar_mem_random_uniform(v_cpu_d, seed, c1, c2, c3, &status); report_time(n, "uniform", "double", "CPU", oskar_timer_elapsed(tmr)); ASSERT_EQ(0, status) << oskar_get_error_string(status); oskar_timer_start(tmr); oskar_mem_random_uniform(v_gpu_d, seed, c1, c2, c3, &status); report_time(n, "uniform", "double", "GPU", oskar_timer_elapsed(tmr)); ASSERT_EQ(0, status) << oskar_get_error_string(status); // Check consistency between CPU and GPU results. oskar_mem_evaluate_relative_error(v_gpu_d, v_cpu_d, 0, &max_err, &avg_err, 0, &status); EXPECT_LT(max_err, 1e-10); EXPECT_LT(avg_err, 1e-10); // Check consistency between single and double precision. oskar_mem_evaluate_relative_error(v_cpu_f, v_cpu_d, 0, &max_err, &avg_err, 0, &status); EXPECT_LT(max_err, 1e-5); EXPECT_LT(avg_err, 1e-5); if (save) { FILE* fhan = fopen("random_uniform.txt", "w"); oskar_mem_save_ascii(fhan, 4, n, &status, v_cpu_f, v_gpu_f, v_cpu_d, v_gpu_d); fclose(fhan); } // Free memory. oskar_mem_free(v_cpu_f, &status); oskar_mem_free(v_gpu_f, &status); oskar_mem_free(v_cpu_d, &status); oskar_mem_free(v_gpu_d, &status); oskar_timer_free(tmr); }
bool Adapt<Scalar>::adapt(Hermes::vector<RefinementSelectors::Selector<Scalar> *> refinement_selectors, double thr, int strat, int regularize, double to_be_processed) { error_if(!have_errors, "element errors have to be calculated first, call Adapt<Scalar>::calc_err_est()."); error_if(refinement_selectors == Hermes::vector<RefinementSelectors::Selector<Scalar> *>(), "selector not provided"); if (spaces.size() != refinement_selectors.size()) error("Wrong number of refinement selectors."); Hermes::TimePeriod cpu_time; //get meshes int max_id = -1; Mesh* meshes[H2D_MAX_COMPONENTS]; for (int j = 0; j < this->num; j++) { meshes[j] = this->spaces[j]->get_mesh(); if (rsln[j] != NULL) { rsln[j]->set_quad_2d(&g_quad_2d_std); rsln[j]->enable_transform(false); } if (meshes[j]->get_max_element_id() > max_id) max_id = meshes[j]->get_max_element_id(); } //reset element refinement info int** idx = new int*[max_id]; for(int i = 0; i < max_id; i++) idx[i] = new int[num]; for(int j = 0; j < max_id; j++) for(int l = 0; l < this->num; l++) idx[j][l] = -1; // element not refined double err0_squared = 1000.0; double processed_error_squared = 0.0; std::vector<ElementToRefine> elem_inx_to_proc; //list of indices of elements that are going to be processed elem_inx_to_proc.reserve(num_act_elems); //adaptivity loop double error_squared_threshod = -1; //an error threshold that breaks the adaptivity loop in a case of strategy 1 int num_exam_elem = 0; //a number of examined elements int num_ignored_elem = 0; //a number of ignored elements int num_not_changed = 0; //a number of element that were not changed int num_priority_elem = 0; //a number of elements that were processed using priority queue bool first_regular_element = true; //true if first regular element was not processed yet int inx_regular_element = 0; while (inx_regular_element < num_act_elems || !priority_queue.empty()) { int id, comp, inx_element; //get element identification if (priority_queue.empty()) { id = regular_queue[inx_regular_element].id; comp = regular_queue[inx_regular_element].comp; inx_element = inx_regular_element; inx_regular_element++; } else { id = priority_queue.front().id; comp = priority_queue.front().comp; inx_element = -1; priority_queue.pop(); num_priority_elem++; } num_exam_elem++; //get info linked with the element double err_squared = errors[comp][id]; Mesh* mesh = meshes[comp]; Element* e = mesh->get_element(id); if (!should_ignore_element(inx_element, mesh, e)) { //check if adaptivity loop should end if (inx_element >= 0) { //prepare error threshold for strategy 1 if (first_regular_element) { error_squared_threshod = thr * err_squared; first_regular_element = false; } // first refinement strategy: // refine elements until prescribed amount of error is processed // if more elements have similar error refine all to keep the mesh symmetric if ((strat == 0) && (processed_error_squared > sqrt(thr) * errors_squared_sum) && fabs((err_squared - err0_squared)/err0_squared) > 1e-3) break; // second refinement strategy: // refine all elements whose error is bigger than some portion of maximal error if ((strat == 1) && (err_squared < error_squared_threshod)) break; if ((strat == 2) && (err_squared < thr)) break; if ((strat == 3) && ( (err_squared < error_squared_threshod) || ( processed_error_squared > 1.5 * to_be_processed )) ) break; } // get refinement suggestion ElementToRefine elem_ref(id, comp); int current = this->spaces[comp]->get_element_order(id); // rsln[comp] may be unset if refinement_selectors[comp] == HOnlySelector or POnlySelector bool refined = refinement_selectors[comp]->select_refinement(e, current, rsln[comp], elem_ref); //add to a list of elements that are going to be refined if (can_refine_element(mesh, e, refined, elem_ref) ) { idx[id][comp] = (int)elem_inx_to_proc.size(); elem_inx_to_proc.push_back(elem_ref); err0_squared = err_squared; processed_error_squared += err_squared; } else { debug_log("Element (id:%d, comp:%d) not changed", e->id, comp); num_not_changed++; } } else { num_ignored_elem++; } } verbose("Examined elements: %d", num_exam_elem); verbose(" Elements taken from priority queue: %d", num_priority_elem); verbose(" Ignored elements: %d", num_ignored_elem); verbose(" Not changed elements: %d", num_not_changed); verbose(" Elements to process: %d", elem_inx_to_proc.size()); bool done = false; if (num_exam_elem == 0) done = true; else if (elem_inx_to_proc.empty()) { warn("None of the elements selected for refinement could be refined. Adaptivity step not successful, returning 'true'."); done = true; } //fix refinement if multimesh is used fix_shared_mesh_refinements(meshes, elem_inx_to_proc, idx, refinement_selectors); //apply refinements apply_refinements(elem_inx_to_proc); // in singlemesh case, impose same orders across meshes homogenize_shared_mesh_orders(meshes); // mesh regularization if (regularize >= 0) { if (regularize == 0) { regularize = 1; warn("Total mesh regularization is not supported in adaptivity. 1-irregular mesh is used instead."); } for (int i = 0; i < this->num; i++) { int* parents; parents = meshes[i]->regularize(regularize); this->spaces[i]->distribute_orders(meshes[i], parents); ::free(parents); } } for (int j = 0; j < this->num; j++) if (rsln[j] != NULL) rsln[j]->enable_transform(true); verbose("Refined elements: %d", elem_inx_to_proc.size()); report_time("Refined elements in: %g s", cpu_time.tick().last()); //store for the user to retrieve last_refinements.swap(elem_inx_to_proc); have_errors = false; if (strat == 2 && done == true) have_errors = true; // space without changes // since space changed, assign dofs: Space<Scalar>::assign_dofs(this->spaces); return done; }
/* spl_image defined in spl.c */ void spl_sboot_extend(void) { uint8_t csum[20]; uint8_t out_digest[20]; uint8_t image_buffer[SBOOT_SPL_READ_SIZE]; SHA1_CTX ctx; #ifdef CONFIG_SBOOT_TIMING uint32_t timer_begin = get_timer_masked(); #endif sha1_starts(&ctx); /* Only support MMC/FAT */ #if defined(CONFIG_SPL_MMC_SUPPORT) && defined(CONFIG_SPL_FAT_SUPPORT) /* Todo: add a configuration option to limit the memory read length. * This will allow us to SHA1 in blocks. * Todo: add a configuration option to use the TPM's SHA1 for extreme * memory contention scenarios. */ sha1_update(&ctx, (unsigned char *) spl_image.load_addr, spl_image.size); #else #warning "Warning: sboot does not support the U-Boot storage configuration." #endif sha1_finish(&ctx, csum); if (sboot_extend(SBOOT_PCR_UBOOT, csum, out_digest) != SBOOT_SUCCESS) { puts("SPL: (sboot) error while measuring U-Boot\n"); goto finished; } sha1_starts(&ctx); /* Extend EEPROM, support I2C only */ #ifdef CONFIG_ENV_EEPROM_IS_ON_I2C /* for (i = 0; i * SBOOT_SPL_READ_SIZE < CONFIG_SYS_I2C_EEPROM_SIZE; ++i) { memset(image_buffer, 0, SBOOT_SPL_READ_SIZE); if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, CONFIG_SYS_I2C_EEPROM_ADDR_LEN, image_buffer, SBOOT_SPL_READ_SIZE)) { puts("SPL: (sboot) could not read the EEPROM\n"); return; } sha1_update(&ctx, image_buffer, SBOOT_SPL_READ_SIZE); }*/ debug("SPL: (sboot) measuring EEPROM\n"); i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, CONFIG_SYS_I2C_EEPROM_ADDR_LEN, image_buffer, CONFIG_SYS_I2C_EEPROM_SIZE); sha1_update(&ctx, image_buffer, CONFIG_SYS_I2C_EEPROM_SIZE); debug("SPL: (sboot) finished\n"); #else #warning "Warning: sboot does not support the ENV storage configuration." #endif sha1_finish(&ctx, csum); if (sboot_extend(SBOOT_PCR_CHIPSET_CONFIG, csum, out_digest) != SBOOT_SUCCESS) { puts("SPL: (sboot) error while measuring chipset config\n"); goto finished; } finished: #ifdef CONFIG_SBOOT_TIMING report_time("extend", get_timer_masked() - timer_begin); #endif return; }