Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 29 Jul 1997 07:48:27 +1000
From:      David Nugent <davidn@labs.usn.blaze.net.au>
To:        Wolfgang Helbig <helbig@MX.BA-Stuttgart.De>
Cc:        FreeBSD-current@FreeBSD.ORG
Subject:   Re: Sound Blaster PnP in -current 
Message-ID:  <199707282148.HAA13318@labs.usn.blaze.net.au>
In-Reply-To: Your message of "Sun, 27 Jul 1997 22:27:39 %2B0200." <199707272027.WAA00364@helbig.informatik.ba-stuttgart.de> 

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multipart MIME message.

--==_Exmh_-1001429240
Content-Type: text/plain; charset=us-ascii

>  I installed Sound Blaster 16 PnP. It is not recognized by my kernel.
>  Rumors have it that Sound Blaster 16 PnP works well in 2.2.x.

The rumours are wrong.

>  So I am wondering if anyone got it to work under -current.

Yes.

Method 1: boot dos first and run ctcm.

Method 2: use the pnp patch to configure the card (my -current-fied)
version of this attached. Apply in /usr/src/sys. You'll have to edit
pnp.c to insert your card's settings. As you can see, I'm using 0x220,
0x300 (usually 0x330, but I have an aha1542 at that address), 0x388,
and dma 1 7 (usually 5), irq 5.

Regards,
David



--==_Exmh_-1001429240
Content-Type: text/plain ; name="pnp.diff"; charset=us-ascii
Content-Description: pnp.diff
Content-Disposition: attachment; filename="pnp.diff"

diff -ur --new-file OLD/i386/conf/LINT i386/conf/LINT
--- OLD/i386/conf/LINT	Fri May  3 04:46:25 1996
+++ i386/conf/LINT	Sun May  5 22:12:50 1996
@@ -407,6 +407,11 @@
 controller	isa0
 
 #
+# Optional ISA Plug-n-Play device support
+#
+controller     pnp0
+
+#
 # Options for `isa':
 #
 # AUTO_EOI_1 enables the `automatic EOI' feature for the master 8259A
diff -ur --new-file OLD/i386/conf/files.i386 i386/conf/files.i386
--- OLD/i386/conf/files.i386	Sat May  4 04:59:45 1996
+++ i386/conf/files.i386	Sun May  5 22:13:22 1996
@@ -127,6 +127,7 @@
 i386/isa/pcvt/pcvt_out.c	optional	vt	device-driver
 i386/isa/pcvt/pcvt_sup.c	optional	vt	device-driver
 i386/isa/pcvt/pcvt_vtf.c	optional	vt	device-driver
+i386/isa/pnp.c			optional	pnp	device-driver
 i386/isa/prof_machdep.c		optional	profiling-routine
 i386/isa/psm.c			optional	psm	device-driver
 i386/isa/qcam.c			optional	qcam	device-driver
diff -ur --new-file OLD/i386/i386/autoconf.c i386/i386/autoconf.c
--- OLD/i386/i386/autoconf.c	Thu May  2 10:54:05 1996
+++ i386/i386/autoconf.c	Sun May  5 22:15:04 1996
@@ -65,6 +65,11 @@
 #include <i386/isa/isa_device.h>
 #endif
 
+#include "pnp.h"
+#if NPNP > 0
+#include <i386/isa/pnp.h>
+#endif
+
 #include "eisa.h"
 #if NEISA > 0
 #include <i386/eisa/eisaconf.h>
@@ -186,6 +191,10 @@
 
 #if NPCI > 0
 	pci_configure();
+#endif
+
+#if NPNP > 0
+	pnp_configure();
 #endif
 
 #if NISA > 0
