Lines Matching refs:bs
73 struct image_header *out_hdr, struct boot_status *bs) in boot_read_image_header() argument
88 if (bs && !boot_status_is_reset(bs)) { in boot_read_image_header()
103 if (bs->op == BOOT_STATUS_OP_MOVE && slot == 0 && bs->idx > last_idx) { in boot_read_image_header()
105 } else if (bs->op == BOOT_STATUS_OP_SWAP) { in boot_read_image_header()
106 if (bs->idx > 1 && bs->idx <= last_idx) { in boot_read_image_header()
108 } else if (bs->idx == 1) { in boot_read_image_header()
111 } else if (slot == 1 && bs->state == 2) { in boot_read_image_header()
132 if (bs != NULL && out_hdr->ih_magic != IMAGE_MAGIC) { in boot_read_image_header()
146 struct boot_loader_state *state, struct boot_status *bs) in swap_read_status_bytes() argument
208 bs->op = BOOT_STATUS_OP_MOVE; in swap_read_status_bytes()
209 bs->idx = (found_idx / BOOT_STATUS_MOVE_STATE_COUNT) + BOOT_STATUS_IDX_0; in swap_read_status_bytes()
210 bs->state = (found_idx % BOOT_STATUS_MOVE_STATE_COUNT) + BOOT_STATUS_STATE_0;; in swap_read_status_bytes()
212 bs->op = BOOT_STATUS_OP_SWAP; in swap_read_status_bytes()
213 bs->idx = ((found_idx - move_entries) / BOOT_STATUS_SWAP_STATE_COUNT) + BOOT_STATUS_IDX_0; in swap_read_status_bytes()
214 … bs->state = ((found_idx - move_entries) % BOOT_STATUS_SWAP_STATE_COUNT) + BOOT_STATUS_STATE_0; in swap_read_status_bytes()
221 boot_status_internal_off(const struct boot_status *bs, int elem_sz) in boot_status_internal_off() argument
226 idx_sz = elem_sz * ((bs->op == BOOT_STATUS_OP_MOVE) ? in boot_status_internal_off()
229 off = ((bs->op == BOOT_STATUS_OP_MOVE) ? in boot_status_internal_off()
231 (bs->idx - BOOT_STATUS_IDX_0) * idx_sz + in boot_status_internal_off()
232 (bs->state - BOOT_STATUS_STATE_0) * elem_sz; in boot_status_internal_off()
388 struct boot_status *bs, const struct flash_area *fap_pri, in boot_move_sector_up() argument
404 if (bs->idx == BOOT_STATUS_IDX_0) { in boot_move_sector_up()
405 if (bs->source != BOOT_STATUS_SOURCE_PRIMARY_SLOT) { in boot_move_sector_up()
409 rc = swap_status_init(state, fap_pri, bs); in boot_move_sector_up()
423 rc = boot_write_status(state, bs); in boot_move_sector_up()
425 bs->idx++; in boot_move_sector_up()
431 struct boot_status *bs, const struct flash_area *fap_pri, in boot_swap_sectors() argument
443 if (bs->state == BOOT_STATUS_STATE_0) { in boot_swap_sectors()
450 rc = boot_write_status(state, bs); in boot_swap_sectors()
451 bs->state = BOOT_STATUS_STATE_1; in boot_swap_sectors()
455 if (bs->state == BOOT_STATUS_STATE_1) { in boot_swap_sectors()
462 rc = boot_write_status(state, bs); in boot_swap_sectors()
463 bs->idx++; in boot_swap_sectors()
464 bs->state = BOOT_STATUS_STATE_0; in boot_swap_sectors()
480 fixup_revert(const struct boot_loader_state *state, struct boot_status *bs, in fixup_revert() argument
491 if (bs->swap_type != BOOT_SWAP_TYPE_REVERT || in fixup_revert()
492 bs->op != BOOT_STATUS_OP_MOVE || in fixup_revert()
493 bs->idx != BOOT_STATUS_IDX_0) { in fixup_revert()
509 rc = boot_write_swap_size(fap_sec, bs->swap_size); in fixup_revert()
518 swap_run(struct boot_loader_state *state, struct boot_status *bs, in swap_run() argument
540 if (boot_status_is_reset(bs)) { in swap_run()
558 bs->swap_type = BOOT_SWAP_TYPE_NONE; in swap_run()
571 fixup_revert(state, bs, fap_sec); in swap_run()
573 if (bs->op == BOOT_STATUS_OP_MOVE) { in swap_run()
576 if (idx <= (last_idx - bs->idx + 1)) { in swap_run()
577 boot_move_sector_up(idx, sector_sz, state, bs, fap_pri, fap_sec); in swap_run()
581 bs->idx = BOOT_STATUS_IDX_0; in swap_run()
584 bs->op = BOOT_STATUS_OP_SWAP; in swap_run()
588 if (idx >= bs->idx) { in swap_run()
589 boot_swap_sectors(idx, sector_sz, state, bs, fap_pri, fap_sec); in swap_run()