Add basic platform support for NetBSD on the Avalon A12. I'm running this

CVS commit on one right now...
This commit is contained in:
ross 1998-01-29 21:42:50 +00:00
parent 683fada0e3
commit 12f93343cd
8 changed files with 1622 additions and 0 deletions

217
sys/arch/alpha/pci/a12c.c Normal file
View File

@ -0,0 +1,217 @@
/* $NetBSD: a12c.c,v 1.1 1998/01/29 21:42:50 ross Exp $ */
/* [Notice revision 2.0]
* Copyright (c) 1997 Avalon Computer Systems, Inc.
* All rights reserved.
*
* Author: Ross Harvey
*
* 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 and
* author 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. Neither the name of Avalon Computer Systems, Inc. nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
* 4. This copyright will be assigned to The NetBSD Foundation on
* 1/1/2000 unless these terms (including possibly the assignment
* date) are updated in writing by Avalon prior to the latest specified
* assignment date.
*
* THIS SOFTWARE IS PROVIDED BY AVALON COMPUTER SYSTEMS, 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 "opt_avalon_a12.h" /* Config options headers */
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: a12c.c,v 1.1 1998/01/29 21:42:50 ross Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/device.h>
#include <vm/vm.h>
#include <machine/autoconf.h>
#include <machine/rpb.h>
#include <dev/isa/isareg.h>
#include <dev/isa/isavar.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <alpha/pci/a12creg.h>
#include <alpha/pci/a12cvar.h>
#include <alpha/pci/pci_a12.h>
int a12cmatch __P((struct device *, struct cfdata *, void *));
void a12cattach __P((struct device *, struct device *, void *));
struct cfattach a12c_ca = {
sizeof(struct a12c_softc), a12cmatch, a12cattach,
};
extern struct cfdriver a12c_cd;
static int a12cprint __P((void *, const char *pnp));
static void hrh_noclock(void);
/* There can be only one. */
int a12cfound;
struct a12c_config a12c_configuration;
int
a12cmatch(parent, match, aux)
struct device *parent;
struct cfdata *match;
void *aux;
{
struct confargs *ca = aux;
/* Make sure that we're looking for an A12C. */
if (strcmp(ca->ca_name, a12c_cd.cd_name) != 0)
return (0);
if (a12cfound)
return (0);
return (1);
}
/*
* Set up the chipset's function pointers.
*/
void
a12c_init(ccp, mallocsafe)
struct a12c_config *ccp;
int mallocsafe;
{
if (!ccp->ac_initted) {
/* someday these may allocate memory, do once only */
ccp->ac_iot = 0;
ccp->ac_memt = a12c_bus_mem_init(ccp);
}
ccp->ac_mallocsafe = mallocsafe;
a12c_pci_init(&ccp->ac_pc, ccp);
a12c_dma_init(ccp);
ccp->ac_initted = 1;
}
void
a12cattach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct a12c_softc *sc = (struct a12c_softc *)self;
struct a12c_config *ccp;
struct pcibus_attach_args pba;
/* note that we've attached the chipset; can't have 2 A12Cs. */
a12cfound = 1;
/*
* set up the chipset's info; done once at console init time
* (maybe), but we must do it here as well to take care of things
* that need to use memory allocation.
*/
ccp = sc->sc_ccp = &a12c_configuration;
a12c_init(ccp, 1);
/* XXX print chipset information */
printf("\n");
switch (hwrpb->rpb_type) {
#ifdef AVALON_A12
case ST_AVALON_A12:
pci_a12_pickintr(ccp);
#ifdef EVCNT_COUNTERS
evcnt_attach(self, "intr", &a12_intr_evcnt);
#endif
break;
#endif
default:
panic("a12cattach: shouldn't be here, really...");
}
pba.pba_busname = "pci";
pba.pba_iot = 0;
pba.pba_memt = ccp->ac_memt;
pba.pba_dmat = &ccp->ac_dmat_direct;
pba.pba_pc = &ccp->ac_pc;
pba.pba_bus = 0;
pba.pba_flags = PCI_FLAGS_MEM_ENABLED;
config_found(self, &pba, a12cprint);
hrh_noclock();
}
static int
a12cprint(aux, pnp)
void *aux;
const char *pnp;
{
register struct pcibus_attach_args *pba = aux;
/* can attach xbar or pci to a12c */
if (pnp)
printf("%s at %s", pba->pba_busname, pnp);
printf(" bus %d", pba->pba_bus);
return (UNCONF);
}
#include <dev/dec/clockvar.h>
static const struct clocktime zeroct;
static void noclock_init(struct device *);
static void noclock_get(struct device *, time_t, struct clocktime *);
static void noclock_set(struct device *, struct clocktime *);
static void noclock_init(struct device *dev) {
dev = dev;
}
static void noclock_get(struct device *dev, time_t t, struct clocktime *ct)
{
*ct = zeroct;
}
static void noclock_set(struct device *dev, struct clocktime *ct)
{
if(dev!=NULL)
*ct = *ct;
}
static const struct clockfns noclock_fns = {
noclock_init, noclock_get, noclock_set
};
static void
hrh_noclock(void) {
extern const struct clockfns *clockfns;
clockfns = &noclock_fns;
}

View File

