1 /* $NetBSD: mdesc.h,v 1.4 2015/09/06 16:45:09 martin 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 struct md_header { 20 uint32_t transport_version; 21 uint32_t node_blk_sz; 22 uint32_t name_blk_sz; 23 uint32_t data_blk_sz; 24 }; 25 26 struct md_element { 27 uint8_t tag; 28 uint8_t name_len; 29 uint16_t _reserved_field; 30 uint32_t name_offset; 31 union { 32 struct { 33 uint32_t data_len; 34 uint32_t data_offset; 35 } y; 36 uint64_t val; 37 } d; 38 }; 39 40 #ifdef _KERNEL 41 psize_t mdesc_get_len(void); 42 void mdesc_init(vaddr_t, paddr_t, psize_t); 43 uint64_t mdesc_get_prop_val(int, const char *); 44 const char *mdesc_get_prop_str(int, const char *); 45 const char *mdesc_get_prop_data(int, const char *, size_t *); 46 int mdesc_find(const char *, uint64_t); 47 int mdesc_find_child(int, const char *, uint64_t); 48 int mdesc_find_node(const char *); 49 int mdesc_find_node_by_idx(int, const char *); 50 int mdesc_next_node(int); 51 const char *mdesc_name_by_idx(int); 52 #endif 53