2000-12-03 04:42:29 +03:00
|
|
|
/* $NetBSD: apbus_subr.c,v 1.3 2000/12/03 01:42:29 matt Exp $ */
|
1999-12-22 08:55:24 +03:00
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (C) 1999 SHIMIZU Ryo. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
|
|
|
|
#include <newsmips/apbus/apbusvar.h>
|
|
|
|
|
2000-12-03 04:42:29 +03:00
|
|
|
static void apctl_dump (struct apbus_ctl *);
|
|
|
|
|
1999-12-22 08:55:24 +03:00
|
|
|
void *
|
|
|
|
apbus_device_to_hwaddr(apbus_dev)
|
1999-12-23 09:52:30 +03:00
|
|
|
struct apbus_dev *apbus_dev;
|
1999-12-22 08:55:24 +03:00
|
|
|
{
|
|
|
|
struct apbus_ctl *ctl;
|
|
|
|
|
1999-12-23 09:52:30 +03:00
|
|
|
if (apbus_dev == NULL)
|
|
|
|
return NULL;
|
1999-12-22 08:55:24 +03:00
|
|
|
|
|
|
|
ctl = apbus_dev->apbd_ctl;
|
1999-12-23 09:52:30 +03:00
|
|
|
if (ctl == NULL)
|
|
|
|
return NULL;
|
1999-12-22 08:55:24 +03:00
|
|
|
|
|
|
|
return (void *)ctl->apbc_hwbase;
|
|
|
|
}
|
|
|
|
|
1999-12-23 09:52:30 +03:00
|
|
|
struct apbus_dev *
|
1999-12-22 08:55:24 +03:00
|
|
|
apbus_lookupdev(devname)
|
|
|
|
char *devname;
|
|
|
|
{
|
1999-12-23 09:52:30 +03:00
|
|
|
struct apbus_dev *dp;
|
1999-12-22 08:55:24 +03:00
|
|
|
|
|
|
|
dp = _sip->apbsi_dev;
|
1999-12-23 09:52:30 +03:00
|
|
|
if (devname == NULL || *devname == '\0')
|
1999-12-22 08:55:24 +03:00
|
|
|
return dp;
|
|
|
|
|
1999-12-23 09:52:30 +03:00
|
|
|
/* search apbus_dev named 'devname' */
|
1999-12-22 08:55:24 +03:00
|
|
|
while (dp) {
|
|
|
|
if (strcmp(devname,dp->apbd_name) == 0)
|
|
|
|
return dp;
|
|
|
|
|
|
|
|
dp = dp->apbd_link;
|
|
|
|
}
|
|
|
|
|
1999-12-23 09:52:30 +03:00
|
|
|
return NULL;
|
1999-12-22 08:55:24 +03:00
|
|
|
}
|
|
|
|
|
2000-12-03 04:42:29 +03:00
|
|
|
static void
|
1999-12-22 08:55:24 +03:00
|
|
|
apctl_dump(apctl)
|
|
|
|
struct apbus_ctl *apctl;
|
|
|
|
{
|
|
|
|
unsigned int *p;
|
|
|
|
|
|
|
|
if (!apctl)
|
|
|
|
return;
|
|
|
|
|
1999-12-23 09:52:30 +03:00
|
|
|
printf(" apbus_ctl dump (%p)\n", apctl);
|
1999-12-22 08:55:24 +03:00
|
|
|
|
|
|
|
p = (void *)apctl;
|
|
|
|
|
|
|
|
printf(" Num: %d\n", apctl->apbc_ctlno);
|
|
|
|
printf(" HWaddr: 0x%08x\n", apctl->apbc_hwbase);
|
|
|
|
printf(" softc: %p\n", apctl->apbc_softc);
|
|
|
|
printf(" Slot: %d\n", apctl->apbc_sl);
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
if (apctl->apbc_link)
|
|
|
|
apctl_dump(apctl->apbc_link);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
apdevice_dump(apdev)
|
1999-12-23 09:52:30 +03:00
|
|
|
struct apbus_dev *apdev;
|
1999-12-22 08:55:24 +03:00
|
|
|
{
|
|
|
|
struct apbus_ctl *apctl;
|
|
|
|
|
1999-12-23 09:52:30 +03:00
|
|
|
if (apdev == NULL)
|
1999-12-22 08:55:24 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* only no pseudo device */
|
|
|
|
apctl = apdev->apbd_ctl;
|
1999-12-23 09:52:30 +03:00
|
|
|
if (apctl == NULL || apctl->apbc_hwbase == 0)
|
1999-12-22 08:55:24 +03:00
|
|
|
return;
|
|
|
|
|
1999-12-23 09:52:30 +03:00
|
|
|
printf("apbus_dev dump (%p)\n", apdev);
|
|
|
|
printf("name: %s\n", apdev->apbd_name);
|
|
|
|
printf("vendor: %s\n", apdev->apbd_vendor);
|
1999-12-22 08:55:24 +03:00
|
|
|
printf("atr: %08x\n", apdev->apbd_atr);
|
|
|
|
printf("rev: %d\n", apdev->apbd_rev);
|
|
|
|
printf("driver: 0x%08x\n", (unsigned int)apdev->apbd_driver);
|
|
|
|
printf("ctl: 0x%08x\n", (unsigned int)apdev->apbd_ctl);
|
|
|
|
printf("link: 0x%08x\n", (unsigned int)apdev->apbd_link);
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
apctl_dump(apctl);
|
|
|
|
}
|