@ -0,0 +1,521 @@
/* $NetBSD: a12c_bus_mem.c,v 1.1 1998/01/29 21:42:51 ross Exp $ */
/* [Notice revision 2.0]
* Copyright (c) 1997 Avalon Computer Systems, Inc.
* All rights reserved.
*
* Author: Ross Harvey
*
* 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 and
* author 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. Neither the name of Avalon Computer Systems, Inc. nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
* 4. This copyright will be assigned to The NetBSD Foundation on
* 1/1/2000 unless these terms (including possibly the assignment
* date) are updated in writing by Avalon prior to the latest specified
* assignment date.
*
* THIS SOFTWARE IS PROVIDED BY AVALON COMPUTER SYSTEMS, 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 "opt_avalon_a12.h" /* Config options headers */
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <machine/bus.h>
#include <alpha/pci/a12creg.h>
#include <alpha/pci/a12cvar.h>
__KERNEL_RCSID(0, "$NetBSD: a12c_bus_mem.c,v 1.1 1998/01/29 21:42:51 ross Exp $");
/* Memory barrier */
void pci_a12c_mem_barrier __P((void *, bus_space_handle_t,
bus_size_t, bus_size_t, int));
/* Memory read (single) */
u_int8_t pci_a12c_mem_read_1 __P((void *, bus_space_handle_t,
bus_size_t));
u_int16_t pci_a12c_mem_read_2 __P((void *, bus_space_handle_t,
bus_size_t));
u_int32_t pci_a12c_mem_read_4 __P((void *, bus_space_handle_t,
bus_size_t));
u_int64_t pci_a12c_mem_read_8 __P((void *, bus_space_handle_t,
bus_size_t));
/* Memory read multiple */
void pci_a12c_mem_read_multi_1 __P((void *, bus_space_handle_t,
bus_size_t, u_int8_t *, bus_size_t));
void pci_a12c_mem_read_multi_2 __P((void *, bus_space_handle_t,
bus_size_t, u_int16_t *, bus_size_t));
void pci_a12c_mem_read_multi_4 __P((void *, bus_space_handle_t,
bus_size_t, u_int32_t *, bus_size_t));
void pci_a12c_mem_read_multi_8 __P((void *, bus_space_handle_t,
bus_size_t, u_int64_t *, bus_size_t));
/* Memory read region */
void pci_a12c_mem_read_region_1 __P((void *, bus_space_handle_t,
bus_size_t, u_int8_t *, bus_size_t));
void pci_a12c_mem_read_region_2 __P((void *, bus_space_handle_t,
bus_size_t, u_int16_t *, bus_size_t));
void pci_a12c_mem_read_region_4 __P((void *, bus_space_handle_t,
bus_size_t, u_int32_t *, bus_size_t));
void pci_a12c_mem_read_region_8 __P((void *, bus_space_handle_t,
bus_size_t, u_int64_t *, bus_size_t));
/* Memory write (single) */
void pci_a12c_mem_write_1 __P((void *, bus_space_handle_t,
bus_size_t, u_int8_t));
void pci_a12c_mem_write_2 __P((void *, bus_space_handle_t,
bus_size_t, u_int16_t));
void pci_a12c_mem_write_4 __P((void *, bus_space_handle_t,
bus_size_t, u_int32_t));
void pci_a12c_mem_write_8 __P((void *, bus_space_handle_t,
bus_size_t, u_int64_t));
/* Memory write multiple */
void pci_a12c_mem_write_multi_1 __P((void *, bus_space_handle_t,
bus_size_t, const u_int8_t *, bus_size_t));
void pci_a12c_mem_write_multi_2 __P((void *, bus_space_handle_t,
bus_size_t, const u_int16_t *, bus_size_t));
void pci_a12c_mem_write_multi_4 __P((void *, bus_space_handle_t,
bus_size_t, const u_int32_t *, bus_size_t));
void pci_a12c_mem_write_multi_8 __P((void *, bus_space_handle_t,
bus_size_t, const u_int64_t *, bus_size_t));
/* Memory write region */
void pci_a12c_mem_write_region_1 __P((void *, bus_space_handle_t,
bus_size_t, const u_int8_t *, bus_size_t));
void pci_a12c_mem_write_region_2 __P((void *, bus_space_handle_t,
bus_size_t, const u_int16_t *, bus_size_t));
void pci_a12c_mem_write_region_4 __P((void *, bus_space_handle_t,
bus_size_t, const u_int32_t *, bus_size_t));
void pci_a12c_mem_write_region_8 __P((void *, bus_space_handle_t,
bus_size_t, const u_int64_t *, bus_size_t));
/* Memory set multiple */
void pci_a12c_mem_set_multi_1 __P((void *, bus_space_handle_t,
bus_size_t, u_int8_t, bus_size_t));
void pci_a12c_mem_set_multi_2 __P((void *, bus_space_handle_t,
bus_size_t, u_int16_t, bus_size_t));
void pci_a12c_mem_set_multi_4 __P((void *, bus_space_handle_t,
bus_size_t, u_int32_t, bus_size_t));
void pci_a12c_mem_set_multi_8 __P((void *, bus_space_handle_t,
bus_size_t, u_int64_t, bus_size_t));
/* Memory set region */
void pci_a12c_mem_set_region_1 __P((void *, bus_space_handle_t,
bus_size_t, u_int8_t, bus_size_t));
void pci_a12c_mem_set_region_2 __P((void *, bus_space_handle_t,
bus_size_t, u_int16_t, bus_size_t));
void pci_a12c_mem_set_region_4 __P((void *, bus_space_handle_t,
bus_size_t, u_int32_t, bus_size_t));
void pci_a12c_mem_set_region_8 __P((void *, bus_space_handle_t,
bus_size_t, u_int64_t, bus_size_t));
/* Memory copy */
void pci_a12c_mem_copy_region_1 __P((void *, bus_space_handle_t,
bus_size_t, bus_space_handle_t, bus_size_t, bus_size_t));
void pci_a12c_mem_copy_region_2 __P((void *, bus_space_handle_t,
bus_size_t, bus_space_handle_t, bus_size_t, bus_size_t));
void pci_a12c_mem_copy_region_4 __P((void *, bus_space_handle_t,
bus_size_t, bus_space_handle_t, bus_size_t, bus_size_t));
void pci_a12c_mem_copy_region_8 __P((void *, bus_space_handle_t,
bus_size_t, bus_space_handle_t, bus_size_t, bus_size_t));
#define __S(S) __STRING(S)
/* mapping/unmapping */
int pci_a12c_mem_map __P((void *, bus_addr_t, bus_size_t, int,
bus_space_handle_t *));
void pci_a12c_mem_unmap __P((void *, bus_space_handle_t,
bus_size_t));
int pci_a12c_mem_subregion __P((void *, bus_space_handle_t,
bus_size_t, bus_size_t, bus_space_handle_t *));
/* allocation/deallocation */
int pci_a12c_mem_alloc __P((void *, bus_addr_t, bus_addr_t,
bus_size_t, bus_size_t, bus_addr_t, int, bus_addr_t *,
bus_space_handle_t *));
void pci_a12c_mem_free __P((void *, bus_space_handle_t,
bus_size_t));
static struct alpha_bus_space pci_a12c_mem_space = {
/* cookie */
NULL,
/* mapping/unmapping */
pci_a12c_mem_map,
pci_a12c_mem_unmap,
pci_a12c_mem_subregion,
/* allocation/deallocation */
pci_a12c_mem_alloc,
pci_a12c_mem_free,
/* barrier */
pci_a12c_mem_barrier,
/* read (single) */
pci_a12c_mem_read_1,
pci_a12c_mem_read_2,
pci_a12c_mem_read_4,
pci_a12c_mem_read_8,
/* read multiple */
pci_a12c_mem_read_multi_1,
pci_a12c_mem_read_multi_2,
pci_a12c_mem_read_multi_4,
pci_a12c_mem_read_multi_8,
/* read region */
pci_a12c_mem_read_region_1,
pci_a12c_mem_read_region_2,
pci_a12c_mem_read_region_4,
pci_a12c_mem_read_region_8,
/* write (single) */
pci_a12c_mem_write_1,
pci_a12c_mem_write_2,
pci_a12c_mem_write_4,
pci_a12c_mem_write_8,
/* write multiple */
pci_a12c_mem_write_multi_1,
pci_a12c_mem_write_multi_2,
pci_a12c_mem_write_multi_4,
pci_a12c_mem_write_multi_8,
/* write region */
pci_a12c_mem_write_region_1,
pci_a12c_mem_write_region_2,
pci_a12c_mem_write_region_4,
pci_a12c_mem_write_region_8,
/* set multiple */
pci_a12c_mem_set_multi_1,
pci_a12c_mem_set_multi_2,
pci_a12c_mem_set_multi_4,
pci_a12c_mem_set_multi_8,
/* set region */
pci_a12c_mem_set_region_1,
pci_a12c_mem_set_region_2,
pci_a12c_mem_set_region_4,
pci_a12c_mem_set_region_8,
/* copy */
pci_a12c_mem_copy_region_1,
pci_a12c_mem_copy_region_2,
pci_a12c_mem_copy_region_4,
pci_a12c_mem_copy_region_8,
};
bus_space_tag_t
a12c_bus_mem_init(v)
void *v;
{
bus_space_tag_t t;
t = &pci_a12c_mem_space;
t->abs_cookie = v;
return (t);
}
int
pci_a12c_mem_map(v, memaddr, memsize, flags, memhp)
void *v;
bus_addr_t memaddr;
bus_size_t memsize;
int flags;
bus_space_handle_t *memhp;
{
if(flags & BUS_SPACE_MAP_LINEAR)
printf("warning, linear a12 pci map requested\n");
if(memaddr >= 1L<<28 || memaddr<0)
return -1;
*memhp = memaddr;
return 0;
}
void
pci_a12c_mem_unmap(v, memh, memsize)
void *v;
bus_space_handle_t memh;
bus_size_t memsize;
{
}
int
pci_a12c_mem_subregion(v, memh, offset, size, nmemh)
void *v;
bus_space_handle_t memh, *nmemh;
bus_size_t offset, size;
{
*nmemh = memh + offset;
return 0;
}
int
pci_a12c_mem_alloc(v, rstart, rend, size, align, boundary, flags,
addrp, bshp)
void *v;
bus_addr_t rstart, rend, *addrp;
bus_size_t size, align, boundary;
int flags;
bus_space_handle_t *bshp;
{
return -1;
}
void
pci_a12c_mem_free(v, bsh, size)
void *v;
bus_space_handle_t bsh;
bus_size_t size;
{
}
void
pci_a12c_mem_barrier(v, h, o, l, f)
void *v;
bus_space_handle_t h;
bus_size_t o, l;
int f;
{
/* optimize for wmb-only case but fall back to the more general mb */
if (f == BUS_SPACE_BARRIER_WRITE)
alpha_wmb();
else alpha_mb();
}
/*
* Don't worry about calling small subroutines on the alpha. In the
* time it takes to do a PCI bus target transfer, the 21164-400 can execute
* 160 cycles, and up to 320 integer instructions.
*/
static void *
setup_target_transfer(bus_space_handle_t memh, bus_size_t off)
{
register u_int64_t addr,t;
alpha_mb();
addr = memh + off;
t = REGVAL(A12_OMR) & ~A12_PCIAddr2;
if (addr & 4)
t |= A12_PCIAddr2;
REGVAL(A12_OMR) = t;
alpha_mb();
return (void *)ALPHA_PHYS_TO_K0SEG(A12_PCITarget | (addr & ~4L));
}
#define TARGET_EA(t,memh,off) ((t *)setup_target_transfer((memh),(off)))
#define TARGET_READ(n,t) \
\
t \
__CONCAT(pci_a12c_mem_read_,n)(void *v, \
bus_space_handle_t memh, \
bus_size_t off) \
{ \
return *TARGET_EA(t,memh,off); \
}
TARGET_READ(1, u_int8_t)
TARGET_READ(2, u_int16_t)
TARGET_READ(4, u_int32_t)
TARGET_READ(8, u_int64_t)
#define pci_a12c_mem_read_multi_N(BYTES,TYPE) \
void \
__CONCAT(pci_a12c_mem_read_multi_,BYTES)(v, h, o, a, c) \
void *v; \
bus_space_handle_t h; \
bus_size_t o, c; \
TYPE *a; \
{ \
\
while (c-- > 0) { \
alpha_mb(); \
*a++ = __CONCAT(pci_a12c_mem_read_,BYTES)(v, h, o); \
} \
}
pci_a12c_mem_read_multi_N(1,u_int8_t)
pci_a12c_mem_read_multi_N(2,u_int16_t)
pci_a12c_mem_read_multi_N(4,u_int32_t)
pci_a12c_mem_read_multi_N(8,u_int64_t)
/*
* In this case, we _really_ don't want all those barriers that the
* bus_space_read's once did, and that we have carried over into
* the A12 version. Perhaps we need a gratuitous barrier-on mode.
* The only reason to have the bus_space_r/w functions do barriers is
* to make up for call sites that incorrectly omit the bus_space_barrier
* calls.
*/
#define pci_a12c_mem_read_region_N(BYTES,TYPE) \
void \
__CONCAT(pci_a12c_mem_read_region_,BYTES)(v, h, o, a, c) \
void *v; \
bus_space_handle_t h; \
bus_size_t o, c; \
TYPE *a; \
{ \
\
while (c-- > 0) { \
*a++ = __CONCAT(pci_a12c_mem_read_,BYTES)(v, h, o); \
o += sizeof *a; \
} \
}
pci_a12c_mem_read_region_N(1,u_int8_t)
pci_a12c_mem_read_region_N(2,u_int16_t)
pci_a12c_mem_read_region_N(4,u_int32_t)
pci_a12c_mem_read_region_N(8,u_int64_t)
#define TARGET_WRITE(n,t) \
void \
__CONCAT(pci_a12c_mem_write_,n)(v, memh, off, val) \
void *v; \
bus_space_handle_t memh; \
bus_size_t off; \
t val; \
{ \
alpha_wmb(); \
*TARGET_EA(t,memh,off) = val; \
alpha_wmb(); \
}
TARGET_WRITE(1,u_int8_t)
TARGET_WRITE(2,u_int16_t)
TARGET_WRITE(4,u_int32_t)
TARGET_WRITE(8,u_int64_t)
#define pci_a12c_mem_write_multi_N(BYTES,TYPE) \
void \
__CONCAT(pci_a12c_mem_write_multi_,BYTES)(v, h, o, a, c) \
void *v; \
bus_space_handle_t h; \
bus_size_t o, c; \
const TYPE *a; \
{ \
\
while (c-- > 0) { \
__CONCAT(pci_a12c_mem_write_,BYTES)(v, h, o, *a++); \
alpha_wmb(); \
} \
}
pci_a12c_mem_write_multi_N(1,u_int8_t)
pci_a12c_mem_write_multi_N(2,u_int16_t)
pci_a12c_mem_write_multi_N(4,u_int32_t)
pci_a12c_mem_write_multi_N(8,u_int64_t)
#define pci_a12c_mem_write_region_N(BYTES,TYPE) \
void \
__CONCAT(pci_a12c_mem_write_region_,BYTES)(v, h, o, a, c) \
void *v; \
bus_space_handle_t h; \
bus_size_t o, c; \
const TYPE *a; \
{ \
\
while (c-- > 0) { \
__CONCAT(pci_a12c_mem_write_,BYTES)(v, h, o, *a++); \
o += sizeof *a; \
} \
}
pci_a12c_mem_write_region_N(1,u_int8_t)
pci_a12c_mem_write_region_N(2,u_int16_t)
pci_a12c_mem_write_region_N(4,u_int32_t)
pci_a12c_mem_write_region_N(8,u_int64_t)
#define pci_a12c_mem_set_multi_N(BYTES,TYPE) \
void \
__CONCAT(pci_a12c_mem_set_multi_,BYTES)(v, h, o, val, c) \
void *v; \
bus_space_handle_t h; \
bus_size_t o, c; \
TYPE val; \
{ \
\
while (c-- > 0) { \
__CONCAT(pci_a12c_mem_write_,BYTES)(v, h, o, val); \
alpha_wmb(); \
} \
}
pci_a12c_mem_set_multi_N(1,u_int8_t)
pci_a12c_mem_set_multi_N(2,u_int16_t)
pci_a12c_mem_set_multi_N(4,u_int32_t)
pci_a12c_mem_set_multi_N(8,u_int64_t)
#define pci_a12c_mem_set_region_N(BYTES,TYPE) \
void \
__CONCAT(pci_a12c_mem_set_region_,BYTES)(v, h, o, val, c) \
void *v; \
bus_space_handle_t h; \
bus_size_t o, c; \
TYPE val; \
{ \
\
while (c-- > 0) { \
__CONCAT(pci_a12c_mem_write_,BYTES)(v, h, o, val); \
o += sizeof val; \
} \
}
pci_a12c_mem_set_region_N(1,u_int8_t)
pci_a12c_mem_set_region_N(2,u_int16_t)
pci_a12c_mem_set_region_N(4,u_int32_t)
pci_a12c_mem_set_region_N(8,u_int64_t)
#define pci_a12c_mem_copy_region_N(BYTES) \
void \
__CONCAT(pci_a12c_mem_copy_region_,BYTES)(v, h1, o1, h2, o2, c) \
void *v; \
bus_space_handle_t h1, h2; \
bus_size_t o1, o2, c; \
{ \
bus_size_t o; \
\
if ((h1 >> 63) != 0 && (h2 >> 63) != 0) { \
ovbcopy((void *)(h1 + o1), (void *)(h2 + o2), c * BYTES); \
return; \
} \
\
if (h1 + o1 >= h2 + o2) \
/* src after dest: copy forward */ \
for (o = 0; c > 0; c--, o += BYTES) \
__CONCAT(pci_a12c_mem_write_,BYTES)(v, h2, o2 + o, \
__CONCAT(pci_a12c_mem_read_,BYTES)(v, h1, o1 + o)); \
else \
/* dest after src: copy backwards */ \
for (o = (c - 1) * BYTES; c > 0; c--, o -= BYTES) \
__CONCAT(pci_a12c_mem_write_,BYTES)(v, h2, o2 + o, \
__CONCAT(pci_a12c_mem_read_,BYTES)(v, h1, o1 + o)); \
}
pci_a12c_mem_copy_region_N(1)
pci_a12c_mem_copy_region_N(2)
pci_a12c_mem_copy_region_N(4)
pci_a12c_mem_copy_region_N(8)

