Separate out netslot-specific code into its own file, so that one day we can

make it optional.
This commit is contained in:
bjh21 2001-07-02 23:18:34 +00:00
parent ebdb9f12f3
commit 659b8ab115
4 changed files with 169 additions and 103 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: files.arm32,v 1.120 2001/06/23 16:47:41 bjh21 Exp $
# $NetBSD: files.arm32,v 1.121 2001/07/02 23:18:34 bjh21 Exp $
#
# First try for arm-specific configuration info
#
@ -226,6 +226,7 @@ attach podulebus at root
file arch/arm32/podulebus/podulebus.c podulebus needs-flag
file arch/arm32/podulebus/podulebus_io.c podulebus
file arch/arm32/podulebus/podulebus_io_asm.S podulebus
file arch/arm32/podulebus/netslot.c podulebus
include "dev/podulebus/files.podulebus"

View File

@ -1,4 +1,4 @@
/* $NetBSD: podulebus_machdep.h,v 1.4 2001/06/08 22:38:07 bjh21 Exp $ */
/* $NetBSD: podulebus_machdep.h,v 1.5 2001/07/02 23:18:35 bjh21 Exp $ */
/*
* Copyright (c) 1995 Mark Brinicombe.
@ -160,6 +160,10 @@ extern void *podulebus_irq_establish __P((podulebus_intr_handle_t, int,
extern void podulebus_shift_tag __P((bus_space_tag_t, u_int,
bus_space_tag_t *));
/* Used internally by the podulebus code */
extern void netslotscan(struct device *);
extern void poduleexamine(podule_t *, struct device *, int);
#endif
/* End of podulebus.h */

View File

