1 /*
2  * Copyright (c) 2015, Xilinx Inc. and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 /*
8  * @file	generic/sys.h
9  * @brief	Generic system primitives for libmetal.
10  */
11 
12 #ifndef __METAL_SYS__H__
13 #error "Include metal/sys.h instead of metal/generic/sys.h"
14 #endif
15 
16 #ifndef __METAL_GENERIC_SYS__H__
17 #define __METAL_GENERIC_SYS__H__
18 
19 #include <limits.h>
20 #include <metal/cpu.h>
21 #include <metal/errno.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <stdarg.h>
25 #include <string.h>
26 
27 #ifdef XLNX_PLATFORM
28 #include <metal/system/generic/xlnx/sys.h>
29 #else
30 #include "./@PROJECT_MACHINE@/sys.h"
31 #endif
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #ifndef METAL_MAX_DEVICE_REGIONS
38 #define METAL_MAX_DEVICE_REGIONS 1
39 #endif
40 
41 /** Structure of generic libmetal runtime state. */
42 struct metal_state {
43 
44 	/** Common (system independent) data. */
45 	struct metal_common_state common;
46 };
47 
48 #define metal_yield() metal_cpu_yield()
49 
50 #ifdef METAL_INTERNAL
51 
52 /**
53  * @brief restore interrupts to state before disable_global_interrupt()
54  */
55 void sys_irq_restore_enable(unsigned int flags);
56 
57 /**
58  * @brief disable all interrupts
59  */
60 unsigned int sys_irq_save_disable(void);
61 
62 #endif /* METAL_INTERNAL */
63 
64 #ifdef __cplusplus
65 }
66 #endif
67 
68 #endif /* __METAL_GENERIC_SYS__H__ */
69