View File

@ -0,0 +1,174 @@
/* $NetBSD: a12c_dma.c,v 1.1 1998/01/29 21:42:51 ross Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* 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.
*/
/*
* Stub version -- drivers used on the A12 (primarily ade) were adapted
* for NetBSD prior to the availability of bus_dma.
* They employ ad-hoc support for the required sram
* bounce buffers and are not in the NetBSD source
* tree. When a bus_dma if_de is available, this
* module will need to be completed! I certainly
* would not mind committing if_ade, but it doesn't
* have any lasting value.
*/
#include "opt_avalon_a12.h" /* Config options headers */
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: a12c_dma.c,v 1.1 1998/01/29 21:42:51 ross Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
#include <sys/malloc.h>
#include <vm/vm.h>
#define _ALPHA_BUS_DMA_PRIVATE
#include <machine/bus.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <alpha/pci/a12creg.h>
#include <alpha/pci/a12cvar.h>
bus_dma_tag_t a12c_dma_get_tag __P((bus_dma_tag_t, alpha_bus_t));
int a12c_bus_dmamap_load_direct __P((bus_dma_tag_t, bus_dmamap_t, void *,
bus_size_t, struct proc *, int));
int a12c_bus_dmamap_load_mbuf_direct __P((bus_dma_tag_t, bus_dmamap_t,
struct mbuf *, int));
int a12c_bus_dmamap_load_uio_direct __P((bus_dma_tag_t, bus_dmamap_t,
struct uio *, int));
int a12c_bus_dmamap_load_raw_direct __P((bus_dma_tag_t, bus_dmamap_t,
bus_dma_segment_t *, int, bus_size_t, int));
void
a12c_dma_init(ccp)
struct a12c_config *ccp;
{
}
/*
* Return the bus dma tag to be used for the specified bus type.
* INTERNAL USE ONLY!
*/
bus_dma_tag_t
a12c_dma_get_tag(t, bustype)
bus_dma_tag_t t;
alpha_bus_t bustype;
{
DIE();
}
/*
* Load a A12C direct-mapped DMA map with a linear buffer.
*/
int
a12c_bus_dmamap_load_direct(t, map, buf, buflen, p, flags)
bus_dma_tag_t t;
bus_dmamap_t map;
void *buf;
bus_size_t buflen;
struct proc *p;
int flags;
{
DIE();
#if 0
return (_bus_dmamap_load_direct_common(t, map, buf, buflen, p,
flags, A12C_DIRECT_MAPPED_BASE));
#endif
}
/*
* Load a A12C direct-mapped DMA map with an mbuf chain.
*/
int
a12c_bus_dmamap_load_mbuf_direct(t, map, m, flags)
bus_dma_tag_t t;
bus_dmamap_t map;
struct mbuf *m;
int flags;
{
DIE();
#if 0
return (_bus_dmamap_load_mbuf_direct_common(t, map, m,
flags, A12C_DIRECT_MAPPED_BASE));
#endif
}
/*
* Load a A12C direct-mapped DMA map with a uio.
*/
int
a12c_bus_dmamap_load_uio_direct(t, map, uio, flags)
bus_dma_tag_t t;
bus_dmamap_t map;
struct uio *uio;
int flags;
{
DIE();
#if 0
return (_bus_dmamap_load_uio_direct_common(t, map, uio,
flags, A12C_DIRECT_MAPPED_BASE));
#endif
}
/*
* Load a A12C direct-mapped DMA map with raw memory.
*/
int
a12c_bus_dmamap_load_raw_direct(t, map, segs, nsegs, size, flags)
bus_dma_tag_t t;
bus_dmamap_t map;
bus_dma_segment_t *segs;
int nsegs;
bus_size_t size;
int flags;
{
DIE();
#if 0
return (_bus_dmamap_load_raw_direct_common(t, map, segs, nsegs,
size, flags, A12C_DIRECT_MAPPED_BASE));
#endif
}

