ddi_impl.c revision 288e29327ca3984072a7c23213c22a6f4b3485bd
/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* PC specific DDI implementation
*/
#include <sys/autoconf.h>
#include <sys/bootconf.h>
#include <sys/ddi_impldefs.h>
#include <sys/ddi_subrdefs.h>
#include <sys/ethernet.h>
#include <sys/instance.h>
#include <sys/machsystm.h>
#include <sys/prom_plat.h>
#include <sys/ndi_impldefs.h>
#include <sys/ddi_impldefs.h>
#include <sys/sysmacros.h>
#include <sys/systeminfo.h>
#include <sys/archsystm.h>
#include <vm/seg_kmem.h>
#include <sys/pci_impl.h>
#if defined(__xpv)
#include <sys/hypervisor.h>
#endif
#include <sys/mach_intr.h>
#include <sys/x86_archext.h>
/*
* DDI Boot Configuration
*/
/*
* Platform drivers on this platform
*/
char *platform_module_list[] = {
"acpippm",
"ppm",
(char *)0
};
/* pci bus resource maps */
struct pci_bus_resource *pci_bus_res;
int pseudo_isa = 0;
/*
* Forward declarations
*/
static int getlongprop_buf();
static void get_boot_properties(void);
static void impl_bus_initialprobe(void);
static void impl_bus_reprobe(void);
#define CTGENTRIES 15
static struct ctgas {
int ctg_index;
void *ctg_addr[CTGENTRIES];
} ctglist;
/*
* Minimum pfn value of page_t's put on the free list. This is to simplify
* support of ddi dma memory requests which specify small, non-zero addr_lo
* values.
*
* The default value of 2, which corresponds to the only known non-zero addr_lo
* value used, means a single page will be sacrificed (pfn typically starts
* at 1). ddiphysmin can be set to 0 to disable. It cannot be set above 0x100
* otherwise mp startup panics.
*/
static void
check_driver_disable(void)
{
int proplen = 128;
char *prop_name;
continue;
drv_name);
}
}
}
}
/*
* Configure the hardware on the system.
* Called before the rootfs is mounted
*/
void
configure(void)
{
extern void i_ddi_init_root();
#if defined(__i386)
extern int fpu_pentium_fdivbug;
#endif /* __i386 */
extern int fpu_ignored;
/*
* Determine if an FPU is attached
*/
fpu_probe();
#if defined(__i386)
if (fpu_pentium_fdivbug) {
printf("\
FP hardware exhibits Pentium floating point divide problem\n");
}
#endif /* __i386 */
if (fpu_ignored) {
printf("FP hardware will not be used\n");
} else if (!fpu_exists) {
printf("No FPU in configuration\n");
}
/*
* Initialize devices on the machine.
* Uses configuration tree built by the PROMs to determine what
* is present, and builds a tree of prototype dev_info nodes
* corresponding to the hardware which identified itself.
*/
/*
* Initialize root node.
*/
/* reprogram devices not set up by firmware (BIOS) */
/*
* attach the isa nexus to get ACPI resource usage
* isa is "kind of" a pseudo node
*/
#if defined(__xpv)
if (DOMAIN_IS_INITDOMAIN(xen_info)) {
if (pseudo_isa)
(void) i_ddi_attach_pseudo_node("isa");
else
(void) i_ddi_attach_hw_nodes("isa");
}
#else
if (pseudo_isa)
(void) i_ddi_attach_pseudo_node("isa");
else
(void) i_ddi_attach_hw_nodes("isa");
#endif
#endif /* !SAS && !MPSAS */
}
/*
* The "status" property indicates the operational status of a device.
* If this property is present, the value is a string indicating the
* status of the device as follows:
*
* "okay" operational.
* "disabled" not operational, but might become operational.
* "fail" not operational because a fault has been detected,
* and it is unlikely that the device will become
* operational without repair. no additional details
* are available.
* "fail-xxx" not operational because a fault has been detected,
* and it is unlikely that the device will become
* operational without repair. "xxx" is additional
* human-readable information about the particular
* fault condition that was detected.
*
* The absence of this property means that the operational status is
* unknown or okay.
*
* This routine checks the status property of the specified device node
* and returns 0 if the operational status indicates failure, and 1 otherwise.
*
* The property may exist on plug-in cards the existed before IEEE 1275-1994.
* And, in that case, the property may not even be a string. So we carefully
* check for the value "fail", in the beginning of the string, noting
* the property length.
*/
int
{
char status_buf[OBP_MAXPROPNAME];
int proplen;
static const char *status = "status";
static const char *fail = "fail";
/*
* Get the proplen ... if it's smaller than "fail",
* or doesn't exist ... then we don't care, since
* the value can't begin with the char string "fail".
*
* NB: proplen, if it's a string, includes the NULL in the
* the size of the property, and fail_len does not.
*/
return (1);
/*
* if a buffer was provided, use it
*/
bufp = status_buf;
len = sizeof (status_buf);
}
*bufp = (char)0;
/*
* Get the property into the buffer, to the extent of the buffer,
* and in case the buffer is smaller than the property size,
* NULL terminate the buffer. (This handles the case where
* a buffer was passed in and the caller wants to print the
* value, but the buffer was too small).
*/
/*
* If the value begins with the char string "fail",
* then it means the node is failed. We don't care
* about any other values. We assume the node is ok
* although it might be 'disabled'.
*/
return (0);
return (1);
}
/*
* Check the status of the device node passed as an argument.
*
* if ((status is OKAY) || (status is DISABLED))
* return DDI_SUCCESS
* else
* print a warning and return DDI_FAILURE
*/
/*ARGSUSED1*/
int
{
char status_buf[64];
char devtype_buf[OBP_MAXPROPNAME];
int retval = DDI_FAILURE;
/*
* is the status okay?
*/
return (DDI_SUCCESS);
/*
* a status property indicating bad memory will be associated
* with a node which has a "device_type" property with a value of
* "memory-controller". in this situation, return DDI_SUCCESS
*/
sizeof (devtype_buf)) > 0) {
}
/*
* print the status property information
*/
return (retval);
}
/*ARGSUSED*/
{
softint();
return (1);
}
/*
* Allow for implementation specific correction of PROM property values.
*/
/*ARGSUSED*/
void
{
/*
* There are no adjustments needed in this implementation.
*/
}
static int
{
int size;
return (-1);
return (-1);
size += 1;
}
}
return (size);
}
static int
{
int ret;
== DDI_PROP_SUCCESS) {
}
return (ret);
}
/*
* Node Configuration
*/
struct prop_ispec {
};
/*
* For the x86, we're prepared to claim that the interrupt string
* is in the form of a list of <ipl,vec> specifications.
*/
#define VEC_MIN 1
#define VEC_MAX 255
static int
struct ddi_parent_private_data *pdptr)
{
int n;
int *inpri;
int got_len;
extern int ignore_hardware_nodes; /* force flag from ddi_impl.c */
static char bad_intr_fmt[] =
"bad interrupt spec from %s%d - ipl %d, irq %d\n";
/*
* determine if the driver is expecting the new style "interrupts"
* property which just contains the IRQ, or the old style which
* contains pairs of <IPL,IRQ>. if it is the new style, we always
* assign IPL 5 unless an "interrupt-priorities" property exists.
* in that case, the "interrupt-priorities" property contains the
* IPL values that match, one for one, the IRQ values in the
* "interrupts" property.
*/
/* the old style "interrupts" property... */
/*
* The list consists of <ipl,vec> elements
*/
return (DDI_FAILURE);
while (n--) {
goto broken;
}
if (vec != 2)
else
/*
* irq 2 on the PC bus is tied to irq 9
* on ISA, EISA and MicroChannel
*/
new++;
}
return (DDI_SUCCESS);
} else {
/* the new style "interrupts" property... */
/*
* The list consists of <vec> elements
*/
if ((n = (*in++)) < 1)
return (DDI_FAILURE);
/* XXX check for "interrupt-priorities" property... */
== DDI_PROP_SUCCESS) {
if (n != (got_len / sizeof (int))) {
"bad interrupt-priorities length"
" from %s%d: expected %d, got %d\n",
(int)(got_len / sizeof (int)));
goto broken;
}
}
while (n--) {
int level;
level = 5;
else
goto broken;
}
if (vec != 2)
else
/*
* irq 2 on the PC bus is tied to irq 9
* on ISA, EISA and MicroChannel
*/
new++;
}
return (DDI_SUCCESS);
}
return (DDI_FAILURE);
}
/*
* Create a ddi_parent_private_data structure from the ddi properties of
* the dev_info node.
*
* The "reg" and either an "intr" or "interrupts" properties are required
* if the driver wishes to create mappings or field interrupts on behalf
* of the device.
*
* The "reg" property is assumed to be a list of at least one triple
*
* <bustype, address, size>*1
*
* The "intr" property is assumed to be a list of at least one duple
*
* <SPARC ipl, vector#>*1
*
* The "interrupts" property is assumed to be a list of at least one
* n-tuples that describes the interrupt capabilities of the bus the device
* is connected to. For SBus, this looks like
*
* <SBus-level>*1
*
* (This property obsoletes the 'intr' property).
*
* The "ranges" property is optional.
*/
void
{
struct ddi_parent_private_data *pdptr;
int n;
/*
* Handle the 'reg' property.
*/
DDI_PROP_SUCCESS) && (reg_len != 0)) {
}
/*
* See if I have a range (adding one where needed - this
* means to add one for sbus node in sun4c, when romvec > 0,
* if no range is already defined in the PROM node.
* (Currently no sun4c PROMS define range properties,
* but they should and may in the future.) For the SBus
* node, the range is defined by the SBus reg property.
*/
== DDI_PROP_SUCCESS) {
}
/*
* Handle the 'intr' and 'interrupts' properties
*/
/*
* For backwards compatibility
* we first look for the 'intr' property for the device.
*/
!= DDI_PROP_SUCCESS) {
intr_len = 0;
}
/*
* If we're to support bus adapters and future platforms cleanly,
* we need to support the generalized 'interrupts' property.
*/
&irupts_len) != DDI_PROP_SUCCESS) {
irupts_len = 0;
} else if (intr_len != 0) {
/*
* If both 'intr' and 'interrupts' are defined,
* then 'interrupts' wins and we toss the 'intr' away.
*/
ddi_prop_free((void *)intr_prop);
intr_len = 0;
}
if (intr_len != 0) {
/*
* Translate the 'intr' property into an array
* an array of struct intrspec's. There's not really
* very much to do here except copy what's out there.
*/
struct prop_ispec *l;
l = (struct prop_ispec *)intr_prop;
while (n--) {
new++;
l++;
}
ddi_prop_free((void *)intr_prop);
} else if ((n = irupts_len) != 0) {
int *out;
/*
* Translate the 'interrupts' property into an array
* of intrspecs for the rest of the DDI framework to
* toy with. Only our ancestors really know how to
* do this, so ask 'em. We massage the 'interrupts'
* property so that it is pre-pended by a count of
* the number of integers in the argument.
*/
size = sizeof (int) + n;
*out = n / sizeof (int);
ddi_prop_free((void *)irupts_prop);
"Unable to translate 'interrupts' for %s%d\n",
}
}
}
/*
* Name a child
*/
static int
{
/*
* Fill in parent-private data and this function returns to us
* an indication if it used "registers" to fill in the data.
*/
struct ddi_parent_private_data *pdptr;
}
name[0] = '\0';
if (sparc_pd_getnreg(child) > 0) {
}
return (DDI_SUCCESS);
}
/*
* Called from the bus_ctl op of sunbus (sbus, obio, etc) nexus drivers
* to implement the DDI_CTLOPS_INITCHILD operation. That is, it names
* the children of sun busses based on the reg spec.
*
* Handles the following properties (in make_ddi_ppd):
* Property value
* Name type
* reg register spec
* intr old-form interrupt spec
* interrupts new (bus-oriented) interrupt spec
* ranges range spec
*/
int
{
char name[MAXNAMELEN];
void impl_ddi_sunbus_removechild(dev_info_t *);
/*
* Name the child, also makes parent private data
*/
/*
* Attempt to merge a .conf node; if successful, remove the
* .conf node.
*/
if ((ndi_dev_is_persistent_node(child) == 0) &&
/*
* Return failure to remove node
*/
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
void
{
struct ddi_parent_private_data *pdptr;
size_t n;
return;
/*
* Note that kmem_free is used here (instead of
* ddi_prop_free) because the contents of the
* property were placed into a separate buffer and
* mucked with a bit before being stored in par_intr.
* The actual return value from the prop lookup
* was freed with ddi_prop_free previously.
*/
}
void
{
/*
* Strip the node to properly convert it back to prototype form
*/
}
/*
* DDI Interrupt
*/
/*
* turn this on to force isa, eisa, and mca device to ignore the new
* hardware nodes in the device tree (normally turned on only for
* drivers that need it by setting the property "ignore-hardware-nodes"
* in their driver.conf file).
*
* 7/31/96 -- Turned off globally. Leaving variable in for the moment
* as safety valve.
*/
int ignore_hardware_nodes = 0;
/*
* Local data
*/
static struct impl_bus_promops *impl_busp;
/*
* New DDI interrupt framework
*/
/*
* i_ddi_intr_ops:
*
* This is the interrupt operator function wrapper for the bus function
* bus_intr_op.
*/
int
{
int ret = DDI_FAILURE;
/* request parent to process this interrupt op */
if (NEXUS_HAS_INTR_OP(pdip))
else
"for %s%d due to down-rev nexus driver %s%d",
return (ret);
}
/*
* i_ddi_add_softint - allocate and add a soft interrupt to the system
*/
int
{
int ret;
/* add soft interrupt handler */
}
void
{
}
extern void (*setsoftint)(int, struct av_softinfo *);
int
{
return (DDI_EPENDING);
return (DDI_SUCCESS);
}
/*
* i_ddi_set_softint_pri:
*
* The way this works is that it first tries to add a softint vector
* at the new priority in hdlp. If that succeeds; then it removes the
* existing softint vector at the old priority.
*/
int
{
int ret;
/*
* If a softint is pending at the old priority then fail the request.
*/
return (DDI_FAILURE);
}
void
{
}
void
{
}
int
{
struct ddi_parent_private_data *pdp;
return (0);
}
/*
*/
/*
* Support for allocating DMAable memory to implement
* ddi_dma_mem_alloc(9F) interface.
*/
#define KA_ALIGN_SHIFT 7
/*
* Dummy DMA attribute template for kmem_io[].kmem_io_attr. We only
* care about addr_lo, addr_hi, and align. addr_hi will be dynamically set.
*/
static ddi_dma_attr_t kmem_io_attr = {
0x0000000000000000ULL, /* dma_attr_addr_lo */
0x0000000000000000ULL, /* dma_attr_addr_hi */
0x00ffffff,
0x1000, /* dma_attr_align */
1, 1, 0xffffffffULL, 0xffffffffULL, 0x1, 1, 0
};
/* kmem io memory ranges and indices */
enum {
};
static struct {
static int kmem_io_idx; /* index of first populated kmem_io[] */
static page_t *
{
}
#ifdef __xpv
static void
{
extern void page_destroy_io(page_t *);
}
#endif
static void *
{
}
static void *
{
}
static void *
{
}
static void *
{
}
static void *
{
}
static void *
{
}
static void *
{
}
static void *
{
}
static void *
{
}
static void *
{
}
static void *
{
}
struct {
char *io_name;
int io_initial; /* kmem_io_init during startup */
} io_arena_params[MAX_MEM_RANGES] = {
};
void
kmem_io_init(int a)
{
int c;
char name[40];
#ifdef __xpv
#else
#endif
heap_arena, 0, VM_SLEEP);
for (c = 0; c < KA_NCACHE; c++) {
kmem_io[a].kmem_io_arena, 0);
}
}
/*
* Return the index of the highest memory range for addr.
*/
static int
{
int n;
for (n = kmem_io_idx; n < MAX_MEM_RANGES; n++) {
kmem_io_init(n);
return (n);
}
}
panic("kmem_io_index: invalid addr - must be at least 16m");
/*NOTREACHED*/
}
/*
* Return the index of the next kmem_io populated memory range
* after curindex.
*/
static int
{
int n;
if (kmem_io[n].kmem_io_arena)
return (n);
}
return (-1);
}
/*
* allow kmem to be mapped in with different PTE cache attribute settings.
* Used by i_ddi_mem_alloc()
*/
int
{
return (-1);
}
hat_attr &= ~HAT_ORDER_MASK;
kva += MMU_PAGESIZE;
}
return (0);
}
void
ka_init(void)
{
int a;
#if !defined(__xpv)
#else
#endif
for (a = 0; a < MAX_MEM_RANGES; a++) {
else
a++;
break;
}
}
kmem_io_idx = a;
for (; a < MAX_MEM_RANGES; a++) {
/*
* maxphysaddr and to the "common" io memory ranges that
* have io_initial set to a non-zero value.
*/
kmem_io_init(a);
}
}
/*
*/
static void *
{
int i;
CTGLOCK();
do {
break;
}
} while (ctgp);
CTGUNLOCK();
return (ctgp);
}
/*
* get contig size by addr
*/
static size_t
{
int i, j;
CTGLOCK();
while (ctgp) {
continue;
if (i != j) {
}
CTGUNLOCK();
return (sz);
}
}
CTGUNLOCK();
return (0);
}
/*
* contig_alloc:
*
* allocates contiguous memory to satisfy the 'size' and dma attributes
* specified in 'attr'.
*
* Not all of memory need to be physically contiguous if the
* scatter-gather list length is greater than 1.
*/
/*ARGSUSED*/
void *
{
int pflag;
void *addr;
/* segkmem_xalloc */
else
if (addr) {
return (NULL);
}
if (cansleep)
/* 4k req gets from freelists rather than pfn search */
pflag |= PG_PHYSCONTIG;
if (!ppl) {
return (NULL);
}
}
}
return (addr);
}
void
{
if (!pp)
panic("contig_free: contig pp not found");
if (!page_tryupgrade(pp)) {
panic("contig_free: page freed");
}
page_destroy(pp, 0);
}
}
/*
* Allocate from the system, aligned on a specific boundary.
* The alignment, if non-zero, must be a power of 2.
*/
static void *
{
int a, i, c;
return (NULL);
/*
* All of our allocators guarantee 16-byte alignment, so we don't
* need to reserve additional space for the header.
* To simplify picking the correct kmem_io_cache, we round up to
* a multiple of KA_ALIGN.
*/
else
return (addr);
}
return (NULL);
}
} else {
}
int na;
return (NULL);
/*
* System does not have memory in the requested range.
* Try smaller kmem io ranges and larger cache sizes
* to see if there might be memory available in
* these other caches.
*/
if (raddr)
goto kallocdone;
}
/* now try the larger kmem io cache sizes */
for (i = c + 1; i < KA_NCACHE; i++) {
if (raddr)
goto kallocdone;
}
}
return (NULL);
}
return (addr);
}
static void
{
} else {
if (saddr[-4] == 0)
saddr[-1]);
else
(void *)saddr[-2]);
}
}
/*ARGSUSED*/
void
{
}
/*
* Check if the specified cache attribute is supported on the platform.
* This function must be called before i_ddi_cacheattr_to_hatacc().
*/
{
/*
* The cache attributes are mutually exclusive. Any combination of
* the attributes leads to a failure.
*/
return (B_FALSE);
return (B_TRUE);
/* undefined attributes */
return (B_FALSE);
}
/* set HAT cache attributes from the cache attributes */
void
{
static char *fname = "i_ddi_cacheattr_to_hatacc";
/*
* If write-combining is not supported, then it falls back
* to uncacheable.
*/
/*
* set HAT attrs according to the cache attrs.
*/
switch (cache_attr) {
case IOMEM_DATA_UNCACHED:
*hataccp &= ~HAT_ORDER_MASK;
break;
case IOMEM_DATA_UC_WR_COMBINE:
*hataccp &= ~HAT_ORDER_MASK;
break;
case IOMEM_DATA_CACHED:
*hataccp &= ~HAT_ORDER_MASK;
*hataccp |= HAT_UNORDERED_OK;
break;
/*
* This case must not occur because the cache attribute is scrutinized
* before this function is called.
*/
default:
/*
* set cacheable to hat attrs.
*/
*hataccp &= ~HAT_ORDER_MASK;
*hataccp |= HAT_UNORDERED_OK;
fname, cache_attr);
}
}
/*
* This should actually be called i_ddi_dma_mem_alloc. There should
* also be an i_ddi_pio_mem_alloc. i_ddi_dma_mem_alloc should call
* through the device tree with the DDI_CTLOPS_DMA_ALIGN ctl ops to
* get alignment requirements for DMA memory. i_ddi_pio_mem_alloc
* should use DDI_CTLOPS_PIO_ALIGN. Since we only have i_ddi_mem_alloc
* so far which is used for both, DMA and PIO, we have to use the DMA
* ctl ops to make everybody happy.
*/
/*ARGSUSED*/
int
{
caddr_t a;
int iomin;
int physcontig = 0;
int e;
/*
* Check legality of arguments
*/
return (DDI_FAILURE);
}
return (DDI_FAILURE);
}
/*
* figure out most restrictive alignment requirement
*/
if (iomin == 0)
return (DDI_FAILURE);
/*
* if we allocate memory with IOMEM_DATA_UNCACHED or
* IOMEM_DATA_UC_WR_COMBINE, make sure we allocate a page aligned
* memory that ends on a page boundry.
* Don't want to have to different cache mappings to the same
* physical page.
*/
if (OVERRIDE_CACHE_ATTR(flags)) {
}
/*
* Determine if we need to satisfy the request for physically
* contiguous memory or alignments larger than pagesize.
*/
if (minctg > 1) {
/*
* verify that the minimum contig requirement for the
* actual length does not cross segment boundary.
*/
size_t);
return (DDI_FAILURE);
physcontig = 1;
} else {
}
/*
* Allocate the requested amount from the system.
*/
return (DDI_FAILURE);
/*
* if we to modify the cache attributes, go back and muck with the
* mappings.
*/
if (OVERRIDE_CACHE_ATTR(flags)) {
order = 0;
if (e != 0) {
kfreea(a);
return (DDI_FAILURE);
}
}
if (real_length) {
*real_length = length;
}
if (ap) {
/*
* initialize access handle
*/
}
return (DDI_SUCCESS);
}
/*
* covert old DMA limits structure to DMA attribute structure
* and continue
*/
int
{
int ret;
return (DDI_FAILURE);
}
/*
* set up DMA attribute structure to pass to i_ddi_mem_alloc()
*/
attrp->dma_attr_flags = 0;
if (ret == DDI_SUCCESS) {
if (real_length)
}
return (ret);
}
/* ARGSUSED */
void
{
/*
* if we modified the cache attributes on alloc, go back and
* fix them since this memory could be returned to the
* general pool.
*/
int e;
if (e != 0) {
"override cache attrs, memory leaked\n");
return;
}
}
}
}
/*
* Access Barriers
*
*/
/*ARGSUSED*/
int
{
return (DDI_FAILURE);
}
/*ARGSUSED*/
void
{
}
/*
* Misc Functions
*/
/*
* Implementation instance override functions
*
* No override on i86pc
*/
/*ARGSUSED*/
{
return ((uint_t)-1);
}
/*ARGSUSED*/
int
{
#if defined(__xpv)
/*
* Do not persist instance numbers assigned to devices in dom0
*/
if (DOMAIN_IS_INITDOMAIN(xen_info)) {
return (DDI_SUCCESS);
}
#endif
return (DDI_FAILURE);
}
/*ARGSUSED*/
int
{
return (DDI_FAILURE);
}
/*ARGSUSED*/
int
{
return (DDI_SUCCESS);
}
/*
* Referenced in common/cpr_driver.c: Power off machine.
* Don't know how to power off i86pc.
*/
void
{}
/*
* Copy name to property_name, since name
* is in the low address range below kernelbase.
*/
static void
{
int i = 0;
i++;
}
kern_str[i] = 0; /* null terminate */
if (boot_str[i] != '\0')
"boot property string is truncated to %s", kern_str);
}
static void
get_boot_properties(void)
{
extern char hw_provider[];
char *name;
int length;
void *bop_staging_area;
/*
* Import "root" properties from the boot.
*
* We do this by invoking BOP_NEXTPROP until the list
* is completely copied in.
*/
devi = ddi_root_node();
name; /* NULL => DONE */
/* copy string to memory above kernelbase */
/*
* Skip vga properties. They will be picked up later
* by get_vga_properties.
*/
continue;
}
if (length == 0)
continue;
if (length > MMU_PAGESIZE) {
"boot property %s longer than 0x%x, ignored\n",
continue;
}
/*
* special properties:
* si-machine, si-hw-provider
* goes to kernel data structures.
* bios-boot-device and stdout
* goes to hardware property list so it may show up
* in the prtconf -vp output. This is needed by
* this can be taken out.
*/
SYS_NMLN);
property_name, *((int *)bop_staging_area));
} else {
/* Property type unknown, use old prop interface */
length);
}
}
}
static void
get_vga_properties(void)
{
char *name;
int length;
char property_val[50];
void *bop_staging_area;
/*
* XXXX Hack Allert!
* There really needs to be a better way for identifying various
* console framebuffers and their related issues. Till then,
* check for this one as a replacement to vgatext.
*/
return;
}
return;
/*
* Import "vga" properties from the boot.
*/
name = "display-edif-block";
}
/*
* kdmconfig is also looking for display-type and
* video-adapter-type. We default to color and svga.
*
* Could it be "monochrome", "vga"?
* Nah, you've got to come to the 21st century...
* And you can set monitor type manually in kdmconfig
* if you are really an old junky.
*/
(void) ndi_prop_update_string(DDI_DEV_T_NONE,
(void) ndi_prop_update_string(DDI_DEV_T_NONE,
name = "display-edif-id";
(void) ndi_prop_update_string(DDI_DEV_T_NONE,
}
}
/*
* This is temporary, but absolutely necessary. If we are being
* booted with a device tree created by the DevConf project's bootconf
* program, then we have device information nodes that reflect
* reality. At this point in time in the Solaris release schedule, the
* kernel drivers aren't prepared for reality. They still depend on their
* own ad-hoc interpretations of the properties created when their .conf
* files were interpreted. These drivers use an "ignore-hardware-nodes"
* property to prevent them from using the nodes passed up from the bootconf
* device tree.
*
* Trying to assemble root file system drivers as we are booting from
* devconf will fail if the kernel driver is basing its name_addr's on the
* psuedo-node device info while the bootpath passed up from bootconf is using
* reality-based name_addrs. We help the boot along in this case by
* looking at the pre-bootconf bootpath and determining if we would have
* successfully matched if that had been the bootpath we had chosen.
*
* Note that we only even perform this extra check if we've booted
* using bootconf's 1275 compliant bootpath, this is the boot device, and
* we're trying to match the name_addr specified in the 1275 bootpath.
*/
#define MAXCOMPONENTLEN 32
int
{
/*
* There are multiple criteria to be met before we can even
* consider allowing a name_addr match here.
*
* 1) We must have been booted such that the bootconf program
* created device tree nodes and properties. This can be
* determined by examining the 'bootpath' property. This
* property will be a non-null string iff bootconf was
* involved in the boot.
*
* 2) The module that we want to match must be the boot device.
*
* 3) The instance of the module we are thinking of letting be
* our match must be ignoring hardware nodes.
*
* 4) The name_addr we want to match must be the name_addr
* specified in the 1275 bootpath.
*/
static char bootdev_module[MAXCOMPONENTLEN];
static char bootdev_oldmod[MAXCOMPONENTLEN];
static char bootdev_newaddr[MAXCOMPONENTLEN];
static char bootdev_oldaddr[MAXCOMPONENTLEN];
static int quickexit;
char *daddr;
int dlen;
char *lkupname;
int rv = DDI_FAILURE;
"ignore-hardware-nodes", -1) != -1)) {
return (DDI_SUCCESS);
}
}
if (quickexit)
return (rv);
if (bootdev_module[0] == '\0') {
ddi_root_node(), 0, "bootpath",
bp1275len <= 1) {
/*
* We didn't boot from bootconf so we never need to
* do any special matches.
*/
quickexit = 1;
if (bp1275)
return (rv);
}
ddi_root_node(), 0, "boot-path",
/*
* No fallback position for matching. This is
* certainly unexpected, but we'll handle it
* just in case.
*/
quickexit = 1;
if (bp)
return (rv);
}
/*
* Determine boot device module and 1275 name_addr
*
*/
*atp = '\0';
*eoaddrp = '\0';
}
}
}
} else {
quickexit = 1;
return (rv);
}
/*
* Determine fallback name_addr
*
* 10/3/96 - Also save fallback module name because it
* might actually be different than the current module
* name. E.G., ISA pnp drivers have new names.
*
*/
*atp = '\0';
*eoaddrp = '\0';
}
}
}
}
/* Free up the bootpath storage now that we're done with it. */
if (bootdev_oldaddr[0] == '\0') {
quickexit = 1;
return (rv);
}
}
"ignore-hardware-nodes", -1) != -1) ||
rv = DDI_SUCCESS;
}
return (rv);
}
/*
* Perform a copy from a memory mapped device (whose devinfo pointer is devi)
* separately mapped at devaddr in the kernel to a kernel buffer at kaddr.
*/
/*ARGSUSED*/
int
{
return (0);
}
/*
* Perform a copy to a memory mapped device (whose devinfo pointer is devi)
* separately mapped at devaddr in the kernel from a kernel buffer at kaddr.
*/
/*ARGSUSED*/
int
{
return (0);
}
static int
{
int err = DDI_SUCCESS;
/* Set up protected environment. */
case sizeof (uint8_t):
break;
case sizeof (uint16_t):
break;
case sizeof (uint32_t):
break;
case sizeof (uint64_t):
break;
default:
err = DDI_FAILURE;
break;
}
} else
err = DDI_FAILURE;
/* Take down protected environment. */
no_trap();
return (err);
}
static int
{
int err = DDI_SUCCESS;
case sizeof (uint8_t):
break;
case sizeof (uint16_t):
break;
case sizeof (uint32_t):
break;
case sizeof (uint64_t):
break;
default:
err = DDI_FAILURE;
break;
}
} else
err = DDI_FAILURE;
no_trap();
return (err);
}
/*
* Assume that this is for memory, as nexi take care of device safe accesses.
*/
int
{
}
/*
* calling pci_ereport_post() on all puts and for any gets that return -1
*/
static int
{
int rval = DDI_SUCCESS;
int check_err = 0;
if (ctlop == DDI_CTLOPS_POKE &&
return (DDI_SUCCESS);
if (ctlop == DDI_CTLOPS_PEEK &&
case sizeof (uint8_t):
check_err = 1;
break;
case sizeof (uint16_t):
check_err = 1;
break;
case sizeof (uint32_t):
0xffffffff)
check_err = 1;
break;
case sizeof (uint64_t):
0xffffffffffffffff)
check_err = 1;
break;
}
}
if (check_err == 0)
return (DDI_SUCCESS);
}
/*
* for a cautious put or get or a non-cautious get that returned -1 call
* io framework to see if there really was an error
*/
/*
* We only get here with DDI_DEFAULT_ACC for config space gets.
* Non-hardened drivers may be probing the hardware and
* expecting -1 returned. So need to treat errors on
* DDI_DEFAULT_ACC as DDI_FM_ERR_EXPECTED.
*/
} else {
/*
* Hardened driver doing protected accesses shouldn't
* get errors unless there's a hardware problem. Treat
* as nonfatal if there's an error, but set UNEXPECTED
* so we raise ereports on any errors and potentially
* fault the device
*/
}
rval = DDI_FAILURE;
}
return (rval);
}
/*
* pci_peekpoke_check_nofma() is for when an error occurs on a register access
* during pci_ereport_post(). We can't call pci_ereport_post() again or we'd
* recurse, so assume all puts are OK and gets have failed if they return -1
*/
static int
{
int rval = DDI_SUCCESS;
if (ctlop == DDI_CTLOPS_POKE)
return (rval);
case sizeof (uint8_t):
rval = DDI_FAILURE;
break;
case sizeof (uint16_t):
rval = DDI_FAILURE;
break;
case sizeof (uint32_t):
rval = DDI_FAILURE;
break;
case sizeof (uint64_t):
0xffffffffffffffff)
rval = DDI_FAILURE;
break;
}
}
rval == DDI_FAILURE) {
}
return (rval);
}
int
{
int rval;
/*
* which don't have a handle
*/
return (DDI_FAILURE);
if (!mutex_tryenter(err_mutexp)) {
/*
* As this may be a recursive call from within
* pci_ereport_post() we can't wait for the mutexes.
* Fortunately we know someone is already calling
* pci_ereport_post() which will handle the error bits
* for us, and as this is a config space access we can
* just do the access and check return value for -1
* using pci_peekpoke_check_nofma().
*/
if (rval == DDI_SUCCESS)
return (rval);
}
/*
* This can't be a recursive call. Drop the err_mutex and get
* both mutexes in the right order. If an error hasn't already
* been detected by the ontrap code, use pci_peekpoke_check_fma
* which will call pci_ereport_post() to check error status.
*/
}
if (rval == DDI_SUCCESS) {
}
return (rval);
}
void
impl_setup_ddi(void)
{
#if !defined(__xpv)
extern void startup_bios_disk(void);
extern int post_fastreboot;
#endif
int err;
(void) BOP_GETPROP(bootops,
"ramdisk_start", (void *)&ramdisk_start);
(void) BOP_GETPROP(bootops,
"ramdisk_end", (void *)&ramdisk_end);
#ifdef __xpv
ramdisk_start -= ONE_GIG;
ramdisk_end -= ONE_GIG;
#endif
sizeof (rd_mem_prop));
/* isa node */
if (pseudo_isa) {
"device_type", "isa");
"bus-type", "isa");
(void) ndi_devi_bind_driver(isa_dip, 0);
}
/*
* Read in the properties from the boot.
*/
/* not framebuffer should be enumerated, if present */
/*
* Check for administratively disabled drivers.
*/
#if !defined(__xpv)
if (!post_fastreboot)
#endif
/* do bus dependent probes. */
}
getrootdev(void)
{
/*
*/
if (root_is_svm == B_TRUE) {
return (ddi_pathname_to_dev_t(svm_bootpath));
}
/*
* Usually rootfs.bo_name is initialized by the
* the bootpath property from bootenv.rc, but
* defaults to "/ramdisk:a" otherwise.
*/
}
static struct bus_probe {
void (*probe)(int);
} *bus_probes;
void
impl_bus_add_probe(void (*func)(int))
{
if (!bus_probes) {
bus_probes = probe;
return;
}
}
/*ARGSUSED*/
void
impl_bus_delete_probe(void (*func)(int))
{
while (probe) {
break;
}
return;
if (prev)
else
}
/*
* impl_bus_initialprobe
* Modload the prom simulator, then let it probe to verify existence
* and type of PCI support.
*/
static void
impl_bus_initialprobe(void)
{
/* load modules to install bus probes */
#if defined(__xpv)
if (DOMAIN_IS_INITDOMAIN(xen_info)) {
panic("failed to load misc/pci_autoconfig");
}
}
#else
panic("failed to load misc/pci_autoconfig");
}
#endif
probe = bus_probes;
while (probe) {
/* run the probe functions */
}
}
/*
* impl_bus_reprobe
* Reprogram devices not set up by firmware.
*/
static void
impl_bus_reprobe(void)
{
probe = bus_probes;
while (probe) {
/* run the probe function */
}
}
/*
* The following functions ready a cautious request to go up to the nexus
* driver. It is up to the nexus driver to decide how to process the request.
* It may choose to call i_ddi_do_caut_get/put in this file, or do it
* differently.
*/
static void
{
}
{
return (value);
}
{
return (value);
}
{
return (value);
}
{
return (value);
}
void
{
}
void
{
}
void
{
}
void
{
}
void
{
}
void
{
}
void
{
}
void
{
}
void
{
}
void
{
}
void
{
}
void
{
}
{
return (B_TRUE);
}
return (B_FALSE);
}
{
return (dma_max_copybuf_size);
}
/*
* i_ddi_dma_max()
* returns the maximum DMA size which can be performed in a single DMA
* window taking into account the devices DMA contraints (attrp), the
* maximum copy buffer size (if applicable), and the worse case buffer
* fragmentation.
*/
/*ARGSUSED*/
{
/*
* take the min of maxxfer and the the worse case fragementation
* (e.g. every cookie <= 1 page)
*/
/*
* If the DMA engine can't reach all off memory, we also need to take
* the max size of the copybuf into consideration.
*/
if (i_ddi_copybuf_required(attrp)) {
}
/*
* we only return a 32-bit value. Make sure it's not -1. Round to a
* page so it won't be mistaken for an error value during debug.
*/
if (maxxfer >= 0xFFFFFFFF) {
maxxfer = 0xFFFFF000;
}
/*
* make sure the value we return is a whole multiple of the
* granlarity.
*/
}
}