diff -ur --new-file OLD/i386/isa/pnp.c i386/isa/pnp.c
--- sys/i386/isa/pnp.c.orig	Tue Jul 22 05:41:20 1997
+++ sys/i386/isa/pnp.c	Tue Jul 22 06:09:13 1997
@@ -0,0 +1,290 @@
+/*
+ * Copyright (c) 1996, Sujal M. Patel
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ *      $Id: pnpcfg.c,v 1.6 1996/05/06 02:08:25 smpatel Exp smpatel $
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <machine/clock.h>
+#include <machine/cpufunc.h>
+
+#include <i386/isa/pnp.h>
+
+
+#define SEND(d, r)	{ outb (ADDRESS, d); outb (WRITE_DATA, r); }
+
+
+/* The READ_DATA port that we are using currently */
+static int rd_port;
+
+
+/*
+ * Hard coded for now -- Will need to use resource information from
+ * ISA, PCI, and EISA drivers to auto-configure the PnP-devices
+ */
+static struct cinfo cinfo[] = 
+{
+	/* Configuration for a Creative Labs Soundblaster16 */
+	{
+		0x00006e24, 		/* Serial Number */
+		        -1,		/* Logical Device Number */
+		{
+			{  5, -1 },	/* Primary IRQ Number, Type */
+			{ -1, -1 }	/* Second  IRQ Number, Type */
+		},
+		{ 1, 7 },		/* DRQ Number */
+		{
+			0x220,		/* Ports 1 */
+			0x300,		/* Ports 2 */
+			0x388,		/* Ports 3 */
+			   -1,		/* Ports 4 */
+			   -1,		/* Ports 5 */
+			   -1,		/* Ports 6 */
+			   -1,		/* Ports 7 */
+			   -1,		/* Ports 8 */
+		},
+		{
+			{ -1, -1, -1 },	/* Memory desc0 - base, ctrl, range */
+			{ -1, -1, -1 },	/* Memory desc1 - base, ctrl, range */
+			{ -1, -1, -1 },	/* Memory desc2 - base, ctrl, range */
+			{ -1, -1, -1 }	/* Memory desc3 - base, ctrl, range */ 
+		}
+	},
+
+};
+
+
+int power __P((int base, int exp));
+void send_Initiation_LFSR __P((void));
+int get_serial __P((unsigned char *data));
+void config_device __P((unsigned char *data, int csn));
+int isolation_protocol __P((void));
+
+
+int
+power(base, exp)
+	int base, exp;
+{
+	if (exp <= 1)
+		return base;
+	else
+		return base * power(base, exp - 1);
+}
+
+
+/*
+ * Send Initiation LFSR as described in "Plug and Play ISA Specification,
+ * Intel May 94."
+ */
+void
+send_Initiation_LFSR()
+{
+	int cur, i;
+
+	/* Reset the LSFR */
+	outb(ADDRESS, 0);
+	outb(ADDRESS, 0);
+
+	cur = 0x6a;
+	outb(ADDRESS, cur);
+
+	for (i = 1; i < 32; i++) {
+		cur = (cur >> 1) | (((cur ^ (cur >> 1)) << 7) & 0xff);
+		outb(ADDRESS, cur);
+	}
+}
+
+
+/*
+ * Get the device's serial number.  Returns 1 if the serial is valid.
+ */
+int
+get_serial(data)
+	unsigned char *data;
+{
+	int i, bit, valid = 0, sum = 0x6a;
+
+	bzero(data, sizeof(char) * 9);
+
+	for (i = 0; i < 72; i++) {
+		bit = inb((rd_port << 2) | 0x3) == 0x55;
+		DELAY(250);	/* Delay 250 usec */
+
+		/* Can't Short Circuit the next evaluation, so 'and' is last */
+		bit = (inb((rd_port << 2) | 0x3) == 0xaa) && bit;
+		DELAY(250);	/* Delay 250 usec */
+
+		valid = valid || bit;
+
+		if (i < 64)
+			sum = (sum >> 1) |
+			    (((sum ^ (sum >> 1) ^ bit) << 7) & 0xff);
+
+		data[i / 8] = (data[i / 8] >> 1) | (bit ? 0x80 : 0);
+	}
+
+	valid = valid && (data[8] == sum);
+
+	return valid;
+}
+
+
+/*
+ * Configure PnP devices
+ */
+void
+config_device(data, csn)
+	unsigned char *data;
+	int csn;
+{
+	struct cinfo *ci;
+	int i;
+
+	if (bootverbose)
+		printf("Card assigned CSN #%d\n", csn);
+
+	printf("Board Vendor ID: %c%c%c%02x%02x",
+	    ((data[0] & 0x7c) >> 2) + 64,
+	    (((data[0] & 0x03) << 3) | ((data[1] & 0xe0) >> 5)) + 64,
+	    (data[1] & 0x1f) + 64, data[2], data[3]);
+	printf("     Board Serial Number: %08x\n", *(int *)&(data[4]));
+
+	SEND(SET_CSN, csn); /* Move this out of this function XXX */
+	outb(ADDRESS, STATUS);
+
+	for (ci = cinfo; (int)ci < ((int)cinfo + sizeof (cinfo)); ci++) {
+		if (ci->serial == *(int *)&(data[4])) {
+			printf ("	Configuring (Logical Device %x)\n",
+				ci->ldn != -1 ? ci->ldn : 0);
+
+			if (ci->ldn >= 0)
+				SEND (SET_LDN, ci->ldn);
+
+			for (i = 0; i < 8; i++)
+				if (ci->port[i] > 0) {
+					SEND (IO_CONFIG_BASE + i * 2,
+						ci->port[i] >> 8);
+					SEND (IO_CONFIG_BASE + i * 2 + 1,
+						ci->port[i] & 0xff);
+				}
+
+			for (i = 0; i < 2; i++)
+				if (ci->irq[i].num > 0) {
+					SEND (IRQ_CONFIG + i * 2,
+						ci->irq[i].num);
+					if (ci->irq[i].type >= 0)
+						SEND (IRQ_CONFIG + i * 2 + 1,
+							ci->irq[i].type);
+				}
+
+			for (i = 0; i < 2; i++)
+				if (ci->drq[i] > 0) {
+					SEND (DRQ_CONFIG + i,
+						ci->drq[i]);
+				}
+
+			for (i = 0; i < 4; i++)
+				if (ci->mem[i].base > 0) {
+					SEND (MEM_CONFIG + i * 8,
+						ci->mem[i].base >> 16);
+					SEND (MEM_CONFIG + i * 8 + 1,
+						(ci->mem[i].base >> 8) &
+						0xff);
+					/*
+					 * This needs to be handled better for
+					 * the user's sake. XXX
+					 */
+					if (ci->mem[i].control >= 0) {
+						SEND (MEM_CONFIG + i * 8 + 2,
+							ci->mem[i].control);
+					}
+					SEND (MEM_CONFIG + i * 8 + 3,
+						ci->mem[i].range >> 16);
+					SEND (MEM_CONFIG + i * 8 + 4,
+						(ci->mem[i].range >> 8) &
+						0xff);
+				}
+			SEND (IO_RANGE_CHECK, 0);
+			SEND (ACTIVATE, 1);
+		}
+	}
+}
+
+
+/*
+ * Run the isolation protocol. Use rd_port as the READ_DATA port value (caller
+ * should try multiple READ_DATA locations before giving up). Upon exiting,
+ * all cards are aware that they should use rd_port as the READ_DATA port;
+ */
+int
+isolation_protocol()
+{
+	int csn;
+	unsigned char data[9];
+
+	send_Initiation_LFSR();
+
+	/* Reset CSN for All Cards */
+	SEND(0x02, 0x04);
+
+	for (csn = 1; (csn < MAX_CARDS); csn++) {
+		/* Wake up cards without a CSN */
+		SEND(WAKE, 0);
+		SEND(SET_RD_DATA, rd_port);
+		outb(ADDRESS, SERIAL_ISOLATION);
+		DELAY(1000);	/* Delay 1 msec */
+
+		if (get_serial(data))
+			config_device(data, csn);
+		else
+			break;
+	}
+	return csn - 1;
+}
+
+
+void
+pnp_configure()
+{
+	int num_pnp_devs;
+
+	printf("Checking for Plug-n-Play devices...\n");
+
+	/* Try various READ_DATA ports from 0x203-0x3ff */
+	for (rd_port = 0x80; (rd_port < 0xff); rd_port += 0x10) {
+		if (bootverbose)
+			printf("Trying Read_Port at %x\n",
+				(rd_port << 2) | 0x3);
+
+		num_pnp_devs = isolation_protocol();
+		if (num_pnp_devs)
+			break;
+	}
+	if (!num_pnp_devs) {
+		printf("No Plug-n-Play devices were found\n");
+		return;
+	}
+}
--- sys/i386/isa/pnp.h.orig	Tue Jul 22 05:41:20 1997
+++ sys/i386/isa/pnp.h	Tue Jul 22 05:41:20 1997
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 1996, Sujal M. Patel
+ * 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 Sujal M. Patel
+ * 4. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ *      $Id: pnpcfg.h,v 1.2 1996/01/12 21:35:10 smpatel Exp smpatel $
+ */
+
+#ifndef _I386_ISA_PNP_H_
+#define _I386_ISA_PNP_H_
+
+/* Maximum Number of PnP Devices.  8 should be plenty */
+#define MAX_CARDS 8
+
+
+/* Static ports */
+#define ADDRESS			0x279
+#define WRITE_DATA		0xa79
+
+
+/* PnP Registers.  Write to ADDRESS and then use WRITE/READ_DATA */
+#define SET_RD_DATA		0x00
+#define SERIAL_ISOLATION	0x01
+#define WAKE			0x03
+#define	RESOURCE_DATA		0x04
+#define STATUS			0x05
+#define SET_CSN			0x06
+#define SET_LDN			0x07
+#define ACTIVATE		0x30
+#define IO_RANGE_CHECK		0x31
+#define MEM_CONFIG		0x40
+#define IO_CONFIG_BASE		0x60
+#define IRQ_CONFIG		0x70
+#define DRQ_CONFIG		0x74
+
+/* Small Resource Item names */
+#define PNP_VERSION		0x1
+#define LOG_DEVICE_ID		0x2
+#define COMP_DEVICE_ID		0x3
+#define IRQ_FORMAT		0x4
+#define DMA_FORMAT		0x5
+#define START_DEPEND_FUNC	0x6
+#define END_DEPEND_FUNC		0x7
+#define IO_PORT_DESC		0x8
+#define FIXED_IO_PORT_DESC	0x9
+#define SM_RES_RESERVED		0xa-0xd
+#define SM_VENDOR_DEFINED	0xe
+#define END_TAG			0xf
+
+/* Large Resource Item names */
+#define MEMORY_RANGE_DESC	0x1
+#define ID_STRING_ANSI		0x2
+#define ID_STRING_UNICODE	0x3
+#define LG_VENDOR_DEFINED	0x4
+#define _32BIT_MEM_RANGE_DESC	0x5
+#define _32BIT_FIXED_LOC_DESC	0x6
+#define LG_RES_RESERVED		0x7-0x7f
+
+/* Configuration Information */
+struct cinfo {
+	unsigned int serial;	/* Board's Serial Number */
+	int ldn;		/* Log. Device #, If only 1 ld then ldn = -1 */
+	struct {
+		int num;	/* IRQ Number */
+		int type;	/* IRQ Type */
+	} irq[2];
+	int drq[2];
+	int port[8];		/* The Base Address of the Port */
+	struct {
+		int base;	/* Memory Base Address */
+		int control;	/* Memory Control Register */
+		int range;	/* Memory Range *OR* Upper Limit */
+	} mem[4];
+};
+
+void pnp_configure __P((void));
+
+#endif /* !_I386_ISA_PNP_H_ */

--==_Exmh_-1001429240
Content-Type: text/plain; charset=us-ascii

David Nugent - Unique Computing Pty Ltd - Melbourne, Australia
Voice +61-3-9791-9547  Data/BBS +61-3-9792-3507  3:632/348@fidonet
davidn@freebsd.org davidn@blaze.net.au http://www.blaze.net.au/~davidn/

--==_Exmh_-1001429240--





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199707282148.HAA13318>