mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-06 13:09:50 +00:00
Get out the roto-rooter and clean up the abuse of nexus ivars by the
i386/isa/pcibus.c. This gets -current running again on multiple host->pci machines after the most recent nexus commits. I had discussed this with Mike Smith, but ended up doing it slightly differently to what we discussed as it turned out cleaner this way. Mike was suggesting creating a new resource (SYS_RES_PCIBUS) or something and using *_[gs]et_resource(), but IMHO that wasn't ideal as SYS_RES_* is meant to be a global platform property, not a quirk of a given implementation. This does use the ivar methods but does so properly. It also now prints the physical pci bus that a host->pci bridge (pcib) corresponds to.
This commit is contained in:
parent
47b15ad38f
commit
b6c8407840
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=66416
@ -57,6 +57,7 @@
|
||||
#include <vm/pmap.h>
|
||||
#include <machine/pmap.h>
|
||||
|
||||
#include <machine/nexusvar.h>
|
||||
#include <machine/resource.h>
|
||||
#ifdef APIC_IO
|
||||
#include <machine/smp.h>
|
||||
@ -78,6 +79,7 @@ MALLOC_DEFINE(M_NEXUSDEV, "nexusdev", "Nexus device");
|
||||
|
||||
struct nexus_device {
|
||||
struct resource_list nx_resources;
|
||||
int nx_pcibus;
|
||||
};
|
||||
|
||||
#define DEVTONX(dev) ((struct nexus_device *)device_get_ivars(dev))
|
||||
@ -94,6 +96,8 @@ static device_t nexus_add_child(device_t bus, int order, const char *name,
|
||||
int unit);
|
||||
static struct resource *nexus_alloc_resource(device_t, device_t, int, int *,
|
||||
u_long, u_long, u_long, u_int);
|
||||
static int nexus_read_ivar(device_t, device_t, int, uintptr_t *);
|
||||
static int nexus_write_ivar(device_t, device_t, int, uintptr_t);
|
||||
static int nexus_activate_resource(device_t, device_t, int, int,
|
||||
struct resource *);
|
||||
static int nexus_deactivate_resource(device_t, device_t, int, int,
|
||||
@ -120,8 +124,8 @@ static device_method_t nexus_methods[] = {
|
||||
/* Bus interface */
|
||||
DEVMETHOD(bus_print_child, nexus_print_child),
|
||||
DEVMETHOD(bus_add_child, nexus_add_child),
|
||||
DEVMETHOD(bus_read_ivar, bus_generic_read_ivar),
|
||||
DEVMETHOD(bus_write_ivar, bus_generic_write_ivar),
|
||||
DEVMETHOD(bus_read_ivar, nexus_read_ivar),
|
||||
DEVMETHOD(bus_write_ivar, nexus_write_ivar),
|
||||
DEVMETHOD(bus_alloc_resource, nexus_alloc_resource),
|
||||
DEVMETHOD(bus_release_resource, nexus_release_resource),
|
||||
DEVMETHOD(bus_activate_resource, nexus_activate_resource),
|
||||
@ -299,7 +303,7 @@ nexus_print_all_resources(device_t dev)
|
||||
struct resource_list *rl = &ndev->nx_resources;
|
||||
int retval = 0;
|
||||
|
||||
if (SLIST_FIRST(rl))
|
||||
if (SLIST_FIRST(rl) || ndev->nx_pcibus != -1)
|
||||
retval += printf(" at");
|
||||
|
||||
retval += nexus_print_resources(rl, "port", SYS_RES_IOPORT, "%#lx");
|
||||
@ -312,10 +316,13 @@ nexus_print_all_resources(device_t dev)
|
||||
static int
|
||||
nexus_print_child(device_t bus, device_t child)
|
||||
{
|
||||
struct nexus_device *ndev = DEVTONX(child);
|
||||
int retval = 0;
|
||||
|
||||
retval += bus_print_child_header(bus, child);
|
||||
retval += nexus_print_all_resources(child);
|
||||
if (ndev->nx_pcibus != -1)
|
||||
retval += printf(" pcibus %d", ndev->nx_pcibus);
|
||||
retval += printf(" on motherboard\n"); /* XXX "motherboard", ick */
|
||||
|
||||
return (retval);
|
||||
@ -332,6 +339,7 @@ nexus_add_child(device_t bus, int order, const char *name, int unit)
|
||||
return(0);
|
||||
bzero(ndev, sizeof(struct nexus_device));
|
||||
resource_list_init(&ndev->nx_resources);
|
||||
ndev->nx_pcibus = -1;
|
||||
|
||||
child = device_add_child_ordered(bus, order, name, unit);
|
||||
|
||||
@ -341,6 +349,38 @@ nexus_add_child(device_t bus, int order, const char *name, int unit)
|
||||
return(child);
|
||||
}
|
||||
|
||||
static int
|
||||
nexus_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
|
||||
{
|
||||
struct nexus_device *ndev = DEVTONX(child);
|
||||
|
||||
switch (which) {
|
||||
case NEXUS_IVAR_PCIBUS:
|
||||
*result = ndev->nx_pcibus;
|
||||
break;
|
||||
default:
|
||||
return ENOENT;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
nexus_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
|
||||
{
|
||||
struct nexus_device *ndev = DEVTONX(child);
|
||||
|
||||
switch (which) {
|
||||
case NEXUS_IVAR_PCIBUS:
|
||||
ndev->nx_pcibus = value;
|
||||
break;
|
||||
default:
|
||||
return ENOENT;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Allocate a resource on behalf of child. NB: child is usually going to be a
|
||||
* child of one of our descendants, not a direct child of nexus0.
|
||||
|
@ -57,6 +57,7 @@
|
||||
#include <vm/pmap.h>
|
||||
#include <machine/pmap.h>
|
||||
|
||||
#include <machine/nexusvar.h>
|
||||
#include <machine/resource.h>
|
||||
#ifdef APIC_IO
|
||||
#include <machine/smp.h>
|
||||
@ -78,6 +79,7 @@ MALLOC_DEFINE(M_NEXUSDEV, "nexusdev", "Nexus device");
|
||||
|
||||
struct nexus_device {
|
||||
struct resource_list nx_resources;
|
||||
int nx_pcibus;
|
||||
};
|
||||
|
||||
#define DEVTONX(dev) ((struct nexus_device *)device_get_ivars(dev))
|
||||
@ -94,6 +96,8 @@ static device_t nexus_add_child(device_t bus, int order, const char *name,
|
||||
int unit);
|
||||
static struct resource *nexus_alloc_resource(device_t, device_t, int, int *,
|
||||
u_long, u_long, u_long, u_int);
|
||||
static int nexus_read_ivar(device_t, device_t, int, uintptr_t *);
|
||||
static int nexus_write_ivar(device_t, device_t, int, uintptr_t);
|
||||
static int nexus_activate_resource(device_t, device_t, int, int,
|
||||
struct resource *);
|
||||
static int nexus_deactivate_resource(device_t, device_t, int, int,
|
||||
@ -120,8 +124,8 @@ static device_method_t nexus_methods[] = {
|
||||
/* Bus interface */
|
||||
DEVMETHOD(bus_print_child, nexus_print_child),
|
||||
DEVMETHOD(bus_add_child, nexus_add_child),
|
||||
DEVMETHOD(bus_read_ivar, bus_generic_read_ivar),
|
||||
DEVMETHOD(bus_write_ivar, bus_generic_write_ivar),
|
||||
DEVMETHOD(bus_read_ivar, nexus_read_ivar),
|
||||
DEVMETHOD(bus_write_ivar, nexus_write_ivar),
|
||||
DEVMETHOD(bus_alloc_resource, nexus_alloc_resource),
|
||||
DEVMETHOD(bus_release_resource, nexus_release_resource),
|
||||
DEVMETHOD(bus_activate_resource, nexus_activate_resource),
|
||||
@ -299,7 +303,7 @@ nexus_print_all_resources(device_t dev)
|
||||
struct resource_list *rl = &ndev->nx_resources;
|
||||
int retval = 0;
|
||||
|
||||
if (SLIST_FIRST(rl))
|
||||
if (SLIST_FIRST(rl) || ndev->nx_pcibus != -1)
|
||||
retval += printf(" at");
|
||||
|
||||
retval += nexus_print_resources(rl, "port", SYS_RES_IOPORT, "%#lx");
|
||||
@ -312,10 +316,13 @@ nexus_print_all_resources(device_t dev)
|
||||
static int
|
||||
nexus_print_child(device_t bus, device_t child)
|
||||
{
|
||||
struct nexus_device *ndev = DEVTONX(child);
|
||||
int retval = 0;
|
||||
|
||||
retval += bus_print_child_header(bus, child);
|
||||
retval += nexus_print_all_resources(child);
|
||||
if (ndev->nx_pcibus != -1)
|
||||
retval += printf(" pcibus %d", ndev->nx_pcibus);
|
||||
retval += printf(" on motherboard\n"); /* XXX "motherboard", ick */
|
||||
|
||||
return (retval);
|
||||
@ -332,6 +339,7 @@ nexus_add_child(device_t bus, int order, const char *name, int unit)
|
||||
return(0);
|
||||
bzero(ndev, sizeof(struct nexus_device));
|
||||
resource_list_init(&ndev->nx_resources);
|
||||
ndev->nx_pcibus = -1;
|
||||
|
||||
child = device_add_child_ordered(bus, order, name, unit);
|
||||
|
||||
@ -341,6 +349,38 @@ nexus_add_child(device_t bus, int order, const char *name, int unit)
|
||||
return(child);
|
||||
}
|
||||
|
||||
static int
|
||||
nexus_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
|
||||
{
|
||||
struct nexus_device *ndev = DEVTONX(child);
|
||||
|
||||
switch (which) {
|
||||
case NEXUS_IVAR_PCIBUS:
|
||||
*result = ndev->nx_pcibus;
|
||||
break;
|
||||
default:
|
||||
return ENOENT;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
nexus_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
|
||||
{
|
||||
struct nexus_device *ndev = DEVTONX(child);
|
||||
|
||||
switch (which) {
|
||||
case NEXUS_IVAR_PCIBUS:
|
||||
ndev->nx_pcibus = value;
|
||||
break;
|
||||
default:
|
||||
return ENOENT;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Allocate a resource on behalf of child. NB: child is usually going to be a
|
||||
* child of one of our descendants, not a direct child of nexus0.
|
||||
|
55
sys/amd64/include/legacyvar.h
Normal file
55
sys/amd64/include/legacyvar.h
Normal file
@ -0,0 +1,55 @@
|
||||
/*-
|
||||
* Copyright (c) 2000 Peter Wemm <peter@FreeBSD.org>
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _MACHINE_NEXUSVAR_H_
|
||||
#define _MACHINE_NEXUSVAR_H_ 1
|
||||
|
||||
enum nexus_device_ivars {
|
||||
NEXUS_IVAR_PCIBUS
|
||||
};
|
||||
|
||||
#define NEXUS_ACCESSOR(A, B, T) \
|
||||
\
|
||||
static __inline T nexus_get_ ## A(device_t dev) \
|
||||
{ \
|
||||
uintptr_t v; \
|
||||
BUS_READ_IVAR(device_get_parent(dev), dev, NEXUS_IVAR_ ## B, &v); \
|
||||
return (T) v; \
|
||||
} \
|
||||
\
|
||||
static __inline void nexus_set_ ## A(device_t dev, T t) \
|
||||
{ \
|
||||
uintptr_t v = (uintptr_t) t; \
|
||||
BUS_WRITE_IVAR(device_get_parent(dev), dev, NEXUS_IVAR_ ## B, v); \
|
||||
}
|
||||
|
||||
NEXUS_ACCESSOR(pcibus, PCIBUS, u_int32_t)
|
||||
|
||||
#undef NEXUS_ACCESSOR
|
||||
|
||||
#endif /* !_MACHINE_NEXUSVAR_H_ */
|
@ -38,6 +38,7 @@
|
||||
#include <pci/pcireg.h>
|
||||
#include <i386/isa/pcibus.h>
|
||||
#include <isa/isavar.h>
|
||||
#include <machine/nexusvar.h>
|
||||
|
||||
#include <machine/segments.h>
|
||||
#include <machine/pc/bios.h>
|
||||
@ -574,7 +575,6 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
|
||||
int pcifunchigh;
|
||||
int found824xx = 0;
|
||||
device_t child;
|
||||
int *ivar;
|
||||
|
||||
if (pci_cfgopen() == 0)
|
||||
return;
|
||||
@ -623,10 +623,7 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
|
||||
if (strcmp(device_get_name(devs[i]),
|
||||
"pcib") != 0)
|
||||
continue;
|
||||
ivar = device_get_ivars(devs[i]);
|
||||
if (ivar == NULL)
|
||||
continue;
|
||||
if (busnum == *ivar)
|
||||
if (nexus_get_pcibus(devs[i]) == busnum)
|
||||
s = NULL;
|
||||
}
|
||||
free(devs, M_TEMP);
|
||||
@ -641,13 +638,7 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
|
||||
child = BUS_ADD_CHILD(parent, 100,
|
||||
"pcib", busnum);
|
||||
device_set_desc(child, s);
|
||||
|
||||
ivar = malloc(sizeof ivar[0], M_DEVBUF,
|
||||
M_NOWAIT);
|
||||
if (ivar == NULL)
|
||||
panic("out of memory");
|
||||
device_set_ivars(child, ivar);
|
||||
ivar[0] = busnum;
|
||||
nexus_set_pcibus(child, busnum);
|
||||
|
||||
found = 1;
|
||||
if (id == 0x12258086)
|
||||
@ -669,11 +660,7 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
|
||||
printf(
|
||||
"nexus_pcib_identify: no bridge found, adding pcib0 anyway\n");
|
||||
child = BUS_ADD_CHILD(parent, 100, "pcib", 0);
|
||||
ivar = malloc(sizeof ivar[0], M_DEVBUF, M_NOWAIT);
|
||||
if (ivar == NULL)
|
||||
panic("out of memory");
|
||||
device_set_ivars(child, ivar);
|
||||
ivar[0] = 0;
|
||||
nexus_set_pcibus(child, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -703,7 +690,7 @@ nexus_pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
|
||||
|
||||
switch (which) {
|
||||
case PCIB_IVAR_BUS:
|
||||
*result = *(int*) device_get_ivars(dev);
|
||||
*result = nexus_get_pcibus(dev);
|
||||
return 0;
|
||||
}
|
||||
return ENOENT;
|
||||
@ -715,7 +702,7 @@ nexus_pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
|
||||
|
||||
switch (which) {
|
||||
case PCIB_IVAR_BUS:
|
||||
*(int*) device_get_ivars(dev) = value;
|
||||
nexus_set_pcibus(dev, value);
|
||||
return 0;
|
||||
}
|
||||
return ENOENT;
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include <pci/pcireg.h>
|
||||
#include <i386/isa/pcibus.h>
|
||||
#include <isa/isavar.h>
|
||||
#include <machine/nexusvar.h>
|
||||
|
||||
#include <machine/segments.h>
|
||||
#include <machine/pc/bios.h>
|
||||
@ -574,7 +575,6 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
|
||||
int pcifunchigh;
|
||||
int found824xx = 0;
|
||||
device_t child;
|
||||
int *ivar;
|
||||
|
||||
if (pci_cfgopen() == 0)
|
||||
return;
|
||||
@ -623,10 +623,7 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
|
||||
if (strcmp(device_get_name(devs[i]),
|
||||
"pcib") != 0)
|
||||
continue;
|
||||
ivar = device_get_ivars(devs[i]);
|
||||
if (ivar == NULL)
|
||||
continue;
|
||||
if (busnum == *ivar)
|
||||
if (nexus_get_pcibus(devs[i]) == busnum)
|
||||
s = NULL;
|
||||
}
|
||||
free(devs, M_TEMP);
|
||||
@ -641,13 +638,7 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
|
||||
child = BUS_ADD_CHILD(parent, 100,
|
||||
"pcib", busnum);
|
||||
device_set_desc(child, s);
|
||||
|
||||
ivar = malloc(sizeof ivar[0], M_DEVBUF,
|
||||
M_NOWAIT);
|
||||
if (ivar == NULL)
|
||||
panic("out of memory");
|
||||
device_set_ivars(child, ivar);
|
||||
ivar[0] = busnum;
|
||||
nexus_set_pcibus(child, busnum);
|
||||
|
||||
found = 1;
|
||||
if (id == 0x12258086)
|
||||
@ -669,11 +660,7 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
|
||||
printf(
|
||||
"nexus_pcib_identify: no bridge found, adding pcib0 anyway\n");
|
||||
child = BUS_ADD_CHILD(parent, 100, "pcib", 0);
|
||||
ivar = malloc(sizeof ivar[0], M_DEVBUF, M_NOWAIT);
|
||||
if (ivar == NULL)
|
||||
panic("out of memory");
|
||||
device_set_ivars(child, ivar);
|
||||
ivar[0] = 0;
|
||||
nexus_set_pcibus(child, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -703,7 +690,7 @@ nexus_pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
|
||||
|
||||
switch (which) {
|
||||
case PCIB_IVAR_BUS:
|
||||
*result = *(int*) device_get_ivars(dev);
|
||||
*result = nexus_get_pcibus(dev);
|
||||
return 0;
|
||||
}
|
||||
return ENOENT;
|
||||
@ -715,7 +702,7 @@ nexus_pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
|
||||
|
||||
switch (which) {
|
||||
case PCIB_IVAR_BUS:
|
||||
*(int*) device_get_ivars(dev) = value;
|
||||
nexus_set_pcibus(dev, value);
|
||||
return 0;
|
||||
}
|
||||
return ENOENT;
|
||||
|
@ -208,7 +208,7 @@ static __inline T pci_get_ ## A(device_t dev) \
|
||||
\
|
||||
static __inline void pci_set_ ## A(device_t dev, T t) \
|
||||
{ \
|
||||
u_long v = (u_long) t; \
|
||||
uintptr_t v = (uintptr_t) t; \
|
||||
BUS_WRITE_IVAR(device_get_parent(dev), dev, PCI_IVAR_ ## B, v); \
|
||||
}
|
||||
|
||||
@ -229,6 +229,8 @@ PCI_ACCESSOR(function, FUNCTION, u_int8_t)
|
||||
PCI_ACCESSOR(secondarybus, SECONDARYBUS, u_int8_t)
|
||||
PCI_ACCESSOR(subordinatebus, SUBORDINATEBUS, u_int8_t)
|
||||
|
||||
#undef PCI_ACCESSOR
|
||||
|
||||
static __inline u_int32_t
|
||||
pci_read_config(device_t dev, int reg, int width)
|
||||
{
|
||||
@ -261,12 +263,14 @@ static __inline T pcib_get_ ## A(device_t dev) \
|
||||
\
|
||||
static __inline void pcib_set_ ## A(device_t dev, T t) \
|
||||
{ \
|
||||
u_long v = (u_long) t; \
|
||||
uintptr_t v = (uintptr_t) t; \
|
||||
BUS_WRITE_IVAR(device_get_parent(dev), dev, PCIB_IVAR_ ## B, v); \
|
||||
}
|
||||
|
||||
PCIB_ACCESSOR(bus, BUS, u_int32_t)
|
||||
|
||||
#undef PCIB_ACCESSOR
|
||||
|
||||
#endif
|
||||
|
||||
/* for compatibility to FreeBSD-2.2 and 3.x versions of PCI code */
|
||||
|
@ -57,6 +57,7 @@
|
||||
#include <vm/pmap.h>
|
||||
#include <machine/pmap.h>
|
||||
|
||||
#include <machine/nexusvar.h>
|
||||
#include <machine/resource.h>
|
||||
#ifdef APIC_IO
|
||||
#include <machine/smp.h>
|
||||
@ -78,6 +79,7 @@ MALLOC_DEFINE(M_NEXUSDEV, "nexusdev", "Nexus device");
|
||||
|
||||
struct nexus_device {
|
||||
struct resource_list nx_resources;
|
||||
int nx_pcibus;
|
||||
};
|
||||
|
||||
#define DEVTONX(dev) ((struct nexus_device *)device_get_ivars(dev))
|
||||
@ -94,6 +96,8 @@ static device_t nexus_add_child(device_t bus, int order, const char *name,
|
||||
int unit);
|
||||
static struct resource *nexus_alloc_resource(device_t, device_t, int, int *,
|
||||
u_long, u_long, u_long, u_int);
|
||||
static int nexus_read_ivar(device_t, device_t, int, uintptr_t *);
|
||||
static int nexus_write_ivar(device_t, device_t, int, uintptr_t);
|
||||
static int nexus_activate_resource(device_t, device_t, int, int,
|
||||
struct resource *);
|
||||
static int nexus_deactivate_resource(device_t, device_t, int, int,
|
||||
@ -120,8 +124,8 @@ static device_method_t nexus_methods[] = {
|
||||
/* Bus interface */
|
||||
DEVMETHOD(bus_print_child, nexus_print_child),
|
||||
DEVMETHOD(bus_add_child, nexus_add_child),
|
||||
DEVMETHOD(bus_read_ivar, bus_generic_read_ivar),
|
||||
DEVMETHOD(bus_write_ivar, bus_generic_write_ivar),
|
||||
DEVMETHOD(bus_read_ivar, nexus_read_ivar),
|
||||
DEVMETHOD(bus_write_ivar, nexus_write_ivar),
|
||||
DEVMETHOD(bus_alloc_resource, nexus_alloc_resource),
|
||||
DEVMETHOD(bus_release_resource, nexus_release_resource),
|
||||
DEVMETHOD(bus_activate_resource, nexus_activate_resource),
|
||||
@ -299,7 +303,7 @@ nexus_print_all_resources(device_t dev)
|
||||
struct resource_list *rl = &ndev->nx_resources;
|
||||
int retval = 0;
|
||||
|
||||
if (SLIST_FIRST(rl))
|
||||
if (SLIST_FIRST(rl) || ndev->nx_pcibus != -1)
|
||||
retval += printf(" at");
|
||||
|
||||
retval += nexus_print_resources(rl, "port", SYS_RES_IOPORT, "%#lx");
|
||||
@ -312,10 +316,13 @@ nexus_print_all_resources(device_t dev)
|
||||
static int
|
||||
nexus_print_child(device_t bus, device_t child)
|
||||
{
|
||||
struct nexus_device *ndev = DEVTONX(child);
|
||||
int retval = 0;
|
||||
|
||||
retval += bus_print_child_header(bus, child);
|
||||
retval += nexus_print_all_resources(child);
|
||||
if (ndev->nx_pcibus != -1)
|
||||
retval += printf(" pcibus %d", ndev->nx_pcibus);
|
||||
retval += printf(" on motherboard\n"); /* XXX "motherboard", ick */
|
||||
|
||||
return (retval);
|
||||
@ -332,6 +339,7 @@ nexus_add_child(device_t bus, int order, const char *name, int unit)
|
||||
return(0);
|
||||
bzero(ndev, sizeof(struct nexus_device));
|
||||
resource_list_init(&ndev->nx_resources);
|
||||
ndev->nx_pcibus = -1;
|
||||
|
||||
child = device_add_child_ordered(bus, order, name, unit);
|
||||
|
||||
@ -341,6 +349,38 @@ nexus_add_child(device_t bus, int order, const char *name, int unit)
|
||||
return(child);
|
||||
}
|
||||
|
||||
static int
|
||||
nexus_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
|
||||
{
|
||||
struct nexus_device *ndev = DEVTONX(child);
|
||||
|
||||
switch (which) {
|
||||
case NEXUS_IVAR_PCIBUS:
|
||||
*result = ndev->nx_pcibus;
|
||||
break;
|
||||
default:
|
||||
return ENOENT;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
nexus_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
|
||||
{
|
||||
struct nexus_device *ndev = DEVTONX(child);
|
||||
|
||||
switch (which) {
|
||||
case NEXUS_IVAR_PCIBUS:
|
||||
ndev->nx_pcibus = value;
|
||||
break;
|
||||
default:
|
||||
return ENOENT;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Allocate a resource on behalf of child. NB: child is usually going to be a
|
||||
* child of one of our descendants, not a direct child of nexus0.
|
||||
|
@ -57,6 +57,7 @@
|
||||
#include <vm/pmap.h>
|
||||
#include <machine/pmap.h>
|
||||
|
||||
#include <machine/nexusvar.h>
|
||||
#include <machine/resource.h>
|
||||
#ifdef APIC_IO
|
||||
#include <machine/smp.h>
|
||||
@ -78,6 +79,7 @@ MALLOC_DEFINE(M_NEXUSDEV, "nexusdev", "Nexus device");
|
||||
|
||||
struct nexus_device {
|
||||
struct resource_list nx_resources;
|
||||
int nx_pcibus;
|
||||
};
|
||||
|
||||
#define DEVTONX(dev) ((struct nexus_device *)device_get_ivars(dev))
|
||||
@ -94,6 +96,8 @@ static device_t nexus_add_child(device_t bus, int order, const char *name,
|
||||
int unit);
|
||||
static struct resource *nexus_alloc_resource(device_t, device_t, int, int *,
|
||||
u_long, u_long, u_long, u_int);
|
||||
static int nexus_read_ivar(device_t, device_t, int, uintptr_t *);
|
||||
static int nexus_write_ivar(device_t, device_t, int, uintptr_t);
|
||||
static int nexus_activate_resource(device_t, device_t, int, int,
|
||||
struct resource *);
|
||||
static int nexus_deactivate_resource(device_t, device_t, int, int,
|
||||
@ -120,8 +124,8 @@ static device_method_t nexus_methods[] = {
|
||||
/* Bus interface */
|
||||
DEVMETHOD(bus_print_child, nexus_print_child),
|
||||
DEVMETHOD(bus_add_child, nexus_add_child),
|
||||
DEVMETHOD(bus_read_ivar, bus_generic_read_ivar),
|
||||
DEVMETHOD(bus_write_ivar, bus_generic_write_ivar),
|
||||
DEVMETHOD(bus_read_ivar, nexus_read_ivar),
|
||||
DEVMETHOD(bus_write_ivar, nexus_write_ivar),
|
||||
DEVMETHOD(bus_alloc_resource, nexus_alloc_resource),
|
||||
DEVMETHOD(bus_release_resource, nexus_release_resource),
|
||||
DEVMETHOD(bus_activate_resource, nexus_activate_resource),
|
||||
@ -299,7 +303,7 @@ nexus_print_all_resources(device_t dev)
|
||||
struct resource_list *rl = &ndev->nx_resources;
|
||||
int retval = 0;
|
||||
|
||||
if (SLIST_FIRST(rl))
|
||||
if (SLIST_FIRST(rl) || ndev->nx_pcibus != -1)
|
||||
retval += printf(" at");
|
||||
|
||||
retval += nexus_print_resources(rl, "port", SYS_RES_IOPORT, "%#lx");
|
||||
@ -312,10 +316,13 @@ nexus_print_all_resources(device_t dev)
|
||||
static int
|
||||
nexus_print_child(device_t bus, device_t child)
|
||||
{
|
||||
struct nexus_device *ndev = DEVTONX(child);
|
||||
int retval = 0;
|
||||
|
||||
retval += bus_print_child_header(bus, child);
|
||||
retval += nexus_print_all_resources(child);
|
||||
if (ndev->nx_pcibus != -1)
|
||||
retval += printf(" pcibus %d", ndev->nx_pcibus);
|
||||
retval += printf(" on motherboard\n"); /* XXX "motherboard", ick */
|
||||
|
||||
return (retval);
|
||||
@ -332,6 +339,7 @@ nexus_add_child(device_t bus, int order, const char *name, int unit)
|
||||
return(0);
|
||||
bzero(ndev, sizeof(struct nexus_device));
|
||||
resource_list_init(&ndev->nx_resources);
|
||||
ndev->nx_pcibus = -1;
|
||||
|
||||
child = device_add_child_ordered(bus, order, name, unit);
|
||||
|
||||
@ -341,6 +349,38 @@ nexus_add_child(device_t bus, int order, const char *name, int unit)
|
||||
return(child);
|
||||
}
|
||||
|
||||
static int
|
||||
nexus_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
|
||||
{
|
||||
struct nexus_device *ndev = DEVTONX(child);
|
||||
|
||||
switch (which) {
|
||||
case NEXUS_IVAR_PCIBUS:
|
||||
*result = ndev->nx_pcibus;
|
||||
break;
|
||||
default:
|
||||
return ENOENT;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
nexus_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
|
||||
{
|
||||
struct nexus_device *ndev = DEVTONX(child);
|
||||
|
||||
switch (which) {
|
||||
case NEXUS_IVAR_PCIBUS:
|
||||
ndev->nx_pcibus = value;
|
||||
break;
|
||||
default:
|
||||
return ENOENT;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Allocate a resource on behalf of child. NB: child is usually going to be a
|
||||
* child of one of our descendants, not a direct child of nexus0.
|
||||
|
55
sys/i386/include/legacyvar.h
Normal file
55
sys/i386/include/legacyvar.h
Normal file
@ -0,0 +1,55 @@
|
||||
/*-
|
||||
* Copyright (c) 2000 Peter Wemm <peter@FreeBSD.org>
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _MACHINE_NEXUSVAR_H_
|
||||
#define _MACHINE_NEXUSVAR_H_ 1
|
||||
|
||||
enum nexus_device_ivars {
|
||||
NEXUS_IVAR_PCIBUS
|
||||
};
|
||||
|
||||
#define NEXUS_ACCESSOR(A, B, T) \
|
||||
\
|
||||
static __inline T nexus_get_ ## A(device_t dev) \
|
||||
{ \
|
||||
uintptr_t v; \
|
||||
BUS_READ_IVAR(device_get_parent(dev), dev, NEXUS_IVAR_ ## B, &v); \
|
||||
return (T) v; \
|
||||
} \
|
||||
\
|
||||
static __inline void nexus_set_ ## A(device_t dev, T t) \
|
||||
{ \
|
||||
uintptr_t v = (uintptr_t) t; \
|
||||
BUS_WRITE_IVAR(device_get_parent(dev), dev, NEXUS_IVAR_ ## B, v); \
|
||||
}
|
||||
|
||||
NEXUS_ACCESSOR(pcibus, PCIBUS, u_int32_t)
|
||||
|
||||
#undef NEXUS_ACCESSOR
|
||||
|
||||
#endif /* !_MACHINE_NEXUSVAR_H_ */
|
55
sys/i386/include/nexusvar.h
Normal file
55
sys/i386/include/nexusvar.h
Normal file
@ -0,0 +1,55 @@
|
||||
/*-
|
||||
* Copyright (c) 2000 Peter Wemm <peter@FreeBSD.org>
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _MACHINE_NEXUSVAR_H_
|
||||
#define _MACHINE_NEXUSVAR_H_ 1
|
||||
|
||||
enum nexus_device_ivars {
|
||||
NEXUS_IVAR_PCIBUS
|
||||
};
|
||||
|
||||
#define NEXUS_ACCESSOR(A, B, T) \
|
||||
\
|
||||
static __inline T nexus_get_ ## A(device_t dev) \
|
||||
{ \
|
||||
uintptr_t v; \
|
||||
BUS_READ_IVAR(device_get_parent(dev), dev, NEXUS_IVAR_ ## B, &v); \
|
||||
return (T) v; \
|
||||
} \
|
||||
\
|
||||
static __inline void nexus_set_ ## A(device_t dev, T t) \
|
||||
{ \
|
||||
uintptr_t v = (uintptr_t) t; \
|
||||
BUS_WRITE_IVAR(device_get_parent(dev), dev, NEXUS_IVAR_ ## B, v); \
|
||||
}
|
||||
|
||||
NEXUS_ACCESSOR(pcibus, PCIBUS, u_int32_t)
|
||||
|
||||
#undef NEXUS_ACCESSOR
|
||||
|
||||
#endif /* !_MACHINE_NEXUSVAR_H_ */
|
@ -38,6 +38,7 @@
|
||||
#include <pci/pcireg.h>
|
||||
#include <i386/isa/pcibus.h>
|
||||
#include <isa/isavar.h>
|
||||
#include <machine/nexusvar.h>
|
||||
|
||||
#include <machine/segments.h>
|
||||
#include <machine/pc/bios.h>
|
||||
@ -574,7 +575,6 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
|
||||
int pcifunchigh;
|
||||
int found824xx = 0;
|
||||
device_t child;
|
||||
int *ivar;
|
||||
|
||||
if (pci_cfgopen() == 0)
|
||||
return;
|
||||
@ -623,10 +623,7 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
|
||||
if (strcmp(device_get_name(devs[i]),
|
||||
"pcib") != 0)
|
||||
continue;
|
||||
ivar = device_get_ivars(devs[i]);
|
||||
if (ivar == NULL)
|
||||
continue;
|
||||
if (busnum == *ivar)
|
||||
if (nexus_get_pcibus(devs[i]) == busnum)
|
||||
s = NULL;
|
||||
}
|
||||
free(devs, M_TEMP);
|
||||
@ -641,13 +638,7 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
|
||||
child = BUS_ADD_CHILD(parent, 100,
|
||||
"pcib", busnum);
|
||||
device_set_desc(child, s);
|
||||
|
||||
ivar = malloc(sizeof ivar[0], M_DEVBUF,
|
||||
M_NOWAIT);
|
||||
if (ivar == NULL)
|
||||
panic("out of memory");
|
||||
device_set_ivars(child, ivar);
|
||||
ivar[0] = busnum;
|
||||
nexus_set_pcibus(child, busnum);
|
||||
|
||||
found = 1;
|
||||
if (id == 0x12258086)
|
||||
@ -669,11 +660,7 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
|
||||
printf(
|
||||
"nexus_pcib_identify: no bridge found, adding pcib0 anyway\n");
|
||||
child = BUS_ADD_CHILD(parent, 100, "pcib", 0);
|
||||
ivar = malloc(sizeof ivar[0], M_DEVBUF, M_NOWAIT);
|
||||
if (ivar == NULL)
|
||||
panic("out of memory");
|
||||
device_set_ivars(child, ivar);
|
||||
ivar[0] = 0;
|
||||
nexus_set_pcibus(child, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -703,7 +690,7 @@ nexus_pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
|
||||
|
||||
switch (which) {
|
||||
case PCIB_IVAR_BUS:
|
||||
*result = *(int*) device_get_ivars(dev);
|
||||
*result = nexus_get_pcibus(dev);
|
||||
return 0;
|
||||
}
|
||||
return ENOENT;
|
||||
@ -715,7 +702,7 @@ nexus_pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
|
||||
|
||||
switch (which) {
|
||||
case PCIB_IVAR_BUS:
|
||||
*(int*) device_get_ivars(dev) = value;
|
||||
nexus_set_pcibus(dev, value);
|
||||
return 0;
|
||||
}
|
||||
return ENOENT;
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include <pci/pcireg.h>
|
||||
#include <i386/isa/pcibus.h>
|
||||
#include <isa/isavar.h>
|
||||
#include <machine/nexusvar.h>
|
||||
|
||||
#include <machine/segments.h>
|
||||
#include <machine/pc/bios.h>
|
||||
@ -574,7 +575,6 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
|
||||
int pcifunchigh;
|
||||
int found824xx = 0;
|
||||
device_t child;
|
||||
int *ivar;
|
||||
|
||||
if (pci_cfgopen() == 0)
|
||||
return;
|
||||
@ -623,10 +623,7 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
|
||||
if (strcmp(device_get_name(devs[i]),
|
||||
"pcib") != 0)
|
||||
continue;
|
||||
ivar = device_get_ivars(devs[i]);
|
||||
if (ivar == NULL)
|
||||
continue;
|
||||
if (busnum == *ivar)
|
||||
if (nexus_get_pcibus(devs[i]) == busnum)
|
||||
s = NULL;
|
||||
}
|
||||
free(devs, M_TEMP);
|
||||
@ -641,13 +638,7 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
|
||||
child = BUS_ADD_CHILD(parent, 100,
|
||||
"pcib", busnum);
|
||||
device_set_desc(child, s);
|
||||
|
||||
ivar = malloc(sizeof ivar[0], M_DEVBUF,
|
||||
M_NOWAIT);
|
||||
if (ivar == NULL)
|
||||
panic("out of memory");
|
||||
device_set_ivars(child, ivar);
|
||||
ivar[0] = busnum;
|
||||
nexus_set_pcibus(child, busnum);
|
||||
|
||||
found = 1;
|
||||
if (id == 0x12258086)
|
||||
@ -669,11 +660,7 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
|
||||
printf(
|
||||
"nexus_pcib_identify: no bridge found, adding pcib0 anyway\n");
|
||||
child = BUS_ADD_CHILD(parent, 100, "pcib", 0);
|
||||
ivar = malloc(sizeof ivar[0], M_DEVBUF, M_NOWAIT);
|
||||
if (ivar == NULL)
|
||||
panic("out of memory");
|
||||
device_set_ivars(child, ivar);
|
||||
ivar[0] = 0;
|
||||
nexus_set_pcibus(child, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -703,7 +690,7 @@ nexus_pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
|
||||
|
||||
switch (which) {
|
||||
case PCIB_IVAR_BUS:
|
||||
*result = *(int*) device_get_ivars(dev);
|
||||
*result = nexus_get_pcibus(dev);
|
||||
return 0;
|
||||
}
|
||||
return ENOENT;
|
||||
@ -715,7 +702,7 @@ nexus_pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
|
||||
|
||||
switch (which) {
|
||||
case PCIB_IVAR_BUS:
|
||||
*(int*) device_get_ivars(dev) = value;
|
||||
nexus_set_pcibus(dev, value);
|
||||
return 0;
|
||||
}
|
||||
return ENOENT;
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include <pci/pcireg.h>
|
||||
#include <i386/isa/pcibus.h>
|
||||
#include <isa/isavar.h>
|
||||
#include <machine/nexusvar.h>
|
||||
|
||||
#include <machine/segments.h>
|
||||
#include <machine/pc/bios.h>
|
||||
@ -574,7 +575,6 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
|
||||
int pcifunchigh;
|
||||
int found824xx = 0;
|
||||
device_t child;
|
||||
int *ivar;
|
||||
|
||||
if (pci_cfgopen() == 0)
|
||||
return;
|
||||
@ -623,10 +623,7 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
|
||||
if (strcmp(device_get_name(devs[i]),
|
||||
"pcib") != 0)
|
||||
continue;
|
||||
ivar = device_get_ivars(devs[i]);
|
||||
if (ivar == NULL)
|
||||
continue;
|
||||
if (busnum == *ivar)
|
||||
if (nexus_get_pcibus(devs[i]) == busnum)
|
||||
s = NULL;
|
||||
}
|
||||
free(devs, M_TEMP);
|
||||
@ -641,13 +638,7 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
|
||||
child = BUS_ADD_CHILD(parent, 100,
|
||||
"pcib", busnum);
|
||||
device_set_desc(child, s);
|
||||
|
||||
ivar = malloc(sizeof ivar[0], M_DEVBUF,
|
||||
M_NOWAIT);
|
||||
if (ivar == NULL)
|
||||
panic("out of memory");
|
||||
device_set_ivars(child, ivar);
|
||||
ivar[0] = busnum;
|
||||
nexus_set_pcibus(child, busnum);
|
||||
|
||||
found = 1;
|
||||
if (id == 0x12258086)
|
||||
@ -669,11 +660,7 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
|
||||
printf(
|
||||
"nexus_pcib_identify: no bridge found, adding pcib0 anyway\n");
|
||||
child = BUS_ADD_CHILD(parent, 100, "pcib", 0);
|
||||
ivar = malloc(sizeof ivar[0], M_DEVBUF, M_NOWAIT);
|
||||
if (ivar == NULL)
|
||||
panic("out of memory");
|
||||
device_set_ivars(child, ivar);
|
||||
ivar[0] = 0;
|
||||
nexus_set_pcibus(child, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -703,7 +690,7 @@ nexus_pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
|
||||
|
||||
switch (which) {
|
||||
case PCIB_IVAR_BUS:
|
||||
*result = *(int*) device_get_ivars(dev);
|
||||
*result = nexus_get_pcibus(dev);
|
||||
return 0;
|
||||
}
|
||||
return ENOENT;
|
||||
@ -715,7 +702,7 @@ nexus_pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
|
||||
|
||||
switch (which) {
|
||||
case PCIB_IVAR_BUS:
|
||||
*(int*) device_get_ivars(dev) = value;
|
||||
nexus_set_pcibus(dev, value);
|
||||
return 0;
|
||||
}
|
||||
return ENOENT;
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include <pci/pcireg.h>
|
||||
#include <i386/isa/pcibus.h>
|
||||
#include <isa/isavar.h>
|
||||
#include <machine/nexusvar.h>
|
||||
|
||||
#include <machine/segments.h>
|
||||
#include <machine/pc/bios.h>
|
||||
@ -574,7 +575,6 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
|
||||
int pcifunchigh;
|
||||
int found824xx = 0;
|
||||
device_t child;
|
||||
int *ivar;
|
||||
|
||||
if (pci_cfgopen() == 0)
|
||||
return;
|
||||
@ -623,10 +623,7 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
|
||||
if (strcmp(device_get_name(devs[i]),
|
||||
"pcib") != 0)
|
||||
continue;
|
||||
ivar = device_get_ivars(devs[i]);
|
||||
if (ivar == NULL)
|
||||
continue;
|
||||
if (busnum == *ivar)
|
||||
if (nexus_get_pcibus(devs[i]) == busnum)
|
||||
s = NULL;
|
||||
}
|
||||
free(devs, M_TEMP);
|
||||
@ -641,13 +638,7 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
|
||||
child = BUS_ADD_CHILD(parent, 100,
|
||||
"pcib", busnum);
|
||||
device_set_desc(child, s);
|
||||
|
||||
ivar = malloc(sizeof ivar[0], M_DEVBUF,
|
||||
M_NOWAIT);
|
||||
if (ivar == NULL)
|
||||
panic("out of memory");
|
||||
device_set_ivars(child, ivar);
|
||||
ivar[0] = busnum;
|
||||
nexus_set_pcibus(child, busnum);
|
||||
|
||||
found = 1;
|
||||
if (id == 0x12258086)
|
||||
@ -669,11 +660,7 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
|
||||
printf(
|
||||
"nexus_pcib_identify: no bridge found, adding pcib0 anyway\n");
|
||||
child = BUS_ADD_CHILD(parent, 100, "pcib", 0);
|
||||
ivar = malloc(sizeof ivar[0], M_DEVBUF, M_NOWAIT);
|
||||
if (ivar == NULL)
|
||||
panic("out of memory");
|
||||
device_set_ivars(child, ivar);
|
||||
ivar[0] = 0;
|
||||
nexus_set_pcibus(child, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -703,7 +690,7 @@ nexus_pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
|
||||
|
||||
switch (which) {
|
||||
case PCIB_IVAR_BUS:
|
||||
*result = *(int*) device_get_ivars(dev);
|
||||
*result = nexus_get_pcibus(dev);
|
||||
return 0;
|
||||
}
|
||||
return ENOENT;
|
||||
@ -715,7 +702,7 @@ nexus_pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
|
||||
|
||||
switch (which) {
|
||||
case PCIB_IVAR_BUS:
|
||||
*(int*) device_get_ivars(dev) = value;
|
||||
nexus_set_pcibus(dev, value);
|
||||
return 0;
|
||||
}
|
||||
return ENOENT;
|
||||
|
@ -208,7 +208,7 @@ static __inline T pci_get_ ## A(device_t dev) \
|
||||
\
|
||||
static __inline void pci_set_ ## A(device_t dev, T t) \
|
||||
{ \
|
||||
u_long v = (u_long) t; \
|
||||
uintptr_t v = (uintptr_t) t; \
|
||||
BUS_WRITE_IVAR(device_get_parent(dev), dev, PCI_IVAR_ ## B, v); \
|
||||
}
|
||||
|
||||
@ -229,6 +229,8 @@ PCI_ACCESSOR(function, FUNCTION, u_int8_t)
|
||||
PCI_ACCESSOR(secondarybus, SECONDARYBUS, u_int8_t)
|
||||
PCI_ACCESSOR(subordinatebus, SUBORDINATEBUS, u_int8_t)
|
||||
|
||||
#undef PCI_ACCESSOR
|
||||
|
||||
static __inline u_int32_t
|
||||
pci_read_config(device_t dev, int reg, int width)
|
||||
{
|
||||
@ -261,12 +263,14 @@ static __inline T pcib_get_ ## A(device_t dev) \
|
||||
\
|
||||
static __inline void pcib_set_ ## A(device_t dev, T t) \
|
||||
{ \
|
||||
u_long v = (u_long) t; \
|
||||
uintptr_t v = (uintptr_t) t; \
|
||||
BUS_WRITE_IVAR(device_get_parent(dev), dev, PCIB_IVAR_ ## B, v); \
|
||||
}
|
||||
|
||||
PCIB_ACCESSOR(bus, BUS, u_int32_t)
|
||||
|
||||
#undef PCIB_ACCESSOR
|
||||
|
||||
#endif
|
||||
|
||||
/* for compatibility to FreeBSD-2.2 and 3.x versions of PCI code */
|
||||
|
Loading…
Reference in New Issue
Block a user