View File

@ -0,0 +1,226 @@
/* $NetBSD: a12c_pci.c,v 1.1 1998/01/29 21:42:52 ross Exp $ */
/* [Notice revision 2.0]
* Copyright (c) 1997 Avalon Computer Systems, Inc.
* All rights reserved.
*
* Author: Ross Harvey
*
* 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 and
* author 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. Neither the name of Avalon Computer Systems, Inc. nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
* 4. This copyright will be assigned to The NetBSD Foundation on
* 1/1/2000 unless these terms (including possibly the assignment
* date) are updated in writing by Avalon prior to the latest specified
* assignment date.
*
* THIS SOFTWARE IS PROVIDED BY AVALON COMPUTER SYSTEMS, 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 "opt_avalon_a12.h" /* Config options headers */
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: a12c_pci.c,v 1.1 1998/01/29 21:42:52 ross Exp $");
__KERNEL_COPYRIGHT(0,
"Copyright (c) 1997 Christopher G. Demetriou. All rights reserved.");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
#include <vm/vm.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <alpha/pci/a12creg.h>
#include <alpha/pci/a12cvar.h>
#include <machine/rpb.h> /* XXX for eb164 CIA firmware workarounds. */
void a12c_attach_hook __P((struct device *, struct device *,
struct pcibus_attach_args *));
int a12c_bus_maxdevs __P((void *, int));
pcitag_t a12c_make_tag __P((void *, int, int, int));
void a12c_decompose_tag __P((void *, pcitag_t, int *, int *,
int *));
pcireg_t a12c_conf_read __P((void *, pcitag_t, int));
void a12c_conf_write __P((void *, pcitag_t, int, pcireg_t));
void
a12c_pci_init(pc, v)
pci_chipset_tag_t pc;
void *v;
{
pc->pc_conf_v = v;
pc->pc_attach_hook = a12c_attach_hook;
pc->pc_bus_maxdevs = a12c_bus_maxdevs;
pc->pc_make_tag = a12c_make_tag;
pc->pc_decompose_tag = a12c_decompose_tag;
pc->pc_conf_read = a12c_conf_read;
pc->pc_conf_write = a12c_conf_write;
}
void
a12c_attach_hook(parent, self, pba)
struct device *parent, *self;
struct pcibus_attach_args *pba;
{
}
int
a12c_bus_maxdevs(cpv, busno)
void *cpv;
int busno;
{
return 1;
}
pcitag_t
a12c_make_tag(cpv, b, d, f)
void *cpv;
int b, d, f;
{
return (b << 16) | (d << 11) | (f << 8);
}
void
a12c_decompose_tag(cpv, tag, bp, dp, fp)
void *cpv;
pcitag_t tag;
int *bp, *dp, *fp;
{
if (bp != NULL)
*bp = (tag >> 16) & 0xff;
if (dp != NULL)
*dp = (tag >> 11) & 0x1f;
if (fp != NULL)
*fp = (tag >> 8) & 0x7;
}
static void
a12_clear_master_abort(void)
{
alpha_pal_draina();
alpha_mb();
REGVAL(A12_GSR) = REGVAL(A12_GSR) | A12_PCIMasterAbort;
alpha_mb();
}
static int
a12_check_for_master_abort(void)
{
alpha_pal_draina();
alpha_mb();
return (REGVAL(A12_GSR) & A12_PCIMasterAbort)!=0;
}
static int
a12_set_pci_config_cycle(int offset)
{
alpha_pal_draina();
alpha_mb();
REGVAL(A12_OMR) = REGVAL(A12_OMR)
| A12_PCIConfigCycle
| (offset & 4 ? A12_PCIAddr2 : 0);
alpha_mb();
return offset & ~4;
}
static void
a12_reset_pci_config_cycle(void)
{
alpha_pal_draina();
alpha_mb();
REGVAL(A12_OMR) = REGVAL(A12_OMR) & ~(A12_PCIConfigCycle|A12_PCIAddr2);
alpha_mb();
}
pcireg_t
a12c_conf_read(cpv, tag, offset)
void *cpv;
pcitag_t tag;
int offset;
{
pcireg_t *datap, data;
int s, ba;
int32_t old_haxr2; /* XXX */
s = 0; /* XXX gcc -Wuninitialized */
old_haxr2 = 0; /* XXX gcc -Wuninitialized */
if(tag)
return ~0;
s = splhigh();
a12_clear_master_abort();
offset = a12_set_pci_config_cycle(offset);
datap = (pcireg_t *)(ALPHA_PHYS_TO_K0SEG(A12_PCITarget+offset));
data = ~0L;
if(!(ba = badaddr(datap, sizeof *datap)))
data = *datap;
a12_reset_pci_config_cycle();
if(a12_check_for_master_abort())
data = ~0L;
splx(s);
#if 0
printf("a12c_conf_read: tag 0x%lx, reg 0x%lx -> %x @ %p%s\n", tag, offset,
data, datap, ba ? " (badaddr)" : "");
#endif
return data;
}
void
a12c_conf_write(cpv, tag, offset, data)
void *cpv;
pcitag_t tag;
int offset;
pcireg_t data;
{
pcireg_t *datap;
int s;
s = 0; /* XXX gcc -Wuninitialized */
if(tag) {
What();
return;
}
s = splhigh();
offset = a12_set_pci_config_cycle(offset);
datap = (pcireg_t *)(ALPHA_PHYS_TO_K0SEG(A12_PCITarget+offset));
*datap = data;
a12_reset_pci_config_cycle();
splx(s);
#if 0
printf("a12c_conf_write: tag 0x%lx, reg 0x%lx -> 0x%x @ %p\n", tag,
offset, data, datap);
#endif
}

