blob: 847e4069bf49297f3fdf022c133ea0de1163827d [file] [log] [blame]
Ken Liu91d44da2018-09-20 22:42:31 +08001/*
Ken Liuc25558c2021-05-20 15:31:28 +08002 * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
Ken Liu91d44da2018-09-20 22:42:31 +08003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7#ifndef __TFM_UTILS_H__
8#define __TFM_UTILS_H__
9
Summer Qin83214922020-06-22 15:07:08 +080010#include <stdbool.h>
Edison Ai93dabfd2019-12-03 13:44:45 +080011#include <stdio.h>
12
13/*
14 * CPU spin here.
15 * Note: this function is used to handle PROGRAMMER ERROR.
16 */
Edison Ai9059ea02019-11-28 13:46:14 +080017void tfm_core_panic(void);
Ken Liu91d44da2018-09-20 22:42:31 +080018
Ken Liuf250b8b2019-12-27 16:31:24 +080019/* Core assert and spin */
20#ifndef NDEBUG
21#define TFM_CORE_ASSERT(cond) \
Ken Liu91d44da2018-09-20 22:42:31 +080022 do { \
23 if (!(cond)) { \
Ken Liu91d44da2018-09-20 22:42:31 +080024 while (1) \
25 ; \
26 } \
27 } while (0)
Ken Liuf250b8b2019-12-27 16:31:24 +080028#else
29#define TFM_CORE_ASSERT(cond)
30#endif
Ken Liu91d44da2018-09-20 22:42:31 +080031
Edison Ai1e5822f2018-09-21 14:56:08 +080032/* Get container structure start address from member */
Ken Liuc25558c2021-05-20 15:31:28 +080033#define TO_CONTAINER(ptr, type, member) \
Edison Ai1e5822f2018-09-21 14:56:08 +080034 (type *)((unsigned long)(ptr) - offsetof(type, member))
35
Summer Qin83214922020-06-22 15:07:08 +080036#define ERROR_MSG(msg)
37
Ken Liuf250b8b2019-12-27 16:31:24 +080038#endif /* __TFM_UTILS_H__ */