/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* This file contains ddi functions common to intel architectures
*/
#include <sys/archsystm.h>
#include <sys/dditypes.h>
#include <sys/ddi_impldefs.h>
/*
* DDI Mapping
*/
/*
* i_ddi_bus_map:
* Generic bus_map entry point, for byte addressable devices
* to be programmed at this level.
*/
int
{
int error;
/*
* First, if given an rnumber, convert it to a regspec...
*/
#ifdef DDI_MAP_DEBUG
static char *out_of_range =
"i_ddi_bus_map: Out of range rnumber <%d>, device <%s>";
#endif /* DDI_MAP_DEBUG */
#ifdef DDI_MAP_DEBUG
ddi_get_name(rdip));
#endif /* DDI_MAP_DEBUG */
return (DDI_ME_RNUMBER_RANGE);
}
/*
* Convert the given ddi_map_req_t from rnumber to regspec...
*/
}
/*
* Adjust offset and length correspnding to called values...
* XXX: A non-zero length means override the one in the regspec.
* XXX: (Regardless of what's in the parent's range)
*/
#ifdef DDI_MAP_DEBUG
"i_ddi_bus_map: <%s,%s> <0x%x, 0x%x, 0x%d> "
"offset %d len %d handle 0x%x\n",
#endif /* DDI_MAP_DEBUG */
/*
* I/O or memory mapping
*
* <bustype=0, addr=x, len=x>: memory
* <bustype=1, addr=x, len=x>: i/o
* <bustype>1, addr=0, len=x>: x86-compatibility i/o
*/
return (DDI_ME_INVAL);
}
/*
* compatibility i/o mapping
*/
} else {
/*
* Normal memory or i/o mapping
*/
}
if (len != 0)
#ifdef DDI_MAP_DEBUG
" <%s,%s> <0x%x, 0x%x, 0x%d> "
"offset %d len %d\n",
#endif /* DDI_MAP_DEBUG */
/*
* If we had an MMU, this is where you'd program the MMU and hat layer.
* Since we're using the default function here, we do not have an MMU
* to program.
*/
/*
* Apply any parent ranges at this level, if applicable.
* (This is where nexus specific regspec translation takes place.
* Use of this function is implicit agreement that translation is
* provided via ddi_apply_range.) Note that we assume that
* the request is within the parents limits.
*/
#ifdef DDI_MAP_DEBUG
ddi_map_debug("applying range of parent <%s> to child <%s>...\n",
#endif /* DDI_MAP_DEBUG */
return (error);
/*
* Call my parents bus_map function with modified values...
*/
}
/*
* Creating register mappings and handling interrupts:
*/
struct regspec *
{
return ((struct regspec *)0);
}
/*
* Static function to determine if a reg prop is enclosed within
* a given a range spec. (For readability: only used by i_ddi_aply_range.).
*/
static int
{
return (0);
return (0);
return (1); /* size is really 2**(bits_per_word) */
return (1);
return (0);
}
/*
* i_ddi_apply_range:
* Apply range of dp to struct regspec *rp, if applicable.
* If there's any range defined, it gets applied.
*/
int
{
int nrange, b;
static char *out_of_range =
"Out of range register specification from device node <%s>\n";
if (nrange == 0) {
#ifdef DDI_MAP_DEBUG
ddi_map_debug(" No range.\n");
#endif /* DDI_MAP_DEBUG */
return (0);
}
/*
* Find a match, making sure the regspec is within the range
* of the parent, noting that a size of zero in a range spec
* really means a size of 2**(bitsperword).
*/
break; /* found a match */
if (b == nrange) {
return (DDI_ME_REGSPEC_RANGE);
}
#ifdef DDI_MAP_DEBUG
ddi_map_debug(" Range: %x.%x %x.%x %x\n",
#endif /* DDI_MAP_DEBUG */
#ifdef DDI_MAP_DEBUG
#endif /* DDI_MAP_DEBUG */
return (0);
}
/*
* i_ddi_map_fault: wrapper for bus_map_fault.
*/
int
{
return (DDI_FAILURE);
/* request appropriate parent to map fault */
}
/*
* Return an integer in native machine format from an OBP 1275 integer
* representation, which is big-endian, with no particular alignment
* guarantees. intp points to the OBP data, and n the number of bytes.
*
* Byte-swapping is needed on intel.
*/
int
{
int i = 0;
ASSERT(n > 0 && n <= 4);
intp += n;
while (n-- > 0) {
i = (i << 8) | *(--intp);
}
return (i);
}
int drv_usec_coarse_timing = 0;
/*
* Time delay function called by drivers
*/
void
{
int tens = 0;
extern int gethrtime_hires;
if (gethrtime_hires) {
if (drv_usec_coarse_timing) {
/* revert to the wait time as before using tsc */
/* in case there are callers depending on the */
/* old behaviour */
} else {
}
SMT_PAUSE();
}
return;
}
if (count > 10)
tens++; /* roundup; wait at least 10 microseconds */
while (tens > 0) {
tenmicrosec();
tens--;
}
}