View File

@ -0,0 +1,109 @@
/* $NetBSD: a12creg.h,v 1.1 1998/01/29 21:42:52 ross Exp $ */
/* [Notice revision 2.0]
* Copyright (c) 1997 Avalon Computer Systems, Inc.
* All rights reserved.
*
* Author: Ross Harvey
*
* 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 and
* author 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. Neither the name of Avalon Computer Systems, Inc. nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
* 4. This copyright will be assigned to The NetBSD Foundation on
* 1/1/2000 unless these terms (including possibly the assignment
* date) are updated in writing by Avalon prior to the latest specified
* assignment date.
*
* THIS SOFTWARE IS PROVIDED BY AVALON COMPUTER SYSTEMS, 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.
*/
#ifndef a12creg_h_INCLUDED
#define a12creg_h_INCLUDED
#define REGVAL(r) (*(volatile long *)ALPHA_PHYS_TO_K0SEG(r))
/*
* -- A d d r e s s L i n e --
*
* 39 36 29 28 27-13 12 .11 10 9 8-6 5 4 3
*
* IMALR 1 1 a a a-a a . a a a a-a 0 0
* IMALR_LB 1 1 a a a-a a . a a a a-a 0 1
* OMALR 1 1 a a a-a a . a a a a-a 1 0
* OMALR_LB 1 1 a a a-a a . a a a a-a 1 1
* MCRP 1 0 0 0 . 0 0 0 a-a a a a
* MCRP_LWE 1 0 0 0 . 0 0 1 0 1
* MCRP_LWO 1 0 0 0 . 0 1 0 1 1
* MCSR 1 0 0 1 . 0 0 1 1
* OMR 1 0 0 1 . 0 1 0 1
* GSR 1 0 0 1 . 0 1 1 1
* IETCR 1 0 0 1 . 1 0 0 1
* CDR 1 0 0 1 . 1 0 1 1
* PMEM 1 0 0 1 . 1 1 0 1
* SOR 1 0 0 1 . 1 1 1 1
* PCI Buffer 1 0 1 0 a-a a . a a a a a a
* PCI Target 1 0 1 1 a-a a . a a a a a a
* Main Memory 0 0 a a a-a a . a a a a a a
*
*
*/
#define _A12_IO 0x8000000000L
#define A12_OFFS_FIFO 0x0000
#define A12_OFFS_FIFO_LWE 0x0200
#define A12_OFFS_FIFO_LWO 0x0400
#define A12_OFFS_VERS 0x1010
#define A12_OFFS_MCSR 0x1210
#define A12_OFFS_OMR 0x1410
#define A12_OFFS_GSR 0x1610
#define A12_OFFS_IETCR 0x1810
#define A12_OFFS_CDR 0x1a10
#define A12_OFFS_PMEM 0x1c10
#define A12_OFFS_SOR 0x1e10
#define A12_FIFO (_A12_IO|A12_OFFS_FIFO)
#define A12_FIFO_LWE (_A12_IO|A12_OFFS_FIFO_LWE)
#define A12_FIFO_LWO (_A12_IO|A12_OFFS_FIFO_LWO)
#define A12_VERS (_A12_IO|A12_OFFS_VERS)
#define A12_MCSR (_A12_IO|A12_OFFS_MCSR)
#define A12_OMR (_A12_IO|A12_OFFS_OMR)
#define A12_GSR (_A12_IO|A12_OFFS_GSR)
#define A12_IETCR (_A12_IO|A12_OFFS_IETCR)
#define A12_CDR (_A12_IO|A12_OFFS_CDR)
#define A12_PMEM (_A12_IO|A12_OFFS_PMEM)
#define A12_SOR (_A12_IO|A12_OFFS_SOR)
#define A12_PCIBuffer 0x8020000000L
#define A12_PCITarget 0x8030000000L
#define A12_PCIMasterAbort 0x8000 /* GSR */
#define A12_PCIAddr2 0x1000 /* OMR */
#define A12_PCIConfigCycle 0x800 /* OMR */
#define A12_CBMAOFFSET 0x100
#define A12_XBAR_CHANNEL_MAX 14
#define A12_TMP_PID_COUNT 12
#endif /* a12creg_h_INCLUDED */
#define DIE() do { printf("Nice try file=%s line=%d\n", \
__FILE__, __LINE__); panic("Nice try."); } while(0)
#define What() printf("%s: line %d. What?\n", __FILE__, __LINE__)

