Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-5]: src/sys Pullup from trunk:
details: https://anonhg.NetBSD.org/src/rev/316f22ce6f05
branches: netbsd-1-5
changeset: 489060:316f22ce6f05
user: thorpej <thorpej%NetBSD.org@localhost>
date: Fri Aug 11 18:00:03 2000 +0000
description:
Pullup from trunk:
Add EISA configuration readining infrastructure.
diffstat:
sys/arch/alpha/conf/files.alpha | 4 +-
sys/arch/alpha/eisa/eisa_machdep.c | 653 ++++++++++++++++++++++++++++++++++
sys/arch/alpha/include/eisa_machdep.h | 20 +-
sys/arch/alpha/pci/sio.c | 9 +-
sys/arch/i386/eisa/eisa_machdep.c | 46 ++-
sys/arch/i386/include/eisa_machdep.h | 11 +-
sys/dev/eisa/eisareg.h | 4 +-
sys/dev/eisa/eisavar.h | 82 ++++-
8 files changed, 819 insertions(+), 10 deletions(-)
diffs (truncated from 937 to 300 lines):
diff -r e8032584517a -r 316f22ce6f05 sys/arch/alpha/conf/files.alpha
--- a/sys/arch/alpha/conf/files.alpha Fri Aug 11 17:09:57 2000 +0000
+++ b/sys/arch/alpha/conf/files.alpha Fri Aug 11 18:00:03 2000 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.alpha,v 1.118.2.2 2000/07/12 20:56:02 thorpej Exp $
+# $NetBSD: files.alpha,v 1.118.2.3 2000/08/11 18:00:03 thorpej Exp $
#
# alpha-specific configuration info
@@ -245,6 +245,8 @@
include "dev/eisa/files.eisa"
+file arch/alpha/eisa/eisa_machdep.c eisa
+
device jensenio {[port = -1]}: eisabus, isabus, isadma_bounce
attach jensenio at mainbus
file arch/alpha/jensenio/jensenio.c jensenio
diff -r e8032584517a -r 316f22ce6f05 sys/arch/alpha/eisa/eisa_machdep.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/alpha/eisa/eisa_machdep.c Fri Aug 11 18:00:03 2000 +0000
@@ -0,0 +1,653 @@
+/* $NetBSD: eisa_machdep.c,v 1.4.2.2 2000/08/11 18:00:05 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * 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/cdefs.h>
+
+__KERNEL_RCSID(0, "$NetBSD: eisa_machdep.c,v 1.4.2.2 2000/08/11 18:00:05 thorpej Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+#include <sys/queue.h>
+
+#include <machine/intr.h>
+#include <machine/rpb.h>
+
+#include <dev/eisa/eisareg.h>
+#include <dev/eisa/eisavar.h>
+
+#define EISA_SLOT_HEADER_SIZE 31
+#define EISA_SLOT_INFO_OFFSET 20
+
+#define EISA_FUNC_INFO_OFFSET 34
+#define EISA_CONFIG_BLOCK_SIZE 320
+
+#define ECUF_TYPE_STRING 0x01
+#define ECUF_MEM_ENTRY 0x02
+#define ECUF_IRQ_ENTRY 0x04
+#define ECUF_DMA_ENTRY 0x08
+#define ECUF_IO_ENTRY 0x10
+#define ECUF_INIT_ENTRY 0x20
+#define ECUF_DISABLED 0x80
+
+#define ECUF_SELECTIONS_SIZE 26
+#define ECUF_TYPE_STRING_SIZE 80
+#define ECUF_MEM_ENTRY_SIZE 7
+#define ECUF_IRQ_ENTRY_SIZE 2
+#define ECUF_DMA_ENTRY_SIZE 2
+#define ECUF_IO_ENTRY_SIZE 3
+#define ECUF_INIT_ENTRY_SIZE 60
+
+#define ECUF_MEM_ENTRY_CNT 9
+#define ECUF_IRQ_ENTRY_CNT 7
+#define ECUF_DMA_ENTRY_CNT 4
+#define ECUF_IO_ENTRY_CNT 20
+
+/*
+ * EISA configuration space, as set up by the ECU, may be sparse.
+ */
+bus_size_t eisa_config_stride;
+paddr_t eisa_config_addr; /* defaults to 0 */
+paddr_t eisa_config_header_addr;
+
+struct ecu_mem {
+ SIMPLEQ_ENTRY(ecu_mem) ecum_list;
+ struct eisa_cfg_mem ecum_mem;
+};
+
+struct ecu_irq {
+ SIMPLEQ_ENTRY(ecu_irq) ecui_list;
+ struct eisa_cfg_irq ecui_irq;
+};
+
+struct ecu_dma {
+ SIMPLEQ_ENTRY(ecu_dma) ecud_list;
+ struct eisa_cfg_dma ecud_dma;
+};
+
+struct ecu_io {
+ SIMPLEQ_ENTRY(ecu_io) ecuio_list;
+ struct eisa_cfg_io ecuio_io;
+};
+
+struct ecu_func {
+ SIMPLEQ_ENTRY(ecu_func) ecuf_list;
+ int ecuf_funcno;
+ u_int32_t ecuf_id;
+ u_int16_t ecuf_slot_info;
+ u_int16_t ecuf_cfg_ext;
+ u_int8_t ecuf_selections[ECUF_SELECTIONS_SIZE];
+ u_int8_t ecuf_func_info;
+ u_int8_t ecuf_type_string[ECUF_TYPE_STRING_SIZE];
+ u_int8_t ecuf_init[ECUF_INIT_ENTRY_SIZE];
+ SIMPLEQ_HEAD(, ecu_mem) ecuf_mem;
+ SIMPLEQ_HEAD(, ecu_irq) ecuf_irq;
+ SIMPLEQ_HEAD(, ecu_dma) ecuf_dma;
+ SIMPLEQ_HEAD(, ecu_io) ecuf_io;
+};
+
+struct ecu_data {
+ SIMPLEQ_ENTRY(ecu_data) ecud_list;
+ int ecud_slot;
+ u_int8_t ecud_eisaid[EISA_IDSTRINGLEN];
+ u_int32_t ecud_offset;
+
+ /* General slot info. */
+ u_int8_t ecud_slot_info;
+ u_int16_t ecud_ecu_major_rev;
+ u_int16_t ecud_ecu_minor_rev;
+ u_int16_t ecud_cksum;
+ u_int16_t ecud_ndevfuncs;
+ u_int8_t ecud_funcinfo;
+ u_int32_t ecud_comp_id;
+
+ /* The functions */
+ SIMPLEQ_HEAD(, ecu_func) ecud_funcs;
+};
+
+SIMPLEQ_HEAD(, ecu_data) ecu_data_list =
+ SIMPLEQ_HEAD_INITIALIZER(ecu_data_list);
+
+static void
+ecuf_init(struct ecu_func *ecuf)
+{
+
+ memset(ecuf, 0, sizeof(*ecuf));
+ SIMPLEQ_INIT(&ecuf->ecuf_mem);
+ SIMPLEQ_INIT(&ecuf->ecuf_irq);
+ SIMPLEQ_INIT(&ecuf->ecuf_dma);
+ SIMPLEQ_INIT(&ecuf->ecuf_io);
+}
+
+static void
+eisa_parse_mem(struct ecu_func *ecuf, u_int8_t *dp)
+{
+ struct ecu_mem *ecum;
+ int i;
+
+ for (i = 0; i < ECUF_MEM_ENTRY_CNT; i++) {
+ ecum = malloc(sizeof(*ecum), M_DEVBUF, M_WAITOK);
+
+ ecum->ecum_mem.ecm_isram = dp[0] & 0x1;
+ ecum->ecum_mem.ecm_unitsize = dp[1] & 0x3;
+ ecum->ecum_mem.ecm_decode = (dp[1] >> 2) & 0x3;
+ ecum->ecum_mem.ecm_addr =
+ (dp[2] | (dp[3] << 8) | (dp[4] << 16)) << 8;
+ ecum->ecum_mem.ecm_size = (dp[5] | (dp[6] << 8)) << 10;
+ if (ecum->ecum_mem.ecm_size == 0)
+ ecum->ecum_mem.ecm_size = (1 << 26);
+ SIMPLEQ_INSERT_TAIL(&ecuf->ecuf_mem, ecum, ecum_list);
+
+#if 0
+ printf("MEM 0x%lx 0x%lx %d %d %d\n",
+ ecum->ecum_mem.ecm_addr, ecum->ecum_mem.ecm_size,
+ ecum->ecum_mem.ecm_isram, ecum->ecum_mem.ecm_unitsize,
+ ecum->ecum_mem.ecm_decode);
+#endif
+
+ if ((dp[0] & 0x80) == 0)
+ break;
+ dp += ECUF_MEM_ENTRY_SIZE;
+ }
+}
+
+static void
+eisa_parse_irq(struct ecu_func *ecuf, u_int8_t *dp)
+{
+ struct ecu_irq *ecui;
+ int i;
+
+ for (i = 0; i < ECUF_IRQ_ENTRY_CNT; i++) {
+ ecui = malloc(sizeof(*ecui), M_DEVBUF, M_WAITOK);
+
+ ecui->ecui_irq.eci_irq = dp[0] & 0xf;
+ ecui->ecui_irq.eci_ist = (dp[0] & 0x20) ? IST_LEVEL : IST_EDGE;
+ ecui->ecui_irq.eci_shared = (dp[0] & 0x40) ? 1 : 0;
+ SIMPLEQ_INSERT_TAIL(&ecuf->ecuf_irq, ecui, ecui_list);
+
+#if 0
+ printf("IRQ %d %s%s\n", ecui->eci_irq.ecui_irq,
+ ecui->eci_irq.ecui_ist == IST_LEVEL ? "level" : "edge",
+ ecui->eci_irq.ecui_shared ? " shared" : "");
+#endif
+
+ if ((dp[0] & 0x80) == 0)
+ break;
+ dp += ECUF_IRQ_ENTRY_SIZE;
+ }
+}
+
+static void
+eisa_parse_dma(struct ecu_func *ecuf, u_int8_t *dp)
+{
+ struct ecu_dma *ecud;
+ int i;
+
+ for (i = 0; i < ECUF_DMA_ENTRY_CNT; i++) {
+ ecud = malloc(sizeof(*ecud), M_DEVBUF, M_WAITOK);
+
+ ecud->ecud_dma.ecd_drq = dp[0] & 0x7;
+ ecud->ecud_dma.ecd_shared = dp[0] & 0x40;
+ ecud->ecud_dma.ecd_size = (dp[1] >> 2) & 0x3;
+ ecud->ecud_dma.ecd_timing = (dp[1] >> 4) & 0x3;
+ SIMPLEQ_INSERT_TAIL(&ecuf->ecuf_dma, ecud, ecud_list);
+
+#if 0
+ printf("DRQ %d%s %d %d\n", ecud->ecud_dma.ecd_drq,
+ ecud->ecud_dma.ecd_shared ? " shared" : "",
+ ecud->ecud_dma.ecd_size, ecud->ecud_dma.ecd_timing);
+#endif
+
+ if ((dp[0] & 0x80) == 0)
+ break;
+ dp += ECUF_DMA_ENTRY_SIZE;
+ }
+}
+
+static void
+eisa_parse_io(struct ecu_func *ecuf, u_int8_t *dp)
+{
+ struct ecu_io *ecuio;
+ int i;
+
+ for (i = 0; i < ECUF_IO_ENTRY_CNT; i++) {
+ ecuio = malloc(sizeof(*ecuio), M_DEVBUF, M_WAITOK);
+
+ ecuio->ecuio_io.ecio_addr = dp[1] | (dp[2] << 8);
+ ecuio->ecuio_io.ecio_size = (dp[0] & 0x1f) + 1;
+ ecuio->ecuio_io.ecio_shared = (dp[0] & 0x40) ? 1 : 0;
+
+#if 0
+ printf("IO 0x%lx 0x%lx%s\n", ecuio->ecuio_io.ecio_addr,
+ ecuio->ecuio_io.ecio_size,
+ ecuio->ecuio_io.ecio_shared ? " shared" : "");
+#endif
+
+ if ((dp[0] & 0x80) == 0)
+ break;
+ dp += ECUF_IO_ENTRY_SIZE;
+ }
+}
+
+static void
+eisa_read_config_bytes(paddr_t addr, void *buf, size_t count)
+{
+ const u_int8_t *src = (const u_int8_t *)ALPHA_PHYS_TO_K0SEG(addr);
+ u_int8_t *dst = buf;
+
+ for (; count != 0; count--) {
+ *dst++ = *src;
+ src += eisa_config_stride;
+ }
+}
Home |
Main Index |
Thread Index |
Old Index