1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* 28 * Deimos - cryptographic acceleration based upon Broadcom 582x. 29 */ 30 31 #include <sys/types.h> 32 #include <sys/ddi.h> 33 #include <sys/sunddi.h> 34 #include <sys/cmn_err.h> 35 #include <sys/varargs.h> 36 #include <sys/crypto/dca.h> 37 38 /* 39 * Debugging and messaging. 40 */ 41 #if DEBUG 42 static int dca_debug = 0; 43 44 void 45 dca_dprintf(dca_t *dca, int level, const char *fmt, ...) 46 { 47 va_list ap; 48 char buf[256]; 49 50 if (dca_debug & level) { 51 va_start(ap, fmt); 52 if (dca == NULL) { 53 (void) sprintf(buf, "%s\n", fmt); 54 } else { 55 (void) sprintf(buf, "%s/%d: %s\n", 56 ddi_driver_name(dca->dca_dip), 57 ddi_get_instance(dca->dca_dip), fmt); 58 } 59 vprintf(buf, ap); 60 va_end(ap); 61 } 62 } 63 #endif 64 65 void 66 dca_error(dca_t *dca, const char *fmt, ...) 67 { 68 va_list ap; 69 va_start(ap, fmt); 70 dca_dipverror(dca->dca_dip, fmt, ap); 71 va_end(ap); 72 } 73 74 void 75 dca_diperror(dev_info_t *dip, const char *fmt, ...) 76 { 77 va_list ap; 78 va_start(ap, fmt); 79 dca_dipverror(dip, fmt, ap); 80 va_end(ap); 81 } 82 83 void 84 dca_dipverror(dev_info_t *dip, const char *fmt, va_list ap) 85 { 86 char buf[256]; 87 (void) sprintf(buf, "%s%d: %s", ddi_driver_name(dip), 88 ddi_get_instance(dip), fmt); 89 vcmn_err(CE_WARN, buf, ap); 90 } 91