1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
/** @file
*
* Copyright (c) 2013, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
* which accompanies this distribution. The full text of the license may be found at
* http://opensource.org/licenses/bsd-license.php
*
* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*
**/
#ifndef __NVM_H__
#define __NVM_H__
#ifndef __ASSEMBLY__
#include <stddef.h>
#include <tftf.h>
#include "tests_list.h"
#define TEST_BUFFER_SIZE 0x80
typedef struct {
/*
* @brief Last executed TFTF build message which consists of date and
* time when TFTF is built.
*
* A mismatch with the build message of currently executing binary will
* determine whether TFTF data structures stored in NVM needs to be
* initialised or not.
*/
char build_message[BUILD_MESSAGE_SIZE];
/*
* The following 2 fields track the progress in the test session. They
* indicate which test case we are dealing with and the progress of this
* test, i.e. whether it hasn't started yet, or it is being executed
* right now, ...
*/
test_ref_t test_to_run;
test_progress_t test_progress;
/*
* @brief Scratch buffer for test internal use.
*
* A buffer that the test can use as a scratch area for whatever it is
* doing.
*/
char testcase_buffer[TEST_BUFFER_SIZE];
/*
* @brief Results of tests.
*
* @note TESTCASE_RESULT_COUNT is defined in tests_list.h
* (auto-generated file).
*/
TESTCASE_RESULT testcase_results[TESTCASE_RESULT_COUNT];
/*
* @brief Size of \a result_buffer.
*/
unsigned result_buffer_size;
/*
* Buffer containing the output of all tests.
* Each test appends its output to the end of \a result_buffer.
* Tests which produce no output write nothing in \a result_buffer.
*/
char *result_buffer;
} tftf_state_t;
/*
* Helper macros to access fields of \a tftf_state_t structure.
*/
#define TFTF_STATE_OFFSET(_field) offsetof(tftf_state_t, _field)
/*
* Return 1 if we need to start a new test session;
* 0 if we need to resume an interrupted session.
*/
unsigned int new_test_session(void);
/*
* @brief Initialize NVM if necessary.
*
* When TFTF is launched on the target, its data structures need
* to be initialised in NVM. However if some test resets the board
* (as part of its normal behaviour or because it crashed) then
* TFTF data structure must be left unchanged in order to resume
* the test session where it has been left.
*
* This function detects whether TFTF has just been launched and if so
* initialises its data structures. If TFTF has just reset then it does
* nothing.
*
* @return STATUS_SUCCESS on success, another status code on failure.
*/
STATUS tftf_init_nvm(void);
/*
* @brief Clean NVM.
*
* Clean TFTF data structures in NVM.
* This function must be called when all tests have completed.
*
* @return STATUS_SUCCESS on success, another status code on failure.
*/
STATUS tftf_clean_nvm(void);
/* Writes the buffer to the flash at offset with length equal to
* size
* Returns: STATUS_FAIL, STATUS_SUCCESS, STATUS_OUT_OF_RESOURCES
*/
STATUS tftf_nvm_write(UINTN offset, const void *buffer, UINTN size);
/* Reads the flash into buffer at offset with length equal to
* size
* Returns: STATUS_FAIL, STATUS_SUCCESS, STATUS_OUT_OF_RESOURCES
*/
STATUS tftf_nvm_read(UINTN offset, void *buffer, UINTN size);
#endif /*__ASSEMBLY__*/
#endif
|