1999-05-22 15:18:28 +00:00
|
|
|
/*-
|
2017-11-27 15:23:17 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD AND MIT
|
|
|
|
*
|
1999-05-22 15:18:28 +00:00
|
|
|
* Copyright (c) 1999 Doug Rabson
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* Modifications for Intel architecture by Garrett A. Wollman.
|
|
|
|
* Copyright 1998 Massachusetts Institute of Technology
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software and
|
|
|
|
* its documentation for any purpose and without fee is hereby
|
|
|
|
* granted, provided that both the above copyright notice and this
|
|
|
|
* permission notice appear in all copies, that both the above
|
|
|
|
* copyright notice and this permission notice appear in all
|
|
|
|
* supporting documentation, and that the name of M.I.T. not be used
|
|
|
|
* in advertising or publicity pertaining to distribution of the
|
|
|
|
* software without specific, written prior permission. M.I.T. makes
|
|
|
|
* no representations about the suitability of this software for any
|
|
|
|
* purpose. It is provided "as is" without express or implied
|
|
|
|
* warranty.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
|
|
|
|
* ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
|
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
|
|
|
|
* SHALL M.I.T. 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Parts of the ISA bus implementation common to all architectures.
|
|
|
|
*/
|
|
|
|
|
2003-06-11 00:34:37 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
2006-06-12 21:07:13 +00:00
|
|
|
#include "opt_isa.h"
|
|
|
|
|
1999-05-22 15:18:28 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/bus.h>
|
2017-12-23 22:57:14 +00:00
|
|
|
#include <sys/endian.h>
|
1999-05-22 15:18:28 +00:00
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/module.h>
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <sys/rman.h>
|
2017-12-23 22:57:14 +00:00
|
|
|
#include <sys/sysctl.h>
|
1999-05-22 15:18:28 +00:00
|
|
|
|
|
|
|
#include <machine/resource.h>
|
|
|
|
|
|
|
|
#include <isa/isavar.h>
|
|
|
|
#include <isa/isa_common.h>
|
|
|
|
|
2000-07-12 00:42:08 +00:00
|
|
|
static int isa_print_child(device_t bus, device_t dev);
|
|
|
|
|
2000-12-08 20:09:00 +00:00
|
|
|
static MALLOC_DEFINE(M_ISADEV, "isadev", "ISA device");
|
1999-05-22 15:18:28 +00:00
|
|
|
|
1999-11-11 16:48:00 +00:00
|
|
|
static int isa_running;
|
1999-05-22 15:18:28 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* At 'probe' time, we add all the devices which we know about to the
|
|
|
|
* bus. The generic attach routine will probe and attach them if they
|
|
|
|
* are alive.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
isa_probe(device_t dev)
|
|
|
|
{
|
|
|
|
device_set_desc(dev, "ISA bus");
|
2001-12-21 21:54:56 +00:00
|
|
|
isa_init(dev); /* Allow machdep code to initialise */
|
2004-12-24 22:31:47 +00:00
|
|
|
return (0);
|
1999-05-22 15:18:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extern device_t isa_bus_device;
|
|
|
|
|
|
|
|
static int
|
|
|
|
isa_attach(device_t dev)
|
|
|
|
{
|
|
|
|
/*
|
1999-09-01 20:53:43 +00:00
|
|
|
* Arrange for isa_probe_children(dev) to be called later. XXX
|
1999-05-22 15:18:28 +00:00
|
|
|
*/
|
|
|
|
isa_bus_device = dev;
|
2004-12-24 22:31:47 +00:00
|
|
|
return (0);
|
1999-05-22 15:18:28 +00:00
|
|
|
}
|
|
|
|
|
1999-09-01 20:53:43 +00:00
|
|
|
/*
|
|
|
|
* Find a working set of memory regions for a child using the ranges
|
|
|
|
* in *config and return the regions in *result. Returns non-zero if
|
|
|
|
* a set of ranges was found.
|
|
|
|
*/
|
|
|
|
static int
|
2004-12-24 22:31:47 +00:00
|
|
|
isa_find_memory(device_t child, struct isa_config *config,
|
|
|
|
struct isa_config *result)
|
1999-09-01 20:53:43 +00:00
|
|
|
{
|
|
|
|
int success, i;
|
|
|
|
struct resource *res[ISA_NMEM];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* First clear out any existing resource definitions.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < ISA_NMEM; i++) {
|
* Add struct resource_list* argument to resource_list_alloc and
resource_list_release. This removes the dependancy on the
layout of ivars.
* Move set_resource, get_resource and delete_resource from
isa_if.m to bus_if.m.
* Simplify driver code by providing wrappers to those methods:
bus_set_resource(dev, type, rid, start, count);
bus_get_resource(dev, type, rid, startp, countp);
bus_get_resource_start(dev, type, rid);
bus_get_resource_count(dev, type, rid);
bus_delete_resource(dev, type, rid);
* Delete isa_get_rsrc and use bus_get_resource_start instead.
* Fix a stupid typo in isa_alloc_resource reported by Takahashi
Yoshihiro <nyan@FreeBSD.org>.
* Print a diagnostic message if we can't assign resources to a PnP
device.
* Change device_print_prettyname() so that it doesn't print
"(no driver assigned)-1" for anonymous devices.
1999-10-12 21:35:51 +00:00
|
|
|
bus_delete_resource(child, SYS_RES_MEMORY, i);
|
1999-09-01 20:53:43 +00:00
|
|
|
res[i] = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
success = 1;
|
|
|
|
result->ic_nmem = config->ic_nmem;
|
|
|
|
for (i = 0; i < config->ic_nmem; i++) {
|
2004-12-24 22:31:47 +00:00
|
|
|
uint32_t start, end, size, align;
|
Rework the ISA PnP driver pnp and the PnP resource parser to fix
the following bugs.
- When constructing a resource configuration, respect the order
in which resource descriptors are read, in order to establish
the correct mapping between the descriptors and configuration
registers.
"Plug and Play ISA Specification, Version 1.0a", Sec 4.6.1, May 5,
1994. "Clarifications to the Plug and Play ISA Specification,
Version 1.0a", Sec 6.2.1, Dec. 10, 1994.
- Do not ignore null (empty) descriptors; they are valid descriptors
acting as filler.
"Clarifications to the Plug and Play ISA Specification, Version 1.0a",
Sec 6.2.1.
- Correctly set up logical device configuration registers for null
resources.
"Clarifications to the Plug and Play ISA Specification, Version 1.0a"
- Handle null resources properly in the resource allocator for the
ISA bus.
2001-09-05 03:54:33 +00:00
|
|
|
|
|
|
|
size = config->ic_mem[i].ir_size;
|
|
|
|
|
|
|
|
/* the PnP device may have a null resource as filler */
|
|
|
|
if (size == 0) {
|
|
|
|
result->ic_mem[i].ir_start = 0;
|
|
|
|
result->ic_mem[i].ir_end = 0;
|
|
|
|
result->ic_mem[i].ir_size = 0;
|
|
|
|
result->ic_mem[i].ir_align = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
1999-09-01 20:53:43 +00:00
|
|
|
for (start = config->ic_mem[i].ir_start,
|
|
|
|
end = config->ic_mem[i].ir_end,
|
|
|
|
align = config->ic_mem[i].ir_align;
|
2005-01-23 03:03:58 +00:00
|
|
|
start + size - 1 <= end && start + size > start;
|
2007-04-17 15:14:23 +00:00
|
|
|
start += MAX(align, 1)) {
|
* Add struct resource_list* argument to resource_list_alloc and
resource_list_release. This removes the dependancy on the
layout of ivars.
* Move set_resource, get_resource and delete_resource from
isa_if.m to bus_if.m.
* Simplify driver code by providing wrappers to those methods:
bus_set_resource(dev, type, rid, start, count);
bus_get_resource(dev, type, rid, startp, countp);
bus_get_resource_start(dev, type, rid);
bus_get_resource_count(dev, type, rid);
bus_delete_resource(dev, type, rid);
* Delete isa_get_rsrc and use bus_get_resource_start instead.
* Fix a stupid typo in isa_alloc_resource reported by Takahashi
Yoshihiro <nyan@FreeBSD.org>.
* Print a diagnostic message if we can't assign resources to a PnP
device.
* Change device_print_prettyname() so that it doesn't print
"(no driver assigned)-1" for anonymous devices.
1999-10-12 21:35:51 +00:00
|
|
|
bus_set_resource(child, SYS_RES_MEMORY, i,
|
1999-09-01 20:53:43 +00:00
|
|
|
start, size);
|
2016-02-19 03:37:56 +00:00
|
|
|
res[i] = bus_alloc_resource_any(child,
|
|
|
|
SYS_RES_MEMORY, &i,
|
2004-12-27 18:18:38 +00:00
|
|
|
rman_make_alignment_flags(align) /* !RF_ACTIVE */);
|
1999-09-01 20:53:43 +00:00
|
|
|
if (res[i]) {
|
|
|
|
result->ic_mem[i].ir_start = start;
|
|
|
|
result->ic_mem[i].ir_end = start + size - 1;
|
|
|
|
result->ic_mem[i].ir_size = size;
|
|
|
|
result->ic_mem[i].ir_align = align;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we didn't find a place for memory range i, then
|
|
|
|
* give up now.
|
|
|
|
*/
|
|
|
|
if (!res[i]) {
|
|
|
|
success = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ISA_NMEM; i++) {
|
|
|
|
if (res[i])
|
|
|
|
bus_release_resource(child, SYS_RES_MEMORY,
|
|
|
|
i, res[i]);
|
|
|
|
}
|
|
|
|
|
2004-12-24 22:31:47 +00:00
|
|
|
return (success);
|
1999-09-01 20:53:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find a working set of port regions for a child using the ranges
|
|
|
|
* in *config and return the regions in *result. Returns non-zero if
|
|
|
|
* a set of ranges was found.
|
|
|
|
*/
|
|
|
|
static int
|
2004-12-24 22:31:47 +00:00
|
|
|
isa_find_port(device_t child, struct isa_config *config,
|
|
|
|
struct isa_config *result)
|
1999-09-01 20:53:43 +00:00
|
|
|
{
|
|
|
|
int success, i;
|
|
|
|
struct resource *res[ISA_NPORT];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* First clear out any existing resource definitions.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < ISA_NPORT; i++) {
|
* Add struct resource_list* argument to resource_list_alloc and
resource_list_release. This removes the dependancy on the
layout of ivars.
* Move set_resource, get_resource and delete_resource from
isa_if.m to bus_if.m.
* Simplify driver code by providing wrappers to those methods:
bus_set_resource(dev, type, rid, start, count);
bus_get_resource(dev, type, rid, startp, countp);
bus_get_resource_start(dev, type, rid);
bus_get_resource_count(dev, type, rid);
bus_delete_resource(dev, type, rid);
* Delete isa_get_rsrc and use bus_get_resource_start instead.
* Fix a stupid typo in isa_alloc_resource reported by Takahashi
Yoshihiro <nyan@FreeBSD.org>.
* Print a diagnostic message if we can't assign resources to a PnP
device.
* Change device_print_prettyname() so that it doesn't print
"(no driver assigned)-1" for anonymous devices.
1999-10-12 21:35:51 +00:00
|
|
|
bus_delete_resource(child, SYS_RES_IOPORT, i);
|
1999-09-01 20:53:43 +00:00
|
|
|
res[i] = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
success = 1;
|
|
|
|
result->ic_nport = config->ic_nport;
|
|
|
|
for (i = 0; i < config->ic_nport; i++) {
|
2004-12-24 22:31:47 +00:00
|
|
|
uint32_t start, end, size, align;
|
Rework the ISA PnP driver pnp and the PnP resource parser to fix
the following bugs.
- When constructing a resource configuration, respect the order
in which resource descriptors are read, in order to establish
the correct mapping between the descriptors and configuration
registers.
"Plug and Play ISA Specification, Version 1.0a", Sec 4.6.1, May 5,
1994. "Clarifications to the Plug and Play ISA Specification,
Version 1.0a", Sec 6.2.1, Dec. 10, 1994.
- Do not ignore null (empty) descriptors; they are valid descriptors
acting as filler.
"Clarifications to the Plug and Play ISA Specification, Version 1.0a",
Sec 6.2.1.
- Correctly set up logical device configuration registers for null
resources.
"Clarifications to the Plug and Play ISA Specification, Version 1.0a"
- Handle null resources properly in the resource allocator for the
ISA bus.
2001-09-05 03:54:33 +00:00
|
|
|
|
|
|
|
size = config->ic_port[i].ir_size;
|
|
|
|
|
|
|
|
/* the PnP device may have a null resource as filler */
|
|
|
|
if (size == 0) {
|
|
|
|
result->ic_port[i].ir_start = 0;
|
|
|
|
result->ic_port[i].ir_end = 0;
|
|
|
|
result->ic_port[i].ir_size = 0;
|
|
|
|
result->ic_port[i].ir_align = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
1999-09-01 20:53:43 +00:00
|
|
|
for (start = config->ic_port[i].ir_start,
|
|
|
|
end = config->ic_port[i].ir_end,
|
|
|
|
align = config->ic_port[i].ir_align;
|
|
|
|
start + size - 1 <= end;
|
|
|
|
start += align) {
|
* Add struct resource_list* argument to resource_list_alloc and
resource_list_release. This removes the dependancy on the
layout of ivars.
* Move set_resource, get_resource and delete_resource from
isa_if.m to bus_if.m.
* Simplify driver code by providing wrappers to those methods:
bus_set_resource(dev, type, rid, start, count);
bus_get_resource(dev, type, rid, startp, countp);
bus_get_resource_start(dev, type, rid);
bus_get_resource_count(dev, type, rid);
bus_delete_resource(dev, type, rid);
* Delete isa_get_rsrc and use bus_get_resource_start instead.
* Fix a stupid typo in isa_alloc_resource reported by Takahashi
Yoshihiro <nyan@FreeBSD.org>.
* Print a diagnostic message if we can't assign resources to a PnP
device.
* Change device_print_prettyname() so that it doesn't print
"(no driver assigned)-1" for anonymous devices.
1999-10-12 21:35:51 +00:00
|
|
|
bus_set_resource(child, SYS_RES_IOPORT, i,
|
1999-09-01 20:53:43 +00:00
|
|
|
start, size);
|
2016-02-19 03:37:56 +00:00
|
|
|
res[i] = bus_alloc_resource_any(child,
|
|
|
|
SYS_RES_IOPORT, &i,
|
2004-12-27 18:18:38 +00:00
|
|
|
rman_make_alignment_flags(align) /* !RF_ACTIVE */);
|
1999-09-01 20:53:43 +00:00
|
|
|
if (res[i]) {
|
|
|
|
result->ic_port[i].ir_start = start;
|
|
|
|
result->ic_port[i].ir_end = start + size - 1;
|
|
|
|
result->ic_port[i].ir_size = size;
|
|
|
|
result->ic_port[i].ir_align = align;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we didn't find a place for port range i, then
|
|
|
|
* give up now.
|
|
|
|
*/
|
|
|
|
if (!res[i]) {
|
|
|
|
success = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ISA_NPORT; i++) {
|
|
|
|
if (res[i])
|
|
|
|
bus_release_resource(child, SYS_RES_IOPORT,
|
|
|
|
i, res[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the index of the first bit in the mask (or -1 if mask is empty.
|
|
|
|
*/
|
|
|
|
static int
|
2004-12-24 22:31:47 +00:00
|
|
|
find_first_bit(uint32_t mask)
|
1999-09-01 20:53:43 +00:00
|
|
|
{
|
2004-12-24 22:31:47 +00:00
|
|
|
return (ffs(mask) - 1);
|
1999-09-01 20:53:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the index of the next bit in the mask, or -1 if there are no more.
|
|
|
|
*/
|
|
|
|
static int
|
2004-12-24 22:31:47 +00:00
|
|
|
find_next_bit(uint32_t mask, int bit)
|
1999-09-01 20:53:43 +00:00
|
|
|
{
|
|
|
|
bit++;
|
|
|
|
while (bit < 32 && !(mask & (1 << bit)))
|
|
|
|
bit++;
|
|
|
|
if (bit != 32)
|
2004-12-24 22:31:47 +00:00
|
|
|
return (bit);
|
|
|
|
return (-1);
|
1999-09-01 20:53:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find a working set of irqs for a child using the masks in *config
|
|
|
|
* and return the regions in *result. Returns non-zero if a set of
|
|
|
|
* irqs was found.
|
|
|
|
*/
|
|
|
|
static int
|
2004-12-24 22:31:47 +00:00
|
|
|
isa_find_irq(device_t child, struct isa_config *config,
|
|
|
|
struct isa_config *result)
|
1999-09-01 20:53:43 +00:00
|
|
|
{
|
|
|
|
int success, i;
|
|
|
|
struct resource *res[ISA_NIRQ];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* First clear out any existing resource definitions.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < ISA_NIRQ; i++) {
|
* Add struct resource_list* argument to resource_list_alloc and
resource_list_release. This removes the dependancy on the
layout of ivars.
* Move set_resource, get_resource and delete_resource from
isa_if.m to bus_if.m.
* Simplify driver code by providing wrappers to those methods:
bus_set_resource(dev, type, rid, start, count);
bus_get_resource(dev, type, rid, startp, countp);
bus_get_resource_start(dev, type, rid);
bus_get_resource_count(dev, type, rid);
bus_delete_resource(dev, type, rid);
* Delete isa_get_rsrc and use bus_get_resource_start instead.
* Fix a stupid typo in isa_alloc_resource reported by Takahashi
Yoshihiro <nyan@FreeBSD.org>.
* Print a diagnostic message if we can't assign resources to a PnP
device.
* Change device_print_prettyname() so that it doesn't print
"(no driver assigned)-1" for anonymous devices.
1999-10-12 21:35:51 +00:00
|
|
|
bus_delete_resource(child, SYS_RES_IRQ, i);
|
1999-09-01 20:53:43 +00:00
|
|
|
res[i] = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
success = 1;
|
|
|
|
result->ic_nirq = config->ic_nirq;
|
|
|
|
for (i = 0; i < config->ic_nirq; i++) {
|
2004-12-24 22:31:47 +00:00
|
|
|
uint32_t mask = config->ic_irqmask[i];
|
1999-09-01 20:53:43 +00:00
|
|
|
int irq;
|
Rework the ISA PnP driver pnp and the PnP resource parser to fix
the following bugs.
- When constructing a resource configuration, respect the order
in which resource descriptors are read, in order to establish
the correct mapping between the descriptors and configuration
registers.
"Plug and Play ISA Specification, Version 1.0a", Sec 4.6.1, May 5,
1994. "Clarifications to the Plug and Play ISA Specification,
Version 1.0a", Sec 6.2.1, Dec. 10, 1994.
- Do not ignore null (empty) descriptors; they are valid descriptors
acting as filler.
"Clarifications to the Plug and Play ISA Specification, Version 1.0a",
Sec 6.2.1.
- Correctly set up logical device configuration registers for null
resources.
"Clarifications to the Plug and Play ISA Specification, Version 1.0a"
- Handle null resources properly in the resource allocator for the
ISA bus.
2001-09-05 03:54:33 +00:00
|
|
|
|
|
|
|
/* the PnP device may have a null resource as filler */
|
|
|
|
if (mask == 0) {
|
|
|
|
result->ic_irqmask[i] = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
1999-09-01 20:53:43 +00:00
|
|
|
for (irq = find_first_bit(mask);
|
|
|
|
irq != -1;
|
|
|
|
irq = find_next_bit(mask, irq)) {
|
* Add struct resource_list* argument to resource_list_alloc and
resource_list_release. This removes the dependancy on the
layout of ivars.
* Move set_resource, get_resource and delete_resource from
isa_if.m to bus_if.m.
* Simplify driver code by providing wrappers to those methods:
bus_set_resource(dev, type, rid, start, count);
bus_get_resource(dev, type, rid, startp, countp);
bus_get_resource_start(dev, type, rid);
bus_get_resource_count(dev, type, rid);
bus_delete_resource(dev, type, rid);
* Delete isa_get_rsrc and use bus_get_resource_start instead.
* Fix a stupid typo in isa_alloc_resource reported by Takahashi
Yoshihiro <nyan@FreeBSD.org>.
* Print a diagnostic message if we can't assign resources to a PnP
device.
* Change device_print_prettyname() so that it doesn't print
"(no driver assigned)-1" for anonymous devices.
1999-10-12 21:35:51 +00:00
|
|
|
bus_set_resource(child, SYS_RES_IRQ, i,
|
1999-09-01 20:53:43 +00:00
|
|
|
irq, 1);
|
2004-03-17 17:50:55 +00:00
|
|
|
res[i] = bus_alloc_resource_any(child,
|
|
|
|
SYS_RES_IRQ, &i,
|
|
|
|
0 /* !RF_ACTIVE */ );
|
1999-09-01 20:53:43 +00:00
|
|
|
if (res[i]) {
|
|
|
|
result->ic_irqmask[i] = (1 << irq);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we didn't find a place for irq range i, then
|
|
|
|
* give up now.
|
|
|
|
*/
|
|
|
|
if (!res[i]) {
|
|
|
|
success = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ISA_NIRQ; i++) {
|
|
|
|
if (res[i])
|
|
|
|
bus_release_resource(child, SYS_RES_IRQ,
|
|
|
|
i, res[i]);
|
|
|
|
}
|
|
|
|
|
2004-12-24 22:31:47 +00:00
|
|
|
return (success);
|
1999-09-01 20:53:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find a working set of drqs for a child using the masks in *config
|
|
|
|
* and return the regions in *result. Returns non-zero if a set of
|
|
|
|
* drqs was found.
|
|
|
|
*/
|
|
|
|
static int
|
2004-12-24 22:31:47 +00:00
|
|
|
isa_find_drq(device_t child, struct isa_config *config,
|
|
|
|
struct isa_config *result)
|
1999-09-01 20:53:43 +00:00
|
|
|
{
|
|
|
|
int success, i;
|
|
|
|
struct resource *res[ISA_NDRQ];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* First clear out any existing resource definitions.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < ISA_NDRQ; i++) {
|
* Add struct resource_list* argument to resource_list_alloc and
resource_list_release. This removes the dependancy on the
layout of ivars.
* Move set_resource, get_resource and delete_resource from
isa_if.m to bus_if.m.
* Simplify driver code by providing wrappers to those methods:
bus_set_resource(dev, type, rid, start, count);
bus_get_resource(dev, type, rid, startp, countp);
bus_get_resource_start(dev, type, rid);
bus_get_resource_count(dev, type, rid);
bus_delete_resource(dev, type, rid);
* Delete isa_get_rsrc and use bus_get_resource_start instead.
* Fix a stupid typo in isa_alloc_resource reported by Takahashi
Yoshihiro <nyan@FreeBSD.org>.
* Print a diagnostic message if we can't assign resources to a PnP
device.
* Change device_print_prettyname() so that it doesn't print
"(no driver assigned)-1" for anonymous devices.
1999-10-12 21:35:51 +00:00
|
|
|
bus_delete_resource(child, SYS_RES_DRQ, i);
|
1999-09-01 20:53:43 +00:00
|
|
|
res[i] = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
success = 1;
|
|
|
|
result->ic_ndrq = config->ic_ndrq;
|
|
|
|
for (i = 0; i < config->ic_ndrq; i++) {
|
2004-12-24 22:31:47 +00:00
|
|
|
uint32_t mask = config->ic_drqmask[i];
|
1999-09-01 20:53:43 +00:00
|
|
|
int drq;
|
Rework the ISA PnP driver pnp and the PnP resource parser to fix
the following bugs.
- When constructing a resource configuration, respect the order
in which resource descriptors are read, in order to establish
the correct mapping between the descriptors and configuration
registers.
"Plug and Play ISA Specification, Version 1.0a", Sec 4.6.1, May 5,
1994. "Clarifications to the Plug and Play ISA Specification,
Version 1.0a", Sec 6.2.1, Dec. 10, 1994.
- Do not ignore null (empty) descriptors; they are valid descriptors
acting as filler.
"Clarifications to the Plug and Play ISA Specification, Version 1.0a",
Sec 6.2.1.
- Correctly set up logical device configuration registers for null
resources.
"Clarifications to the Plug and Play ISA Specification, Version 1.0a"
- Handle null resources properly in the resource allocator for the
ISA bus.
2001-09-05 03:54:33 +00:00
|
|
|
|
|
|
|
/* the PnP device may have a null resource as filler */
|
|
|
|
if (mask == 0) {
|
|
|
|
result->ic_drqmask[i] = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
1999-09-01 20:53:43 +00:00
|
|
|
for (drq = find_first_bit(mask);
|
|
|
|
drq != -1;
|
|
|
|
drq = find_next_bit(mask, drq)) {
|
* Add struct resource_list* argument to resource_list_alloc and
resource_list_release. This removes the dependancy on the
layout of ivars.
* Move set_resource, get_resource and delete_resource from
isa_if.m to bus_if.m.
* Simplify driver code by providing wrappers to those methods:
bus_set_resource(dev, type, rid, start, count);
bus_get_resource(dev, type, rid, startp, countp);
bus_get_resource_start(dev, type, rid);
bus_get_resource_count(dev, type, rid);
bus_delete_resource(dev, type, rid);
* Delete isa_get_rsrc and use bus_get_resource_start instead.
* Fix a stupid typo in isa_alloc_resource reported by Takahashi
Yoshihiro <nyan@FreeBSD.org>.
* Print a diagnostic message if we can't assign resources to a PnP
device.
* Change device_print_prettyname() so that it doesn't print
"(no driver assigned)-1" for anonymous devices.
1999-10-12 21:35:51 +00:00
|
|
|
bus_set_resource(child, SYS_RES_DRQ, i,
|
1999-09-01 20:53:43 +00:00
|
|
|
drq, 1);
|
2004-03-17 17:50:55 +00:00
|
|
|
res[i] = bus_alloc_resource_any(child,
|
|
|
|
SYS_RES_DRQ, &i,
|
|
|
|
0 /* !RF_ACTIVE */);
|
1999-09-01 20:53:43 +00:00
|
|
|
if (res[i]) {
|
|
|
|
result->ic_drqmask[i] = (1 << drq);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we didn't find a place for drq range i, then
|
|
|
|
* give up now.
|
|
|
|
*/
|
|
|
|
if (!res[i]) {
|
|
|
|
success = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ISA_NDRQ; i++) {
|
|
|
|
if (res[i])
|
|
|
|
bus_release_resource(child, SYS_RES_DRQ,
|
|
|
|
i, res[i]);
|
|
|
|
}
|
|
|
|
|
2004-12-24 22:31:47 +00:00
|
|
|
return (success);
|
1999-09-01 20:53:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Attempt to find a working set of resources for a device. Return
|
|
|
|
* non-zero if a working configuration is found.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
isa_assign_resources(device_t child)
|
|
|
|
{
|
|
|
|
struct isa_device *idev = DEVTOISA(child);
|
|
|
|
struct isa_config_entry *ice;
|
2001-08-10 07:50:14 +00:00
|
|
|
struct isa_config *cfg;
|
2002-02-24 23:24:01 +00:00
|
|
|
const char *reason;
|
|
|
|
|
|
|
|
reason = "Empty ISA id_configs";
|
2001-08-10 07:50:14 +00:00
|
|
|
cfg = malloc(sizeof(struct isa_config), M_TEMP, M_NOWAIT|M_ZERO);
|
|
|
|
if (cfg == NULL)
|
|
|
|
return(0);
|
1999-09-01 20:53:43 +00:00
|
|
|
TAILQ_FOREACH(ice, &idev->id_configs, ice_link) {
|
2002-02-24 22:27:54 +00:00
|
|
|
reason = "memory";
|
2001-08-10 07:50:14 +00:00
|
|
|
if (!isa_find_memory(child, &ice->ice_config, cfg))
|
1999-09-01 20:53:43 +00:00
|
|
|
continue;
|
2002-02-24 22:27:54 +00:00
|
|
|
reason = "port";
|
2001-08-10 07:50:14 +00:00
|
|
|
if (!isa_find_port(child, &ice->ice_config, cfg))
|
1999-09-01 20:53:43 +00:00
|
|
|
continue;
|
2002-02-24 22:27:54 +00:00
|
|
|
reason = "irq";
|
2001-08-10 07:50:14 +00:00
|
|
|
if (!isa_find_irq(child, &ice->ice_config, cfg))
|
1999-09-01 20:53:43 +00:00
|
|
|
continue;
|
2002-02-24 22:27:54 +00:00
|
|
|
reason = "drq";
|
2001-08-10 07:50:14 +00:00
|
|
|
if (!isa_find_drq(child, &ice->ice_config, cfg))
|
1999-09-01 20:53:43 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A working configuration was found enable the device
|
|
|
|
* with this configuration.
|
|
|
|
*/
|
2002-02-24 22:27:54 +00:00
|
|
|
reason = "no callback";
|
1999-09-01 20:53:43 +00:00
|
|
|
if (idev->id_config_cb) {
|
|
|
|
idev->id_config_cb(idev->id_config_arg,
|
2001-08-10 07:50:14 +00:00
|
|
|
cfg, 1);
|
|
|
|
free(cfg, M_TEMP);
|
2004-12-24 22:31:47 +00:00
|
|
|
return (1);
|
1999-09-01 20:53:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable the device.
|
|
|
|
*/
|
2000-07-12 00:42:08 +00:00
|
|
|
bus_print_child_header(device_get_parent(child), child);
|
2002-02-24 22:27:54 +00:00
|
|
|
printf(" can't assign resources (%s)\n", reason);
|
2000-07-12 00:42:08 +00:00
|
|
|
if (bootverbose)
|
2004-12-24 22:31:47 +00:00
|
|
|
isa_print_child(device_get_parent(child), child);
|
2001-08-10 07:50:14 +00:00
|
|
|
bzero(cfg, sizeof (*cfg));
|
1999-09-01 20:53:43 +00:00
|
|
|
if (idev->id_config_cb)
|
2001-08-10 07:50:14 +00:00
|
|
|
idev->id_config_cb(idev->id_config_arg, cfg, 0);
|
1999-09-01 20:53:43 +00:00
|
|
|
device_disable(child);
|
|
|
|
|
2001-08-10 07:50:14 +00:00
|
|
|
free(cfg, M_TEMP);
|
2004-12-24 22:31:47 +00:00
|
|
|
return (0);
|
1999-09-01 20:53:43 +00:00
|
|
|
}
|
|
|
|
|
2008-11-18 21:01:54 +00:00
|
|
|
/*
|
|
|
|
* Claim any unallocated resources to keep other devices from using
|
|
|
|
* them.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
isa_claim_resources(device_t dev, device_t child)
|
|
|
|
{
|
|
|
|
struct isa_device *idev = DEVTOISA(child);
|
|
|
|
struct resource_list *rl = &idev->id_resources;
|
|
|
|
struct resource_list_entry *rle;
|
|
|
|
int rid;
|
|
|
|
|
|
|
|
STAILQ_FOREACH(rle, rl, link) {
|
|
|
|
if (!rle->res) {
|
|
|
|
rid = rle->rid;
|
|
|
|
resource_list_alloc(rl, dev, child, rle->type, &rid,
|
2016-03-03 05:07:35 +00:00
|
|
|
0, ~0, 1, 0);
|
2008-11-18 21:01:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Called after other devices have initialised to probe for isa devices.
|
|
|
|
*/
|
1999-09-01 20:53:43 +00:00
|
|
|
void
|
|
|
|
isa_probe_children(device_t dev)
|
|
|
|
{
|
2008-11-18 21:01:54 +00:00
|
|
|
struct isa_device *idev;
|
|
|
|
device_t *children, child;
|
2001-08-10 07:50:14 +00:00
|
|
|
struct isa_config *cfg;
|
2017-12-23 22:57:14 +00:00
|
|
|
int nchildren, i, err;
|
1999-09-01 20:53:43 +00:00
|
|
|
|
1999-11-11 16:48:00 +00:00
|
|
|
/*
|
2008-11-18 21:01:54 +00:00
|
|
|
* Create all the non-hinted children by calling drivers'
|
|
|
|
* identify methods.
|
1999-11-11 16:48:00 +00:00
|
|
|
*/
|
|
|
|
bus_generic_probe(dev);
|
|
|
|
|
1999-09-01 20:53:43 +00:00
|
|
|
if (device_get_children(dev, &children, &nchildren))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
1999-10-03 12:13:06 +00:00
|
|
|
* First disable all pnp devices so that they don't get
|
|
|
|
* matched by legacy probes.
|
|
|
|
*/
|
1999-11-11 16:48:00 +00:00
|
|
|
if (bootverbose)
|
|
|
|
printf("isa_probe_children: disabling PnP devices\n");
|
2001-08-10 07:50:14 +00:00
|
|
|
|
|
|
|
cfg = malloc(sizeof(*cfg), M_TEMP, M_NOWAIT|M_ZERO);
|
|
|
|
if (cfg == NULL) {
|
|
|
|
free(children, M_TEMP);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-10-03 12:13:06 +00:00
|
|
|
for (i = 0; i < nchildren; i++) {
|
2008-11-18 21:01:54 +00:00
|
|
|
idev = DEVTOISA(children[i]);
|
1999-10-03 12:13:06 +00:00
|
|
|
|
2001-08-10 07:50:14 +00:00
|
|
|
bzero(cfg, sizeof(*cfg));
|
1999-10-03 12:13:06 +00:00
|
|
|
if (idev->id_config_cb)
|
2001-08-10 07:50:14 +00:00
|
|
|
idev->id_config_cb(idev->id_config_arg, cfg, 0);
|
1999-10-03 12:13:06 +00:00
|
|
|
}
|
|
|
|
|
2001-08-10 07:50:14 +00:00
|
|
|
free(cfg, M_TEMP);
|
|
|
|
|
1999-10-03 12:13:06 +00:00
|
|
|
/*
|
2008-11-18 21:01:54 +00:00
|
|
|
* Next, probe all the PnP BIOS devices so they can subsume any
|
|
|
|
* hints.
|
1999-09-01 20:53:43 +00:00
|
|
|
*/
|
2008-11-18 21:01:54 +00:00
|
|
|
for (i = 0; i < nchildren; i++) {
|
|
|
|
child = children[i];
|
|
|
|
idev = DEVTOISA(child);
|
|
|
|
|
|
|
|
if (idev->id_order > ISA_ORDER_PNPBIOS)
|
|
|
|
continue;
|
|
|
|
if (!TAILQ_EMPTY(&idev->id_configs) &&
|
|
|
|
!isa_assign_resources(child))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (device_probe_and_attach(child) == 0)
|
|
|
|
isa_claim_resources(dev, child);
|
|
|
|
}
|
|
|
|
free(children, M_TEMP);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Next, enumerate hinted devices and probe all non-pnp devices so
|
|
|
|
* that they claim their resources first.
|
|
|
|
*/
|
|
|
|
bus_enumerate_hinted_children(dev);
|
|
|
|
if (device_get_children(dev, &children, &nchildren))
|
|
|
|
return;
|
1999-11-11 16:48:00 +00:00
|
|
|
if (bootverbose)
|
|
|
|
printf("isa_probe_children: probing non-PnP devices\n");
|
1999-09-01 20:53:43 +00:00
|
|
|
for (i = 0; i < nchildren; i++) {
|
2008-11-18 21:01:54 +00:00
|
|
|
child = children[i];
|
|
|
|
idev = DEVTOISA(child);
|
1999-09-01 20:53:43 +00:00
|
|
|
|
2008-11-18 21:01:54 +00:00
|
|
|
if (device_is_attached(child) ||
|
|
|
|
!TAILQ_EMPTY(&idev->id_configs))
|
1999-09-01 20:53:43 +00:00
|
|
|
continue;
|
|
|
|
|
2017-12-23 22:57:14 +00:00
|
|
|
err = device_probe_and_attach(child);
|
|
|
|
if (err == 0 && idev->id_vendorid == 0 &&
|
2017-12-30 08:16:31 +00:00
|
|
|
strcmp(kern_ident, "GENERIC") == 0 &&
|
|
|
|
device_is_attached(child))
|
2017-12-23 22:57:14 +00:00
|
|
|
device_printf(child,
|
2017-12-30 08:16:31 +00:00
|
|
|
"non-PNP ISA device will be removed from GENERIC in FreeBSD 12.\n");
|
1999-09-01 20:53:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1999-10-03 12:13:06 +00:00
|
|
|
* Finally assign resource to pnp devices and probe them.
|
1999-09-01 20:53:43 +00:00
|
|
|
*/
|
1999-11-11 16:48:00 +00:00
|
|
|
if (bootverbose)
|
|
|
|
printf("isa_probe_children: probing PnP devices\n");
|
1999-09-01 20:53:43 +00:00
|
|
|
for (i = 0; i < nchildren; i++) {
|
2008-11-18 21:01:54 +00:00
|
|
|
child = children[i];
|
|
|
|
idev = DEVTOISA(child);
|
1999-09-01 20:53:43 +00:00
|
|
|
|
2008-11-18 21:01:54 +00:00
|
|
|
if (device_is_attached(child) || TAILQ_EMPTY(&idev->id_configs))
|
1999-09-01 20:53:43 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (isa_assign_resources(child)) {
|
|
|
|
device_probe_and_attach(child);
|
2008-11-18 21:01:54 +00:00
|
|
|
isa_claim_resources(dev, child);
|
1999-09-01 20:53:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
free(children, M_TEMP);
|
1999-11-11 16:48:00 +00:00
|
|
|
|
|
|
|
isa_running = 1;
|
1999-09-01 20:53:43 +00:00
|
|
|
}
|
|
|
|
|
1999-05-22 15:18:28 +00:00
|
|
|
/*
|
|
|
|
* Add a new child with default ivars.
|
|
|
|
*/
|
|
|
|
static device_t
|
2010-09-10 11:19:03 +00:00
|
|
|
isa_add_child(device_t dev, u_int order, const char *name, int unit)
|
1999-05-22 15:18:28 +00:00
|
|
|
{
|
1999-12-03 08:41:24 +00:00
|
|
|
device_t child;
|
1999-05-22 15:18:28 +00:00
|
|
|
struct isa_device *idev;
|
|
|
|
|
2002-09-30 07:56:12 +00:00
|
|
|
child = device_add_child_ordered(dev, order, name, unit);
|
|
|
|
if (child == NULL)
|
|
|
|
return (child);
|
|
|
|
|
2000-12-08 21:51:06 +00:00
|
|
|
idev = malloc(sizeof(struct isa_device), M_ISADEV, M_NOWAIT | M_ZERO);
|
1999-05-22 15:18:28 +00:00
|
|
|
if (!idev)
|
2004-12-24 22:31:47 +00:00
|
|
|
return (0);
|
1999-05-22 15:18:28 +00:00
|
|
|
|
|
|
|
resource_list_init(&idev->id_resources);
|
1999-09-01 20:53:43 +00:00
|
|
|
TAILQ_INIT(&idev->id_configs);
|
2008-11-18 21:01:54 +00:00
|
|
|
idev->id_order = order;
|
1999-05-22 15:18:28 +00:00
|
|
|
|
2002-09-30 07:56:12 +00:00
|
|
|
device_set_ivars(child, idev);
|
1999-12-03 08:41:24 +00:00
|
|
|
|
2002-09-30 07:56:12 +00:00
|
|
|
return (child);
|
1999-05-22 15:18:28 +00:00
|
|
|
}
|
|
|
|
|
1999-07-29 01:03:04 +00:00
|
|
|
static int
|
2000-06-25 09:19:02 +00:00
|
|
|
isa_print_all_resources(device_t dev)
|
1999-05-22 15:18:28 +00:00
|
|
|
{
|
|
|
|
struct isa_device *idev = DEVTOISA(dev);
|
|
|
|
struct resource_list *rl = &idev->id_resources;
|
1999-07-29 01:03:04 +00:00
|
|
|
int retval = 0;
|
|
|
|
|
2005-03-18 05:19:50 +00:00
|
|
|
if (STAILQ_FIRST(rl) || device_get_flags(dev))
|
1999-07-29 01:03:04 +00:00
|
|
|
retval += printf(" at");
|
1999-05-22 15:18:28 +00:00
|
|
|
|
2016-03-22 22:25:08 +00:00
|
|
|
retval += resource_list_print_type(rl, "port", SYS_RES_IOPORT, "%#jx");
|
|
|
|
retval += resource_list_print_type(rl, "iomem", SYS_RES_MEMORY, "%#jx");
|
|
|
|
retval += resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%jd");
|
|
|
|
retval += resource_list_print_type(rl, "drq", SYS_RES_DRQ, "%jd");
|
1999-09-07 08:42:49 +00:00
|
|
|
if (device_get_flags(dev))
|
|
|
|
retval += printf(" flags %#x", device_get_flags(dev));
|
2005-08-01 07:03:10 +00:00
|
|
|
if (idev->id_vendorid)
|
|
|
|
retval += printf(" pnpid %s", pnp_eisaformat(idev->id_vendorid));
|
1999-07-29 01:03:04 +00:00
|
|
|
|
2004-12-24 22:31:47 +00:00
|
|
|
return (retval);
|
2000-06-25 09:19:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
isa_print_child(device_t bus, device_t dev)
|
|
|
|
{
|
|
|
|
int retval = 0;
|
|
|
|
|
|
|
|
retval += bus_print_child_header(bus, dev);
|
|
|
|
retval += isa_print_all_resources(dev);
|
1999-07-29 01:03:04 +00:00
|
|
|
retval += bus_print_child_footer(bus, dev);
|
1999-05-22 15:18:28 +00:00
|
|
|
|
1999-07-29 01:03:04 +00:00
|
|
|
return (retval);
|
1999-05-22 15:18:28 +00:00
|
|
|
}
|
|
|
|
|
2000-06-25 09:19:02 +00:00
|
|
|
static void
|
|
|
|
isa_probe_nomatch(device_t dev, device_t child)
|
|
|
|
{
|
2000-07-12 00:42:08 +00:00
|
|
|
if (bootverbose) {
|
|
|
|
bus_print_child_header(dev, child);
|
|
|
|
printf(" failed to probe");
|
2000-06-25 09:19:02 +00:00
|
|
|
isa_print_all_resources(child);
|
2000-07-12 00:42:08 +00:00
|
|
|
bus_print_child_footer(dev, child);
|
|
|
|
}
|
2000-06-25 09:19:02 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-05-22 15:18:28 +00:00
|
|
|
static int
|
|
|
|
isa_read_ivar(device_t bus, device_t dev, int index, uintptr_t * result)
|
|
|
|
{
|
|
|
|
struct isa_device* idev = DEVTOISA(dev);
|
|
|
|
struct resource_list *rl = &idev->id_resources;
|
|
|
|
struct resource_list_entry *rle;
|
|
|
|
|
|
|
|
switch (index) {
|
|
|
|
case ISA_IVAR_PORT_0:
|
|
|
|
rle = resource_list_find(rl, SYS_RES_IOPORT, 0);
|
|
|
|
if (rle)
|
|
|
|
*result = rle->start;
|
|
|
|
else
|
|
|
|
*result = -1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ISA_IVAR_PORT_1:
|
|
|
|
rle = resource_list_find(rl, SYS_RES_IOPORT, 1);
|
|
|
|
if (rle)
|
|
|
|
*result = rle->start;
|
|
|
|
else
|
|
|
|
*result = -1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ISA_IVAR_PORTSIZE_0:
|
|
|
|
rle = resource_list_find(rl, SYS_RES_IOPORT, 0);
|
|
|
|
if (rle)
|
|
|
|
*result = rle->count;
|
|
|
|
else
|
|
|
|
*result = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ISA_IVAR_PORTSIZE_1:
|
|
|
|
rle = resource_list_find(rl, SYS_RES_IOPORT, 1);
|
|
|
|
if (rle)
|
|
|
|
*result = rle->count;
|
|
|
|
else
|
|
|
|
*result = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ISA_IVAR_MADDR_0:
|
|
|
|
rle = resource_list_find(rl, SYS_RES_MEMORY, 0);
|
|
|
|
if (rle)
|
|
|
|
*result = rle->start;
|
|
|
|
else
|
|
|
|
*result = -1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ISA_IVAR_MADDR_1:
|
|
|
|
rle = resource_list_find(rl, SYS_RES_MEMORY, 1);
|
|
|
|
if (rle)
|
|
|
|
*result = rle->start;
|
|
|
|
else
|
|
|
|
*result = -1;
|
|
|
|
break;
|
|
|
|
|
2002-10-15 00:02:51 +00:00
|
|
|
case ISA_IVAR_MEMSIZE_0:
|
1999-05-22 15:18:28 +00:00
|
|
|
rle = resource_list_find(rl, SYS_RES_MEMORY, 0);
|
|
|
|
if (rle)
|
|
|
|
*result = rle->count;
|
|
|
|
else
|
|
|
|
*result = 0;
|
|
|
|
break;
|
|
|
|
|
2002-10-15 00:02:51 +00:00
|
|
|
case ISA_IVAR_MEMSIZE_1:
|
1999-05-22 15:18:28 +00:00
|
|
|
rle = resource_list_find(rl, SYS_RES_MEMORY, 1);
|
|
|
|
if (rle)
|
|
|
|
*result = rle->count;
|
|
|
|
else
|
|
|
|
*result = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ISA_IVAR_IRQ_0:
|
|
|
|
rle = resource_list_find(rl, SYS_RES_IRQ, 0);
|
|
|
|
if (rle)
|
|
|
|
*result = rle->start;
|
|
|
|
else
|
|
|
|
*result = -1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ISA_IVAR_IRQ_1:
|
|
|
|
rle = resource_list_find(rl, SYS_RES_IRQ, 1);
|
|
|
|
if (rle)
|
|
|
|
*result = rle->start;
|
|
|
|
else
|
|
|
|
*result = -1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ISA_IVAR_DRQ_0:
|
|
|
|
rle = resource_list_find(rl, SYS_RES_DRQ, 0);
|
|
|
|
if (rle)
|
|
|
|
*result = rle->start;
|
|
|
|
else
|
|
|
|
*result = -1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ISA_IVAR_DRQ_1:
|
|
|
|
rle = resource_list_find(rl, SYS_RES_DRQ, 1);
|
|
|
|
if (rle)
|
|
|
|
*result = rle->start;
|
|
|
|
else
|
|
|
|
*result = -1;
|
|
|
|
break;
|
|
|
|
|
1999-05-30 11:02:17 +00:00
|
|
|
case ISA_IVAR_VENDORID:
|
|
|
|
*result = idev->id_vendorid;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ISA_IVAR_SERIAL:
|
|
|
|
*result = idev->id_serial;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ISA_IVAR_LOGICALID:
|
|
|
|
*result = idev->id_logicalid;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ISA_IVAR_COMPATID:
|
|
|
|
*result = idev->id_compatid;
|
|
|
|
break;
|
|
|
|
|
2001-09-03 09:45:41 +00:00
|
|
|
case ISA_IVAR_CONFIGATTR:
|
|
|
|
*result = idev->id_config_attr;
|
|
|
|
break;
|
|
|
|
|
2008-11-02 18:48:54 +00:00
|
|
|
case ISA_IVAR_PNP_CSN:
|
|
|
|
*result = idev->id_pnp_csn;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ISA_IVAR_PNP_LDN:
|
|
|
|
*result = idev->id_pnp_ldn;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ISA_IVAR_PNPBIOS_HANDLE:
|
|
|
|
*result = idev->id_pnpbios_handle;
|
|
|
|
break;
|
|
|
|
|
1999-05-30 11:02:17 +00:00
|
|
|
default:
|
2004-12-24 22:31:47 +00:00
|
|
|
return (ENOENT);
|
1999-05-22 15:18:28 +00:00
|
|
|
}
|
1999-05-30 11:02:17 +00:00
|
|
|
|
2004-12-24 22:31:47 +00:00
|
|
|
return (0);
|
1999-05-22 15:18:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2004-12-24 22:31:47 +00:00
|
|
|
isa_write_ivar(device_t bus, device_t dev, int index, uintptr_t value)
|
1999-05-22 15:18:28 +00:00
|
|
|
{
|
|
|
|
struct isa_device* idev = DEVTOISA(dev);
|
|
|
|
|
|
|
|
switch (index) {
|
|
|
|
case ISA_IVAR_PORT_0:
|
|
|
|
case ISA_IVAR_PORT_1:
|
|
|
|
case ISA_IVAR_PORTSIZE_0:
|
|
|
|
case ISA_IVAR_PORTSIZE_1:
|
|
|
|
case ISA_IVAR_MADDR_0:
|
|
|
|
case ISA_IVAR_MADDR_1:
|
2002-10-15 00:02:51 +00:00
|
|
|
case ISA_IVAR_MEMSIZE_0:
|
|
|
|
case ISA_IVAR_MEMSIZE_1:
|
1999-05-22 15:18:28 +00:00
|
|
|
case ISA_IVAR_IRQ_0:
|
|
|
|
case ISA_IVAR_IRQ_1:
|
|
|
|
case ISA_IVAR_DRQ_0:
|
|
|
|
case ISA_IVAR_DRQ_1:
|
2004-12-24 22:31:47 +00:00
|
|
|
return (EINVAL);
|
1999-05-22 15:18:28 +00:00
|
|
|
|
1999-05-30 11:02:17 +00:00
|
|
|
case ISA_IVAR_VENDORID:
|
|
|
|
idev->id_vendorid = value;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ISA_IVAR_SERIAL:
|
|
|
|
idev->id_serial = value;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ISA_IVAR_LOGICALID:
|
|
|
|
idev->id_logicalid = value;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ISA_IVAR_COMPATID:
|
|
|
|
idev->id_compatid = value;
|
|
|
|
break;
|
|
|
|
|
2001-09-03 09:45:41 +00:00
|
|
|
case ISA_IVAR_CONFIGATTR:
|
|
|
|
idev->id_config_attr = value;
|
|
|
|
break;
|
|
|
|
|
1999-05-22 15:18:28 +00:00
|
|
|
default:
|
|
|
|
return (ENOENT);
|
|
|
|
}
|
1999-05-30 11:02:17 +00:00
|
|
|
|
1999-05-22 15:18:28 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1999-09-01 20:53:43 +00:00
|
|
|
/*
|
|
|
|
* Free any resources which the driver missed or which we were holding for
|
|
|
|
* it (see isa_probe_children).
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
isa_child_detached(device_t dev, device_t child)
|
|
|
|
{
|
|
|
|
struct isa_device* idev = DEVTOISA(child);
|
|
|
|
|
2008-11-18 21:01:54 +00:00
|
|
|
if (TAILQ_FIRST(&idev->id_configs))
|
|
|
|
isa_claim_resources(dev, child);
|
1999-09-01 20:53:43 +00:00
|
|
|
}
|
|
|
|
|
1999-11-11 16:48:00 +00:00
|
|
|
static void
|
|
|
|
isa_driver_added(device_t dev, driver_t *driver)
|
|
|
|
{
|
|
|
|
device_t *children;
|
|
|
|
int nchildren, i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't do anything if drivers are dynamically
|
|
|
|
* added during autoconfiguration (cf. ymf724).
|
|
|
|
* since that would end up calling identify
|
|
|
|
* twice.
|
|
|
|
*/
|
|
|
|
if (!isa_running)
|
|
|
|
return;
|
|
|
|
|
|
|
|
DEVICE_IDENTIFY(driver, dev);
|
|
|
|
if (device_get_children(dev, &children, &nchildren))
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < nchildren; i++) {
|
|
|
|
device_t child = children[i];
|
|
|
|
struct isa_device *idev = DEVTOISA(child);
|
|
|
|
struct resource_list *rl = &idev->id_resources;
|
|
|
|
struct resource_list_entry *rle;
|
|
|
|
|
|
|
|
if (device_get_state(child) != DS_NOTPRESENT)
|
|
|
|
continue;
|
2000-06-25 09:19:02 +00:00
|
|
|
if (!device_is_enabled(child))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Free resources which we were holding on behalf of
|
|
|
|
* the device.
|
|
|
|
*/
|
2005-03-18 05:19:50 +00:00
|
|
|
STAILQ_FOREACH(rle, &idev->id_resources, link) {
|
2000-06-25 09:19:02 +00:00
|
|
|
if (rle->res)
|
|
|
|
resource_list_release(rl, dev, child,
|
|
|
|
rle->type,
|
|
|
|
rle->rid,
|
|
|
|
rle->res);
|
|
|
|
}
|
1999-11-11 16:48:00 +00:00
|
|
|
|
|
|
|
if (TAILQ_FIRST(&idev->id_configs))
|
|
|
|
if (!isa_assign_resources(child))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
device_probe_and_attach(child);
|
|
|
|
|
2008-11-18 21:01:54 +00:00
|
|
|
if (TAILQ_FIRST(&idev->id_configs))
|
|
|
|
isa_claim_resources(dev, child);
|
1999-11-11 16:48:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
free(children, M_TEMP);
|
|
|
|
}
|
|
|
|
|
1999-05-22 15:18:28 +00:00
|
|
|
static int
|
|
|
|
isa_set_resource(device_t dev, device_t child, int type, int rid,
|
2016-01-27 02:23:54 +00:00
|
|
|
rman_res_t start, rman_res_t count)
|
1999-05-22 15:18:28 +00:00
|
|
|
{
|
|
|
|
struct isa_device* idev = DEVTOISA(child);
|
|
|
|
struct resource_list *rl = &idev->id_resources;
|
|
|
|
|
|
|
|
if (type != SYS_RES_IOPORT && type != SYS_RES_MEMORY
|
|
|
|
&& type != SYS_RES_IRQ && type != SYS_RES_DRQ)
|
2004-12-24 22:31:47 +00:00
|
|
|
return (EINVAL);
|
1999-09-01 20:53:43 +00:00
|
|
|
if (rid < 0)
|
2004-12-24 22:31:47 +00:00
|
|
|
return (EINVAL);
|
1999-09-01 20:53:43 +00:00
|
|
|
if (type == SYS_RES_IOPORT && rid >= ISA_NPORT)
|
2004-12-24 22:31:47 +00:00
|
|
|
return (EINVAL);
|
1999-09-01 20:53:43 +00:00
|
|
|
if (type == SYS_RES_MEMORY && rid >= ISA_NMEM)
|
2004-12-24 22:31:47 +00:00
|
|
|
return (EINVAL);
|
1999-09-01 20:53:43 +00:00
|
|
|
if (type == SYS_RES_IRQ && rid >= ISA_NIRQ)
|
2004-12-24 22:31:47 +00:00
|
|
|
return (EINVAL);
|
1999-09-01 20:53:43 +00:00
|
|
|
if (type == SYS_RES_DRQ && rid >= ISA_NDRQ)
|
2004-12-24 22:31:47 +00:00
|
|
|
return (EINVAL);
|
1999-05-22 15:18:28 +00:00
|
|
|
|
|
|
|
resource_list_add(rl, type, rid, start, start + count - 1, count);
|
|
|
|
|
2004-12-24 22:31:47 +00:00
|
|
|
return (0);
|
1999-05-22 15:18:28 +00:00
|
|
|
}
|
|
|
|
|
2000-11-28 07:12:12 +00:00
|
|
|
static struct resource_list *
|
|
|
|
isa_get_resource_list (device_t dev, device_t child)
|
1999-05-22 15:18:28 +00:00
|
|
|
{
|
|
|
|
struct isa_device* idev = DEVTOISA(child);
|
|
|
|
struct resource_list *rl = &idev->id_resources;
|
|
|
|
|
2000-11-28 07:12:12 +00:00
|
|
|
if (!rl)
|
|
|
|
return (NULL);
|
1999-05-22 15:18:28 +00:00
|
|
|
|
2000-11-28 07:12:12 +00:00
|
|
|
return (rl);
|
1999-05-30 11:02:17 +00:00
|
|
|
}
|
|
|
|
|
1999-09-01 20:53:43 +00:00
|
|
|
static int
|
2004-12-24 22:31:47 +00:00
|
|
|
isa_add_config(device_t dev, device_t child, int priority,
|
|
|
|
struct isa_config *config)
|
1999-09-01 20:53:43 +00:00
|
|
|
{
|
|
|
|
struct isa_device* idev = DEVTOISA(child);
|
|
|
|
struct isa_config_entry *newice, *ice;
|
|
|
|
|
|
|
|
newice = malloc(sizeof *ice, M_DEVBUF, M_NOWAIT);
|
|
|
|
if (!newice)
|
2004-12-24 22:31:47 +00:00
|
|
|
return (ENOMEM);
|
1999-09-01 20:53:43 +00:00
|
|
|
|
|
|
|
newice->ice_priority = priority;
|
|
|
|
newice->ice_config = *config;
|
|
|
|
|
|
|
|
TAILQ_FOREACH(ice, &idev->id_configs, ice_link) {
|
|
|
|
if (ice->ice_priority > priority)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (ice)
|
|
|
|
TAILQ_INSERT_BEFORE(ice, newice, ice_link);
|
|
|
|
else
|
|
|
|
TAILQ_INSERT_TAIL(&idev->id_configs, newice, ice_link);
|
|
|
|
|
2004-12-24 22:31:47 +00:00
|
|
|
return (0);
|
1999-09-01 20:53:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-12-24 22:31:47 +00:00
|
|
|
isa_set_config_callback(device_t dev, device_t child, isa_config_cb *fn,
|
|
|
|
void *arg)
|
1999-09-01 20:53:43 +00:00
|
|
|
{
|
|
|
|
struct isa_device* idev = DEVTOISA(child);
|
|
|
|
|
|
|
|
idev->id_config_cb = fn;
|
|
|
|
idev->id_config_arg = arg;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
isa_pnp_probe(device_t dev, device_t child, struct isa_pnp_id *ids)
|
|
|
|
{
|
|
|
|
struct isa_device* idev = DEVTOISA(child);
|
|
|
|
|
|
|
|
if (!idev->id_vendorid)
|
2004-12-24 22:31:47 +00:00
|
|
|
return (ENOENT);
|
1999-09-01 20:53:43 +00:00
|
|
|
|
2001-08-30 09:14:28 +00:00
|
|
|
while (ids && ids->ip_id) {
|
1999-09-01 20:53:43 +00:00
|
|
|
/*
|
|
|
|
* Really ought to support >1 compat id per device.
|
|
|
|
*/
|
|
|
|
if (idev->id_logicalid == ids->ip_id
|
|
|
|
|| idev->id_compatid == ids->ip_id) {
|
1999-09-04 14:43:35 +00:00
|
|
|
if (ids->ip_desc)
|
|
|
|
device_set_desc(child, ids->ip_desc);
|
2004-12-24 22:31:47 +00:00
|
|
|
return (0);
|
1999-09-01 20:53:43 +00:00
|
|
|
}
|
|
|
|
ids++;
|
|
|
|
}
|
|
|
|
|
2004-12-24 22:31:47 +00:00
|
|
|
return (ENXIO);
|
1999-09-01 20:53:43 +00:00
|
|
|
}
|
|
|
|
|
2005-08-01 07:03:10 +00:00
|
|
|
static int
|
|
|
|
isa_child_pnpinfo_str(device_t bus, device_t child, char *buf,
|
|
|
|
size_t buflen)
|
|
|
|
{
|
|
|
|
struct isa_device *idev = DEVTOISA(child);
|
|
|
|
|
|
|
|
if (idev->id_vendorid)
|
|
|
|
snprintf(buf, buflen, "pnpid=%s",
|
|
|
|
pnp_eisaformat(idev->id_vendorid));
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
isa_child_location_str(device_t bus, device_t child, char *buf,
|
|
|
|
size_t buflen)
|
|
|
|
{
|
2008-11-02 18:48:54 +00:00
|
|
|
#if 0
|
|
|
|
/* id_pnphandle isn't there yet */
|
|
|
|
struct isa_device *idev = DEVTOISA(child);
|
|
|
|
|
|
|
|
if (idev->id_vendorid)
|
|
|
|
snprintf(buf, buflen, "pnphandle=%d", idev->id_pnphandle);
|
|
|
|
#endif
|
2005-08-01 07:03:10 +00:00
|
|
|
/* Nothing here yet */
|
|
|
|
*buf = '\0';
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1999-05-22 15:18:28 +00:00
|
|
|
static device_method_t isa_methods[] = {
|
|
|
|
/* Device interface */
|
|
|
|
DEVMETHOD(device_probe, isa_probe),
|
|
|
|
DEVMETHOD(device_attach, isa_attach),
|
|
|
|
DEVMETHOD(device_detach, bus_generic_detach),
|
|
|
|
DEVMETHOD(device_shutdown, bus_generic_shutdown),
|
|
|
|
DEVMETHOD(device_suspend, bus_generic_suspend),
|
|
|
|
DEVMETHOD(device_resume, bus_generic_resume),
|
|
|
|
|
|
|
|
/* Bus interface */
|
|
|
|
DEVMETHOD(bus_add_child, isa_add_child),
|
|
|
|
DEVMETHOD(bus_print_child, isa_print_child),
|
2000-06-25 09:19:02 +00:00
|
|
|
DEVMETHOD(bus_probe_nomatch, isa_probe_nomatch),
|
1999-05-22 15:18:28 +00:00
|
|
|
DEVMETHOD(bus_read_ivar, isa_read_ivar),
|
|
|
|
DEVMETHOD(bus_write_ivar, isa_write_ivar),
|
1999-09-01 20:53:43 +00:00
|
|
|
DEVMETHOD(bus_child_detached, isa_child_detached),
|
1999-11-11 16:48:00 +00:00
|
|
|
DEVMETHOD(bus_driver_added, isa_driver_added),
|
2011-05-06 13:48:53 +00:00
|
|
|
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
|
|
|
|
DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
|
2000-11-28 07:12:12 +00:00
|
|
|
|
|
|
|
DEVMETHOD(bus_get_resource_list,isa_get_resource_list),
|
1999-05-22 15:18:28 +00:00
|
|
|
DEVMETHOD(bus_alloc_resource, isa_alloc_resource),
|
|
|
|
DEVMETHOD(bus_release_resource, isa_release_resource),
|
2000-11-28 07:12:12 +00:00
|
|
|
DEVMETHOD(bus_set_resource, isa_set_resource),
|
|
|
|
DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource),
|
|
|
|
DEVMETHOD(bus_delete_resource, bus_generic_rl_delete_resource),
|
1999-05-22 15:18:28 +00:00
|
|
|
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
|
|
|
|
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
|
2005-08-01 07:03:10 +00:00
|
|
|
DEVMETHOD(bus_child_pnpinfo_str, isa_child_pnpinfo_str),
|
|
|
|
DEVMETHOD(bus_child_location_str, isa_child_location_str),
|
2008-11-18 21:01:54 +00:00
|
|
|
DEVMETHOD(bus_hinted_child, isa_hinted_child),
|
|
|
|
DEVMETHOD(bus_hint_device_unit, isa_hint_device_unit),
|
1999-05-22 15:18:28 +00:00
|
|
|
|
|
|
|
/* ISA interface */
|
1999-09-01 20:53:43 +00:00
|
|
|
DEVMETHOD(isa_add_config, isa_add_config),
|
|
|
|
DEVMETHOD(isa_set_config_callback, isa_set_config_callback),
|
|
|
|
DEVMETHOD(isa_pnp_probe, isa_pnp_probe),
|
1999-05-22 15:18:28 +00:00
|
|
|
|
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
2008-11-18 21:01:54 +00:00
|
|
|
DEFINE_CLASS_0(isa, isa_driver, isa_methods, 0);
|
1999-05-22 15:18:28 +00:00
|
|
|
|
2004-12-24 23:03:17 +00:00
|
|
|
devclass_t isa_devclass;
|
|
|
|
|
1999-05-22 15:18:28 +00:00
|
|
|
/*
|
2004-12-24 23:03:17 +00:00
|
|
|
* ISA can be attached to a PCI-ISA bridge, or other locations on some
|
|
|
|
* platforms.
|
1999-05-22 15:18:28 +00:00
|
|
|
*/
|
|
|
|
DRIVER_MODULE(isa, isab, isa_driver, isa_devclass, 0, 0);
|
2000-12-12 23:33:29 +00:00
|
|
|
DRIVER_MODULE(isa, eisab, isa_driver, isa_devclass, 0, 0);
|
2003-04-15 04:19:49 +00:00
|
|
|
MODULE_VERSION(isa, 1);
|
2003-07-08 18:56:58 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Code common to ISA bridges.
|
|
|
|
*/
|
|
|
|
|
|
|
|
devclass_t isab_devclass;
|
|
|
|
|
|
|
|
int
|
|
|
|
isab_attach(device_t dev)
|
|
|
|
{
|
|
|
|
device_t child;
|
|
|
|
|
|
|
|
child = device_add_child(dev, "isa", 0);
|
|
|
|
if (child != NULL)
|
|
|
|
return (bus_generic_attach(dev));
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
2017-12-23 22:57:14 +00:00
|
|
|
|
|
|
|
char *
|
|
|
|
pnp_eisaformat(uint32_t id)
|
|
|
|
{
|
|
|
|
uint8_t *data;
|
|
|
|
static char idbuf[8];
|
|
|
|
const char hextoascii[] = "0123456789abcdef";
|
|
|
|
|
|
|
|
id = htole32(id);
|
|
|
|
data = (uint8_t *)&id;
|
|
|
|
idbuf[0] = '@' + ((data[0] & 0x7c) >> 2);
|
|
|
|
idbuf[1] = '@' + (((data[0] & 0x3) << 3) + ((data[1] & 0xe0) >> 5));
|
|
|
|
idbuf[2] = '@' + (data[1] & 0x1f);
|
|
|
|
idbuf[3] = hextoascii[(data[2] >> 4)];
|
|
|
|
idbuf[4] = hextoascii[(data[2] & 0xf)];
|
|
|
|
idbuf[5] = hextoascii[(data[3] >> 4)];
|
|
|
|
idbuf[6] = hextoascii[(data[3] & 0xf)];
|
|
|
|
idbuf[7] = 0;
|
|
|
|
return(idbuf);
|
|
|
|
}
|