xref: /netbsd/sys/arch/sparc64/include/mdesc.h (revision 051d8285)
1 /*	$NetBSD: mdesc.h,v 1.5 2016/06/22 20:13:00 palle Exp $	*/
2 /*	$OpenBSD: mdesc.h,v 1.3 2014/11/30 22:26:14 kettenis Exp $	*/
3 /*
4  * Copyright (c) 2009 Mark Kettenis
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 #ifndef	_MDESC_H_
20 #define _MDESC_H_
21 
22 struct md_header {
23 	uint32_t	transport_version;
24 	uint32_t	node_blk_sz;
25 	uint32_t	name_blk_sz;
26 	uint32_t	data_blk_sz;
27 };
28 
29 struct md_element {
30 	uint8_t		tag;
31 	uint8_t		name_len;
32 	uint16_t	_reserved_field;
33 	uint32_t	name_offset;
34 	union {
35 		struct {
36 			uint32_t	data_len;
37 			uint32_t	data_offset;
38 		} y;
39 		uint64_t	val;
40 	} d;
41 };
42 
43 extern vaddr_t mdesc;
44 
45 #ifdef _KERNEL
46 psize_t	mdesc_get_len(void);
47 void	mdesc_init(vaddr_t, paddr_t, psize_t);
48 uint64_t mdesc_get_prop_val(int, const char *);
49 const char *mdesc_get_prop_str(int, const char *);
50 const char *mdesc_get_prop_data(int, const char *, size_t *);
51 int	mdesc_find(const char *, uint64_t);
52 int	mdesc_find_child(int, const char *, uint64_t);
53 int	mdesc_find_node(const char *);
54 int	mdesc_find_node_by_idx(int, const char *);
55 int	mdesc_next_node(int);
56 const char *mdesc_name_by_idx(int);
57 #endif
58 
59 #endif /* _MDESC_H_ */
60