1/* $OpenBSD: mdesc.h,v 1.4 2019/10/20 16:27:19 kettenis Exp $ */
2/*
3 * Copyright (c) 2009 Mark Kettenis
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18struct md_header {
19 uint32_t transport_version;
20 uint32_t node_blk_sz;
21 uint32_t name_blk_sz;
22 uint32_t data_blk_sz;
23};
24
25struct md_element {
26 uint8_t tag;
27 uint8_t name_len;
28 uint16_t _reserved_field;
29 uint32_t name_offset;
30 union {
31 struct {
32 uint32_t data_len;
33 uint32_t data_offset;
34 } y;
35 uint64_t val;
36 } d;
37};
38
39#ifdef _KERNEL
40
41extern caddr_t mdesc;
42extern size_t mdesc_len;
43
44extern caddr_t pri;
45extern size_t pri_len;
46
47void mdesc_init(void);
48uint64_t mdesc_get_prop_val(int, const char *);
49const char *mdesc_get_prop_str(int, const char *);
50const char *mdesc_get_prop_data(int, const char *, size_t *);
51int mdesc_find(const char *, uint64_t);
52int mdesc_find_child(int, const char *, uint64_t);
53int mdesc_find_node(const char *);
54
55#endif