hw/arm/sbsa-ref: Remove unnecessary check for secure_sysmem == NULL
[qemu/ar7.git] / tests / libqos / qgraph_internal.h
blobf4734c8681f316cccb63c2019e495d80c397ad51
1 /*
2 * libqos driver framework
4 * Copyright (c) 2018 Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License version 2 as published by the Free Software Foundation.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, see <http://www.gnu.org/licenses/>
19 #ifndef QGRAPH_INTERNAL_H
20 #define QGRAPH_INTERNAL_H
22 /* This header is declaring additional helper functions defined in
23 * libqos/qgraph.c
24 * It should not be included in tests
27 #include "libqos/qgraph.h"
29 typedef struct QOSGraphMachine QOSGraphMachine;
30 typedef enum QOSEdgeType QOSEdgeType;
31 typedef enum QOSNodeType QOSNodeType;
33 /* callback called when the walk path algorithm found a
34 * valid path
36 typedef void (*QOSTestCallback) (QOSGraphNode *path, int len);
38 /* edge types*/
39 enum QOSEdgeType {
40 QEDGE_CONTAINS,
41 QEDGE_PRODUCES,
42 QEDGE_CONSUMED_BY
45 /* node types*/
46 enum QOSNodeType {
47 QNODE_MACHINE,
48 QNODE_DRIVER,
49 QNODE_INTERFACE,
50 QNODE_TEST
53 /* Graph Node */
54 struct QOSGraphNode {
55 QOSNodeType type;
56 bool available; /* set by QEMU via QMP, used during graph walk */
57 bool visited; /* used during graph walk */
58 char *name; /* used to identify the node */
59 char *command_line; /* used to start QEMU at test execution */
60 union {
61 struct {
62 QOSCreateDriverFunc constructor;
63 } driver;
64 struct {
65 QOSCreateMachineFunc constructor;
66 } machine;
67 struct {
68 QOSTestFunc function;
69 void *arg;
70 QOSBeforeTest before;
71 bool subprocess;
72 } test;
73 } u;
75 /**
76 * only used when traversing the path, never rely on that except in the
77 * qos_traverse_graph callback function
79 QOSGraphEdge *path_edge;
82 /**
83 * qos_graph_get_node(): returns the node mapped to that @key.
84 * It performs an hash map search O(1)
86 * Returns: on success: the %QOSGraphNode
87 * otherwise: #NULL
89 QOSGraphNode *qos_graph_get_node(const char *key);
91 /**
92 * qos_graph_has_node(): returns #TRUE if the node
93 * has map has a node mapped to that @key.
95 bool qos_graph_has_node(const char *node);
97 /**
98 * qos_graph_get_node_type(): returns the %QOSNodeType
99 * of the node @node.
100 * It performs an hash map search O(1)
101 * Returns: on success: the %QOSNodeType
102 * otherwise: #-1
104 QOSNodeType qos_graph_get_node_type(const char *node);
107 * qos_graph_get_node_availability(): returns the availability (boolean)
108 * of the node @node.
110 bool qos_graph_get_node_availability(const char *node);
113 * qos_graph_get_edge(): returns the edge
114 * linking of the node @node with @dest.
116 * Returns: on success: the %QOSGraphEdge
117 * otherwise: #NULL
119 QOSGraphEdge *qos_graph_get_edge(const char *node, const char *dest);
122 * qos_graph_edge_get_type(): returns the edge type
123 * of the edge @edge.
125 * Returns: on success: the %QOSEdgeType
126 * otherwise: #-1
128 QOSEdgeType qos_graph_edge_get_type(QOSGraphEdge *edge);
131 * qos_graph_edge_get_dest(): returns the name of the node
132 * pointed as destination of edge @edge.
134 * Returns: on success: the destination
135 * otherwise: #NULL
137 char *qos_graph_edge_get_dest(QOSGraphEdge *edge);
140 * qos_graph_has_edge(): returns #TRUE if there
141 * exists an edge from @start to @dest.
143 bool qos_graph_has_edge(const char *start, const char *dest);
146 * qos_graph_edge_get_arg(): returns the args assigned
147 * to that @edge.
149 * Returns: on success: the arg
150 * otherwise: #NULL
152 void *qos_graph_edge_get_arg(QOSGraphEdge *edge);
155 * qos_graph_edge_get_after_cmd_line(): returns the edge
156 * command line that will be added after all the node arguments
157 * and all the before_cmd_line arguments.
159 * Returns: on success: the char* arg
160 * otherwise: #NULL
162 char *qos_graph_edge_get_after_cmd_line(QOSGraphEdge *edge);
165 * qos_graph_edge_get_before_cmd_line(): returns the edge
166 * command line that will be added before the node command
167 * line argument.
169 * Returns: on success: the char* arg
170 * otherwise: #NULL
172 char *qos_graph_edge_get_before_cmd_line(QOSGraphEdge *edge);
175 * qos_graph_edge_get_extra_device_opts(): returns the arg
176 * command line that will be added to the node command
177 * line argument.
179 * Returns: on success: the char* arg
180 * otherwise: #NULL
182 char *qos_graph_edge_get_extra_device_opts(QOSGraphEdge *edge);
185 * qos_graph_edge_get_name(): returns the name
186 * assigned to the destination node (different only)
187 * if there are multiple devices with the same node name
188 * e.g. a node has two "generic-sdhci", "emmc" and "sdcard"
189 * there will be two edges with edge_name ="emmc" and "sdcard"
191 * Returns always the char* edge_name
193 char *qos_graph_edge_get_name(QOSGraphEdge *edge);
196 * qos_graph_get_machine(): returns the machine assigned
197 * to that @node name.
199 * It performs a search only trough the list of machines
200 * (i.e. the QOS_ROOT child).
202 * Returns: on success: the %QOSGraphNode
203 * otherwise: #NULL
205 QOSGraphNode *qos_graph_get_machine(const char *node);
208 * qos_graph_has_machine(): returns #TRUE if the node
209 * has map has a node mapped to that @node.
211 bool qos_graph_has_machine(const char *node);
215 * qos_print_graph(): walks the graph and prints
216 * all machine-to-test paths.
218 void qos_print_graph(void);
221 * qos_graph_foreach_test_path(): executes the Depth First search
222 * algorithm and applies @fn to all discovered paths.
224 * See qos_traverse_graph() in qgraph.c for more info on
225 * how it works.
227 void qos_graph_foreach_test_path(QOSTestCallback fn);
230 * qos_get_machine_type(): return QEMU machine type for a machine node.
231 * This function requires every machine @name to be in the form
232 * <arch>/<machine_name>, like "arm/raspi2" or "x86_64/pc".
234 * The function will validate the format and return a pointer to
235 * @machine to <machine_name>. For example, when passed "x86_64/pc"
236 * it will return "pc".
238 * Note that this function *does not* allocate any new string.
240 char *qos_get_machine_type(char *name);
243 * qos_delete_cmd_line(): delete the
244 * command line present in node mapped with key @name.
246 * This function is called when the QMP query returns a node with
247 * { "abstract" : true } attribute.
249 void qos_delete_cmd_line(const char *name);
252 * qos_graph_node_set_availability(): sets the node identified
253 * by @node with availability @av.
255 void qos_graph_node_set_availability(const char *node, bool av);
257 #endif