MCCI Trusted Bootloader
Simple trusted bootloader and tools for small embedded systems
mccibootloaderplatform_getappinfo.c
Go to the documentation of this file.
1/*
2
3Module: mccibootloaderplatform_getappinfo.c
4
5Function:
6 McciBootloaderPlatform_getAppInfo()
7
8Copyright and License:
9 This file copyright (C) 2021 by
10
11 MCCI Corporation
12 3520 Krums Corners Road
13 Ithaca, NY 14850
14
15 See accompanying LICENSE file for copyright and license information.
16
17Author:
18 Terry Moore, MCCI Corporation March 2021
19
20*/
21
25
26/****************************************************************************\
27|
28| Manifest constants & typedefs.
29|
30\****************************************************************************/
31
32
33
34/****************************************************************************\
35|
36| Read-only data.
37|
38\****************************************************************************/
39
40
41
42/****************************************************************************\
43|
44| Variables.
45|
46\****************************************************************************/
47
48
49/*
50
51Name: McciBootloaderPlatform_getAppInfo()
52
53Function:
54 Find the app info structure in a header
55
56Definition:
57 const McciBootloader_AppInfo_t *
58 McciBootloaderPlatform_getAppInfo(
59 const void *pHeader,
60 size_t nHeader
61 );
62
63Description:
64 Given a pointer to the header of an image (not necessarily at
65 its final location), and a count of the buffer bytes, this function
66 returns a pointer to the McciBootloader_AppInfo_t header structure.
67
68Returns:
69 Non-null if the app info structure was found and passes the checks,
70 NULL otherwise.
71
72Notes:
73
74
75*/
76
77const McciBootloader_AppInfo_t *
79 const void *pHeader,
80 size_t nHeader
81 )
82 {
83 const McciBootloader_CortexPageZero_t * const pPageZero = pHeader;
84
85 if (nHeader < sizeof(*pPageZero))
86 return NULL;
87
88 const McciBootloader_AppInfo_t * const pAppInfo =
89 &pPageZero->PageZero.AppInfo;
90
91 if (pAppInfo->magic != MCCI_BOOTLOADER_APP_INFO_MAGIC)
92 return NULL;
93
94 if (pAppInfo->size != sizeof(*pAppInfo))
95 return NULL;
96
97 return pAppInfo;
98 }
99
100/**** end of mccibootloaderplatform_getappinfo.c ****/
#define MCCI_BOOTLOADER_APP_INFO_MAGIC
const McciBootloader_AppInfo_t * McciBootloaderPlatform_getAppInfo(const void *pHeader, size_t nHeader)
McciBootloader_CortexPageZeroContents_t PageZero