@ -0,0 +1,161 @@
/* $NetBSD: netslot.c,v 1.1 2001/07/02 23:18:36 bjh21 Exp $ */
/*
* Copyright (c) 1994-1996 Mark Brinicombe.
* Copyright (c) 1994 Brini.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Brini.
* 4. The name of the company nor the name of the author may be used to
* endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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>
__KERNEL_RCSID(1, "$Id: netslot.c,v 1.1 2001/07/02 23:18:36 bjh21 Exp $");
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/conf.h>
#include <sys/malloc.h>
#include <sys/device.h>
#include <uvm/uvm_extern.h>
#include <machine/io.h>
#include <machine/katelib.h>
#include <machine/irqhandler.h>
#include <machine/bootconfig.h>
#include <machine/pte.h>
#include <machine/pmap.h>
#include <arm32/iomd/iomdreg.h>
#include <arm32/iomd/iomdvar.h>
#include <dev/podulebus/podulebus.h>
#include <dev/podulebus/podules.h>
u_int netslotread __P((u_int, int));
u_int
netslotread(address, offset)
u_int address;
int offset;
{
static int netslotoffset = -1;
offset = offset >> 2;
if (netslotoffset == -1 || offset < netslotoffset) {
WriteByte(address, 0);
netslotoffset = 0;
}
while (netslotoffset < offset) {
(void)ReadByte(address);
++netslotoffset;
}
++netslotoffset;
return(ReadByte(address));
}
void
netslotscan(dev)
struct device *dev;
{
podule_t *podule;
volatile u_char *address;
/* Only one netslot atm */
/* Reset the address counter */
WriteByte(NETSLOT_BASE, 0x00);
address = (u_char *)NETSLOT_BASE;
podule = &podules[MAX_PODULES];
podule->fast_base = NETSLOT_BASE;
podule->medium_base = NETSLOT_BASE;
podule->slow_base = NETSLOT_BASE;
podule->sync_base = NETSLOT_BASE;
podule->mod_base = NETSLOT_BASE;
podule->easi_base = 0;
podule->attached = 0;
podule->slottype = SLOT_NONE;
podule->podulenum = MAX_PODULES;
podule->interrupt = IRQ_NETSLOT;
podule->read_rom = netslotread;
podule->dma_channel = -1;
podule->dma_interrupt = -1;
podule->description[0] = 0;
/* XXX - Really needs to be linked to a DMA manager */
if (IOMD_ID == RPC600_IOMD_ID)
podule->dma_channel = 0;
/* Get information from the podule header */
podule->flags0 = *address;
podule->flags1 = *address;
podule->reserved = *address;
podule->product = *address;
podule->product += (*address << 8);
podule->manufacturer = *address;
podule->manufacturer += (*address << 8);
podule->country = *address;
if (podule->flags1 & PODULE_FLAGS_IS) {
podule->irq_mask = *address;
podule->irq_addr = *address;
podule->irq_addr += (*address << 8);
podule->irq_addr += (*address << 16);
podule->irq_addr += podule->slow_base;
if (podule->irq_mask == 0)
podule->irq_mask = 0x01;
podule->fiq_mask = *address;
podule->fiq_addr = *address;
podule->fiq_addr += (*address << 8);
podule->fiq_addr += (*address << 16);
podule->fiq_addr += podule->slow_base;
if (podule->fiq_mask == 0)
podule->fiq_mask = 0x04;
} else {
podule->irq_addr = podule->slow_base;
podule->irq_mask = 0x01;
podule->fiq_addr = podule->slow_base;
podule->fiq_mask = 0x04;
}
poduleexamine(podule, dev, SLOT_NET);
}
void
netslot_ea(buffer)
u_int8_t *buffer;
{
/* Build station address from machine ID */
buffer[0] = 0x00;
buffer[1] = 0x00;
buffer[2] = 0xa4;
buffer[3] = bootconfig.machine_id[2] + 0x10;
buffer[4] = bootconfig.machine_id[1];
buffer[5] = bootconfig.machine_id[0];
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: podulebus.c,v 1.42 2001/06/08 22:38:07 bjh21 Exp $ */
/* $NetBSD: podulebus.c,v 1.43 2001/07/02 23:18:35 bjh21 Exp $ */
/*
* Copyright (c) 1994-1996 Mark Brinicombe.
@ -78,7 +78,6 @@ extern struct bus_space podulebus_bs_tag;
void map_section __P((vm_offset_t, vm_offset_t, vm_offset_t, int cacheable));
int poduleirqhandler __P((void *arg));
u_int poduleread __P((u_int, int));
u_int netslotread __P((u_int, int));
/*
@ -314,26 +313,6 @@ poduleread(address, offset)
return(ReadByte(address + offset));
}
u_int
netslotread(address, offset)
u_int address;
int offset;
{
static int netslotoffset = -1;
offset = offset >> 2;
if (netslotoffset == -1 || offset < netslotoffset) {
WriteByte(address, 0);
netslotoffset = 0;
}
while (netslotoffset < offset) {
(void)ReadByte(address);
++netslotoffset;
}
++netslotoffset;
return(ReadByte(address));
}
void
podulescan(dev)
struct device *dev;
@ -430,72 +409,6 @@ podulescan(dev)
}
void
netslotscan(dev)
struct device *dev;
{
podule_t *podule;
volatile u_char *address;
/* Only one netslot atm */
/* Reset the address counter */
WriteByte(NETSLOT_BASE, 0x00);
address = (u_char *)NETSLOT_BASE;
podule = &podules[MAX_PODULES];
podule->fast_base = NETSLOT_BASE;
podule->medium_base = NETSLOT_BASE;
podule->slow_base = NETSLOT_BASE;
podule->sync_base = NETSLOT_BASE;
podule->mod_base = NETSLOT_BASE;
podule->easi_base = 0;
podule->attached = 0;
podule->slottype = SLOT_NONE;
podule->podulenum = MAX_PODULES;
podule->interrupt = IRQ_NETSLOT;
podule->read_rom = netslotread;
podule->dma_channel = -1;
podule->dma_interrupt = -1;
podule->description[0] = 0;
/* XXX - Really needs to be linked to a DMA manager */
if (IOMD_ID == RPC600_IOMD_ID)
podule->dma_channel = 0;
/* Get information from the podule header */
podule->flags0 = *address;
podule->flags1 = *address;
podule->reserved = *address;
podule->product = *address + (*address << 8);
podule->manufacturer = *address + (*address << 8);
podule->country = *address;
if (podule->flags1 & PODULE_FLAGS_IS) {
podule->irq_mask = *address;
podule->irq_addr = *address + (*address << 8) + (*address << 16);
podule->irq_addr += podule->slow_base;
if (podule->irq_mask == 0)
podule->irq_mask = 0x01;
podule->fiq_mask = *address;
podule->fiq_addr = *address + (*address << 8) + (*address << 16);
podule->fiq_addr += podule->slow_base;
if (podule->fiq_mask == 0)
podule->fiq_mask = 0x04;
} else {
podule->irq_addr = podule->slow_base;
podule->irq_mask = 0x01;
podule->fiq_addr = podule->slow_base;
podule->fiq_mask = 0x04;
}
poduleexamine(podule, dev, SLOT_NET);
}
/*
* void podulebusattach(struct device *parent, struct device *dev, void *aux)
*
@ -694,19 +607,6 @@ matchpodule(pa, manufacturer, product, required_slot)
return(0);
}
void
netslot_ea(buffer)
u_int8_t *buffer;
{
/* Build station address from machine ID */
buffer[0] = 0x00;
buffer[1] = 0x00;
buffer[2] = 0xa4;
buffer[3] = bootconfig.machine_id[2] + 0x10;
buffer[4] = bootconfig.machine_id[1];
buffer[5] = bootconfig.machine_id[0];
}
void *
podulebus_irq_establish(ih, ipl, func, arg, ev)
podulebus_intr_handle_t ih;