xref: /kvmtool/include/kvm/fdt.h (revision 070fb918a563f5b25902419231e595f3c98b30ae)
1 #ifndef KVM__FDT_H
2 #define KVM__FDT_H
3 
4 #ifdef CONFIG_HAS_LIBFDT
5 #include <libfdt.h>
6 #endif
7 
8 #include <linux/types.h>
9 
10 #include "kvm/fdt-arch.h"
11 
12 #define FDT_MAX_SIZE	0x10000
13 
14 /* Those definitions are generic FDT values for specifying IRQ
15  * types and are used in the Linux kernel internally as well as in
16  * the dts files and their documentation.
17  */
18 enum irq_type {
19 	IRQ_TYPE_NONE		= 0x00000000,
20 	IRQ_TYPE_EDGE_RISING	= 0x00000001,
21 	IRQ_TYPE_EDGE_FALLING	= 0x00000002,
22 	IRQ_TYPE_EDGE_BOTH	= (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING),
23 	IRQ_TYPE_LEVEL_HIGH	= 0x00000004,
24 	IRQ_TYPE_LEVEL_LOW	= 0x00000008,
25 	IRQ_TYPE_LEVEL_MASK	= (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH),
26 };
27 
28 typedef void (*fdt_irq_fn)(void *fdt, u8 irq, enum irq_type irq_type);
29 
30 extern char *fdt_stdout_path;
31 
32 /* Helper for the various bits of code that generate FDT nodes */
33 #define _FDT(exp)							\
34 	do {								\
35 		int ret = (exp);					\
36 		if (ret < 0) {						\
37 			die("Error creating device tree: %s: %s\n",	\
38 			    #exp, fdt_strerror(ret));			\
39 		}							\
40 	} while (0)
41 
42 #endif /* KVM__FDT_H */
43