1 /* $NetBSD: sunddi.h,v 1.6 2019/05/22 08:44:48 hannken Exp $ */ 2 3 /*- 4 * Copyright (c) 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org> 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * $FreeBSD: head/sys/cddl/compat/opensolaris/sys/sunddi.h 277448 2015-01-20 22:27:45Z will $ 29 */ 30 31 #ifndef _OPENSOLARIS_SYS_SUNDDI_H_ 32 #define _OPENSOLARIS_SYS_SUNDDI_H_ 33 34 #ifdef _KERNEL 35 36 #include <sys/kmem.h> 37 #include <lib/libkern/libkern.h> 38 #include <sys/sysevent.h> 39 40 #ifndef _KERNEL 41 #define ddi_copyin(from, to, size, flag) (bcopy((from), (to), (size)), 0) 42 #define ddi_copyout(from, to, size, flag) (bcopy((from), (to), (size)), 0) 43 #else 44 #define ddi_copyin(from, to, size, flag) (ioctl_copyin((flag), (from), (to), (size))) 45 #define ddi_copyout(from, to, size, flag) (ioctl_copyout((flag), (from), (to), (size))) 46 #endif 47 int ddi_strtol(const char *str, char **nptr, int base, long *result); 48 int ddi_strtoul(const char *str, char **nptr, int base, unsigned long *result); 49 int ddi_strtoull(const char *str, char **nptr, int base, 50 unsigned long long *result); 51 52 #define DDI_SUCCESS (0) 53 #define DDI_FAILURE (-1) 54 #define DDI_SLEEP 0x666 55 56 int ddi_soft_state_init(void **statep, size_t size, size_t nitems); 57 void ddi_soft_state_fini(void **statep); 58 59 void *ddi_get_soft_state(void *state, int item); 60 int ddi_soft_state_zalloc(void *state, int item); 61 void ddi_soft_state_free(void *state, int item); 62 63 int _ddi_log_sysevent(char *vendor, char *class_name, char *subclass_name, 64 nvlist_t *attr_list, sysevent_id_t *eidp, int flag); 65 #define ddi_log_sysevent(dip, vendor, class_name, subclass_name, \ 66 attr_list, eidp, flag) \ 67 _ddi_log_sysevent((vendor), (class_name), (subclass_name), \ 68 (attr_list), (eidp), (flag)) 69 70 71 #define DDI_PSEUDO "" 72 73 struct dev_info { 74 int di_cmajor; 75 int di_bmajor; 76 }; 77 typedef struct dev_info dev_info_t; 78 79 int ddi_create_minor_node(dev_info_t *, char *, int, 80 minor_t, char *, int); 81 void ddi_remove_minor_node(dev_info_t *, char *); 82 83 #define ddi_name_to_major(name) devsw_name2blk(name, NULL, 0) 84 #define ddi_prop_update_string(a, b, c, d) DDI_SUCCESS 85 86 #endif /* _KERNEL */ 87 88 #endif /* _OPENSOLARIS_SYS_SUNDDI_H_ */ 89