libmetal
sys.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015, Xilinx Inc. and Contributors. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * 1. Redistributions of source code must retain the above copyright notice,
8  * this list of conditions and the following disclaimer.
9  *
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  *
14  * 3. Neither the name of Xilinx nor the names of its contributors may be used
15  * to endorse or promote products derived from this software without
16  * specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 /*
32  * @file sys.h
33  * @brief System primitives for libmetal.
34  * @brief Top level include internal to libmetal library code.
35  */
36 
37 #ifndef __METAL_SYS__H__
38 #define __METAL_SYS__H__
39 
40 #include <stdlib.h>
41 
42 #include "metal/log.h"
43 #include "metal/list.h"
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
53 typedef unsigned long metal_phys_addr_t;
54 
56 typedef int metal_irq_t;
57 
59 #define METAL_BAD_OFFSET ((unsigned long)-1)
60 
62 #define METAL_BAD_PHYS ((metal_phys_addr_t)-1)
63 
65 #define METAL_BAD_VA ((void *)-1)
66 
68 #define METAL_BAD_IRQ ((metal_irq_t)-1)
69 
74 
77 
80 };
81 
82 #define METAL_INIT_DEFAULTS \
83 { \
84  .log_handler = metal_default_log_handler, \
85  .log_level = METAL_LOG_INFO, \
86 }
87 
95 
98 
101 
104 
107 };
108 
109 struct metal_state;
110 
111 #include "metal/system/@PROJECT_SYSTEM@/sys.h"
112 
114 extern struct metal_state _metal;
115 
127 extern int metal_init(const struct metal_init_params *params);
128 
136 extern void metal_finish(void);
137 
138 #ifdef METAL_INTERNAL
139 
150 extern int metal_sys_init(const struct metal_init_params *params);
151 
160 extern void metal_sys_finish(void);
161 
162 #endif
163 
166 #ifdef __cplusplus
167 }
168 #endif
169 
170 #endif /* __METAL_SYS__H__ */
metal_log_handler log_handler
Definition: sys.h:97
Definition: sys.h:92
struct metal_list generic_shmem_list
Definition: sys.h:103
Definition: sys.h:54
struct metal_list generic_device_list
Definition: sys.h:106
metal_log_handler log_handler
Definition: sys.h:76
struct metal_list bus_list
Definition: sys.h:100
Definition: list.h:48
enum metal_log_level log_level
Definition: sys.h:79
int metal_sys_init(const struct metal_init_params *params)
Definition: init.c:45
void metal_sys_finish(void)
Definition: init.c:52
int metal_irq_t
Definition: sys.h:56
Definition: sys.h:73
metal_log_level
Definition: log.h:47
void(* metal_log_handler)(enum metal_log_level level, const char *format,...)
Definition: log.h:59
void metal_finish(void)
Shutdown libmetal.
Definition: init.c:54
struct metal_state _metal
Definition: init.c:43
int metal_init(const struct metal_init_params *params)
Initialize libmetal.
Definition: init.c:34
enum metal_log_level log_level
Definition: sys.h:94
unsigned long metal_phys_addr_t
Definition: sys.h:53