/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
* Copyright (c) 2002-2006 Neterion, Inc.
*/
#include "xgehal-driver.h"
#include "xgehal-device.h"
#ifdef XGE_OS_MEMORY_CHECK
int g_malloc_cnt = 0;
#endif
/*
* Runtime tracing support
*/
static unsigned long g_module_mask_default = 0;
static int g_level_default = 0;
#ifdef XGE_TRACE_INTO_CIRCULAR_ARR
/**
* xge_hal_driver_tracebuf_dump - Dump the trace buffer.
*
* Dump the trace buffer contents.
*/
void
{
int i;
int off = 0;
if (g_xge_os_tracebuf == NULL) {
return;
}
xge_os_printf("################ Trace dump Begin ###############");
if (g_xge_os_tracebuf->wrapped_once) {
for (i = 0; i < g_xge_os_tracebuf->size -
if (*(dmesg_start + i))
xge_os_printf(dmesg_start + i);
}
}
if (*(dmesg + i))
xge_os_printf(dmesg + i);
}
xge_os_printf("################ Trace dump End ###############");
}
{
int i;
*retsize = 0;
*retbuf = 0;
if (g_xge_os_tracebuf == NULL) {
return XGE_HAL_FAIL;
}
if (g_xge_os_tracebuf->wrapped_once) {
for (i = 0; i < g_xge_os_tracebuf->size -
if (*(dmesg_start + i)) {
"%s\n", dmesg_start + i);
if (retbuf_off > bufsize)
return XGE_HAL_ERR_OUT_OF_MEMORY;
}
}
}
if (*(dmesg + i)) {
"%s\n", dmesg + i);
if (retbuf_off > bufsize)
return XGE_HAL_ERR_OUT_OF_MEMORY;
}
}
*retsize = retbuf_off;
return XGE_HAL_OK;
}
#endif
#ifdef XGE_HAL_DEBUG_BAR0_OFFSET
void
{
0x108);
0x08E0);
0x09E8);
0x1108);
0x1170);
0x1930);
0x19B8);
0x2100);
0x2128);
0x2170);
0x2918);
0x1040);
0x1800);
0x2010);
0x2810);
0x3000);
}
#endif
/**
* xge_hal_driver_initialize - Initialize HAL.
* @config: HAL configuration, see xge_hal_driver_config_t{}.
* @uld_callbacks: Upper-layer driver callbacks, e.g. link-up.
*
* HAL initialization entry point. Not to confuse with device initialization
* (note that HAL "contains" zero or more Xframe devices).
*
* Returns: XGE_HAL_OK - success;
* XGE_HAL_ERR_BAD_DRIVER_CONFIG - Driver configuration params invalid.
*
* See also: xge_hal_device_initialize(), xge_hal_status_e{},
* xge_hal_uld_cbs_t{}.
*/
{
#ifdef XGE_HAL_DEBUG_BAR0_OFFSET
#endif
#ifdef XGE_TRACE_INTO_CIRCULAR_ARR
if (config->tracebuf_size == 0)
/*
* Trace buffer implementation is not lock protected.
* The only harm to expect is memcpy() to go beyond of
* allowed boundaries. To make it safe (driver-wise),
* we pre-allocate needed number of extra bytes.
*/
#endif
if (status != XGE_HAL_OK)
return status;
/* apply config */
sizeof(xge_hal_driver_config_t));
/* apply ULD callbacks */
sizeof(xge_hal_uld_cbs_t));
#ifdef XGE_TRACE_INTO_CIRCULAR_ARR
xge_os_printf("cannot allocate trace buffer!");
return XGE_HAL_ERR_OUT_OF_MEMORY;
}
/* timestamps disabled by default */
if (g_tracebuf.timestamp) {
} else
g_tracebuf.offset = 0;
*g_tracebuf.msg = 0;
*dmesg = 0;
#endif
return XGE_HAL_OK;
}
/**
* xge_hal_driver_terminate - Terminate HAL.
*
* HAL termination entry point.
*
* See also: xge_hal_device_terminate().
*/
void
xge_hal_driver_terminate(void)
{
#ifdef XGE_TRACE_INTO_CIRCULAR_ARR
if (g_tracebuf.size) {
}
#endif
#ifdef XGE_OS_MEMORY_CHECK
{
int i, leaks=0;
for (i=0; i<g_malloc_cnt; i++) {
xge_os_printf("OSPAL: memory leak detected at "
g_malloc_arr[i].file,
g_malloc_arr[i].line,
(unsigned long long)(ulong_t)
g_malloc_arr[i].ptr,
g_malloc_arr[i].size);
leaks++;
}
}
if (leaks) {
} else {
xge_os_printf("OSPAL: no memory leaks detected");
}
}
#endif
}