bootutil_public: added hook for fetch image swap state
Added hook which allows to override boot_read_swap_state_by_id() routine for the primary slot. Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
This commit is contained in:
parent
b8f3969f38
commit
dea293ad4c
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2021 Nordic Semiconductor ASA
|
||||
*
|
||||
* Original license:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Hooks definition implementation API
|
||||
*
|
||||
* This file contains API interface definition for hooks which can be
|
||||
* implemented for overide some of MCUboot's native routines.
|
||||
*/
|
||||
|
||||
#ifndef H_BOOTUTIL_PUBLIC_HOOKS
|
||||
#define H_BOOTUTIL_PUBLIC_HOOKS
|
||||
|
||||
#include "bootutil/boot_hooks.h"
|
||||
|
||||
/** Hook for provide primary image swap state.
|
||||
*
|
||||
* @param img_index the index of the image pair
|
||||
* @param state image swap state structure to be populated
|
||||
*
|
||||
* @retval 0: header was read/populated
|
||||
* FIH_FAILURE: image is invalid,
|
||||
* BOOT_HOOK_REGULAR if hook not implemented for the image-slot,
|
||||
* othervise an error-code value.
|
||||
*/
|
||||
int boot_read_swap_state_primary_slot_hook(int image_index,
|
||||
struct boot_swap_state *state);
|
||||
|
||||
#endif /*H_BOOTUTIL_PUBLIC_HOOKS*/
|
|
@ -50,6 +50,8 @@
|
|||
#include "bootutil/enc_key_public.h"
|
||||
#endif
|
||||
|
||||
#include "bootutil/boot_public_hooks.h"
|
||||
|
||||
#ifdef CONFIG_MCUBOOT
|
||||
BOOT_LOG_MODULE_DECLARE(mcuboot);
|
||||
#else
|
||||
|
@ -418,8 +420,13 @@ boot_swap_type_multi(int image_index)
|
|||
int rc;
|
||||
size_t i;
|
||||
|
||||
rc = BOOT_HOOK_CALL(boot_read_swap_state_primary_slot_hook,
|
||||
BOOT_HOOK_REGULAR, image_index, &primary_slot);
|
||||
if (rc == BOOT_HOOK_REGULAR)
|
||||
{
|
||||
rc = boot_read_swap_state_by_id(FLASH_AREA_IMAGE_PRIMARY(image_index),
|
||||
&primary_slot);
|
||||
}
|
||||
if (rc) {
|
||||
return BOOT_SWAP_TYPE_PANIC;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue