Skip to content

Commit

Permalink
to squash into "swap move commit"
Browse files Browse the repository at this point in the history
Create new header files with swap only definition as suggested in
review.

TO BE SQUASHED LATER

Signed-off-by: Fabio Utzig <utzig@apache.org>
  • Loading branch information
utzig committed Nov 29, 2019
1 parent 41ebdfd commit 5887060
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 26 deletions.
27 changes: 1 addition & 26 deletions boot/bootutil/src/bootutil_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,27 +266,11 @@ int boot_write_swap_info(const struct flash_area *fap, uint8_t swap_type,
uint8_t image_num);
int boot_write_swap_size(const struct flash_area *fap, uint32_t swap_size);
int boot_read_swap_size(int image_index, uint32_t *swap_size);
int boot_erase_trailer_sectors(const struct boot_loader_state *state,
const struct flash_area *fap);
int boot_copy_region(struct boot_loader_state *state,
const struct flash_area *fap_src,
const struct flash_area *fap_dst,
uint32_t off_src, uint32_t off_dst, uint32_t sz);
int boot_erase_region(const struct flash_area *fap, uint32_t off, uint32_t sz);
int boot_status_init(const struct boot_loader_state *state,
const struct flash_area *fap,
const struct boot_status *bs);
void boot_perform_swap(struct boot_loader_state *state,
struct boot_status *bs,
uint32_t copy_size);
int boot_slots_compatible(struct boot_loader_state *state);
int boot_status_source(struct boot_loader_state *state);
int boot_read_status_bytes(const struct flash_area *fap,
struct boot_loader_state *state,
struct boot_status *bs);
uint32_t boot_status_internal_off(const struct boot_status *bs, int elem_sz);
int boot_read_image_header(struct boot_loader_state *state, int slot,
struct image_header *out_hdr, struct boot_status *bs);

#ifdef MCUBOOT_ENC_IMAGES
int boot_write_enc_key(const struct flash_area *fap, uint8_t slot,
const uint8_t *enckey);
Expand Down Expand Up @@ -366,15 +350,6 @@ boot_img_num_sectors(const struct boot_loader_state *state, size_t slot)
return BOOT_IMG(state, slot).num_sectors;
}

#if MCUBOOT_SWAP_USING_SCRATCH
#define BOOT_SCRATCH_AREA(state) ((state)->scratch.area)

static inline size_t boot_scratch_area_size(const struct boot_loader_state *state)
{
return BOOT_SCRATCH_AREA(state)->fa_size;
}
#endif

/*
* Offset of the slot from the beginning of the flash device.
*/
Expand Down
48 changes: 48 additions & 0 deletions boot/bootutil/src/bootutil_swap_priv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*

This comment has been minimized.

Copy link
@oyvindronningstad

oyvindronningstad Nov 29, 2019

Contributor

Thanks!
It would be VERY useful to have one sentence (or more) of docs in this file. And preferable one sentence (or more) for each function.

* Copyright (c) 2019 JUUL Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "mcuboot_config/mcuboot_config.h"

#if defined(MCUBOOT_SWAP_USING_SCRATCH) || defined(MCUBOOT_SWAP_USING_MOVE)

int boot_erase_trailer_sectors(const struct boot_loader_state *state,
const struct flash_area *fap);
int boot_copy_region(struct boot_loader_state *state,
const struct flash_area *fap_src,
const struct flash_area *fap_dst,
uint32_t off_src, uint32_t off_dst, uint32_t sz);
int boot_erase_region(const struct flash_area *fap, uint32_t off, uint32_t sz);
int boot_status_init(const struct boot_loader_state *state,
const struct flash_area *fap,
const struct boot_status *bs);
void boot_perform_swap(struct boot_loader_state *state,
struct boot_status *bs,
uint32_t copy_size);
int boot_status_source(struct boot_loader_state *state);
int boot_read_status_bytes(const struct flash_area *fap,
struct boot_loader_state *state,
struct boot_status *bs);

#if MCUBOOT_SWAP_USING_SCRATCH
#define BOOT_SCRATCH_AREA(state) ((state)->scratch.area)

static inline size_t boot_scratch_area_size(const struct boot_loader_state *state)
{
return BOOT_SCRATCH_AREA(state)->fa_size;
}
#endif

#endif /* defined(MCUBOOT_SWAP_USING_SCRATCH) || defined(MCUBOOT_SWAP_USING_MOVE) */
1 change: 1 addition & 0 deletions boot/bootutil/src/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "bootutil/bootutil.h"
#include "bootutil/image.h"
#include "bootutil_priv.h"
#include "bootutil_swap_priv.h"
#include "bootutil/bootutil_log.h"

#ifdef MCUBOOT_ENC_IMAGES
Expand Down
1 change: 1 addition & 0 deletions boot/bootutil/src/swap_move.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <string.h>
#include "bootutil/bootutil.h"
#include "bootutil_priv.h"
#include "bootutil_swap_priv.h"
#include "bootutil/bootutil_log.h"

#include "mcuboot_config/mcuboot_config.h"
Expand Down
1 change: 1 addition & 0 deletions boot/bootutil/src/swap_scratch.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <string.h>
#include "bootutil/bootutil.h"
#include "bootutil_priv.h"
#include "bootutil_swap_priv.h"
#include "bootutil/bootutil_log.h"

#include "mcuboot_config/mcuboot_config.h"
Expand Down

0 comments on commit 5887060

Please sign in to comment.