1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * CDDL HEADER START
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * The contents of this file are subject to the terms of the
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Common Development and Distribution License (the "License").
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * You may not use this file except in compliance with the License.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * See the License for the specific language governing permissions
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * and limitations under the License.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * When distributing Covered Code, include this CDDL HEADER in each
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * If applicable, add the following below this CDDL HEADER, with the
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * fields enclosed by brackets "[]" replaced with your own identifying
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * information: Portions Copyright [yyyy] [name of copyright owner]
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * CDDL HEADER END
79afa7fba66c808623862442107f913bce5ea783Sean McEnroe * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Use is subject to license terms.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * sun4v DR Utility functions
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * The type argument is currently unused. However, it
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * keeps the interface flexible enough to allows for
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * only disabling certain types of DR.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * DR requires that the kernel is using its own CIF
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * handler. If that is not the case, either because
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * domaining has been explicitly disabled, or because
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * the firmware does not support it, the system must
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * remain static and DR must be disabled.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo cmn_err(CE_NOTE, "!Kernel CIF handler is not enabled, DR "
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo "is not available\n");
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Generate a DR sysevent based on the type of resource and
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * sysevent hint specified. The hint indicates whether the
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * resource was added or removed.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo DR_DBG_ALL("generate_event: type=%s, hint=%s\n", DR_TYPE2STR(type),
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Add the attachment point attribute
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ev = sysevent_alloc(EC_DR, ESC_DR_AP_STATE_CHANGE, pubname, KM_SLEEP);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo rv = sysevent_add_attr(&evnt_attr_list, DR_AP_ID, &evnt_val, KM_SLEEP);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo if (rv != 0) {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo DR_DBG_ALL("generate_event: failed to add attr '%s' for "
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Add the DR hint attribute
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo rv = sysevent_add_attr(&evnt_attr_list, DR_HINT, &evnt_val, KM_SLEEP);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo if (rv != 0) {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo DR_DBG_ALL("generate_event: failed to add attr '%s' for "
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Attach the attribute list to the event
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo if (rv != 0) {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo DR_DBG_ALL("generate_event: failed to add attr list for "
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Log the event
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo if (rv != 0) {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo DR_DBG_ALL("generate_event: failed to log event (%d)\n", rv);
79afa7fba66c808623862442107f913bce5ea783Sean McEnroe *mlp = (struct memlist *)kmem_zalloc(sizeof (struct memlist),\
79afa7fba66c808623862442107f913bce5ea783Sean McEnroe * Free a memlist and its elements
79afa7fba66c808623862442107f913bce5ea783Sean McEnroe kmem_free((void *)ml, sizeof (struct memlist));
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Debugging Features
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LINEWIDTH ((BYTESPERLINE * 3) + (BYTESPERLINE + 2) + 1)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Output a buffer formatted with a set number of bytes on
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * each line. Append each line with the ASCII equivalent of
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * each byte if it falls within the printable ASCII range,
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * and '.' otherwise.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* abort if not debugging transport */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* walk the buffer one line at a time */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Walk the bytes in the current line, storing
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * the hex value for the byte as well as the
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * ASCII representation in a temporary buffer.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * All ASCII values are placed at the end of
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * the line.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo for (j = 0; (j < BYTESPERLINE) && ((i + j) < len); j++) {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Fill in to the start of the ASCII translation
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * with spaces. This will only be necessary if
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * this is the last line and there are not enough
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * bytes to fill the whole line.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#endif /* DEBUG */