View File

@ -0,0 +1,72 @@
/* $NetBSD: a12cvar.h,v 1.1 1998/01/29 21:42:53 ross Exp $ */
/* [Notice revision 2.0]
* Copyright (c) 1997 Avalon Computer Systems, Inc.
* All rights reserved.
*
* Author: Ross Harvey
*
* 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 and
* author 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. Neither the name of Avalon Computer Systems, Inc. nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
* 4. This copyright will be assigned to The NetBSD Foundation on
* 1/1/2000 unless these terms (including possibly the assignment
* date) are updated in writing by Avalon prior to the latest specified
* assignment date.
*
* THIS SOFTWARE IS PROVIDED BY AVALON COMPUTER SYSTEMS, 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 <dev/isa/isavar.h>
#include <dev/pci/pcivar.h>
#include <alpha/pci/pci_sgmap_pte64.h>
/*
* A12 Core Logic -a12c- configuration.
*/
struct a12c_config {
int ac_initted;
bus_space_tag_t ac_iot, ac_memt;
struct alpha_pci_chipset ac_pc;
struct alpha_bus_dma_tag ac_dmat_direct;
struct alpha_bus_dma_tag ac_dmat_sgmap;
struct alpha_sgmap ac_sgmap;
u_int32_t ac_hae_mem;
u_int32_t ac_hae_io;
struct extent *ac_io_ex, *ac_d_mem_ex, *ac_s_mem_ex;
int ac_mallocsafe;
};
struct a12c_softc {
struct device sc_dev;
struct a12c_config *sc_ccp;
};
void a12c_init __P((struct a12c_config *, int));
void a12c_pci_init __P((pci_chipset_tag_t, void *));
void a12c_dma_init __P((struct a12c_config *));
bus_space_tag_t a12c_bus_io_init __P((void *));
bus_space_tag_t a12c_bus_mem_init __P((void *));

