Switch/adapt to new bus space infrastructure.
This commit is contained in:
parent
923175a28a
commit
8a5a3a480a
@ -1,206 +0,0 @@
|
||||
/* $NetBSD: bus_space.c,v 1.4 2003/03/06 05:25:18 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace
|
||||
* Simulation Facility, NASA Ames Research Center.
|
||||
*
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/extent.h>
|
||||
#include <sys/mbuf.h>
|
||||
|
||||
#include <uvm/uvm_extern.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
|
||||
static paddr_t memio_mmap(bus_space_tag_t, bus_addr_t, off_t, int, int);
|
||||
static int memio_map(bus_space_tag_t, bus_addr_t, bus_size_t, int,
|
||||
bus_space_handle_t *);
|
||||
static void memio_unmap(bus_space_tag_t, bus_space_handle_t, bus_size_t);
|
||||
static int memio_alloc(bus_space_tag_t, bus_addr_t, bus_addr_t, bus_size_t,
|
||||
bus_size_t, bus_size_t, int, bus_addr_t *, bus_space_handle_t *);
|
||||
static void memio_free(bus_space_tag_t, bus_space_handle_t, bus_size_t);
|
||||
|
||||
struct powerpc_bus_space bebox_io_bs_tag = {
|
||||
_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
|
||||
BEBOX_BUS_SPACE_IO, 0x00000000, 0x3f800000,
|
||||
NULL,
|
||||
memio_mmap, memio_map, memio_unmap, memio_alloc, memio_free
|
||||
};
|
||||
struct powerpc_bus_space bebox_isa_io_bs_tag = {
|
||||
_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
|
||||
BEBOX_BUS_SPACE_IO, 0x00000000, 0x00010000,
|
||||
NULL,
|
||||
memio_mmap, memio_map, memio_unmap, memio_alloc, memio_free
|
||||
};
|
||||
struct powerpc_bus_space bebox_mem_bs_tag = {
|
||||
_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
|
||||
BEBOX_BUS_SPACE_MEM, 0x00000000, 0x3f000000,
|
||||
NULL,
|
||||
memio_mmap, memio_map, memio_unmap, memio_alloc, memio_free
|
||||
};
|
||||
struct powerpc_bus_space bebox_isa_mem_bs_tag = {
|
||||
_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
|
||||
BEBOX_BUS_SPACE_MEM, 0x00000000, 0x01000000,
|
||||
NULL,
|
||||
memio_mmap, memio_map, memio_unmap, memio_alloc, memio_free
|
||||
};
|
||||
|
||||
static char ex_storage[2][EXTENT_FIXED_STORAGE_SIZE(8)]
|
||||
__attribute__((aligned(8)));
|
||||
|
||||
static int extent_flags;
|
||||
|
||||
void
|
||||
bebox_bus_space_init(void)
|
||||
{
|
||||
int error;
|
||||
|
||||
bebox_io_bs_tag.pbs_extent = extent_create("ioport",
|
||||
bebox_io_bs_tag.pbs_base, bebox_io_bs_tag.pbs_limit - 1,
|
||||
M_DEVBUF,
|
||||
ex_storage[0], sizeof(ex_storage[0]),
|
||||
EX_NOCOALESCE|EX_NOWAIT);
|
||||
error = extent_alloc_region(bebox_io_bs_tag.pbs_extent,
|
||||
0x10000, 0x7F0000, EX_NOWAIT);
|
||||
if (error)
|
||||
panic("bebox_bus_space_init: can't block out reserved "
|
||||
" I/O space 0x10000-0x7fffff: error=%d", error);
|
||||
bebox_mem_bs_tag.pbs_extent = extent_create("iomem",
|
||||
bebox_io_bs_tag.pbs_base, bebox_io_bs_tag.pbs_limit - 1,
|
||||
M_DEVBUF,
|
||||
ex_storage[1], sizeof(ex_storage[1]),
|
||||
EX_NOCOALESCE|EX_NOWAIT);
|
||||
|
||||
bebox_isa_io_bs_tag.pbs_extent = bebox_io_bs_tag.pbs_extent;
|
||||
bebox_isa_mem_bs_tag.pbs_extent = bebox_mem_bs_tag.pbs_extent;
|
||||
}
|
||||
|
||||
void
|
||||
bebox_bus_space_mallocok(void)
|
||||
{
|
||||
extent_flags = EX_MALLOCOK;
|
||||
}
|
||||
|
||||
paddr_t
|
||||
memio_mmap(bus_space_tag_t t, bus_addr_t bpa, off_t offset, int prot, int flags)
|
||||
{
|
||||
return (trunc_page(bpa + offset));
|
||||
}
|
||||
|
||||
int
|
||||
memio_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int flags,
|
||||
bus_space_handle_t *bshp)
|
||||
{
|
||||
int error;
|
||||
|
||||
if (bpa + size > t->pbs_limit)
|
||||
return (EINVAL);
|
||||
|
||||
/*
|
||||
* Can't map I/O space as linear.
|
||||
*/
|
||||
if ((flags & BUS_SPACE_MAP_LINEAR) &&
|
||||
(t->pbs_flags & _BUS_SPACE_IO_TYPE))
|
||||
return (EOPNOTSUPP);
|
||||
|
||||
/*
|
||||
* Before we go any further, let's make sure that this
|
||||
* region is available.
|
||||
*/
|
||||
error = extent_alloc_region(t->pbs_extent, bpa, size,
|
||||
EX_NOWAIT | extent_flags);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
*bshp = t->pbs_offset + bpa;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
memio_unmap(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size)
|
||||
{
|
||||
bus_addr_t bpa = bsh - t->pbs_offset;
|
||||
|
||||
if (extent_free(t->pbs_extent, bpa, size, EX_NOWAIT | extent_flags)) {
|
||||
printf("memio_unmap: %s 0x%lx, size 0x%lx\n",
|
||||
(t->pbs_flags & _BUS_SPACE_IO_TYPE) ? "port" : "mem",
|
||||
(unsigned long)bpa, (unsigned long)size);
|
||||
printf("memio_unmap: can't free region\n");
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
memio_alloc(bus_space_tag_t t, bus_addr_t rstart, bus_addr_t rend,
|
||||
bus_size_t size, bus_size_t alignment, bus_size_t boundary,
|
||||
int flags, bus_addr_t *bpap, bus_space_handle_t *bshp)
|
||||
{
|
||||
u_long bpa;
|
||||
int error;
|
||||
|
||||
if (rstart + size > t->pbs_limit)
|
||||
return (EINVAL);
|
||||
|
||||
/*
|
||||
* Can't map I/O space as linear.
|
||||
*/
|
||||
if ((flags & BUS_SPACE_MAP_LINEAR) &&
|
||||
(t->pbs_flags & _BUS_SPACE_IO_TYPE))
|
||||
return (EOPNOTSUPP);
|
||||
|
||||
if (rstart < t->pbs_extent->ex_start || rend > t->pbs_extent->ex_end)
|
||||
panic("memio_alloc: bad region start/end");
|
||||
|
||||
error = extent_alloc_subregion(t->pbs_extent, rstart, rend, size,
|
||||
alignment, boundary, EX_FAST | EX_NOWAIT | extent_flags, &bpa);
|
||||
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
*bpap = bpa;
|
||||
*bshp = t->pbs_offset + bpa;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
memio_free(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size)
|
||||
{
|
||||
/* memio_unmap() does all that we need to do. */
|
||||
memio_unmap(t, bsh, size);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: locore.S,v 1.9 2003/02/02 20:43:17 matt Exp $ */
|
||||
/* $NetBSD: locore.S,v 1.10 2003/03/18 16:40:18 matt Exp $ */
|
||||
/* $OpenBSD: locore.S,v 1.4 1997/01/26 09:06:38 rahnds Exp $ */
|
||||
|
||||
/*
|
||||
@ -199,3 +199,8 @@ _C_LABEL(debug_led):
|
||||
* Pull in common trap vector code.
|
||||
*/
|
||||
#include <powerpc/powerpc/trap_subr.S>
|
||||
|
||||
/*
|
||||
* Pull in common pio / bus_space code.
|
||||
*/
|
||||
#include <powerpc/powerpc/pio_subr.S>
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: machdep.c,v 1.77 2003/02/03 17:09:54 matt Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.78 2003/03/18 16:40:18 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
@ -40,6 +40,7 @@
|
||||
#include <sys/conf.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/exec.h>
|
||||
#include <sys/extent.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mbuf.h>
|
||||
@ -117,6 +118,10 @@ char *bootpath;
|
||||
|
||||
paddr_t avail_end; /* XXX temporary */
|
||||
|
||||
void bebox_bus_space_init(void);
|
||||
void consinit(void);
|
||||
void ext_intr(void);
|
||||
|
||||
extern void *startsym, *endsym;
|
||||
|
||||
void
|
||||
@ -124,9 +129,6 @@ initppc(startkernel, endkernel, args, btinfo)
|
||||
u_int startkernel, endkernel, args;
|
||||
void *btinfo;
|
||||
{
|
||||
extern void consinit __P((void));
|
||||
extern void ext_intr __P((void));
|
||||
|
||||
/*
|
||||
* copy bootinfo
|
||||
*/
|
||||
@ -254,7 +256,7 @@ cpu_startup()
|
||||
/*
|
||||
* Now that we have VM, malloc's are OK in bus_space.
|
||||
*/
|
||||
bebox_bus_space_mallocok();
|
||||
bus_space_mallocok();
|
||||
|
||||
/*
|
||||
* Now allow hardware interrupts.
|
||||
@ -439,3 +441,54 @@ lcsplx(ipl)
|
||||
{
|
||||
splx(ipl);
|
||||
}
|
||||
|
||||
struct powerpc_bus_space bebox_io_bs_tag = {
|
||||
_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
|
||||
BEBOX_BUS_SPACE_IO, 0x00000000, 0x3f800000,
|
||||
};
|
||||
struct powerpc_bus_space bebox_isa_io_bs_tag = {
|
||||
_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
|
||||
BEBOX_BUS_SPACE_IO, 0x00000000, 0x00010000,
|
||||
};
|
||||
struct powerpc_bus_space bebox_mem_bs_tag = {
|
||||
_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
|
||||
BEBOX_BUS_SPACE_MEM, 0x00000000, 0x3f000000,
|
||||
};
|
||||
struct powerpc_bus_space bebox_isa_mem_bs_tag = {
|
||||
_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
|
||||
BEBOX_BUS_SPACE_MEM, 0x00000000, 0x01000000,
|
||||
};
|
||||
|
||||
static char ex_storage[2][EXTENT_FIXED_STORAGE_SIZE(8)]
|
||||
__attribute__((aligned(8)));
|
||||
|
||||
void
|
||||
bebox_bus_space_init(void)
|
||||
{
|
||||
int error;
|
||||
|
||||
error = bus_space_init(&bebox_io_bs_tag, "ioport",
|
||||
ex_storage[0], sizeof(ex_storage[0]));
|
||||
if (error)
|
||||
panic("bebox_bus_space_init: can't init io tag");
|
||||
|
||||
error = extent_alloc_region(bebox_io_bs_tag.pbs_extent,
|
||||
0x10000, 0x7F0000, EX_NOWAIT);
|
||||
if (error)
|
||||
panic("bebox_bus_space_init: can't block out reserved I/O"
|
||||
" space 0x10000-0x7fffff: error=%d", error);
|
||||
error = bus_space_init(&bebox_mem_bs_tag, "iomem",
|
||||
ex_storage[1], sizeof(ex_storage[1]));
|
||||
if (error)
|
||||
panic("bebox_bus_space_init: can't init mem tag");
|
||||
|
||||
bebox_isa_io_bs_tag.pbs_extent = bebox_io_bs_tag.pbs_extent;
|
||||
error = bus_space_init(&bebox_isa_io_bs_tag, "isa-ioport", NULL, 0);
|
||||
if (error)
|
||||
panic("bebox_bus_space_init: can't init isa io tag");
|
||||
|
||||
bebox_isa_mem_bs_tag.pbs_extent = bebox_mem_bs_tag.pbs_extent;
|
||||
error = bus_space_init(&bebox_isa_mem_bs_tag, "isa-iomem", NULL, 0);
|
||||
if (error)
|
||||
panic("bebox_bus_space_init: can't init isa mem tag");
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: files.bebox,v 1.38 2003/03/05 05:43:52 matt Exp $
|
||||
# $NetBSD: files.bebox,v 1.39 2003/03/18 16:40:19 matt Exp $
|
||||
#
|
||||
# First try for bebox specific configuration info
|
||||
#
|
||||
@ -7,13 +7,13 @@ maxpartitions 16
|
||||
maxusers 2 8 64
|
||||
|
||||
file arch/bebox/bebox/autoconf.c
|
||||
file arch/bebox/bebox/bus_space.c
|
||||
file arch/bebox/bebox/clock.c
|
||||
file arch/bebox/bebox/disksubr.c disk
|
||||
file arch/bebox/bebox/extintr.c
|
||||
file arch/bebox/bebox/machdep.c
|
||||
|
||||
file arch/powerpc/powerpc/bus_dma.c
|
||||
file arch/powerpc/powerpc/bus_space.c
|
||||
file arch/powerpc/powerpc/procfs_machdep.c procfs
|
||||
|
||||
# General files
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: bus.h,v 1.26 2003/03/06 05:25:18 matt Exp $ */
|
||||
/* $NetBSD: bus.h,v 1.27 2003/03/18 16:40:19 matt Exp $ */
|
||||
/* $OpenBSD: bus.h,v 1.1 1997/10/13 10:53:42 pefo Exp $ */
|
||||
|
||||
/*-
|
||||
@ -121,8 +121,6 @@
|
||||
#define BUS_MEM_TO_PHYS(t,x) ((x) & ~MPC105_DIRECT_MAPPED_SPACE)
|
||||
|
||||
#ifdef _KERNEL
|
||||
void bebox_bus_space_init __P((void));
|
||||
void bebox_bus_space_mallocok __P((void));
|
||||
extern struct powerpc_bus_space bebox_io_bs_tag;
|
||||
extern struct powerpc_bus_space bebox_mem_bs_tag;
|
||||
extern struct powerpc_bus_space bebox_isa_io_bs_tag;
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: files.mvmeppc,v 1.6 2003/03/05 05:43:44 matt Exp $
|
||||
# $NetBSD: files.mvmeppc,v 1.7 2003/03/18 16:40:20 matt Exp $
|
||||
#
|
||||
# Motorola's MVMEPPC boards specific configuration info
|
||||
#
|
||||
@ -12,15 +12,15 @@ defflag opt_mvmetype.h SUPPORT_MVME230X
|
||||
defflag opt_mvmetype.h SUPPORT_MVME240X
|
||||
|
||||
file arch/mvmeppc/mvmeppc/autoconf.c
|
||||
file arch/mvmeppc/mvmeppc/bus_space.c
|
||||
file arch/mvmeppc/mvmeppc/clock.c
|
||||
file arch/mvmeppc/mvmeppc/disksubr.c disk
|
||||
file arch/mvmeppc/mvmeppc/extintr.c
|
||||
file arch/mvmeppc/mvmeppc/machdep.c
|
||||
file arch/mvmeppc/mvmeppc/platform.c
|
||||
file arch/mvmeppc/mvmeppc/platform_160x.c support_mvme160x
|
||||
file arch/powerpc/powerpc/bus_dma.c
|
||||
|
||||
file arch/powerpc/powerpc/bus_dma.c
|
||||
file arch/powerpc/powerpc/bus_space.c
|
||||
file arch/powerpc/powerpc/procfs_machdep.c procfs
|
||||
# General files
|
||||
file dev/cons.c
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: bus.h,v 1.1 2002/02/27 21:02:14 scw Exp $ */
|
||||
/* $NetBSD: bus.h,v 1.2 2003/03/18 16:40:20 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 200e The NetBSD Foundation, Inc.
|
||||
@ -58,15 +58,14 @@
|
||||
#define MVMEPPC_BUS_SPACE_MEM 1
|
||||
#define MVMEPPC_BUS_SPACE_NUM_REGIONS 2
|
||||
|
||||
#define PHYS_TO_PCI_MEM(x) ((x) | 0x80000000)
|
||||
#define PCI_MEM_TO_PHYS(x) ((x) & ~0x80000000)
|
||||
#define PHYS_TO_BUS_MEM(t,x) ((x) | 0x80000000)
|
||||
#define BUS_MEM_TO_PHYS(t,x) ((x) & ~0x80000000)
|
||||
|
||||
#ifdef _KERNEL
|
||||
extern void mvmeppc_bus_space_init(void);
|
||||
extern const struct powerpc_bus_space mvmeppc_isa_io_bs_tag;
|
||||
extern const struct powerpc_bus_space mvmeppc_isa_mem_bs_tag;
|
||||
extern const struct powerpc_bus_space mvmeppc_pci_io_bs_tag;
|
||||
extern const struct powerpc_bus_space mvmeppc_pci_mem_bs_tag;
|
||||
extern struct powerpc_bus_space mvmeppc_isa_io_bs_tag;
|
||||
extern struct powerpc_bus_space mvmeppc_isa_mem_bs_tag;
|
||||
extern struct powerpc_bus_space mvmeppc_pci_io_bs_tag;
|
||||
extern struct powerpc_bus_space mvmeppc_pci_mem_bs_tag;
|
||||
#endif
|
||||
|
||||
#endif /* _MVMEPPC_BUS_H_ */
|
||||
|
@ -1,373 +0,0 @@
|
||||
/* $NetBSD: bus_space.c,v 1.4 2003/03/06 05:25:19 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace
|
||||
* Simulation Facility, NASA Ames Research Center.
|
||||
*
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/extent.h>
|
||||
#include <sys/mbuf.h>
|
||||
|
||||
#include <machine/bat.h>
|
||||
#define _POWERPC_BUS_DMA_PRIVATE
|
||||
#include <machine/bus.h>
|
||||
#undef _POWERPC_BUS_DMA_PRIVATE
|
||||
|
||||
paddr_t mvmeppc_memio_mmap (bus_space_tag_t, bus_addr_t, off_t, int, int);
|
||||
int mvmeppc_memio_map (bus_space_tag_t, bus_addr_t, bus_size_t, int,
|
||||
bus_space_handle_t *);
|
||||
void mvmeppc_memio_unmap (bus_space_tag_t, bus_space_handle_t, bus_size_t);
|
||||
int mvmeppc_memio_alloc (bus_space_tag_t, bus_addr_t, bus_addr_t,
|
||||
bus_size_t, bus_size_t, bus_size_t, int, bus_addr_t *,
|
||||
bus_space_handle_t *);
|
||||
void mvmeppc_memio_free (bus_space_tag_t, bus_space_handle_t, bus_size_t);
|
||||
|
||||
|
||||
const struct powerpc_bus_space mvmeppc_isa_io_bs_tag = {
|
||||
MVMEPPC_BUS_SPACE_IO,
|
||||
MVMEPPC_PHYS_BASE_IO, /* 60x-bus address of ISA I/O Space */
|
||||
0x00000000, /* Corresponds to ISA-bus I/O address 0x0 */
|
||||
0x00010000, /* End of ISA-bus I/O address space, +1 */
|
||||
mvmeppc_memio_mmap,
|
||||
mvmeppc_memio_map, mvmeppc_memio_unmap,
|
||||
mvmeppc_memio_alloc, mvmeppc_memio_free
|
||||
};
|
||||
|
||||
const struct powerpc_bus_space mvmeppc_pci_io_bs_tag = {
|
||||
MVMEPPC_BUS_SPACE_IO,
|
||||
MVMEPPC_PHYS_BASE_IO, /* 60x-bus address of PCI I/O Space */
|
||||
0x00000000, /* Corresponds to PCI-bus I/O address 0x0 */
|
||||
MVMEPPC_PHYS_SIZE_IO, /* End of PCI-bus I/O address space, +1 */
|
||||
mvmeppc_memio_mmap,
|
||||
mvmeppc_memio_map, mvmeppc_memio_unmap,
|
||||
mvmeppc_memio_alloc, mvmeppc_memio_free
|
||||
};
|
||||
|
||||
const struct powerpc_bus_space mvmeppc_isa_mem_bs_tag = {
|
||||
MVMEPPC_BUS_SPACE_MEM,
|
||||
MVMEPPC_PHYS_BASE_MEM, /* 60x-bus address of ISA Memory Space */
|
||||
0x00000000, /* Corresponds to ISA-bus Memory addr 0x0 */
|
||||
0x01000000, /* End of ISA-bus Memory addr space, +1 */
|
||||
mvmeppc_memio_mmap,
|
||||
mvmeppc_memio_map, mvmeppc_memio_unmap,
|
||||
mvmeppc_memio_alloc, mvmeppc_memio_free
|
||||
};
|
||||
|
||||
const struct powerpc_bus_space mvmeppc_pci_mem_bs_tag = {
|
||||
MVMEPPC_BUS_SPACE_MEM,
|
||||
MVMEPPC_PHYS_BASE_MEM, /* 60x-bus address of PCI Memory Space */
|
||||
0x00000000, /* Corresponds to PCI-bus Memory addr 0x0 */
|
||||
MVMEPPC_PHYS_SIZE_MEM, /* End of PCI-bus Memory addr space, +1 */
|
||||
mvmeppc_memio_mmap,
|
||||
mvmeppc_memio_map, mvmeppc_memio_unmap,
|
||||
mvmeppc_memio_alloc, mvmeppc_memio_free
|
||||
};
|
||||
|
||||
/*
|
||||
* Evaluates true if `t' is not a valid tag type
|
||||
*/
|
||||
#define BAD_TAG(t) ((t) < 0 || (t) >= MVMEPPC_BUS_SPACE_NUM_REGIONS)
|
||||
|
||||
/*
|
||||
* Bus Space region accounting
|
||||
*/
|
||||
static struct extent *bus_ex[MVMEPPC_BUS_SPACE_NUM_REGIONS];
|
||||
|
||||
/*
|
||||
* We maintain BAT mappings for subsets of I/O and Memory space...
|
||||
*/
|
||||
struct mvmeppc_bat_region {
|
||||
vaddr_t br_kva;
|
||||
bus_addr_t br_len;
|
||||
};
|
||||
static const struct mvmeppc_bat_region bat_regions[] = {
|
||||
{MVMEPPC_KVA_BASE_IO, MVMEPPC_KVA_SIZE_IO},
|
||||
{MVMEPPC_KVA_BASE_MEM, MVMEPPC_KVA_SIZE_MEM}
|
||||
};
|
||||
|
||||
#define page_offset(a) ((a) - trunc_page(a))
|
||||
|
||||
|
||||
void
|
||||
mvmeppc_bus_space_init(void)
|
||||
{
|
||||
|
||||
bus_ex[MVMEPPC_BUS_SPACE_IO] = extent_create("bus_io",
|
||||
0, MVMEPPC_PHYS_SIZE_IO,
|
||||
M_DEVBUF, NULL, 0, EX_NOCOALESCE | EX_NOWAIT | EX_MALLOCOK);
|
||||
|
||||
if (extent_alloc_region(bus_ex[MVMEPPC_BUS_SPACE_IO],
|
||||
MVMEPPC_PHYS_RESVD_START_IO, MVMEPPC_PHYS_RESVD_SIZE_IO,
|
||||
EX_NOWAIT | EX_MALLOCOK) != 0)
|
||||
panic("mvmeppc_bus_space_init: reserving I/O hole");
|
||||
|
||||
bus_ex[MVMEPPC_BUS_SPACE_MEM] = extent_create("bus_mem",
|
||||
0, MVMEPPC_PHYS_SIZE_MEM,
|
||||
M_DEVBUF, NULL, 0, EX_NOCOALESCE | EX_NOWAIT | EX_MALLOCOK);
|
||||
}
|
||||
|
||||
paddr_t
|
||||
mvmeppc_memio_mmap(t, bpa, offset, prot, flags)
|
||||
bus_space_tag_t t;
|
||||
bus_addr_t bpa;
|
||||
off_t offset;
|
||||
int prot, flags;
|
||||
{
|
||||
|
||||
return (trunc_page(bpa + offset));
|
||||
}
|
||||
|
||||
int
|
||||
mvmeppc_memio_map(t, bpa, size, flags, bshp)
|
||||
bus_space_tag_t t;
|
||||
bus_addr_t bpa;
|
||||
bus_size_t size;
|
||||
int flags;
|
||||
bus_space_handle_t *bshp;
|
||||
{
|
||||
const struct mvmeppc_bat_region *br;
|
||||
struct extent *ex;
|
||||
bus_addr_t kpa;
|
||||
vaddr_t va;
|
||||
int error, i;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (BAD_TAG(t->pbs_type))
|
||||
panic("mvmeppc_memio_map: bad tag: %d", t->pbs_type);
|
||||
#endif
|
||||
|
||||
if ((flags & BUS_SPACE_MAP_LINEAR) != 0 &&
|
||||
t->pbs_type == MVMEPPC_BUS_SPACE_IO)
|
||||
return (EOPNOTSUPP);
|
||||
|
||||
br = &bat_regions[t->pbs_type];
|
||||
ex = bus_ex[t->pbs_type];
|
||||
|
||||
if ((bpa + size) > t->pbs_limit)
|
||||
return (EINVAL);
|
||||
|
||||
/*
|
||||
* Bail if trying to map a region which overlaps the end of
|
||||
* a BAT mapping.
|
||||
*
|
||||
* XXX: Watch out, one day we'll trip over this...
|
||||
*/
|
||||
if (bpa < br->br_len && (bpa + size) > br->br_len)
|
||||
return (EINVAL);
|
||||
|
||||
if (ex) {
|
||||
/*
|
||||
* Before we go any further, let's make sure that this
|
||||
* region is available.
|
||||
*/
|
||||
if ((error = extent_alloc_region(ex, bpa, size,
|
||||
EX_NOWAIT | EX_MALLOCOK)) != 0)
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Does the requested bus space region fall within the KVA mapping
|
||||
* set up for this space by a BAT register?
|
||||
*/
|
||||
if ((bpa + size) < br->br_len) {
|
||||
/* We can satisfy this request directly from the BAT mapping */
|
||||
*bshp = (bus_space_handle_t)(bpa + (bus_addr_t)br->br_kva);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Otherwise, we have to manually fix up a mapping.
|
||||
*/
|
||||
va = uvm_km_valloc(kernel_map, round_page(size));
|
||||
if (va == NULL) {
|
||||
(void) extent_free(ex, bpa, size, EX_NOWAIT | EX_MALLOCOK);
|
||||
return (ENOMEM);
|
||||
}
|
||||
|
||||
*bshp = (bus_space_handle_t)((caddr_t)va + page_offset(bpa));
|
||||
kpa = trunc_page(t->pbs_offset + bpa);
|
||||
|
||||
for (i = round_page(size) / NBPG; i > 0; i--, kpa += NBPG, va += NBPG)
|
||||
pmap_enter(pmap_kernel(), va, kpa,
|
||||
VM_PROT_READ | VM_PROT_WRITE,
|
||||
VM_PROT_READ | VM_PROT_WRITE | PMAP_WIRED);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
mvmeppc_memio_unmap(t, bsh, size)
|
||||
bus_space_tag_t t;
|
||||
bus_space_handle_t bsh;
|
||||
bus_size_t size;
|
||||
{
|
||||
const struct mvmeppc_bat_region *br;
|
||||
struct extent *ex;
|
||||
bus_addr_t bpa;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (BAD_TAG(t->pbs_type))
|
||||
panic("mvmeppc_memio_unmap: bad tag: %d", t->pbs_type);
|
||||
#endif
|
||||
|
||||
br = &bat_regions[t->pbs_type];
|
||||
ex = bus_ex[t->pbs_type];
|
||||
|
||||
/*
|
||||
* Was the mapping within the BAT region of this space?
|
||||
*/
|
||||
if (bsh < br->br_kva || bsh >= (br->br_kva + br->br_len)) {
|
||||
/*
|
||||
* Nope. We have to figure out the physical address
|
||||
* and unmap it for real.
|
||||
*/
|
||||
if (!pmap_extract(pmap_kernel(), (vaddr_t)bsh, (void *)&bpa))
|
||||
panic("mvmeppc_memio_unmap: bad bus handle: 0x%x", bsh);
|
||||
uvm_km_free(kernel_map, (vaddr_t)trunc_page(bsh),
|
||||
round_page(size));
|
||||
bpa -= t->pbs_offset;
|
||||
} else
|
||||
bpa = (bus_addr_t) bsh - (bus_addr_t) br->br_kva;
|
||||
|
||||
if (ex && extent_free(ex, bpa, size, EX_NOWAIT | EX_MALLOCOK)) {
|
||||
printf("mvmeppc_memio_unmap: %s 0x%lx, size 0x%lx\n",
|
||||
(t->pbs_type == MVMEPPC_BUS_SPACE_IO) ? "port" : "mem",
|
||||
(u_long)bpa, (u_long)size);
|
||||
printf("mvmeppc_memio_unmap: can't free region\n");
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
mvmeppc_memio_alloc(t, rstart, rend, size, alignment, boundary, flags,
|
||||
bpap, bshp)
|
||||
bus_space_tag_t t;
|
||||
bus_addr_t rstart, rend;
|
||||
bus_size_t size, alignment, boundary;
|
||||
int flags;
|
||||
bus_addr_t *bpap;
|
||||
bus_space_handle_t *bshp;
|
||||
{
|
||||
const struct mvmeppc_bat_region *br;
|
||||
struct extent *ex;
|
||||
bus_dma_segment_t seg;
|
||||
caddr_t va;
|
||||
u_long bpa;
|
||||
int error;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (BAD_TAG(t->pbs_type))
|
||||
panic("mvmeppc_memio_alloc: bad tag: %d", t->pbs_type);
|
||||
#endif
|
||||
|
||||
if ((flags & BUS_SPACE_MAP_LINEAR) != 0 &&
|
||||
t->pbs_type == MVMEPPC_BUS_SPACE_IO)
|
||||
return (EOPNOTSUPP);
|
||||
|
||||
br = &bat_regions[t->pbs_type];
|
||||
ex = bus_ex[t->pbs_type];
|
||||
|
||||
if ((rstart + size) > t->pbs_limit)
|
||||
return (EINVAL);
|
||||
|
||||
if (rstart < ex->ex_start || rend > ex->ex_end)
|
||||
panic("mvmeppc_memio_alloc: bad region start/end");
|
||||
|
||||
if (ex) {
|
||||
error = extent_alloc_subregion(ex, rstart, rend, size,
|
||||
alignment, boundary, EX_FAST | EX_NOWAIT | EX_MALLOCOK,
|
||||
&bpa);
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Bail if trying to map a region which overlaps the end of
|
||||
* a BAT mapping.
|
||||
*
|
||||
* XXX: Watch out, one day we'll trip over this...
|
||||
*/
|
||||
if (bpa < br->br_len && (bpa + size) > br->br_len) {
|
||||
if (ex) {
|
||||
(void) extent_free(ex, bpa, size,
|
||||
EX_NOWAIT | EX_MALLOCOK);
|
||||
}
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Does the requested bus space region fall within the KVA mapping
|
||||
* set up for this space by a BAT register?
|
||||
*/
|
||||
if ((bpa + size) < br->br_len) {
|
||||
/* We can satisfy this request directly from the BAT mapping */
|
||||
*bpap = bpa;
|
||||
*bshp = (bus_space_handle_t)(bpa + (bus_addr_t)br->br_kva);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Otherwise, we have to manually fix up a mapping.
|
||||
*/
|
||||
seg.ds_addr = trunc_page(t->pbs_base + bpa);
|
||||
seg.ds_len = round_page(size);
|
||||
|
||||
if (_bus_dmamem_map(NULL, &seg, 1, seg.ds_len, &va,
|
||||
flags | BUS_DMA_COHERENT)) {
|
||||
if (ex) {
|
||||
(void) extent_free(ex, bpa, size,
|
||||
EX_NOWAIT | EX_MALLOCOK);
|
||||
}
|
||||
return (ENOMEM);
|
||||
}
|
||||
|
||||
*bpap = bpa;
|
||||
*bshp = (bus_space_handle_t)(va + page_offset(bpa));
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
mvmeppc_memio_free(t, bsh, size)
|
||||
bus_space_tag_t t;
|
||||
bus_space_handle_t bsh;
|
||||
bus_size_t size;
|
||||
{
|
||||
|
||||
/* mvmeppc_memio_unmap() does all that we need to do. */
|
||||
mvmeppc_memio_unmap(t, bsh, size);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: locore.S,v 1.2 2003/02/02 20:43:20 matt Exp $ */
|
||||
/* $NetBSD: locore.S,v 1.3 2003/03/18 16:40:21 matt Exp $ */
|
||||
/* $OpenBSD: locore.S,v 1.4 1997/01/26 09:06:38 rahnds Exp $ */
|
||||
|
||||
/*
|
||||
@ -202,3 +202,8 @@ _C_LABEL(disable_intr):
|
||||
* Pull in common trap vector code.
|
||||
*/
|
||||
#include <powerpc/powerpc/trap_subr.S>
|
||||
|
||||
/*
|
||||
* Pull in common pio / bus_space code.
|
||||
*/
|
||||
#include <powerpc/powerpc/pio_subr.S>
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: machdep.c,v 1.9 2003/02/03 17:09:58 matt Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.10 2003/03/18 16:40:21 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
@ -40,6 +40,7 @@
|
||||
#include <sys/conf.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/exec.h>
|
||||
#include <sys/extent.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mbuf.h>
|
||||
@ -104,6 +105,7 @@ void comsoft(void);
|
||||
void initppc(u_long, u_long, void *);
|
||||
void strayintr(int);
|
||||
int lcsplx(int);
|
||||
void mvmeppc_bus_space_init(void);
|
||||
|
||||
|
||||
/*
|
||||
@ -178,14 +180,18 @@ initppc(startkernel, endkernel, btinfo)
|
||||
*/
|
||||
oea_init(platform->ext_intr);
|
||||
|
||||
/*
|
||||
* Init bus_space so consinit can work.
|
||||
*/
|
||||
mvmeppc_bus_space_init();
|
||||
|
||||
#ifdef DEBUG
|
||||
/*
|
||||
* i386 port says, that this shouldn't be here,
|
||||
* but I really think the console should be initialized
|
||||
* as early as possible.
|
||||
* The console should be initialized as early as possible.
|
||||
*/
|
||||
consinit();
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Set the page size.
|
||||
*/
|
||||
@ -245,7 +251,7 @@ cpu_startup()
|
||||
: "=r"(msr) : "K"(PSL_EE));
|
||||
}
|
||||
|
||||
mvmeppc_bus_space_init();
|
||||
bus_space_mallocok();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -299,7 +305,7 @@ dokbd:
|
||||
#if (NCOM > 0)
|
||||
if (!strcmp(bootinfo.bi_consoledev, "PC16550")) {
|
||||
bus_space_tag_t tag = &mvmeppc_isa_io_bs_tag;
|
||||
bus_addr_t caddr[2] = {0x3f8, 0x2f8};
|
||||
static const bus_addr_t caddr[2] = {0x3f8, 0x2f8};
|
||||
int rv;
|
||||
rv = comcnattach(tag, caddr[bootinfo.bi_consolechan],
|
||||
bootinfo.bi_consolespeed, COM_FREQ,
|
||||
@ -398,12 +404,68 @@ lcsplx(ipl)
|
||||
{
|
||||
int oldcpl;
|
||||
|
||||
__asm__ volatile("sync; eieio\n"); /* reorder protect */
|
||||
__asm __volatile("sync; eieio\n"); /* reorder protect */
|
||||
oldcpl = cpl;
|
||||
cpl = ipl;
|
||||
if (ipending & ~ipl)
|
||||
do_pending_int();
|
||||
__asm__ volatile("sync; eieio\n"); /* reorder protect */
|
||||
__asm __volatile("sync; eieio\n"); /* reorder protect */
|
||||
|
||||
return (oldcpl);
|
||||
}
|
||||
|
||||
|
||||
struct powerpc_bus_space mvmeppc_isa_io_bs_tag = {
|
||||
_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
|
||||
MVMEPPC_PHYS_BASE_IO, /* 60x-bus address of ISA I/O Space */
|
||||
0x00000000, /* Corresponds to ISA-bus I/O address 0x0 */
|
||||
0x00010000, /* End of ISA-bus I/O address space, +1 */
|
||||
};
|
||||
|
||||
struct powerpc_bus_space mvmeppc_pci_io_bs_tag = {
|
||||
_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
|
||||
MVMEPPC_PHYS_BASE_IO, /* 60x-bus address of PCI I/O Space */
|
||||
0x00000000, /* Corresponds to PCI-bus I/O address 0x0 */
|
||||
MVMEPPC_PHYS_SIZE_IO, /* End of PCI-bus I/O address space, +1 */
|
||||
};
|
||||
|
||||
struct powerpc_bus_space mvmeppc_isa_mem_bs_tag = {
|
||||
_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
|
||||
MVMEPPC_PHYS_BASE_MEM, /* 60x-bus address of ISA Memory Space */
|
||||
0x00000000, /* Corresponds to ISA-bus Memory addr 0x0 */
|
||||
0x01000000, /* End of ISA-bus Memory addr space, +1 */
|
||||
};
|
||||
|
||||
struct powerpc_bus_space mvmeppc_pci_mem_bs_tag = {
|
||||
_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
|
||||
MVMEPPC_PHYS_BASE_MEM, /* 60x-bus address of PCI Memory Space */
|
||||
0x00000000, /* Corresponds to PCI-bus Memory addr 0x0 */
|
||||
MVMEPPC_PHYS_SIZE_MEM, /* End of PCI-bus Memory addr space, +1 */
|
||||
};
|
||||
static char ex_storage[MVMEPPC_BUS_SPACE_NUM_REGIONS][EXTENT_FIXED_STORAGE_SIZE(8)]
|
||||
__attribute__((aligned(8)));
|
||||
|
||||
|
||||
void
|
||||
mvmeppc_bus_space_init(void)
|
||||
{
|
||||
|
||||
int error;
|
||||
|
||||
error = bus_space_init(&mvmeppc_pci_io_bs_tag, "bus_io",
|
||||
ex_storage[MVMEPPC_BUS_SPACE_IO],
|
||||
sizeof(ex_storage[MVMEPPC_BUS_SPACE_IO]));
|
||||
|
||||
if (extent_alloc_region(mvmeppc_pci_io_bs_tag.pbs_extent,
|
||||
MVMEPPC_PHYS_RESVD_START_IO, MVMEPPC_PHYS_RESVD_SIZE_IO,
|
||||
EX_NOWAIT) != 0)
|
||||
panic("mvmeppc_bus_space_init: reserving I/O hole");
|
||||
|
||||
mvmeppc_isa_io_bs_tag.pbs_extent = mvmeppc_pci_io_bs_tag.pbs_extent;
|
||||
|
||||
error = bus_space_init(&mvmeppc_pci_mem_bs_tag, "bus_mem",
|
||||
ex_storage[MVMEPPC_BUS_SPACE_MEM],
|
||||
sizeof(ex_storage[MVMEPPC_BUS_SPACE_MEM]));
|
||||
|
||||
mvmeppc_isa_mem_bs_tag.pbs_extent = mvmeppc_pci_mem_bs_tag.pbs_extent;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pci_machdep.c,v 1.2 2002/09/27 15:36:27 provos Exp $ */
|
||||
/* $NetBSD: pci_machdep.c,v 1.3 2003/03/18 16:40:21 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
|
||||
@ -52,6 +52,8 @@
|
||||
#include <machine/intr.h>
|
||||
#include <machine/platform.h>
|
||||
|
||||
#include <powerpc/pio.h>
|
||||
|
||||
#include <dev/isa/isavar.h>
|
||||
#include <dev/pci/pcivar.h>
|
||||
#include <dev/pci/pcireg.h>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
# $NetBSD: files.prep,v 1.41 2003/03/05 05:43:50 matt Exp $
|
||||
# $NetBSD: files.prep,v 1.42 2003/03/18 16:40:22 matt Exp $
|
||||
#
|
||||
# prep-specific configuration info
|
||||
#
|
||||
@ -28,7 +28,6 @@ file arch/prep/prep/mot_ulmb60xa.c platform_motorola_ulmb60xa
|
||||
file arch/prep/prep/platform.c
|
||||
|
||||
file arch/prep/prep/autoconf.c
|
||||
file arch/prep/prep/bus_space.c
|
||||
file arch/prep/prep/clock.c
|
||||
file arch/prep/prep/consinit.c
|
||||
file arch/prep/prep/disksubr.c disk
|
||||
@ -37,6 +36,7 @@ file arch/prep/prep/machdep.c
|
||||
file arch/prep/prep/residual.c residual_data_dump
|
||||
|
||||
file arch/powerpc/powerpc/bus_dma.c
|
||||
file arch/powerpc/powerpc/bus_space.c
|
||||
file arch/powerpc/powerpc/procfs_machdep.c procfs
|
||||
|
||||
# General files
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: bus.h,v 1.8 2003/03/06 00:20:41 matt Exp $ */
|
||||
/* $NetBSD: bus.h,v 1.9 2003/03/18 16:40:22 matt Exp $ */
|
||||
/* $OpenBSD: bus.h,v 1.1 1997/10/13 10:53:42 pefo Exp $ */
|
||||
|
||||
/*-
|
||||
@ -120,8 +120,6 @@
|
||||
#define BUS_MEM_TO_PHYS(t, x) ((x) & ~MPC105_DIRECT_MAPPED_SPACE)
|
||||
|
||||
#ifdef _KERNEL
|
||||
void prep_bus_space_init __P((void));
|
||||
void prep_bus_space_mallocok __P((void));
|
||||
extern struct powerpc_bus_space prep_io_space_tag;
|
||||
extern struct powerpc_bus_space prep_isa_io_space_tag;
|
||||
extern struct powerpc_bus_space prep_mem_space_tag;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: prep_pciconf_direct.c,v 1.1 2002/02/24 13:19:08 kleink Exp $ */
|
||||
/* $NetBSD: prep_pciconf_direct.c,v 1.2 2003/03/18 16:40:23 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002 Klaus J. Klein. All rights reserved.
|
||||
@ -52,6 +52,8 @@
|
||||
#include <machine/intr.h>
|
||||
#include <machine/platform.h>
|
||||
|
||||
#include <powerpc/pio.h>
|
||||
|
||||
#include <dev/isa/isavar.h>
|
||||
#include <dev/pci/pcivar.h>
|
||||
#include <dev/pci/pcireg.h>
|
||||
|
@ -1,206 +0,0 @@
|
||||
/* $NetBSD: bus_space.c,v 1.10 2003/03/06 05:25:19 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace
|
||||
* Simulation Facility, NASA Ames Research Center.
|
||||
*
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/extent.h>
|
||||
#include <sys/mbuf.h>
|
||||
|
||||
#include <uvm/uvm_extern.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
|
||||
static paddr_t memio_mmap(bus_space_tag_t, bus_addr_t, off_t, int, int);
|
||||
static int memio_map(bus_space_tag_t, bus_addr_t, bus_size_t, int,
|
||||
bus_space_handle_t *);
|
||||
static void memio_unmap(bus_space_tag_t, bus_space_handle_t, bus_size_t);
|
||||
static int memio_alloc(bus_space_tag_t, bus_addr_t, bus_addr_t, bus_size_t,
|
||||
bus_size_t, bus_size_t, int, bus_addr_t *, bus_space_handle_t *);
|
||||
static void memio_free(bus_space_tag_t, bus_space_handle_t, bus_size_t);
|
||||
|
||||
struct powerpc_bus_space prep_io_space_tag = {
|
||||
_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
|
||||
0x80000000, 0x00000000, 0x3f800000,
|
||||
NULL,
|
||||
memio_mmap, memio_map, memio_unmap, memio_alloc, memio_free
|
||||
};
|
||||
struct powerpc_bus_space prep_isa_io_space_tag = {
|
||||
_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
|
||||
0x80000000, 0x00000000, 0x00010000,
|
||||
NULL,
|
||||
memio_mmap, memio_map, memio_unmap, memio_alloc, memio_free
|
||||
};
|
||||
struct powerpc_bus_space prep_mem_space_tag = {
|
||||
_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
|
||||
0xC0000000, 0x00000000, 0x3f000000,
|
||||
NULL,
|
||||
memio_mmap, memio_map, memio_unmap, memio_alloc, memio_free
|
||||
};
|
||||
struct powerpc_bus_space prep_isa_mem_space_tag = {
|
||||
_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
|
||||
0xC0000000, 0x00000000, 0x01000000,
|
||||
NULL,
|
||||
memio_mmap, memio_map, memio_unmap, memio_alloc, memio_free
|
||||
};
|
||||
|
||||
static char ex_storage[2][EXTENT_FIXED_STORAGE_SIZE(8)]
|
||||
__attribute__((aligned(8)));
|
||||
|
||||
static int extent_flags;
|
||||
|
||||
void
|
||||
prep_bus_space_init(void)
|
||||
{
|
||||
int error;
|
||||
|
||||
prep_io_space_tag.pbs_extent = extent_create("ioport",
|
||||
prep_io_space_tag.pbs_base, prep_io_space_tag.pbs_limit - 1,
|
||||
M_DEVBUF,
|
||||
ex_storage[0], sizeof(ex_storage[0]),
|
||||
EX_NOCOALESCE|EX_NOWAIT);
|
||||
error = extent_alloc_region(prep_io_space_tag.pbs_extent,
|
||||
0x10000, 0x7F0000, EX_NOWAIT);
|
||||
if (error)
|
||||
panic("prep_bus_space_init: can't block out reserved I/O"
|
||||
" space 0x10000-0x7fffff: error=%d", error);
|
||||
prep_mem_space_tag.pbs_extent = extent_create("iomem",
|
||||
prep_mem_space_tag.pbs_base, prep_mem_space_tag.pbs_limit - 1,
|
||||
M_DEVBUF,
|
||||
ex_storage[1], sizeof(ex_storage[1]),
|
||||
EX_NOCOALESCE|EX_NOWAIT);
|
||||
|
||||
prep_isa_io_space_tag.pbs_extent = prep_io_space_tag.pbs_extent;
|
||||
prep_isa_mem_space_tag.pbs_extent = prep_mem_space_tag.pbs_extent;
|
||||
}
|
||||
|
||||
void
|
||||
prep_bus_space_mallocok(void)
|
||||
{
|
||||
extent_flags = EX_MALLOCOK;
|
||||
}
|
||||
|
||||
paddr_t
|
||||
memio_mmap(bus_space_tag_t t, bus_addr_t bpa, off_t offset, int prot, int flags)
|
||||
{
|
||||
return (trunc_page(bpa + offset));
|
||||
}
|
||||
|
||||
int
|
||||
memio_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int flags,
|
||||
bus_space_handle_t *bshp)
|
||||
{
|
||||
int error;
|
||||
|
||||
if (bpa + size > t->pbs_limit)
|
||||
return (EINVAL);
|
||||
|
||||
/*
|
||||
* Can't map I/O space as linear.
|
||||
*/
|
||||
if ((flags & BUS_SPACE_MAP_LINEAR) &&
|
||||
(t->pbs_flags & _BUS_SPACE_IO_TYPE))
|
||||
return (EOPNOTSUPP);
|
||||
|
||||
/*
|
||||
* Before we go any further, let's make sure that this
|
||||
* region is available.
|
||||
*/
|
||||
error = extent_alloc_region(t->pbs_extent, bpa, size,
|
||||
EX_NOWAIT | extent_flags);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
*bshp = t->pbs_offset + bpa;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
memio_unmap(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size)
|
||||
{
|
||||
bus_addr_t bpa = bsh - t->pbs_offset;
|
||||
|
||||
if (extent_free(t->pbs_extent, bpa, size, EX_NOWAIT | extent_flags)) {
|
||||
printf("memio_unmap: %s 0x%lx, size 0x%lx\n",
|
||||
(t->pbs_flags & _BUS_SPACE_IO_TYPE) ? "port" : "mem",
|
||||
(unsigned long)bpa, (unsigned long)size);
|
||||
printf("memio_unmap: can't free region\n");
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
memio_alloc(bus_space_tag_t t, bus_addr_t rstart, bus_addr_t rend,
|
||||
bus_size_t size, bus_size_t alignment, bus_size_t boundary,
|
||||
int flags, bus_addr_t *bpap, bus_space_handle_t *bshp)
|
||||
{
|
||||
u_long bpa;
|
||||
int error;
|
||||
|
||||
if (rstart + size > t->pbs_limit)
|
||||
return (EINVAL);
|
||||
|
||||
/*
|
||||
* Can't map I/O space as linear.
|
||||
*/
|
||||
if ((flags & BUS_SPACE_MAP_LINEAR) &&
|
||||
(t->pbs_flags & _BUS_SPACE_IO_TYPE))
|
||||
return (EOPNOTSUPP);
|
||||
|
||||
if (rstart < t->pbs_extent->ex_start || rend > t->pbs_extent->ex_end)
|
||||
panic("memio_alloc: bad region start/end");
|
||||
|
||||
error = extent_alloc_subregion(t->pbs_extent, rstart, rend, size,
|
||||
alignment, boundary, EX_FAST | EX_NOWAIT | extent_flags, &bpa);
|
||||
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
*bpap = bpa;
|
||||
*bshp = t->pbs_offset + bpa;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
memio_free(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size)
|
||||
{
|
||||
/* memio_unmap() does all that we need to do. */
|
||||
memio_unmap(t, bsh, size);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: locore.S,v 1.4 2003/02/02 20:43:25 matt Exp $ */
|
||||
/* $NetBSD: locore.S,v 1.5 2003/03/18 16:40:24 matt Exp $ */
|
||||
/* $OpenBSD: locore.S,v 1.4 1997/01/26 09:06:38 rahnds Exp $ */
|
||||
|
||||
/*
|
||||
@ -173,15 +173,15 @@ loop:
|
||||
.globl _C_LABEL(enable_intr)
|
||||
_C_LABEL(enable_intr):
|
||||
mfmsr 3
|
||||
ori 3,3,PSL_EE@l
|
||||
mtmsr 3
|
||||
ori 4,3,PSL_EE@l
|
||||
mtmsr 4
|
||||
blr
|
||||
|
||||
.globl _C_LABEL(disable_intr)
|
||||
_C_LABEL(disable_intr):
|
||||
mfmsr 3
|
||||
andi. 3,3,~PSL_EE@l
|
||||
mtmsr 3
|
||||
andi. 4,3,~PSL_EE@l
|
||||
mtmsr 4
|
||||
blr
|
||||
|
||||
/*
|
||||
@ -193,3 +193,8 @@ _C_LABEL(disable_intr):
|
||||
* Pull in common trap vector code.
|
||||
*/
|
||||
#include <powerpc/powerpc/trap_subr.S>
|
||||
|
||||
/*
|
||||
* Pull in common pio / bus_space code.
|
||||
*/
|
||||
#include <powerpc/powerpc/pio_subr.S>
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: machdep.c,v 1.45 2003/02/03 17:10:13 matt Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.46 2003/03/18 16:40:24 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
@ -39,6 +39,7 @@
|
||||
#include <sys/conf.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/exec.h>
|
||||
#include <sys/extent.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mbuf.h>
|
||||
@ -84,10 +85,11 @@ void comsoft(void);
|
||||
#include <ddb/db_extern.h>
|
||||
#endif
|
||||
|
||||
void initppc __P((u_long, u_long, u_int, void *));
|
||||
void dumpsys __P((void));
|
||||
void strayintr __P((int));
|
||||
int lcsplx __P((int));
|
||||
void initppc(u_long, u_long, u_int, void *);
|
||||
void dumpsys(void);
|
||||
void strayintr(int);
|
||||
int lcsplx(int);
|
||||
void prep_bus_space_init(void);
|
||||
|
||||
char bootinfo[BOOTINFO_MAXSIZE];
|
||||
|
||||
@ -259,7 +261,7 @@ cpu_startup()
|
||||
/*
|
||||
* Now safe for bus space allocation to use malloc.
|
||||
*/
|
||||
prep_bus_space_mallocok();
|
||||
bus_space_mallocok();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -376,3 +378,54 @@ lcsplx(ipl)
|
||||
|
||||
return (oldcpl);
|
||||
}
|
||||
|
||||
struct powerpc_bus_space prep_io_space_tag = {
|
||||
_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
|
||||
0x80000000, 0x00000000, 0x3f800000,
|
||||
};
|
||||
struct powerpc_bus_space prep_isa_io_space_tag = {
|
||||
_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
|
||||
0x80000000, 0x00000000, 0x00010000,
|
||||
};
|
||||
struct powerpc_bus_space prep_mem_space_tag = {
|
||||
_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
|
||||
0xC0000000, 0x00000000, 0x3f000000,
|
||||
};
|
||||
struct powerpc_bus_space prep_isa_mem_space_tag = {
|
||||
_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
|
||||
0xC0000000, 0x00000000, 0x01000000,
|
||||
};
|
||||
|
||||
static char ex_storage[2][EXTENT_FIXED_STORAGE_SIZE(8)]
|
||||
__attribute__((aligned(8)));
|
||||
|
||||
void
|
||||
prep_bus_space_init(void)
|
||||
{
|
||||
int error;
|
||||
|
||||
error = bus_space_init(&prep_io_space_tag, "ioport",
|
||||
ex_storage[0], sizeof(ex_storage[0]));
|
||||
if (error)
|
||||
panic("prep_bus_space_init: can't init io tag");
|
||||
|
||||
error = extent_alloc_region(prep_io_space_tag.pbs_extent,
|
||||
0x10000, 0x7F0000, EX_NOWAIT);
|
||||
if (error)
|
||||
panic("prep_bus_space_init: can't block out reserved I/O"
|
||||
" space 0x10000-0x7fffff: error=%d", error);
|
||||
error = bus_space_init(&prep_mem_space_tag, "iomem",
|
||||
ex_storage[1], sizeof(ex_storage[1]));
|
||||
if (error)
|
||||
panic("prep_bus_space_init: can't init mem tag");
|
||||
|
||||
prep_isa_io_space_tag.pbs_extent = prep_io_space_tag.pbs_extent;
|
||||
error = bus_space_init(&prep_isa_io_space_tag, "isa-ioport", NULL, 0);
|
||||
if (error)
|
||||
panic("prep_bus_space_init: can't init isa io tag");
|
||||
|
||||
prep_isa_mem_space_tag.pbs_extent = prep_mem_space_tag.pbs_extent;
|
||||
error = bus_space_init(&prep_isa_mem_space_tag, "isa-iomem", NULL, 0);
|
||||
if (error)
|
||||
panic("prep_bus_space_init: can't init isa mem tag");
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: files.sandpoint,v 1.15 2003/03/05 05:43:49 matt Exp $
|
||||
# $NetBSD: files.sandpoint,v 1.16 2003/03/18 16:40:24 matt Exp $
|
||||
#
|
||||
# Motorola's "SandPoint" evaluation board's specific configuration info
|
||||
#
|
||||
@ -7,13 +7,13 @@ maxpartitions 16
|
||||
maxusers 2 8 64
|
||||
|
||||
file arch/sandpoint/sandpoint/autoconf.c
|
||||
file arch/sandpoint/sandpoint/bus_space.c
|
||||
file arch/sandpoint/sandpoint/clock.c
|
||||
file arch/sandpoint/sandpoint/disksubr.c disk
|
||||
file arch/sandpoint/sandpoint/extintr.c
|
||||
file arch/sandpoint/sandpoint/machdep.c
|
||||
|
||||
file arch/powerpc/powerpc/bus_dma.c
|
||||
file arch/powerpc/powerpc/bus_space.c
|
||||
file arch/powerpc/powerpc/procfs_machdep.c procfs
|
||||
|
||||
# General files
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: bus.h,v 1.4 2003/03/06 00:20:40 matt Exp $ */
|
||||
/* $NetBSD: bus.h,v 1.5 2003/03/18 16:40:24 matt Exp $ */
|
||||
/* $OpenBSD: bus.h,v 1.1 1997/10/13 10:53:42 pefo Exp $ */
|
||||
|
||||
#ifndef _SANDPOINT_BUS_H_
|
||||
@ -25,7 +25,4 @@ extern struct powerpc_bus_space sandpoint_io_bs_tag;
|
||||
extern struct powerpc_bus_space sandpoint_isa_io_bs_tag;
|
||||
extern struct powerpc_bus_space sandpoint_mem_bs_tag;
|
||||
|
||||
void sandpoint_bus_space_init(void);
|
||||
void sandpoint_bus_space_mallocok(void);
|
||||
|
||||
#endif /* _SANDPOINT_BUS_H_ */
|
||||
|
@ -1,204 +0,0 @@
|
||||
/* $NetBSD: bus_space.c,v 1.5 2003/03/06 05:25:19 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace
|
||||
* Simulation Facility, NASA Ames Research Center.
|
||||
*
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/extent.h>
|
||||
#include <sys/mbuf.h>
|
||||
|
||||
#include <uvm/uvm_extern.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
|
||||
static paddr_t memio_mmap(bus_space_tag_t, bus_addr_t, off_t, int, int);
|
||||
static int memio_map(bus_space_tag_t, bus_addr_t, bus_size_t, int,
|
||||
bus_space_handle_t *);
|
||||
static void memio_unmap(bus_space_tag_t, bus_space_handle_t, bus_size_t);
|
||||
static int memio_alloc(bus_space_tag_t, bus_addr_t, bus_addr_t, bus_size_t,
|
||||
bus_size_t, bus_size_t, int, bus_addr_t *, bus_space_handle_t *);
|
||||
static void memio_free(bus_space_tag_t, bus_space_handle_t, bus_size_t);
|
||||
|
||||
struct powerpc_bus_space sandpoint_io_bs_tag = {
|
||||
_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
|
||||
0xfe000000, 0x00000000, 0x00c00000,
|
||||
NULL,
|
||||
memio_mmap, memio_map, memio_unmap, memio_alloc, memio_free
|
||||
};
|
||||
struct powerpc_bus_space sandpoint_isa_io_bs_tag = {
|
||||
_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
|
||||
0xfe000000, 0x00000000, 0x00010000,
|
||||
NULL,
|
||||
memio_mmap, memio_map, memio_unmap, memio_alloc, memio_free
|
||||
};
|
||||
struct powerpc_bus_space sandpoint_mem_bs_tag = {
|
||||
_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
|
||||
0x00000000, 0x80000000, 0xfe000000,
|
||||
NULL,
|
||||
memio_mmap, memio_map, memio_unmap, memio_alloc, memio_free
|
||||
};
|
||||
struct powerpc_bus_space sandpoint_isa_mem_bs_tag = {
|
||||
_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
|
||||
0x00000000, 0xfd000000, 0xfe000000,
|
||||
NULL,
|
||||
memio_mmap, memio_map, memio_unmap, memio_alloc, memio_free
|
||||
};
|
||||
|
||||
static char ex_storage[2][EXTENT_FIXED_STORAGE_SIZE(8)]
|
||||
__attribute__((aligned(8)));
|
||||
|
||||
static int extent_flags;
|
||||
|
||||
void
|
||||
sandpoint_bus_space_init(void)
|
||||
{
|
||||
int error;
|
||||
|
||||
sandpoint_io_bs_tag.pbs_extent = extent_create("ioport",
|
||||
sandpoint_io_bs_tag.pbs_base, sandpoint_io_bs_tag.pbs_limit - 1,
|
||||
M_DEVBUF,
|
||||
ex_storage[0], sizeof(ex_storage[0]),
|
||||
EX_NOCOALESCE|EX_NOWAIT);
|
||||
error = extent_alloc_region(sandpoint_io_bs_tag.pbs_extent,
|
||||
0x00010000, 0x7F0000, EX_NOWAIT);
|
||||
if (error)
|
||||
panic("sandpoint_bus_space_init: can't block out reserved"
|
||||
" I/O space 0x10000-0x7fffff: error=%d", error);
|
||||
|
||||
sandpoint_mem_bs_tag.pbs_extent = extent_create("iomem",
|
||||
sandpoint_mem_bs_tag.pbs_base, sandpoint_mem_bs_tag.pbs_limit - 1,
|
||||
M_DEVBUF,
|
||||
ex_storage[1], sizeof(ex_storage[1]),
|
||||
EX_NOCOALESCE|EX_NOWAIT);
|
||||
}
|
||||
|
||||
void
|
||||
sandpoint_bus_space_mallocok(void)
|
||||
{
|
||||
extent_flags = EX_MALLOCOK;
|
||||
}
|
||||
|
||||
paddr_t
|
||||
memio_mmap(bus_space_tag_t t, bus_addr_t bpa, off_t offset, int prot, int flags)
|
||||
{
|
||||
return (trunc_page(bpa + offset));
|
||||
}
|
||||
|
||||
int
|
||||
memio_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int flags,
|
||||
bus_space_handle_t *bshp)
|
||||
{
|
||||
int error;
|
||||
|
||||
if (bpa + size > t->pbs_limit)
|
||||
return (EINVAL);
|
||||
|
||||
/*
|
||||
* Can't map I/O space as linear.
|
||||
*/
|
||||
if ((flags & BUS_SPACE_MAP_LINEAR) &&
|
||||
(t->pbs_flags & _BUS_SPACE_IO_TYPE))
|
||||
return (EOPNOTSUPP);
|
||||
|
||||
/*
|
||||
* Before we go any further, let's make sure that this
|
||||
* region is available.
|
||||
*/
|
||||
error = extent_alloc_region(t->pbs_extent, bpa, size,
|
||||
EX_NOWAIT | extent_flags);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
*bshp = t->pbs_offset + bpa;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
memio_unmap(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size)
|
||||
{
|
||||
bus_addr_t bpa = bsh - t->pbs_offset;
|
||||
|
||||
if (extent_free(t->pbs_extent, bpa, size, EX_NOWAIT | extent_flags)) {
|
||||
printf("memio_unmap: %s 0x%lx, size 0x%lx\n",
|
||||
(t->pbs_flags & _BUS_SPACE_IO_TYPE) ? "port" : "mem",
|
||||
(unsigned long)bpa, (unsigned long)size);
|
||||
printf("memio_unmap: can't free region\n");
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
memio_alloc(bus_space_tag_t t, bus_addr_t rstart, bus_addr_t rend,
|
||||
bus_size_t size, bus_size_t alignment, bus_size_t boundary,
|
||||
int flags, bus_addr_t *bpap, bus_space_handle_t *bshp)
|
||||
{
|
||||
u_long bpa;
|
||||
int error;
|
||||
|
||||
if (rstart + size > t->pbs_limit)
|
||||
return (EINVAL);
|
||||
|
||||
/*
|
||||
* Can't map I/O space as linear.
|
||||
*/
|
||||
if ((flags & BUS_SPACE_MAP_LINEAR) &&
|
||||
(t->pbs_flags & _BUS_SPACE_IO_TYPE))
|
||||
return (EOPNOTSUPP);
|
||||
|
||||
if (rstart < t->pbs_extent->ex_start || rend > t->pbs_extent->ex_end)
|
||||
panic("memio_alloc: bad region start/end");
|
||||
|
||||
error = extent_alloc_subregion(t->pbs_extent, rstart, rend, size,
|
||||
alignment, boundary, EX_FAST | EX_NOWAIT | extent_flags, &bpa);
|
||||
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
*bpap = bpa;
|
||||
*bshp = t->pbs_offset + bpa;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
memio_free(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size)
|
||||
{
|
||||
/* memio_unmap() does all that we need to do. */
|
||||
memio_unmap(t, bsh, size);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: locore.S,v 1.6 2003/02/03 17:10:14 matt Exp $ */
|
||||
/* $NetBSD: locore.S,v 1.7 2003/03/18 16:40:25 matt Exp $ */
|
||||
/* $OpenBSD: locore.S,v 1.4 1997/01/26 09:06:38 rahnds Exp $ */
|
||||
|
||||
/*
|
||||
@ -172,3 +172,8 @@ _C_LABEL(sandpoint_reboot):
|
||||
* Include common trap / execption code
|
||||
*/
|
||||
#include <powerpc/powerpc/trap_subr.S>
|
||||
|
||||
/*
|
||||
* Include common pio / bus_space code
|
||||
*/
|
||||
#include <powerpc/powerpc/pio_subr.S>
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: machdep.c,v 1.24 2003/02/03 17:10:14 matt Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.25 2003/03/18 16:40:25 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
@ -44,6 +44,7 @@
|
||||
#include <sys/conf.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/exec.h>
|
||||
#include <sys/extent.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mbuf.h>
|
||||
@ -123,8 +124,9 @@ void lcsplx __P((int));
|
||||
#ifdef DDB
|
||||
extern void *startsym, *endsym;
|
||||
#endif
|
||||
extern void consinit (void);
|
||||
extern void ext_intr (void);
|
||||
void consinit(void);
|
||||
void ext_intr(void);
|
||||
void sandpoint_bus_space_init(void);
|
||||
|
||||
void
|
||||
initppc(u_int startkernel, u_int endkernel, u_int args, void *btinfo)
|
||||
@ -252,7 +254,7 @@ cpu_startup(void)
|
||||
/*
|
||||
* Now that we have VM, malloc()s are OK in bus_space.
|
||||
*/
|
||||
sandpoint_bus_space_mallocok();
|
||||
bus_space_mallocok();
|
||||
|
||||
/*
|
||||
* Now allow hardware interrupts.
|
||||
@ -374,3 +376,57 @@ lcsplx(int ipl)
|
||||
{
|
||||
splx(ipl);
|
||||
}
|
||||
|
||||
struct powerpc_bus_space sandpoint_io_bs_tag = {
|
||||
_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
|
||||
0xfe000000, 0x00000000, 0x00c00000,
|
||||
};
|
||||
struct powerpc_bus_space sandpoint_isa_io_bs_tag = {
|
||||
_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
|
||||
0xfe000000, 0x00000000, 0x00010000,
|
||||
};
|
||||
struct powerpc_bus_space sandpoint_mem_bs_tag = {
|
||||
_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
|
||||
0x00000000, 0x80000000, 0xfe000000,
|
||||
};
|
||||
struct powerpc_bus_space sandpoint_isa_mem_bs_tag = {
|
||||
_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
|
||||
0x00000000, 0xfd000000, 0xfe000000,
|
||||
};
|
||||
|
||||
static char ex_storage[2][EXTENT_FIXED_STORAGE_SIZE(8)]
|
||||
__attribute__((aligned(8)));
|
||||
|
||||
void
|
||||
sandpoint_bus_space_init(void)
|
||||
{
|
||||
int error;
|
||||
|
||||
error = bus_space_init(&sandpoint_io_bs_tag, "ioport",
|
||||
ex_storage[0], sizeof(ex_storage[0]));
|
||||
if (error)
|
||||
panic("sandpoint_bus_space_init: can't init ioport tag");
|
||||
|
||||
error = extent_alloc_region(sandpoint_io_bs_tag.pbs_extent,
|
||||
0x00010000, 0x7F0000, EX_NOWAIT);
|
||||
if (error)
|
||||
panic("sandpoint_bus_space_init: can't block out reserved"
|
||||
" I/O space 0x10000-0x7fffff: error=%d", error);
|
||||
|
||||
sandpoint_isa_io_bs_tag.pbs_extent = sandpoint_io_bs_tag.pbs_extent;
|
||||
error = bus_space_init(&sandpoint_isa_io_bs_tag, "isa-iomem",
|
||||
ex_storage[1], sizeof(ex_storage[1]));
|
||||
if (error)
|
||||
panic("sandpoint_bus_space_init: can't init isa iomem tag");
|
||||
|
||||
error = bus_space_init(&sandpoint_mem_bs_tag, "iomem",
|
||||
ex_storage[2], sizeof(ex_storage[2]));
|
||||
if (error)
|
||||
panic("sandpoint_bus_space_init: can't init iomem tag");
|
||||
|
||||
sandpoint_isa_mem_bs_tag.pbs_extent = sandpoint_mem_bs_tag.pbs_extent;
|
||||
error = bus_space_init(&sandpoint_isa_mem_bs_tag, "isa-iomem",
|
||||
ex_storage[3], sizeof(ex_storage[3]));
|
||||
if (error)
|
||||
panic("sandpoint_bus_space_init: can't init isa iomem tag");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user