xref: /openbsd/sys/arch/arm64/stand/efiboot/fdt.h (revision 5dea098c)
1 /*	$OpenBSD: fdt.h,v 1.3 2017/08/23 18:03:54 kettenis Exp $	*/
2 
3 /*
4  * Copyright (c) 2009 Dariusz Swiderski <sfires@sfires.net>
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 struct fdt_head {
20 	uint32_t fh_magic;
21 	uint32_t fh_size;
22 	uint32_t fh_struct_off;
23 	uint32_t fh_strings_off;
24 	uint32_t fh_reserve_off;
25 	uint32_t fh_version;
26 	uint32_t fh_comp_ver;	  /* last compatible version */
27 	uint32_t fh_boot_cpu_id;  /* fh_version >=2 */
28 	uint32_t fh_strings_size; /* fh_version >=3 */
29 	uint32_t fh_struct_size;  /* fh_version >=17 */
30 };
31 
32 struct fdt {
33 	struct fdt_head *header;
34 	char		*tree;
35 	char		*strings;
36 	char		*memory;
37 	char		*end;
38 	int		version;
39 	int		strings_size;
40 	int		struct_size;
41 };
42 
43 #define FDT_MAGIC	0xd00dfeed
44 #define FDT_NODE_BEGIN	0x01
45 #define FDT_NODE_END	0x02
46 #define FDT_PROPERTY	0x03
47 #define FDT_NOP		0x04
48 #define FDT_END		0x09
49 
50 #define FDT_CODE_VERSION 0x11
51 
52 int	 fdt_init(void *);
53 void	 fdt_finalize(void);
54 size_t	 fdt_get_size(void *);
55 void	*fdt_next_node(void *);
56 void	*fdt_child_node(void *);
57 char	*fdt_node_name(void *);
58 void	*fdt_find_node(char *);
59 int	 fdt_node_property(void *, char *, char **);
60 int	 fdt_node_property_int(void *, char *, int *);
61 int	 fdt_node_property_ints(void *, char *, int *, int);
62 int	 fdt_node_set_property(void *, char *, void *, int);
63 int	 fdt_node_add_property(void *, char *, void *, int);
64 int	 fdt_node_add_node(void *, char *, void **);
65 void	*fdt_parent_node(void *);
66 int	 fdt_node_is_compatible(void *, const char *);
67 #ifdef DEBUG
68 void	*fdt_print_property(void *, int);
69 void 	 fdt_print_node(void *, int);
70 void	 fdt_print_tree(void);
71 #endif
72