Christopher Collins | 92ea77f | 2016-12-12 15:59:26 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | #ifndef _BOOT_TEST_H |
| 20 | #define _BOOT_TEST_H |
| 21 | |
| 22 | #include <assert.h> |
| 23 | #include <stddef.h> |
| 24 | #include <stdio.h> |
| 25 | #include <stdlib.h> |
| 26 | #include <string.h> |
| 27 | #include <inttypes.h> |
| 28 | #include "syscfg/syscfg.h" |
| 29 | #include "sysflash/sysflash.h" |
| 30 | #include "testutil/testutil.h" |
| 31 | #include "hal/hal_flash.h" |
| 32 | #include "flash_map/flash_map.h" |
| 33 | #include "bootutil/image.h" |
| 34 | #include "bootutil/bootutil.h" |
| 35 | #include "bootutil_priv.h" |
| 36 | #include "testutil/testutil.h" |
| 37 | |
| 38 | #include "mbedtls/sha256.h" |
| 39 | |
| 40 | #ifdef __cplusplus |
| 41 | extern "C" { |
| 42 | #endif |
| 43 | |
| 44 | #define BOOT_TEST_HEADER_SIZE 0x200 |
| 45 | |
| 46 | /** Internal flash layout. */ |
| 47 | extern struct flash_area boot_test_area_descs[]; |
| 48 | |
| 49 | /** Areas representing the beginning of image slots. */ |
| 50 | extern uint8_t boot_test_slot_areas[]; |
| 51 | |
| 52 | /** Flash offsets of the two image slots. */ |
| 53 | struct boot_test_img_addrs { |
| 54 | uint8_t flash_id; |
| 55 | uint32_t address; |
| 56 | }; |
| 57 | extern struct boot_test_img_addrs boot_test_img_addrs[]; |
| 58 | |
| 59 | #define BOOT_TEST_AREA_IDX_SCRATCH 6 |
| 60 | |
| 61 | uint8_t boot_test_util_byte_at(int img_msb, uint32_t image_offset); |
| 62 | void boot_test_util_init_flash(void); |
| 63 | void boot_test_util_copy_area(int from_area_idx, int to_area_idx); |
| 64 | void boot_test_util_swap_areas(int area_idx1, int area_idx2); |
| 65 | void boot_test_util_write_image(const struct image_header *hdr, |
| 66 | int slot); |
| 67 | void boot_test_util_write_hash(const struct image_header *hdr, int slot); |
| 68 | void boot_test_util_mark_revert(void); |
| 69 | void boot_test_util_verify_area(const struct flash_area *area_desc, |
| 70 | const struct image_header *hdr, |
| 71 | uint32_t image_addr, int img_msb); |
| 72 | void boot_test_util_verify_status_clear(void); |
| 73 | void boot_test_util_verify_flash(const struct image_header *hdr0, |
| 74 | int orig_slot_0, |
| 75 | const struct image_header *hdr1, |
| 76 | int orig_slot_1); |
| 77 | void boot_test_util_verify_all(int expected_swap_type, |
| 78 | const struct image_header *hdr0, |
| 79 | const struct image_header *hdr1); |
| 80 | #ifdef __cplusplus |
| 81 | } |
| 82 | #endif |
| 83 | |
| 84 | #endif /*_BOOT_TEST_H */ |