Move the implementation of bus_space_barrier(9) to the inline function in
the header. Actually, there's only one version for all types of busses, so it doesn't make sense to walk up the hierarchy.
This commit is contained in:
parent
151389a51e
commit
20009df359
@ -58,7 +58,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* from: NetBSD: bus.h,v 1.58 2008/04/28 20:23:36 martin Exp
|
||||
* from: NetBSD: bus.h,v 1.58 2008/04/28 20:23:36 martin Exp
|
||||
* and
|
||||
* from: FreeBSD: src/sys/alpha/include/bus.h,v 1.9 2001/01/09
|
||||
*
|
||||
@ -104,11 +104,7 @@ extern const int bus_stream_asi[];
|
||||
|
||||
struct bus_space_tag {
|
||||
void *bst_cookie;
|
||||
bus_space_tag_t bst_parent;
|
||||
int bst_type;
|
||||
|
||||
void (*bst_bus_barrier)(bus_space_tag_t, bus_space_handle_t,
|
||||
bus_size_t, bus_size_t, int);
|
||||
};
|
||||
|
||||
/*
|
||||
@ -131,23 +127,23 @@ int bus_space_map(bus_space_tag_t tag, bus_addr_t address, bus_size_t size,
|
||||
void bus_space_unmap(bus_space_tag_t tag, bus_space_handle_t handle,
|
||||
bus_size_t size);
|
||||
|
||||
/* This macro finds the first "upstream" implementation of method `f' */
|
||||
#define _BS_CALL(t,f) \
|
||||
while (t->f == NULL) \
|
||||
t = t->bst_parent; \
|
||||
return (*(t)->f)
|
||||
|
||||
static __inline void
|
||||
bus_space_barrier(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
|
||||
bus_size_t s, int f)
|
||||
bus_space_barrier(bus_space_tag_t t __unused, bus_space_handle_t h __unused,
|
||||
bus_size_t o __unused, bus_size_t s __unused, int f __unused)
|
||||
{
|
||||
|
||||
_BS_CALL(t, bst_bus_barrier)(t, h, o, s, f);
|
||||
/*
|
||||
* We have lots of alternatives depending on whether we're
|
||||
* synchronizing loads with loads, loads with stores, stores
|
||||
* with loads, or stores with stores. The only ones that seem
|
||||
* generic are #Sync and #MemIssue. We use #Sync for safety.
|
||||
*/
|
||||
membar(Sync);
|
||||
}
|
||||
|
||||
static __inline int
|
||||
bus_space_subregion(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
|
||||
bus_size_t s, bus_space_handle_t *hp)
|
||||
bus_space_subregion(bus_space_tag_t t __unused, bus_space_handle_t h,
|
||||
bus_size_t o __unused, bus_size_t s __unused, bus_space_handle_t *hp)
|
||||
{
|
||||
|
||||
*hp = h + o;
|
||||
|
@ -40,8 +40,7 @@ int sparc64_bus_mem_map(bus_space_tag_t tag, bus_addr_t addr, bus_size_t size,
|
||||
int flags, vm_offset_t vaddr, bus_space_handle_t *hp);
|
||||
int sparc64_bus_mem_unmap(bus_space_tag_t tag, bus_space_handle_t handle,
|
||||
bus_size_t size);
|
||||
bus_space_tag_t sparc64_alloc_bus_tag(void *cookie,
|
||||
struct bus_space_tag *ptag, int type, void *barrier);
|
||||
bus_space_tag_t sparc64_alloc_bus_tag(void *cookie, int type);
|
||||
bus_space_handle_t sparc64_fake_bustag(int space, bus_addr_t addr,
|
||||
struct bus_space_tag *ptag);
|
||||
|
||||
|
@ -756,12 +756,10 @@ fire_attach(device_t dev)
|
||||
free(range, M_OFWPROP);
|
||||
|
||||
/* Allocate our tags. */
|
||||
sc->sc_pci_iot = sparc64_alloc_bus_tag(NULL, rman_get_bustag(
|
||||
sc->sc_mem_res[FIRE_PCI]), PCI_IO_BUS_SPACE, NULL);
|
||||
sc->sc_pci_iot = sparc64_alloc_bus_tag(NULL, PCI_IO_BUS_SPACE);
|
||||
if (sc->sc_pci_iot == NULL)
|
||||
panic("%s: could not allocate PCI I/O tag", __func__);
|
||||
sc->sc_pci_cfgt = sparc64_alloc_bus_tag(NULL, rman_get_bustag(
|
||||
sc->sc_mem_res[FIRE_PCI]), PCI_CONFIG_BUS_SPACE, NULL);
|
||||
sc->sc_pci_cfgt = sparc64_alloc_bus_tag(NULL, PCI_CONFIG_BUS_SPACE);
|
||||
if (sc->sc_pci_cfgt == NULL)
|
||||
panic("%s: could not allocate PCI configuration space tag",
|
||||
__func__);
|
||||
@ -2072,8 +2070,7 @@ fire_activate_resource(device_t bus, device_t child, int type, int rid,
|
||||
return (bus_generic_activate_resource(bus, child, type, rid,
|
||||
r));
|
||||
case SYS_RES_MEMORY:
|
||||
tag = sparc64_alloc_bus_tag(r, rman_get_bustag(
|
||||
sc->sc_mem_res[FIRE_PCI]), PCI_MEMORY_BUS_SPACE, NULL);
|
||||
tag = sparc64_alloc_bus_tag(r, PCI_MEMORY_BUS_SPACE);
|
||||
if (tag == NULL)
|
||||
return (ENOMEM);
|
||||
rman_set_bustag(r, tag);
|
||||
|
@ -573,12 +573,10 @@ psycho_attach(device_t dev)
|
||||
}
|
||||
|
||||
/* Allocate our tags. */
|
||||
sc->sc_pci_iot = sparc64_alloc_bus_tag(NULL, rman_get_bustag(
|
||||
sc->sc_mem_res), PCI_IO_BUS_SPACE, NULL);
|
||||
sc->sc_pci_iot = sparc64_alloc_bus_tag(NULL, PCI_IO_BUS_SPACE);
|
||||
if (sc->sc_pci_iot == NULL)
|
||||
panic("%s: could not allocate PCI I/O tag", __func__);
|
||||
sc->sc_pci_cfgt = sparc64_alloc_bus_tag(NULL, rman_get_bustag(
|
||||
sc->sc_mem_res), PCI_CONFIG_BUS_SPACE, NULL);
|
||||
sc->sc_pci_cfgt = sparc64_alloc_bus_tag(NULL, PCI_CONFIG_BUS_SPACE);
|
||||
if (sc->sc_pci_cfgt == NULL)
|
||||
panic("%s: could not allocate PCI configuration space tag",
|
||||
__func__);
|
||||
@ -1236,8 +1234,7 @@ psycho_activate_resource(device_t bus, device_t child, int type, int rid,
|
||||
return (bus_generic_activate_resource(bus, child, type, rid,
|
||||
r));
|
||||
case SYS_RES_MEMORY:
|
||||
tag = sparc64_alloc_bus_tag(r, rman_get_bustag(
|
||||
sc->sc_mem_res), PCI_MEMORY_BUS_SPACE, NULL);
|
||||
tag = sparc64_alloc_bus_tag(r, PCI_MEMORY_BUS_SPACE);
|
||||
if (tag == NULL)
|
||||
return (ENOMEM);
|
||||
rman_set_bustag(r, tag);
|
||||
|
@ -580,12 +580,10 @@ schizo_attach(device_t dev)
|
||||
SLIST_INSERT_HEAD(&schizo_softcs, sc, sc_link);
|
||||
|
||||
/* Allocate our tags. */
|
||||
sc->sc_pci_iot = sparc64_alloc_bus_tag(NULL, rman_get_bustag(
|
||||
sc->sc_mem_res[STX_PCI]), PCI_IO_BUS_SPACE, NULL);
|
||||
sc->sc_pci_iot = sparc64_alloc_bus_tag(NULL, PCI_IO_BUS_SPACE);
|
||||
if (sc->sc_pci_iot == NULL)
|
||||
panic("%s: could not allocate PCI I/O tag", __func__);
|
||||
sc->sc_pci_cfgt = sparc64_alloc_bus_tag(NULL, rman_get_bustag(
|
||||
sc->sc_mem_res[STX_PCI]), PCI_CONFIG_BUS_SPACE, NULL);
|
||||
sc->sc_pci_cfgt = sparc64_alloc_bus_tag(NULL, PCI_CONFIG_BUS_SPACE);
|
||||
if (sc->sc_pci_cfgt == NULL)
|
||||
panic("%s: could not allocate PCI configuration space tag",
|
||||
__func__);
|
||||
@ -1412,8 +1410,7 @@ schizo_activate_resource(device_t bus, device_t child, int type, int rid,
|
||||
return (bus_generic_activate_resource(bus, child, type, rid,
|
||||
r));
|
||||
case SYS_RES_MEMORY:
|
||||
tag = sparc64_alloc_bus_tag(r, rman_get_bustag(
|
||||
sc->sc_mem_res[STX_PCI]), PCI_MEMORY_BUS_SPACE, NULL);
|
||||
tag = sparc64_alloc_bus_tag(r, PCI_MEMORY_BUS_SPACE);
|
||||
if (tag == NULL)
|
||||
return (ENOMEM);
|
||||
rman_set_bustag(r, tag);
|
||||
|
@ -803,9 +803,7 @@ sbus_activate_resource(device_t bus, device_t child, int type, int rid,
|
||||
for (i = 0; i < sc->sc_nrange; i++) {
|
||||
if (rman_is_region_manager(r,
|
||||
&sc->sc_rd[i].rd_rman) != 0) {
|
||||
tag = sparc64_alloc_bus_tag(r,
|
||||
rman_get_bustag(sc->sc_sysio_res),
|
||||
SBUS_BUS_SPACE, NULL);
|
||||
tag = sparc64_alloc_bus_tag(r, SBUS_BUS_SPACE);
|
||||
if (tag == NULL)
|
||||
return (ENOMEM);
|
||||
rman_set_bustag(r, tag);
|
||||
|
@ -119,9 +119,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <machine/smp.h>
|
||||
#include <machine/tlb.h>
|
||||
|
||||
static void nexus_bus_barrier(bus_space_tag_t, bus_space_handle_t,
|
||||
bus_size_t, bus_size_t, int);
|
||||
|
||||
/* ASIs for bus access */
|
||||
const int bus_type_asi[] = {
|
||||
ASI_PHYS_BYPASS_EC_WITH_EBIT, /* nexus */
|
||||
@ -715,18 +712,15 @@ sparc64_fake_bustag(int space, bus_addr_t addr, struct bus_space_tag *ptag)
|
||||
{
|
||||
|
||||
ptag->bst_cookie = NULL;
|
||||
ptag->bst_parent = NULL;
|
||||
ptag->bst_type = space;
|
||||
ptag->bst_bus_barrier = nexus_bus_barrier;
|
||||
return (addr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate a bus tag.
|
||||
* Allocate a bus tag
|
||||
*/
|
||||
bus_space_tag_t
|
||||
sparc64_alloc_bus_tag(void *cookie, struct bus_space_tag *ptag, int type,
|
||||
void *barrier)
|
||||
sparc64_alloc_bus_tag(void *cookie, int type)
|
||||
{
|
||||
bus_space_tag_t bt;
|
||||
|
||||
@ -734,42 +728,11 @@ sparc64_alloc_bus_tag(void *cookie, struct bus_space_tag *ptag, int type,
|
||||
if (bt == NULL)
|
||||
return (NULL);
|
||||
bt->bst_cookie = cookie;
|
||||
bt->bst_parent = ptag;
|
||||
bt->bst_type = type;
|
||||
bt->bst_bus_barrier = barrier;
|
||||
return (bt);
|
||||
}
|
||||
|
||||
/*
|
||||
* Base bus space handlers.
|
||||
*/
|
||||
|
||||
static void
|
||||
nexus_bus_barrier(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset,
|
||||
bus_size_t size, int flags)
|
||||
{
|
||||
|
||||
/*
|
||||
* We have lots of alternatives depending on whether we're
|
||||
* synchronizing loads with loads, loads with stores, stores
|
||||
* with loads, or stores with stores. The only ones that seem
|
||||
* generic are #Sync and #MemIssue. I'll use #Sync for safety.
|
||||
*/
|
||||
switch(flags) {
|
||||
case BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE:
|
||||
case BUS_SPACE_BARRIER_READ:
|
||||
case BUS_SPACE_BARRIER_WRITE:
|
||||
membar(Sync);
|
||||
break;
|
||||
default:
|
||||
panic("%s: unknown flags", __func__);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
struct bus_space_tag nexus_bustag = {
|
||||
NULL, /* cookie */
|
||||
NULL, /* parent bus tag */
|
||||
NEXUS_BUS_SPACE, /* type */
|
||||
nexus_bus_barrier, /* bus_space_barrier */
|
||||
NEXUS_BUS_SPACE /* type */
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user