rootnex.c revision a195726fa33097e56cf1c25c31feddb827e140f0
/*
* 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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* sun4 root nexus driver
*/
#include <sys/ddi_subrdefs.h>
#include <vm/seg_kmem.h>
/* Useful debugging Stuff */
#include <sys/nexusdebug.h>
#define ROOTNEX_MAP_DEBUG 0x1
#define ROOTNEX_INTR_DEBUG 0x2
/*
* config information
*/
static int
static int
ddi_intr_handle_impl_t *, void *);
static int
static int
static int
static void
static int
/*
* Defined in $KARCH/io/mach_rootnex.c
*/
#pragma weak rootnex_add_intr_impl
#pragma weak rootnex_remove_intr_impl
#pragma weak rootnex_get_intr_pri
#pragma weak rootnex_name_child_impl
#pragma weak rootnex_initchild_impl
#pragma weak rootnex_uninitchild_impl
#pragma weak rootnex_reportdev_impl
static struct cb_ops rootnex_cb_ops = {
nodev, /* open */
nodev, /* close */
nodev, /* strategy */
nodev, /* print */
nodev, /* dump */
nodev, /* read */
nodev, /* write */
nodev, /* ioctl */
nodev, /* devmap */
nodev, /* mmap */
nodev, /* segmap */
nochpoll, /* chpoll */
ddi_prop_op, /* cb_prop_op */
NULL, /* struct streamtab */
CB_REV, /* Rev */
nodev, /* cb_aread */
nodev /* cb_awrite */
};
static struct bus_ops rootnex_bus_ops = {
NULL,
NULL,
NULL,
ddi_no_dma_map, /* no rootnex_dma_map- now in sysio nexus */
ddi_no_dma_mctl, /* no rootnex_dma_mctl- now in sysio nexus */
NULL, /* bus_intr_ctl */
NULL, /* bus_config */
NULL, /* bus_unconfig */
rootnex_busop_fminit, /* bus_fm_init */
NULL, /* bus_fm_fini */
NULL, /* bus_fm_access_enter */
NULL, /* bus_fm_access_fini */
NULL, /* bus_power */
rootnex_intr_ops /* bus_intr_op */
};
static struct dev_ops rootnex_ops = {
0, /* refcnt */
ddi_no_info, /* info */
nulldev, /* probe */
nodev, /* reset */
};
extern uint_t root_phys_addr_lo_mask;
extern uint_t root_phys_addr_hi_mask;
extern struct mod_ops mod_driverops;
extern struct dev_ops rootnex_ops;
extern ddi_iblock_cookie_t rootnex_err_ibc;
/*
* Add statically defined root properties to this list...
*/
static const int mmu_pagesize = MMU_PAGESIZE;
static const int mmu_pageoffset = MMU_PAGEOFFSET;
struct prop_def {
char *prop_name;
};
static struct prop_def root_props[] = {
};
static vmem_t *rootnex_regspec_arena;
/*
* Module linkage information for the kernel.
*/
&mod_driverops, /* Type of module. This one is a nexus driver */
"sun4 root nexus %I%",
&rootnex_ops, /* Driver ops */
};
static struct modlinkage modlinkage = {
};
int
_init(void)
{
return (mod_install(&modlinkage));
}
int
_fini(void)
{
return (EBUSY);
}
int
{
}
/*
* rootnex_attach:
*
* attach the root nexus.
*/
static void add_root_props(dev_info_t *);
/*ARGSUSED*/
static int
{
int length;
/*
* Only do these functions when the driver is acting as the
* root nexus, not when it is driving a memory controller.
*/
if (ddi_root_node() == devi) {
}
&length) == DDI_PROP_SUCCESS) {
}
/*
* Add a no-suspend-resume property so that NDI
* (or any of its aliases) node.
*/
"pm-hardware-state", "no-suspend-resume");
return (DDI_SUCCESS);
}
/*ARGSUSED*/
static int
{
return (DDI_SUCCESS);
}
static void
{
int i;
/*
* Note that this for loop works because all of the
* properties in root_prop are integers
*/
}
/*
* Create the root node "boolean" property
* corresponding to addressing type supported in the root node:
*
* Choices are:
* "relative-addressing" (OBP PROMS)
*/
/*
* Create fault management capability property
*/
}
static int
{
/*
* Take the bustype and the physical page base within the
* bus space and turn it into a 28 bit page frame number.
*/
/*
* Do a quick sanity check to make sure we are in I/O space.
*/
if (pf_is_memory(pfn))
return (DDI_ME_INVAL);
if (rp->regspec_size == 0) {
"regspec_size\n"));
return (DDI_ME_INVAL);
}
else {
base));
return (DDI_ME_NORESOURCES);
/*
* Now map in the pages we've allocated...
*/
if (hp) {
}
}
return (0);
}
static int
{
return (0);
if (rp->regspec_size == 0) {
"zero regspec_size\n"));
return (DDI_ME_INVAL);
}
/*
* Destroy the pointer - the mapping has logically gone
*/
return (0);
}
static int
{
/*
* Set up the hat_flags for the mapping.
*/
case DDI_NEVERSWAP_ACC:
break;
case DDI_STRUCTURE_BE_ACC:
break;
case DDI_STRUCTURE_LE_ACC:
break;
default:
return (DDI_REGS_ACC_CONFLICT);
}
case DDI_STRICTORDER_ACC:
break;
case DDI_UNORDERED_OK_ACC:
break;
case DDI_MERGING_OK_ACC:
break;
case DDI_LOADCACHING_OK_ACC:
break;
case DDI_STORECACHING_OK_ACC:
break;
default:
return (DDI_FAILURE);
}
if (rp->regspec_size == 0)
return (DDI_ME_INVAL);
return (DDI_SUCCESS);
}
static int
{
int error;
case DDI_MO_MAP_LOCKED:
case DDI_MO_UNMAP:
case DDI_MO_MAP_HANDLE:
break;
default:
return (DDI_ME_UNIMPLEMENTED);
}
"type: user."));
return (DDI_ME_UNIMPLEMENTED);
}
/*
* First, if given an rnumber, convert it to a regspec...
* (Presumably, this is on behalf of a child of the root node?)
*/
"range rnumber <%d>, device <%s>", rnumber,
ddi_get_name(rdip)));
return (DDI_ME_RNUMBER_RANGE);
}
/*
* Convert the given ddi_map_req_t from rnumber to regspec...
*/
}
/*
* Adjust offset and length corresponding 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?.
*/
if (len != 0)
/*
* 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.)
*/
return (error);
case DDI_MO_MAP_LOCKED:
/*
* Set up the locked down kernel mapping to the regspec...
*/
/*
* If we were passed an access handle we need to determine
* the "endian-ness" of the mapping and fill in the handle.
*/
if (mp->map_handlep) {
case DDI_NEVERSWAP_ACC:
break;
case DDI_STRUCTURE_BE_ACC:
break;
case DDI_STRUCTURE_LE_ACC:
break;
default:
return (DDI_REGS_ACC_CONFLICT);
}
case DDI_STRICTORDER_ACC:
break;
case DDI_UNORDERED_OK_ACC:
break;
case DDI_MERGING_OK_ACC:
break;
case DDI_LOADCACHING_OK_ACC:
break;
case DDI_STORECACHING_OK_ACC:
break;
default:
return (DDI_REGS_ACC_CONFLICT);
}
} else {
}
/*
* Set up the mapping.
*/
/*
* Fill in the access handle if needed.
*/
if (hp) {
if (error == 0)
}
return (error);
case DDI_MO_UNMAP:
/*
* Release mapping...
*/
case DDI_MO_MAP_HANDLE:
return (rootnex_map_handle(mp));
}
return (DDI_ME_UNIMPLEMENTED);
}
static int
{
int ret = DDI_SUCCESS;
switch (intr_op) {
case DDI_INTROP_GETCAP:
*(int *)result = DDI_INTR_FLAG_LEVEL;
break;
case DDI_INTROP_SETCAP:
ret = DDI_ENOTSUP;
break;
case DDI_INTROP_ALLOC:
break;
case DDI_INTROP_FREE:
break;
case DDI_INTROP_GETPRI:
break;
case DDI_INTROP_SETPRI:
break;
case DDI_INTROP_ADDISR:
break;
case DDI_INTROP_REMISR:
break;
case DDI_INTROP_ENABLE:
case DDI_INTROP_DISABLE:
break;
case DDI_INTROP_NINTRS:
case DDI_INTROP_NAVAIL:
break;
/* Root nexus driver supports only fixed interrupts */
DDI_INTR_TYPE_FIXED : 0;
break;
default:
ret = DDI_ENOTSUP;
break;
}
return (ret);
}
/*
* Shorthand defines
*/
/*
* rootnex_map_fault:
*
* fault in mappings for requestors
*/
/*ARGSUSED*/
static int
{
extern struct seg_ops segdev_ops;
/*
* This is all terribly broken, but it is a start
*
* XXX Note that this test means that segdev_ops
* must be exported from seg_dev.c.
* XXX What about devices with their own segment drivers?
*/
register struct segdev_data *sdp =
/*
* This is one plausible interpretation of
* a null hat i.e. use the first hat on the
* address space hat list which by convention is
* the hat of the system MMU. At alternative
* would be to panic .. this might well be better ..
*/
}
} else
return (DDI_FAILURE);
return (DDI_SUCCESS);
}
/*
* Name a child of rootnex
*
* This may be called multiple times, independent of initchild calls.
*/
int
{
}
static int
{
return (rootnex_ctl_initchild_impl(dip));
}
int
{
extern void impl_free_ddi_ppd(dev_info_t *);
/*
* strip properties and convert node to prototype form
*/
return (DDI_SUCCESS);
}
static int
{
return (rootnex_ctl_reportdev_impl(dev));
}
static int
void *result)
{
int err = DDI_SUCCESS;
return (DDI_FAILURE);
/* Set up protected environment. */
if (cmd == DDI_CTLOPS_POKE) {
} else {
}
} else
err = DDI_FAILURE;
/* Take down protected environment. */
no_trap();
return (err);
}
/*ARGSUSED*/
static int
{
register int n, *ptr;
register struct ddi_parent_private_data *pdp;
switch (ctlop) {
case DDI_CTLOPS_DMAPMAPC:
return (DDI_FAILURE);
case DDI_CTLOPS_BTOP:
/*
* Convert byte count input to physical page units.
* (byte counts that are not a page-size multiple
* are rounded down)
*/
return (DDI_SUCCESS);
case DDI_CTLOPS_PTOB:
/*
* Convert size in physical pages to bytes
*/
return (DDI_SUCCESS);
case DDI_CTLOPS_BTOPR:
/*
* Convert byte count input to physical page units
* (byte counts that are not a page-size multiple
* are rounded up)
*/
return (DDI_SUCCESS);
case DDI_CTLOPS_INITCHILD:
case DDI_CTLOPS_UNINITCHILD:
case DDI_CTLOPS_REPORTDEV:
return (rootnex_ctl_reportdev(rdip));
case DDI_CTLOPS_IOMIN:
/*
* Nothing to do here but reflect back..
*/
return (DDI_SUCCESS);
case DDI_CTLOPS_REGSIZE:
case DDI_CTLOPS_NREGS:
break;
case DDI_CTLOPS_SIDDEV:
if (ndi_dev_is_prom_node(rdip))
return (DDI_SUCCESS);
return (DDI_SUCCESS);
return (DDI_FAILURE);
case DDI_CTLOPS_POWER: {
}
case DDI_CTLOPS_RESERVED0: /* Was DDI_CTLOPS_NINTRS, obsolete */
case DDI_CTLOPS_RESERVED1: /* Was DDI_CTLOPS_POKE_INIT, obsolete */
case DDI_CTLOPS_RESERVED2: /* Was DDI_CTLOPS_POKE_FLUSH, obsolete */
case DDI_CTLOPS_RESERVED3: /* Was DDI_CTLOPS_POKE_FINI, obsolete */
case DDI_CTLOPS_RESERVED4: /* Was DDI_CTLOPS_INTR_HILEVEL, obsolete */
case DDI_CTLOPS_RESERVED5: /* Was DDI_CTLOPS_XLATE_INTRS, obsolete */
if (!reserved_msg_printed) {
}
return (DDI_FAILURE);
case DDI_CTLOPS_POKE:
case DDI_CTLOPS_PEEK:
result));
default:
return (DDI_FAILURE);
}
/*
* The rest are for "hardware" properties
*/
return (DDI_FAILURE);
if (ctlop == DDI_CTLOPS_NREGS) {
} else { /* ctlop == DDI_CTLOPS_REGSIZE */
n = *ptr;
return (DDI_FAILURE);
}
}
return (DDI_SUCCESS);
}
/* ARGSUSED */
int
{
*ibc = rootnex_err_ibc;
return (ddi_system_fmcap | DDI_FM_ACCCHK_CAPABLE |
}
static void
{
int fmcap;
/* Minimum fm capability level for sun4u platforms */
/*
* Initialize ECC error handling
*/
}