Lines Matching refs:rc
119 int rc; in boot_read_image_headers() local
123 rc = BOOT_HOOK_CALL(boot_read_image_header_hook, BOOT_HOOK_REGULAR, in boot_read_image_headers()
125 if (rc == BOOT_HOOK_REGULAR) in boot_read_image_headers()
127 rc = boot_read_image_header(state, i, boot_img_hdr(state, i), bs); in boot_read_image_headers()
129 if (rc != 0) { in boot_read_image_headers()
139 return rc; in boot_read_image_headers()
160 int rc; in boot_add_shared_data() local
163 rc = boot_save_boot_status(BOOT_CURR_IMG(state), in boot_add_shared_data()
166 if (rc != 0) { in boot_add_shared_data()
168 return rc; in boot_add_shared_data()
173 rc = boot_save_shared_data(boot_img_hdr(state, active_slot), in boot_add_shared_data()
176 if (rc != 0) { in boot_add_shared_data()
178 return rc; in boot_add_shared_data()
317 int rc; in boot_initialize_area() local
337 rc = flash_area_get_sectors(flash_area, &num_sectors, out_sectors); in boot_initialize_area()
340 rc = flash_area_to_sectors(flash_area, (int *)&num_sectors, out_sectors); in boot_initialize_area()
342 if (rc != 0) { in boot_initialize_area()
343 return rc; in boot_initialize_area()
355 int rc; in boot_read_sectors_recovery() local
359 rc = boot_initialize_area(state, FLASH_AREA_IMAGE_PRIMARY(image_index)); in boot_read_sectors_recovery()
360 if (rc != 0) { in boot_read_sectors_recovery()
364 rc = boot_initialize_area(state, FLASH_AREA_IMAGE_SECONDARY(image_index)); in boot_read_sectors_recovery()
365 if (rc != 0) { in boot_read_sectors_recovery()
394 int rc; in boot_verify_slot_dependency() local
408 rc = boot_version_cmp(dep_version, &dep->image_min_version); in boot_verify_slot_dependency()
410 if (rc < 0) { in boot_verify_slot_dependency()
430 rc = 0; in boot_verify_slot_dependency()
433 if (rc >= 0) { in boot_verify_slot_dependency()
435 rc = 0; in boot_verify_slot_dependency()
439 return rc; in boot_verify_slot_dependency()
450 int rc = -1; in boot_verify_dependencies() local
466 rc = boot_verify_slot_dependencies(state, slot); in boot_verify_dependencies()
467 if (rc == 0) { in boot_verify_dependencies()
481 return rc; in boot_verify_dependencies()
502 int rc = -1; in boot_verify_dependencies() local
510 rc = boot_verify_slot_dependencies(state, active_slot); in boot_verify_dependencies()
511 if (rc != 0) { in boot_verify_dependencies()
521 return rc; in boot_verify_dependencies()
525 return rc; in boot_verify_dependencies()
546 int rc; in boot_verify_slot_dependencies() local
549 rc = flash_area_open(area_id, &fap); in boot_verify_slot_dependencies()
550 if (rc != 0) { in boot_verify_slot_dependencies()
551 rc = BOOT_EFLASH; in boot_verify_slot_dependencies()
555 rc = bootutil_tlv_iter_begin(&it, boot_img_hdr(state, slot), fap, in boot_verify_slot_dependencies()
557 if (rc != 0) { in boot_verify_slot_dependencies()
562 rc = bootutil_tlv_iter_next(&it, &off, &len, NULL); in boot_verify_slot_dependencies()
563 if (rc < 0) { in boot_verify_slot_dependencies()
565 } else if (rc > 0) { in boot_verify_slot_dependencies()
566 rc = 0; in boot_verify_slot_dependencies()
571 rc = BOOT_EBADIMAGE; in boot_verify_slot_dependencies()
575 rc = LOAD_IMAGE_DATA(boot_img_hdr(state, slot), in boot_verify_slot_dependencies()
577 if (rc != 0) { in boot_verify_slot_dependencies()
578 rc = BOOT_EFLASH; in boot_verify_slot_dependencies()
583 rc = BOOT_EBADARGS; in boot_verify_slot_dependencies()
588 rc = boot_verify_slot_dependency(state, &dep); in boot_verify_slot_dependencies()
589 if (rc != 0) { in boot_verify_slot_dependencies()
597 return rc; in boot_verify_slot_dependencies()
616 int rc; in boot_read_image_size() local
623 rc = flash_area_open(area_id, &fap); in boot_read_image_size()
624 if (rc != 0) { in boot_read_image_size()
625 rc = BOOT_EFLASH; in boot_read_image_size()
632 rc = BOOT_EFLASH; in boot_read_image_size()
639 rc = BOOT_EBADIMAGE; in boot_read_image_size()
644 rc = BOOT_EFLASH; in boot_read_image_size()
648 rc = BOOT_EBADIMAGE; in boot_read_image_size()
653 rc = BOOT_EBADIMAGE; in boot_read_image_size()
658 rc = 0; in boot_read_image_size()
662 return rc; in boot_read_image_size()
700 int rc; in boot_read_sectors() local
704 rc = boot_initialize_area(state, FLASH_AREA_IMAGE_PRIMARY(image_index)); in boot_read_sectors()
705 if (rc != 0) { in boot_read_sectors()
709 rc = boot_initialize_area(state, FLASH_AREA_IMAGE_SECONDARY(image_index)); in boot_read_sectors()
710 if (rc != 0) { in boot_read_sectors()
716 rc = boot_initialize_area(state, FLASH_AREA_IMAGE_SCRATCH); in boot_read_sectors()
717 if (rc != 0) { in boot_read_sectors()
769 int rc = 0; in boot_write_status() local
792 rc = flash_area_open(area_id, &fap); in boot_write_status()
793 if (rc != 0) { in boot_write_status()
808 rc = flash_area_write(fap, off, buf, align); in boot_write_status()
809 if (rc != 0) { in boot_write_status()
810 rc = BOOT_EFLASH; in boot_write_status()
815 return rc; in boot_write_status()
828 int rc; in boot_image_check() local
836 (void)rc; in boot_image_check()
842 rc = boot_enc_load(BOOT_CURR_ENC(state), 1, hdr, fap, bs); in boot_image_check()
843 if (rc < 0) { in boot_image_check()
846 if (rc == 0 && boot_enc_set_key(BOOT_CURR_ENC(state), 1, bs)) { in boot_image_check()
979 int rc; local
982 rc = flash_area_open(area_id, &fap);
983 if (rc != 0) {
1051 int rc; local
1054 rc = flash_area_open(area_id, &fap);
1055 if (rc != 0) {
1087 rc = boot_version_cmp(
1090 if (rc < 0 && boot_check_header_erased(state, BOOT_PRIMARY_SLOT)) {
1137 rc = flash_area_read(fap, reset_addr, &reset_value, sizeof(reset_value));
1138 if (rc != 0) {
1186 int rc; local
1188 rc = flash_area_open(flash_area_id_from_multi_image_slot(image_index, slot),
1190 if (rc != 0) {
1191 rc = BOOT_EFLASH;
1195 rc = bootutil_get_img_security_cnt(hdr, fap, &img_security_cnt);
1196 if (rc != 0) {
1200 rc = boot_nv_security_counter_update(image_index, img_security_cnt);
1201 if (rc != 0) {
1207 return rc;
1300 int rc; local
1356 rc = flash_area_read(fap_src, off_src + bytes_copied, buf, chunk_sz);
1357 if (rc != 0) {
1407 rc = flash_area_write(fap_dst, off_dst + bytes_copied, buf, chunk_sz);
1408 if (rc != 0) {
1439 int rc; local
1458 rc = boot_read_image_size(state, BOOT_SECONDARY_SLOT, &src_size);
1459 assert(rc == 0);
1467 rc = flash_area_open(FLASH_AREA_IMAGE_PRIMARY(image_index),
1469 assert (rc == 0);
1471 rc = flash_area_open(FLASH_AREA_IMAGE_SECONDARY(image_index),
1473 assert (rc == 0);
1478 rc = boot_erase_region(fap_primary_slot, size, this_size);
1479 assert(rc == 0);
1502 rc = boot_erase_region(fap_primary_slot, off, sz);
1503 assert(rc == 0);
1508 rc = boot_enc_load(BOOT_CURR_ENC(state), BOOT_SECONDARY_SLOT,
1512 if (rc < 0) {
1515 if (rc == 0 && boot_enc_set_key(BOOT_CURR_ENC(state), 1, bs)) {
1523 rc = boot_copy_region(state, fap_secondary_slot, fap_primary_slot, 0, 0, size);
1524 if (rc != 0) {
1525 return rc;
1529 rc = boot_write_magic(fap_primary_slot);
1530 if (rc != 0) {
1531 return rc;
1535 rc = BOOT_HOOK_CALL(boot_copy_region_post_hook, 0, BOOT_CURR_IMG(state),
1537 if (rc != 0) {
1538 return rc;
1547 rc = boot_update_security_counter(BOOT_CURR_IMG(state), BOOT_PRIMARY_SLOT,
1549 if (rc != 0) {
1551 return rc;
1562 rc = boot_erase_region(fap_secondary_slot,
1565 assert(rc == 0);
1570 rc = boot_erase_region(fap_secondary_slot,
1575 assert(rc == 0);
1611 int rc; local
1625 rc = boot_read_image_size(state, BOOT_PRIMARY_SLOT, ©_size);
1626 assert(rc == 0);
1632 rc = boot_enc_load(BOOT_CURR_ENC(state), 0, hdr, fap, bs);
1633 assert(rc >= 0);
1635 if (rc == 0) {
1636 rc = boot_enc_set_key(BOOT_CURR_ENC(state), 0, bs);
1637 assert(rc == 0);
1639 rc = 0;
1648 rc = boot_read_image_size(state, BOOT_SECONDARY_SLOT, &size);
1649 assert(rc == 0);
1656 rc = boot_enc_load(BOOT_CURR_ENC(state), 1, hdr, fap, bs);
1657 assert(rc >= 0);
1659 if (rc == 0) {
1660 rc = boot_enc_set_key(BOOT_CURR_ENC(state), 1, bs);
1661 assert(rc == 0);
1663 rc = 0;
1681 rc = boot_find_status(image_index, &fap);
1683 rc = boot_read_swap_size(fap, &bs->swap_size);
1684 assert(rc == 0);
1690 rc = boot_read_enc_key(fap, slot, bs);
1691 assert(rc == 0);
1718 rc = BOOT_HOOK_CALL(boot_copy_region_post_hook, 0, BOOT_CURR_IMG(state),
1736 int rc; local
1743 rc = boot_copy_image(state, bs);
1750 rc = boot_check_header_erased(state, BOOT_PRIMARY_SLOT);
1752 if (rc == 0 || FIH_NOT_EQ(fih_rc, FIH_SUCCESS)) {
1753 rc = boot_copy_image(state, bs);
1755 rc = boot_swap_image(state, bs);
1758 rc = boot_swap_image(state, bs);
1760 assert(rc == 0);
1769 rc = swap_set_image_ok(BOOT_CURR_IMG(state));
1770 if (rc != 0) {
1786 rc = boot_update_security_counter(
1790 if (rc != 0) {
1799 rc = swap_set_copy_done(BOOT_CURR_IMG(state));
1800 if (rc != 0) {
1806 return rc;
1821 int rc; local
1826 rc = boot_swap_image(state, bs);
1827 assert(rc == 0);
1836 rc = swap_set_image_ok(BOOT_CURR_IMG(state));
1837 if (rc != 0) {
1843 rc = swap_set_copy_done(BOOT_CURR_IMG(state));
1844 if (rc != 0) {
1857 return rc;
1933 int rc; local
1941 rc = boot_read_sectors(state);
1942 if (rc != 0) {
1949 if (rc == BOOT_EFLASH)
1957 rc = boot_read_image_headers(state, false, NULL);
1958 if (rc != 0) {
1983 rc = swap_read_status(state, bs);
1984 if (rc != 0) {
1998 rc = boot_read_image_headers(state, !boot_status_is_reset(bs), bs);
2001 if (rc != 0 && (BOOT_CURR_IMG(state) != BOOT_PRIMARY_SLOT ||
2004 if (rc != 0) {
2033 rc = boot_complete_partial_swap(state, bs);
2034 assert(rc == 0);
2039 rc = boot_read_image_headers(state, false, bs);
2040 assert(rc == 0);
2070 rc = boot_check_header_erased(state, BOOT_PRIMARY_SLOT);
2074 if (rc == 0 || FIH_NOT_EQ(fih_rc, FIH_SUCCESS)) {
2076 rc = (boot_img_hdr(state, BOOT_SECONDARY_SLOT)->ih_magic == IMAGE_MAGIC) ? 1: 0;
2080 if (rc == 1 && FIH_EQ(fih_rc, FIH_SUCCESS)) {
2109 int rc; local
2122 rc = boot_update_security_counter(
2126 if (rc != 0) {
2129 return rc;
2158 int rc; local
2162 rc = bootutil_get_img_security_cnt(&(BOOT_IMG(state, 0).hdr),
2165 if (rc != 0) {
2170 rc = bootutil_get_img_security_cnt(&(BOOT_IMG(state, 1).hdr),
2173 if (rc != 0 || security_counter[0] > security_counter[1]) {
2174 rc = -1;
2178 rc = boot_version_cmp(&boot_img_hdr(state, BOOT_SECONDARY_SLOT)->ih_ver,
2181 if (rc < 0) {
2187 rc = 0;
2189 return rc;
2201 int rc = -1; local
2270 rc = flash_area_open(fa_id, &BOOT_IMG_AREA(state, slot));
2271 assert(rc == 0);
2273 if (rc != 0) {
2275 "cannot continue", fa_id, image_index, (int8_t)slot, rc);
2280 rc = flash_area_open(FLASH_AREA_IMAGE_SCRATCH,
2282 assert(rc == 0);
2284 if (rc != 0) {
2285 BOOT_LOG_ERR("Failed to open scratch flash area: %d, cannot continue", rc);
2303 rc = boot_verify_dependencies(state);
2304 if (rc != 0) {
2311 rc = 0;
2358 rc = BOOT_HOOK_CALL(boot_perform_update_hook, BOOT_HOOK_REGULAR,
2361 if (rc == BOOT_HOOK_REGULAR)
2363 rc = boot_perform_update(state, &bs);
2365 assert(rc == 0);
2375 rc = swap_set_image_ok(BOOT_CURR_IMG(state));
2376 if (rc != 0) {
2421 rc = boot_read_image_headers(state, false, NULL);
2422 if (rc != 0) {
2453 rc = BOOT_EBADIMAGE;
2459 rc = boot_update_hw_rollback_protection(state);
2460 if (rc != 0) {
2465 rc = boot_add_shared_data(state, BOOT_PRIMARY_SLOT);
2466 if (rc != 0) {
2507 int rc; local
2518 rc = flash_area_open(loader_flash_id,
2520 assert(rc == 0);
2522 rc = flash_area_open(split_flash_id,
2524 assert(rc == 0);
2527 rc = boot_read_sectors(&boot_data);
2528 if (rc != 0) {
2529 rc = SPLIT_GO_ERR;
2533 rc = boot_read_image_headers(&boot_data, true, NULL);
2534 if (rc != 0) {
2554 rc = SPLIT_GO_OK;
2561 if (rc) {
2582 int rc; local
2595 rc = flash_area_open(fa_id, &BOOT_IMG_AREA(state, slot));
2596 assert(rc == 0);
2600 rc = boot_read_image_headers(state, false, NULL);
2601 if (rc != 0) {
2603 return rc;
2642 int rc; local
2649 rc = boot_version_cmp(
2652 if (rc == 1) {
2709 int rc; local
2716 rc = flash_area_open(fa_id, &fap);
2717 assert(rc == 0);
2722 rc = boot_read_swap_state(fap, active_swap_state);
2723 assert(rc == 0);
2735 rc = flash_area_erase(fap, 0, flash_area_get_size(fap));
2736 assert(rc == 0);
2739 rc = -1;
2752 rc = boot_write_copy_done(fap);
2753 if (rc != 0) {
2757 rc = 0;
2763 return rc;
2795 int rc; local
2797 rc = boot_get_image_exec_ram_info(BOOT_CURR_IMG(state), &exec_ram_start,
2799 if (rc != 0) {
2862 int rc; local
2866 rc = flash_area_open(area_id, &fap_src);
2867 if (rc != 0){
2874 rc = flash_area_read(fap_src, 0, ram_dst, src_sz);
2875 if (rc != 0) {
2879 rc = boot_enc_load(BOOT_CURR_ENC(state), slot, hdr, fap_src, &bs);
2880 if (rc < 0) {
2885 if (rc == 0 && boot_enc_set_key(BOOT_CURR_ENC(state), slot, &bs)) {
2911 rc = 0;
2916 return rc;
2935 int rc; local
2945 rc = flash_area_open(area_id, &fap_src);
2946 if (rc != 0) {
2951 rc = flash_area_read(fap_src, 0, (void *)(IMAGE_RAM_BASE + img_dst), img_sz);
2952 if (rc != 0) {
2954 BOOT_CURR_IMG(state), rc);
2959 return rc;
3047 int rc; local
3056 rc = boot_read_image_size(state, active_slot, &img_sz);
3057 if (rc != 0) {
3058 return rc;
3064 rc = boot_verify_ram_load_address(state);
3065 if (rc != 0) {
3067 return rc;
3071 rc = boot_check_ram_load_overlapping(state);
3072 if (rc != 0) {
3075 return rc;
3081 rc = boot_decrypt_and_copy_image_to_sram(state, active_slot, hdr, img_sz, img_dst);
3083 rc = boot_copy_image_to_sram(state, active_slot, img_dst, img_sz);
3089 rc = boot_copy_image_to_sram(state, active_slot, img_dst, img_sz);
3091 if (rc != 0) {
3100 rc = BOOT_EBADIMAGE;
3103 if (rc != 0) {
3108 return rc;
3148 int rc; local
3156 rc = flash_area_open(area_id, &fap);
3157 if (rc == 0) {
3162 return rc;
3178 int rc; local
3211 rc = boot_rom_address_check(state);
3212 if (rc != 0) {
3220 rc = boot_select_or_erase(state);
3221 if (rc != 0) {
3236 rc = boot_load_image_to_sram(state);
3237 if (rc != 0 ) {
3276 int rc; local
3289 rc = boot_update_security_counter(BOOT_CURR_IMG(state),
3292 if (rc != 0) {
3294 return rc;
3311 int rc; local
3314 rc = boot_get_slot_usage(state);
3315 if (rc != 0) {
3329 rc = boot_verify_dependencies(state);
3330 if (rc != 0) {
3348 rc = boot_update_hw_rollback_protection(state);
3349 if (rc != 0) {
3354 … rc = boot_add_shared_data(state, (uint8_t)state->slot_usage[BOOT_CURR_IMG(state)].active_slot);
3355 if (rc != 0) {
3371 if (rc != 0) {
3453 int rc = -1; local
3475 rc = flash_area_open(fa_id, &BOOT_IMG_AREA(&boot_data, slot));
3476 assert(rc == 0);
3478 if (rc != 0) {
3484 rc = flash_area_open(FLASH_AREA_IMAGE_SCRATCH,
3486 assert(rc == 0);
3488 if (rc != 0) {
3494 rc = boot_read_sectors_recovery(&boot_data);
3496 if (rc == 0) {