add the plug-and-play code into current...

This code has been submitted by Luigi Rizzo <luigi@labinfo.iet.unipi.it>,
based on work done by Sujal Patel.

This currnetly doesn't provide the ability to register the port address
of PnP cards assigned a PnP driver.  As there aren't any PnP capible
drivers yet, this isn't much of a problem.

The code allows you, through USERCONFIG, configure what the cards port
bases, irqs, and dma's are like.  Currently there isn't support to view
what cards are in the sytem.

It successfully configures my PnP Internal Modem and sio then sees the
card as a normal isa device.

man page will be committed shortly.

Approved-by: jkh
Submitted-by: Luigi Rizzo
This commit is contained in:
John-Mark Gurney 1997-09-09 12:31:58 +00:00
parent ea45a7208a
commit 2daf730067
2 changed files with 806 additions and 0 deletions

515
sys/i386/isa/pnp.c Normal file
View File

@ -0,0 +1,515 @@
/*
* 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 <sys/kernel.h> /* for DATA_SET */
#include <sys/interrupt.h>
#include <machine/clock.h>
#include <machine/cpufunc.h>
#include <i386/isa/pnp.h>
#include <i386/isa/isa_device.h>
#include <i386/isa/isa.h>
#include <i386/isa/icu.h>
int num_pnp_cards = 0;
pnp_id pnp_devices[MAX_PNP_CARDS];
/*
* these entries are initialized using the autoconfig menu
* The struct is invalid (and must be initialized) if the first
* CSN is zero. The init code fills invalid entries with CSN 255
* which is not a supported value.
*/
struct pnp_cinfo pnp_ldn_overrides[MAX_PNP_LDN] = { 0 };
/*
* the following is a flag which tells if the data is valid.
*/
static int doing_pnp_probe = 0 ;
static int current_csn ;
static int current_pnp_id ;
static int current_pnp_serial ;
/*
* the following block is an example on what is needed for
* a PnP device driver.
*/
static char* nullpnp_probe(u_long csn, u_long vendor_id);
static void nullpnp_attach(u_long csn, u_long vendor_id, char *name,
struct isa_device *dev);
static u_long nullpnp_count = 0 ;
static struct pnp_device nullpnp_device = {
"goodpnp",
nullpnp_probe,
nullpnp_attach,
&nullpnp_count,
NULL /* imask */
};
DATA_SET (pnpdevice_set, nullpnp_device);
static char*
nullpnp_probe(u_long tag, u_long type)
{
if (bootverbose)
printf("Called nullpnp_probe with tag 0x%08x, type 0x%08x\n",
tag, type);
return NULL;
}
static void
nullpnp_attach(u_long csn, u_long vend_id, char *name,
struct isa_device *dev)
{
printf("nullpnp_attach: csn %d, vend_id 0x%08x name %s unit %d\n",
csn, vend_id, name, dev->id_unit);
return;
}
/* The READ_DATA port that we are using currently */
static int pnp_rd_port;
void pnp_send_Initiation_LFSR (void);
int pnp_get_serial (pnp_id *p);
void config_pnp_device (pnp_id *p, int csn);
int pnp_isolation_protocol (void);
void pnp_write(int d, u_char r);
u_char pnp_read(int d);
void
pnp_write(int d, u_char r)
{
outb (_PNP_ADDRESS, d);
outb (_PNP_WRITE_DATA, r);
}
u_char
pnp_read(int d)
{
outb (_PNP_ADDRESS, d);
return (inb(3 | (pnp_rd_port <<2)));
}
/*
* Send Initiation LFSR as described in "Plug and Play ISA Specification",
* Intel May 94.
*/
void
pnp_send_Initiation_LFSR()
{
int cur, i;
/* Reset the LSFR */
outb(_PNP_ADDRESS, 0);
outb(_PNP_ADDRESS, 0); /* yes, we do need it twice! */
cur = 0x6a;
outb(_PNP_ADDRESS, cur);
for (i = 1; i < 32; i++) {
cur = (cur >> 1) | (((cur ^ (cur >> 1)) << 7) & 0xff);
outb(_PNP_ADDRESS, cur);
}
}
/*
* Get the device's serial number. Returns 1 if the serial is valid.
*/
int
pnp_get_serial(pnp_id *p)
{
int i, bit, valid = 0, sum = 0x6a;
u_char *data = (u_char *)p;
bzero(data, sizeof(char) * 9);
outb(_PNP_ADDRESS, SERIAL_ISOLATION);
for (i = 0; i < 72; i++) {
bit = inb((pnp_rd_port << 2) | 0x3) == 0x55;
DELAY(250); /* Delay 250 usec */
/* Can't Short Circuit the next evaluation, so 'and' is last */
bit = (inb((pnp_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;
}
/*
* read_pnp_parms loads pnp parameters from the currently selected
* device into the struct pnp_cinfo parameter passed.
* The second argument specifies the Logical Device to use.
*/
int
read_pnp_parms(struct pnp_cinfo *d, int ldn)
{
int i ;
if (doing_pnp_probe == 0 || d == NULL)
return 0 ; /* fail */
bzero(d, sizeof(struct pnp_cinfo));
d->vendor_id = current_pnp_id ;
d->serial = current_pnp_serial ;
d->csn = current_csn ;
d->ldn = ldn ; /* XXX this should be different ... */
pnp_write (SET_LDN, ldn );
i = pnp_read(SET_LDN) ;
if (i != ldn) {
printf("Warning: LDN %d does not exist\n", ldn);
}
for (i = 0; i < 8; i++) {
d->port[i] = pnp_read(IO_CONFIG_BASE + i * 2) << 8 ;
d->port[i] |= pnp_read(IO_CONFIG_BASE + i * 2 + 1);
if (i < 4) {
d->mem[i].base = pnp_read (MEM_CONFIG + i*8) << 16 ;
d->mem[i].base |= pnp_read (MEM_CONFIG + i*8 + 1) << 8 ;
d->mem[i].control = pnp_read (MEM_CONFIG + i*8 + 2) ;
d->mem[i].range = pnp_read (MEM_CONFIG + i*8 + 3) << 16 ;
d->mem[i].range |= pnp_read (MEM_CONFIG + i*8 + 4) << 8 ;
}
if (i < 2) {
d->irq[i] = pnp_read(IRQ_CONFIG + i * 2);
d->irq_type[i] = pnp_read(IRQ_CONFIG + 1 + i * 2);
d->drq[i] = pnp_read(DRQ_CONFIG + i);
}
}
d->enable = pnp_read(ACTIVATE);
for (i = 0 ; i < MAX_PNP_LDN; i++) {
if (pnp_ldn_overrides[i].csn == d->csn &&
pnp_ldn_overrides[i].ldn == ldn) {
d->flags = pnp_ldn_overrides[i].flags ;
d->override = pnp_ldn_overrides[i].override ;
break ;
}
}
printf("port 0x%04x 0x%04x 0x%04x 0x%04x irq %d:%d drq %d:%d en %d\n",
d->port[0], d->port[1], d->port[2], d->port[3],
d->irq[0], d->irq[1],
d->drq[0], d->drq[1],
d->enable);
return 1 ; /* success */
}
/*
* write_pnp_parms initializes a logical device with the parms
* in d, and then activates the board if the last parameter is 1.
*/
int
write_pnp_parms(struct pnp_cinfo *d, int ldn)
{
int i, empty = -1 ;
/*
* some safety checks first.
*/
if (doing_pnp_probe == 0 || d==NULL || d->vendor_id != current_pnp_id)
return 0 ; /* fail */
pnp_write (SET_LDN, ldn );
i = pnp_read(SET_LDN) ;
if (i != ldn) {
printf("Warning: LDN %d does not exist\n", ldn);
}
for (i = 0; i < 8; i++) {
pnp_write(IO_CONFIG_BASE + i * 2, d->port[i] >> 8 );
pnp_write(IO_CONFIG_BASE + i * 2 + 1, d->port[i] & 0xff );
}
for (i = 0; i < 4; i++) {
pnp_write(MEM_CONFIG + i*8, (d->mem[i].base >> 16) & 0xff );
pnp_write(MEM_CONFIG + i*8+1, (d->mem[i].base >> 8) & 0xff );
pnp_write(MEM_CONFIG + i*8+2, d->mem[i].control & 0xff );
pnp_write(MEM_CONFIG + i*8+3, (d->mem[i].range >> 16) & 0xff );
pnp_write(MEM_CONFIG + i*8+4, (d->mem[i].range >> 8) & 0xff );
}
for (i = 0; i < 2; i++) {
pnp_write(IRQ_CONFIG + i*2 , d->irq[i] );
pnp_write(IRQ_CONFIG + i*2 + 1, d->irq_type[i] );
pnp_write(DRQ_CONFIG + i, d->drq[i] );
}
/*
* store parameters read into the current kernel
* so manual editing next time is easier
*/
for (i = 0 ; i < MAX_PNP_LDN; i++) {
if (pnp_ldn_overrides[i].csn == d->csn &&
pnp_ldn_overrides[i].ldn == ldn) {
d->flags = pnp_ldn_overrides[i].flags ;
pnp_ldn_overrides[i] = *d ;
break ;
} else if (pnp_ldn_overrides[i].csn < 1 ||
pnp_ldn_overrides[i].csn == 255)
empty = i ;
}
if (i== MAX_PNP_LDN && empty != -1)
pnp_ldn_overrides[empty] = *d;
/*
* Here should really perform the range check, and
* return a failure if not successful.
*/
pnp_write (IO_RANGE_CHECK, 0);
DELAY(1000); /* XXX is it really necessary ? */
pnp_write (ACTIVATE, d->enable ? 1 : 0);
DELAY(1000); /* XXX is it really necessary ? */
return 1 ;
}
/*
* To finalize a card's initialization, and before accessing its
* registers, we need to bring the card in WaitForKey. To this purpose,
* we need to issue a WaitForKey command, which brings _all_ cards
* in that state. So, before configuring the next board, we must also
* sent the Init-Key to bring cards to the SLEEP state again.
*
* In fact, one could hope that cards respond to normal I/O accesses
* even in the SLEEP state, which could be done by issuing a WAKE[0].
* This seems to work on the CS4236, but not on the CS4232 on my Zappa
* motherboard .
*/
int
enable_pnp_card()
{
/* the next wake should bring the card in WaitForKey ? */
pnp_write (WAKE, 0);
pnp_write(CONFIG_CONTROL, 0x02); /* All cards in WaitForKey */
DELAY(1000); /* XXX is it really necessary ? */
return 1 ; /* success */
}
/*
* Configure PnP devices. pnp_id is made of:
* 4 bytes: board id (which can be printed as an ascii string);
* 4 bytes: board serial number (often 0 or -1 ?)
*/
void
config_pnp_device(pnp_id *p, int csn)
{
struct pnp_cinfo *ci;
int i;
u_char *data = (u_char *)p;
/* these are for autoconfigure a-la pci */
struct pnp_device *dvp, **dvpp;
char *name ;
printf("CSN %d Vendor ID: %c%c%c%02x%02x [0x%08x] Serial 0x%08x\n",
csn,
((data[0] & 0x7c) >> 2) + 64,
(((data[0] & 0x03) << 3) | ((data[1] & 0xe0) >> 5)) + 64,
(data[1] & 0x1f) + 64, data[2], data[3],
p->vendor_id, p->serial);
doing_pnp_probe = 1 ;
current_csn = csn ;
current_pnp_id = p->vendor_id ;
current_pnp_serial = p->serial ;
/*
* use kernel table to override possible devices
*/
for (i = 0 ; i < MAX_PNP_LDN; i++) {
if (pnp_ldn_overrides[i].csn == csn &&
pnp_ldn_overrides[i].override == 1) {
struct pnp_cinfo d;
printf("PnP: override config for CSN %d LDN %d vend_id 0x%08x\n",
csn, pnp_ldn_overrides[i].ldn, current_pnp_id);
/* next assignement is done otherwise read fails */
d.vendor_id = current_pnp_id ;
read_pnp_parms(&d, pnp_ldn_overrides[i].ldn);
if (pnp_ldn_overrides[i].enable == 0) {
/* just disable ... */
d.enable = 0;
write_pnp_parms(&d, pnp_ldn_overrides[i].ldn);
} else {
/* set all parameters */
/* next assignement is done otherwise write fails */
pnp_ldn_overrides[i].vendor_id = current_pnp_id ;
write_pnp_parms(&pnp_ldn_overrides[i],
pnp_ldn_overrides[i].ldn);
}
}
}
/* lookup device in ioconfiguration */
dvpp = (struct pnp_device **)pnpdevice_set.ls_items;
while (dvp = *dvpp++) {
if (dvp->pd_probe) {
if (name = (*dvp->pd_probe)(csn, p->vendor_id))
break;
}
}
if (dvp && name && dvp->pd_count) { /* found a matching device */
int unit ;
/* pnpcb->pnpcb_seen |= ( 1ul << csn ) ; */
/* get and increment the unit */
unit = (*dvp->pd_count)++;
/*
* now call the attach routine. The board has not been
* configured yet, so better not access isa registers in
* the attach routine until enable_pnp_card() has been done.
*/
bzero( &(dvp->dev), sizeof(dvp->dev) );
dvp->dev.id_unit = unit ;
if (dvp->pd_attach)
(*dvp->pd_attach) (csn, p->vendor_id, name, &(dvp->dev));
if (dvp->dev.id_irq) {
/* the board uses interrupts. Register it. */
if (dvp->imask)
INTRMASK( *(dvp->imask), dvp->dev.id_irq );
register_intr(ffs(dvp->dev.id_irq)-1, dvp->dev.id_id,
dvp->dev.id_ri_flags, dvp->dev.id_intr,
dvp->imask, dvp->dev.id_unit);
INTREN(dvp->dev.id_irq);
}
printf("%s%d (%s <%s> sn 0x%08x) at 0x%x "
"irq %d drq %d flags 0x%x id %d\n",
dvp->dev.id_driver && dvp->dev.id_driver->name ?
dvp->dev.id_driver->name : "unknown",
unit,
dvp->pd_name, name, p->serial,
dvp->dev.id_iobase,
ffs(dvp->dev.id_irq)-1,
dvp->dev.id_drq,
dvp->dev.id_flags,
dvp->dev.id_id);
}
doing_pnp_probe = 0 ;
}
/*
* Run the isolation protocol. Use pnp_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
* pnp_rd_port as the READ_DATA port.
*
* In the first pass, a csn is assigned to each board and pnp_id's
* are saved to an array, pnp_devices. In the second pass, each
* card is woken up and the device configuration is called.
*/
int
pnp_isolation_protocol()
{
int i, csn;
pnp_send_Initiation_LFSR();
pnp_write(CONFIG_CONTROL, 0x04); /* Reset CSN for All Cards */
for (csn = 1; (csn < MAX_PNP_CARDS); csn++) {
/* Wake up cards without a CSN */
pnp_write(WAKE, 0);
pnp_write(SET_RD_DATA, pnp_rd_port);
outb(_PNP_ADDRESS, SERIAL_ISOLATION);
DELAY(1000); /* Delay 1 msec */
if (pnp_get_serial( &(pnp_devices[csn-1]) ) ) {
pnp_write(SET_CSN, csn);
/* pnp_write(CONFIG_CONTROL, 2); */
} else
break;
}
num_pnp_cards = csn - 1;
for (csn = 1; csn <= num_pnp_cards ; csn++) {
/*
* make sure cards are in SLEEP state
*/
pnp_send_Initiation_LFSR();
pnp_write(WAKE, csn);
config_pnp_device( &(pnp_devices[csn-1]), csn);
/*
* Put all cards in WaitForKey, just in case the previous
* attach routine forgot it.
*/
pnp_write(CONFIG_CONTROL, 0x02);
DELAY(1000); /* XXX is it really necessary ? */
}
return num_pnp_cards ;
}
/*
* pnp_configure()
*
* autoconfiguration of pnp devices. This routine just runs the
* isolation protocol over several ports, until one is successful.
*
* may be called more than once ?
*
*/
void
pnp_configure()
{
int num_pnp_devs;
if (pnp_ldn_overrides[0].csn == 0) {
printf("Initializing PnP override table\n");
bzero (pnp_ldn_overrides, sizeof(pnp_ldn_overrides));
pnp_ldn_overrides[0].csn = 255 ;
}
printf("Probing for PnP devices:\n");
/* Try various READ_DATA ports from 0x203-0x3ff */
for (pnp_rd_port = 0x80; (pnp_rd_port < 0xff); pnp_rd_port += 0x10) {
if (bootverbose)
printf("Trying Read_Port at %x\n", (pnp_rd_port << 2) | 0x3);
num_pnp_devs = pnp_isolation_protocol();
if (num_pnp_devs)
break;
}
if (!num_pnp_devs) {
printf("No Plug-n-Play devices were found\n");
return;
}
}

291
sys/i386/isa/pnp.h Normal file
View File

@ -0,0 +1,291 @@
/*
* 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 $
*/
#include <i386/isa/isa_device.h>
#ifndef _I386_ISA_PNP_H_
#define _I386_ISA_PNP_H_
/* Maximum Number of PnP Devices. 8 should be plenty */
#define MAX_PNP_CARDS 8
/*
* the following is the maximum number of PnP Logical devices that
* userconfig can handle.
*/
#define MAX_PNP_LDN 20
/* Static ports to access PnP state machine */
#define _PNP_ADDRESS 0x279
#define _PNP_WRITE_DATA 0xa79
/* PnP Registers. Write to ADDRESS and then use WRITE/READ_DATA */
#define SET_RD_DATA 0x00
/***
Writing to this location modifies the address of the port used for
reading from the Plug and Play ISA cards. Bits[7:0] become I/O
read port address bits[9:2]. Reads from this register are ignored.
***/
#define SERIAL_ISOLATION 0x01
/***
A read to this register causes a Plug and Play cards in the Isolation
state to compare one bit of the boards ID.
This register is read only.
***/
#define CONFIG_CONTROL 0x02
/***
Bit[2] Reset CSN to 0
Bit[1] Return to the Wait for Key state
Bit[0] Reset all logical devices and restore configuration
registers to their power-up values.
A write to bit[0] of this register performs a reset function on
all logical devices. This resets the contents of configuration
registers to their default state. All card's logical devices
enter their default state and the CSN is preserved.
A write to bit[1] of this register causes all cards to enter the
Wait for Key state but all CSNs are preserved and logical devices
are not affected.
A write to bit[2] of this register causes all cards to reset their
CSN to zero .
This register is write-only. The values are not sticky, that is,
hardware will automatically clear them and there is no need for
software to clear the bits.
***/
#define WAKE 0x03
/***
A write to this port will cause all cards that have a CSN that
matches the write data[7:0] to go from the Sleep state to the either
the Isolation state if the write data for this command is zero or
the Config state if the write data is not zero. Additionally, the
pointer to the byte-serial device is reset. This register is
writeonly.
***/
#define RESOURCE_DATA 0x04
/***
A read from this address reads the next byte of resource information.
The Status register must be polled until bit[0] is set before this
register may be read. This register is read only.
***/
#define STATUS 0x05
/***
Bit[0] when set indicates it is okay to read the next data byte
from the Resource Data register. This register is readonly.
***/
#define SET_CSN 0x06
/***
A write to this port sets a card's CSN. The CSN is a value uniquely
assigned to each ISA card after the serial identification process
so that each card may be individually selected during a Wake[CSN]
command. This register is read/write.
***/
#define SET_LDN 0x07
/***
Selects the current logical device. All reads and writes of memory,
I/O, interrupt and DMA configuration information access the registers
of the logical device written here. In addition, the I/O Range
Check and Activate commands operate only on the selected logical
device. This register is read/write. If a card has only 1 logical
device, this location should be a read-only value of 0x00.
***/
/*** addresses 0x08 - 0x1F Card Level Reserved for future use ***/
/*** addresses 0x20 - 0x2F Card Level, Vendor Defined ***/
#define ACTIVATE 0x30
/***
For each logical device there is one activate register that controls
whether or not the logical device is active on the ISA bus. Bit[0],
if set, activates the logical device. Bits[7:1] are reserved and
must return 0 on reads. This is a read/write register. Before a
logical device is activated, I/O range check must be disabled.
***/
#define IO_RANGE_CHECK 0x31
/***
This register is used to perform a conflict check on the I/O port
range programmed for use by a logical device.
Bit[7:2] Reserved and must return 0 on reads
Bit[1] Enable I/O Range check, if set then I/O Range Check
is enabled. I/O range check is only valid when the logical
device is inactive.
Bit[0], if set, forces the logical device to respond to I/O reads
of the logical device's assigned I/O range with a 0x55 when I/O
range check is in operation. If clear, the logical device drives
0xAA. This register is read/write.
***/
/*** addr 0x32 - 0x37 Logical Device Control Reserved for future use ***/
/*** addr 0x38 - 0x3F Logical Device Control Vendor Define ***/
#define MEM_CONFIG 0x40
/***
Four memory resource registers per range, four ranges.
Fill with 0 if no ranges are enabled.
Offset 0: RW Memory base address bits[23:16]
Offset 1: RW Memory base address bits[15:8]
Offset 2: Memory control
Bit[1] specifies 8/16-bit control. This bit is set to indicate
16-bit memory, and cleared to indicate 8-bit memory.
Bit[0], if cleared, indicates the next field can be used as a range
length for decode (implies range length and base alignment of memory
descriptor are equal).
Bit[0], if set, indicates the next field is the upper limit for
the address. - - Bit[0] is read-only.
Offset 3: RW upper limit or range len, bits[23:16]
Offset 4: RW upper limit or range len, bits[15:8]
Offset 5-Offset 7: filler, unused.
***/
#define IO_CONFIG_BASE 0x60
/***
Eight ranges, two bytes per range.
Offset 0: I/O port base address bits[15:8]
Offset 1: I/O port base address bits[7:0]
***/
#define IRQ_CONFIG 0x70
/***
Two entries, two bytes per entry.
Offset 0: RW interrupt level (1..15, 0=unused).
Offset 1: Bit[1]: level(1:hi, 0:low),
Bit[0]: type (1:level, 0:edge)
byte 1 can be readonly if 1 type of int is used.
***/
#define DRQ_CONFIG 0x74
/***
Two entries, one byte per entry. Bits[2:0] select
which DMA channel is in use for DMA 0. Zero selects DMA channel
0, seven selects DMA channel 7. DMA channel 4, the cascade channel
is used to indicate no DMA channel is active.
***/
/*** 32-bit memory accesses are at 0x76 ***/
/* 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
/*
* pnp_cinfo contains Configuration Information. They are used
* to communicate to the device driver the actual configuration
* of the device, and also by the userconfig menu to let the
* operating system override any configuration set by the bios.
*
*/
struct pnp_cinfo {
u_int vendor_id; /* board id */
u_int serial; /* Board's Serial Number */
u_long flags; /* OS-reserved flags */
u_char csn; /* assigned Card Select Number */
u_char ldn; /* Logical Device Number */
u_char enable; /* pnp enable */
u_char override; /* override bios parms (in userconfig) */
u_char irq[2]; /* IRQ Number */
u_char irq_type[2]; /* IRQ Type */
u_char drq[2];
u_short port[8]; /* The Base Address of the Port */
struct {
u_long base; /* Memory Base Address */
int control; /* Memory Control Register */
u_long range; /* Memory Range *OR* Upper Limit */
} mem[4];
};
void pnp_configure __P((void));
struct pnp_device {
char *pd_name;
char * (*pd_probe ) (u_long csn, u_long vendor_id);
void (*pd_attach ) (u_long csn, u_long vend_id, char * name,
struct isa_device *dev);
u_long *pd_count;
u_int *imask ;
struct isa_device dev ;
};
struct _pnp_id {
u_long vendor_id;
u_long serial;
u_char checksum;
} ;
typedef struct _pnp_id pnp_id;
extern pnp_id pnp_devices[MAX_PNP_CARDS];
extern struct pnp_cinfo pnp_ldn_overrides[MAX_PNP_LDN];
extern int pnp_overrides_valid;
extern struct linker_set pnpdevice_set;
/*
* these two functions are for use in drivers
*/
int read_pnp_parms(struct pnp_cinfo *d, int ldn);
int write_pnp_parms(struct pnp_cinfo *d, int ldn);
int enable_pnp_card(void);
#endif /* !_I386_ISA_PNP_H_ */