View File

@ -0,0 +1,261 @@
/* $NetBSD: pci_a12.c,v 1.1 1998/01/29 21:42:53 ross Exp $ */
/* [Notice revision 2.0]
* Copyright (c) 1997 Avalon Computer Systems, Inc.
* All rights reserved.
*
* Author: Ross Harvey
*
* 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 and
* author 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. Neither the name of Avalon Computer Systems, Inc. nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
* 4. This copyright will be assigned to The NetBSD Foundation on
* 1/1/2000 unless these terms (including possibly the assignment
* date) are updated in writing by Avalon prior to the latest specified
* assignment date.
*
* THIS SOFTWARE IS PROVIDED BY AVALON COMPUTER SYSTEMS, 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 "opt_avalon_a12.h" /* Config options headers */
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: pci_a12.c,v 1.1 1998/01/29 21:42:53 ross Exp $");
#include <sys/types.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/malloc.h>
#include <sys/device.h>
#include <sys/syslog.h>
#include <vm/vm.h>
#include <machine/autoconf.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <alpha/pci/a12creg.h>
#include <alpha/pci/a12cvar.h>
#include <alpha/pci/pci_a12.h>
#ifndef EVCNT_COUNTERS
#include <machine/intrcnt.h>
#endif
int avalon_a12_intr_map __P((void *, pcitag_t, int, int,
pci_intr_handle_t *));
const char *avalon_a12_intr_string __P((void *, pci_intr_handle_t));
void *avalon_a12_intr_establish __P((void *, pci_intr_handle_t,
int, int (*func)(void *), void *));
void avalon_a12_intr_disestablish __P((void *, void *));
static void clear_gsr_interrupt __P((long));
static void a12_pci_icall __P((int));
static void pci_serr __P((int));
static void a12_xbar_flag __P((int));
static void a12_interval __P((int));
static void a12_check_cdr __P((int));
#ifdef EVCNT_COUNTERS
struct evcnt a12_intr_evcnt;
#endif
static int (*a12_established_device) __P((void *));
static void *ih_arg;
void a12_iointr __P((void *framep, unsigned long vec));
void
pci_a12_pickintr(ccp)
struct a12c_config *ccp;
{
pci_chipset_tag_t pc = &ccp->ac_pc;
pc->pc_intr_v = ccp;
pc->pc_intr_map = avalon_a12_intr_map;
pc->pc_intr_string = avalon_a12_intr_string;
pc->pc_intr_establish = avalon_a12_intr_establish;
pc->pc_intr_disestablish = avalon_a12_intr_disestablish;
set_iointr(a12_iointr);
}
int
avalon_a12_intr_map(ccv, bustag, buspin, line, ihp)
void *ccv;
pcitag_t bustag;
int buspin, line;
pci_intr_handle_t *ihp;
{
/* only one PCI slot (per CPU, that is, but there are 12 CPU's!) */
*ihp = 0;
return 0;
}
const char *
avalon_a12_intr_string(ccv, ih)
void *ccv;
pci_intr_handle_t ih;
{
return "a12 pci irq"; /* see "only one" note above */
}
void *
avalon_a12_intr_establish(ccv, ih, level, func, arg)
void *ccv, *arg;
pci_intr_handle_t ih;
int level;
int (*func) __P((void *));
{
if(a12_established_device)
panic("avalon_a12_intr_establish");
a12_established_device = func;
ih_arg = arg;
REGVAL(A12_OMR) |= 1<<7;
return (void *)func;
}
void
avalon_a12_intr_disestablish(ccv, cookie)
void *ccv, *cookie;
{
if(cookie==a12_established_device)
a12_established_device = 0;
else What();
}
long a12_nothing;
static void
clear_gsr_interrupt(write_1_to_clear)
long write_1_to_clear;
{
REGVAL(A12_GSR) = write_1_to_clear;
alpha_mb();
a12_nothing = REGVAL(A12_GSR);
}
static void a12_pci_icall(i)
{
if(a12_established_device) {
(*a12_established_device)(ih_arg);
return;
}
printf("PCI irq rcvd, but no handler established.\n");
}
static void pci_serr(i) { panic("pci_serr"); }
static void a12_xbar_flag(i) { panic("a12_xbar_flag"); }
static void a12_interval(i) { panic("a12_interval"); }
static void a12_check_cdr(i)
{
}
static struct gintcall {
char flag;
char needsclear;
char intr_index; /* XXX implicit crossref */
void (*f)(int);
} gintcall[] = {
{ 6, 0, 2, a12_pci_icall },
{ 7, 1, 3, pci_serr },
{ 8, 1, 4, a12_xbar_flag },
{ 9, 1, 5, a12_xbar_flag },
/* skip 10, gsr.TEI */
{ 11, 1, 6, a12_interval },
{ 12, 1, 7, a12_xbar_flag },
{ 13, 1, 8, a12_xbar_flag },
{ 14, 1, 9, a12_check_cdr },
{ 0 }
};
static void a12_GInt(void);
static void a12_GInt(void)
{
struct gintcall *gic;
long gsrvalue = REGVAL(A12_GSR) & 0x7fc0;
for(gic=gintcall; gic->f; ++gic) {
if(gsrvalue & 1L<<gic->flag) {
#ifndef EVCNT_COUNTERS
if (gic->intr_index >= INTRCNT_A12_IRQ_LEN)
panic("A12 INTRCNT");
intrcnt[INTRCNT_A12_IRQ + gic->intr_index];
#endif
if(gic->needsclear)
clear_gsr_interrupt(1L<<gic->flag);
(*gic->f)(gic->flag);
alpha_wmb();
}
}
}
static void a12_xbar_omchint(void);
static void a12_xbar_omchint() { panic("a12_xbar_omchint"); };
static void a12_xbar_imchint(void);
static void a12_xbar_imchint() { panic("a12_xbar_imchint"); };
void
a12_iointr(framep, vec)
void *framep;
unsigned long vec;
{
unsigned irq = (vec-0x900) >> 4;
/*
* Xbar device is in the A12 CPU core logic, so its interrupts
* might as well be hardwired.
*/
#ifdef EVCNT_COUNTERS
++a12_intr_evcnt.ev_count;
#else
/* XXX implicit knowledge of intrcnt[] */
if(irq < 2)
++intrcnt[INTRCNT_A12_IRQ + irq];
#if 2 >= INTRCNT_A12_IRQ_LEN
#error INTRCNT_A12_IRQ_LEN inconsistent with respect to intrcnt[] use
#endif
#endif
switch(irq) {
case 0:
a12_xbar_omchint();
return;
case 1:
a12_xbar_imchint();
return;
case 2:
a12_GInt();
return;
default:
panic("a12_iointr");
}
}

View File

@ -0,0 +1,42 @@
/* $NetBSD: pci_a12.h,v 1.1 1998/01/29 21:42:54 ross Exp $ */
/* [Notice revision 2.0]
* Copyright (c) 1997 Avalon Computer Systems, Inc.
* All rights reserved.
*
* Author: Ross Harvey
*
* 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 and
* author 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. Neither the name of Avalon Computer Systems, Inc. nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
* 4. This copyright will be assigned to The NetBSD Foundation on
* 1/1/2000 unless these terms (including possibly the assignment
* date) are updated in writing by Avalon prior to the latest specified
* assignment date.
*
* THIS SOFTWARE IS PROVIDED BY AVALON COMPUTER SYSTEMS, 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.
*/
void pci_a12_pickintr __P((struct a12c_config *));
#ifdef EVCNT_COUNTERS
extern struct evcnt a12_intr_evcnt;
#endif