Added indirect pio into the bus space stuff for the NEC PC-98. bus.h

includes one of bus_at386.h and bus_pc98.h. Becuase only bus_pc98.h
supports indirect pio and bus_at386.h is identical to old bus.h, there
is no functional change in PC-AT's kernels.  That is, it cannot cause
performance loss.

Submitted by:	nyan
Reviewed by:	imp
bde and luoqi provided useful comments for earlier version.
This commit is contained in:
KATO Takenori 2000-03-29 03:15:22 +00:00
parent fe69f87383
commit 91cb959ddb
16 changed files with 867 additions and 2700 deletions

View File

@ -289,7 +289,17 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
rman_set_bustag(rv, I386_BUS_SPACE_MEM);
} else if (type == SYS_RES_IOPORT) {
rman_set_bustag(rv, I386_BUS_SPACE_IO);
#ifdef PC98
/* PC-98: the type of bus_space_handle_t is the structure. */
rv->r_bushandle.bsh_base = rv->r_start;
rv->r_bushandle.bsh_iat = NULL;
rv->r_bushandle.bsh_iatsz = 0;
rv->r_bushandle.bsh_res = NULL;
rv->r_bushandle.bsh_ressz = 0;
#else
/* IBM-PC: the type of bus_space_handle_t is u_int */
rman_set_bushandle(rv, rv->r_start);
#endif
}
if (needactivate) {
@ -329,7 +339,17 @@ nexus_activate_resource(device_t bus, device_t child, int type, int rid,
vaddr = (caddr_t) pmap_mapdev(paddr-poffs, psize+poffs) + poffs;
}
rman_set_virtual(r, vaddr);
#ifdef PC98
/* PC-98: the type of bus_space_handle_t is the structure. */
r->r_bushandle.bsh_base = (bus_addr_t) vaddr;
r->r_bushandle.bsh_iat = NULL;
r->r_bushandle.bsh_iatsz = 0;
r->r_bushandle.bsh_res = NULL;
r->r_bushandle.bsh_ressz = 0;
#else
/* IBM-PC: the type of bus_space_handle_t is u_int */
rman_set_bushandle(r, (bus_space_handle_t) vaddr);
#endif
}
return (rman_activate_resource(r));
}

View File

@ -289,7 +289,17 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
rman_set_bustag(rv, I386_BUS_SPACE_MEM);
} else if (type == SYS_RES_IOPORT) {
rman_set_bustag(rv, I386_BUS_SPACE_IO);
#ifdef PC98
/* PC-98: the type of bus_space_handle_t is the structure. */
rv->r_bushandle.bsh_base = rv->r_start;
rv->r_bushandle.bsh_iat = NULL;
rv->r_bushandle.bsh_iatsz = 0;
rv->r_bushandle.bsh_res = NULL;
rv->r_bushandle.bsh_ressz = 0;
#else
/* IBM-PC: the type of bus_space_handle_t is u_int */
rman_set_bushandle(rv, rv->r_start);
#endif
}
if (needactivate) {
@ -329,7 +339,17 @@ nexus_activate_resource(device_t bus, device_t child, int type, int rid,
vaddr = (caddr_t) pmap_mapdev(paddr-poffs, psize+poffs) + poffs;
}
rman_set_virtual(r, vaddr);
#ifdef PC98
/* PC-98: the type of bus_space_handle_t is the structure. */
r->r_bushandle.bsh_base = (bus_addr_t) vaddr;
r->r_bushandle.bsh_iat = NULL;
r->r_bushandle.bsh_iatsz = 0;
r->r_bushandle.bsh_res = NULL;
r->r_bushandle.bsh_ressz = 0;
#else
/* IBM-PC: the type of bus_space_handle_t is u_int */
rman_set_bushandle(r, (bus_space_handle_t) vaddr);
#endif
}
return (rman_activate_resource(r));
}

File diff suppressed because it is too large Load Diff

View File

@ -69,8 +69,8 @@
*/
/* $FreeBSD$ */
#ifndef _I386_BUS_H_
#define _I386_BUS_H_
#ifndef _I386_BUS_AT386_H_
#define _I386_BUS_AT386_H_
#include <machine/cpufunc.h>
@ -1288,4 +1288,4 @@ void _bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map);
if ((dmamap) != NULL) \
_bus_dmamap_unload(dmat, dmamap)
#endif /* _I386_BUS_H_ */
#endif /* _I386_BUS_AT386_H_ */

View File

@ -69,8 +69,8 @@
*/
/* $FreeBSD$ */
#ifndef _I386_BUS_H_
#define _I386_BUS_H_
#ifndef _I386_BUS_AT386_H_
#define _I386_BUS_AT386_H_
#include <machine/cpufunc.h>
@ -1288,4 +1288,4 @@ void _bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map);
if ((dmamap) != NULL) \
_bus_dmamap_unload(dmat, dmamap)
#endif /* _I386_BUS_H_ */
#endif /* _I386_BUS_AT386_H_ */

View File

@ -69,8 +69,8 @@
*/
/* $FreeBSD$ */
#ifndef _I386_BUS_H_
#define _I386_BUS_H_
#ifndef _I386_BUS_AT386_H_
#define _I386_BUS_AT386_H_
#include <machine/cpufunc.h>
@ -1288,4 +1288,4 @@ void _bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map);
if ((dmamap) != NULL) \
_bus_dmamap_unload(dmat, dmamap)
#endif /* _I386_BUS_H_ */
#endif /* _I386_BUS_AT386_H_ */

View File

@ -62,6 +62,7 @@
#include <sys/bus.h>
#include <sys/malloc.h>
#include <machine/bus.h>
#include <sys/rman.h>
#include <machine/resource.h>
@ -132,12 +133,113 @@ isa_alloc_resource(device_t bus, device_t child, int type, int *rid,
start, end, count, flags);
}
#ifdef PC98
/*
* Indirection support. The type of bus_space_handle_t is
* defined in sys/i386/include/bus_pc98.h.
*/
struct resource *
isa_alloc_resourcev(device_t child, int type, int *rid,
bus_addr_t *res, bus_size_t count, u_int flags)
{
struct isa_device* idev = DEVTOISA(child);
struct resource_list *rl = &idev->id_resources;
device_t bus = device_get_parent(child);
bus_addr_t ioport;
struct resource *re;
struct resource **bsre;
int i, j, k, linear_cnt, ressz, bsrid;
ioport = bus_get_resource_start(child, SYS_RES_IOPORT, 0);
linear_cnt = count;
ressz = 1;
for (i = 1; i < count; ++i) {
if (res[i] > res[i - 1] + 1) {
if (i < linear_cnt)
linear_cnt = i;
++ressz;
}
}
re = isa_alloc_resource(bus, child, type, rid, ioport + res[0],
ioport + res[linear_cnt - 1], linear_cnt, flags);
if (re == NULL)
return NULL;
bsre = malloc(sizeof (struct resource *) * ressz, M_DEVBUF, M_NOWAIT);
if (bsre == NULL) {
resource_list_release(rl, bus, child, type, *rid, re);
return NULL;
}
bsre[0] = re;
for (i = linear_cnt, k = 1; i < count; i = j, k++) {
for (j = i + 1; j < count; j++) {
if (res[j] > res[j - 1] + 1)
break;
}
bsrid = *rid + k;
bsre[k] = isa_alloc_resource(bus, child, type, &bsrid,
ioport + res[i], ioport + res[j - 1], j - i, flags);
if (bsre[k] == NULL) {
for (k--; k >= 0; k--)
resource_list_release(rl, bus, child, type,
*rid + k, bsre[k]);
free(bsre, M_DEVBUF);
return NULL;
}
}
re->r_bushandle.bsh_res = bsre;
re->r_bushandle.bsh_ressz = ressz;
return re;
}
int
isa_load_resourcev(struct resource *re, bus_addr_t *res, bus_size_t count)
{
bus_addr_t *addr;
int i;
addr = malloc(sizeof (bus_addr_t) * count, M_DEVBUF, M_NOWAIT);
if (addr == NULL)
return 1;
for (i = 0; i < count; i++)
addr[i] = rman_get_start(re) + res[i];
rman_set_bustag(re, I386_BUS_SPACE_IO_IND);
re->r_bushandle.bsh_iat = addr;
re->r_bushandle.bsh_iatsz = count;
return 0;
}
#endif /* PC98 */
int
isa_release_resource(device_t bus, device_t child, int type, int rid,
struct resource *r)
{
struct isa_device* idev = DEVTOISA(child);
struct resource_list *rl = &idev->id_resources;
#ifdef PC98
/*
* Indirection support. The type of bus_space_handle_t is
* defined in sys/i386/include/bus_pc98.h.
*/
int i;
for (i = 1; i < r->r_bushandle.bsh_ressz; i++)
resource_list_release(rl, bus, child, type, rid + i,
r->r_bushandle.bsh_res[i]);
if (r->r_bushandle.bsh_res != NULL)
free(r->r_bushandle.bsh_res, M_DEVBUF);
if (r->r_bushandle.bsh_iat != NULL)
free(r->r_bushandle.bsh_iat, M_DEVBUF);
#endif
return resource_list_release(rl, bus, child, type, rid, r);
}

View File

@ -289,7 +289,17 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
rman_set_bustag(rv, I386_BUS_SPACE_MEM);
} else if (type == SYS_RES_IOPORT) {
rman_set_bustag(rv, I386_BUS_SPACE_IO);
#ifdef PC98
/* PC-98: the type of bus_space_handle_t is the structure. */
rv->r_bushandle.bsh_base = rv->r_start;
rv->r_bushandle.bsh_iat = NULL;
rv->r_bushandle.bsh_iatsz = 0;
rv->r_bushandle.bsh_res = NULL;
rv->r_bushandle.bsh_ressz = 0;
#else
/* IBM-PC: the type of bus_space_handle_t is u_int */
rman_set_bushandle(rv, rv->r_start);
#endif
}
if (needactivate) {
@ -329,7 +339,17 @@ nexus_activate_resource(device_t bus, device_t child, int type, int rid,
vaddr = (caddr_t) pmap_mapdev(paddr-poffs, psize+poffs) + poffs;
}
rman_set_virtual(r, vaddr);
#ifdef PC98
/* PC-98: the type of bus_space_handle_t is the structure. */
r->r_bushandle.bsh_base = (bus_addr_t) vaddr;
r->r_bushandle.bsh_iat = NULL;
r->r_bushandle.bsh_iatsz = 0;
r->r_bushandle.bsh_res = NULL;
r->r_bushandle.bsh_ressz = 0;
#else
/* IBM-PC: the type of bus_space_handle_t is u_int */
rman_set_bushandle(r, (bus_space_handle_t) vaddr);
#endif
}
return (rman_activate_resource(r));
}

View File

@ -289,7 +289,17 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
rman_set_bustag(rv, I386_BUS_SPACE_MEM);
} else if (type == SYS_RES_IOPORT) {
rman_set_bustag(rv, I386_BUS_SPACE_IO);
#ifdef PC98
/* PC-98: the type of bus_space_handle_t is the structure. */
rv->r_bushandle.bsh_base = rv->r_start;
rv->r_bushandle.bsh_iat = NULL;
rv->r_bushandle.bsh_iatsz = 0;
rv->r_bushandle.bsh_res = NULL;
rv->r_bushandle.bsh_ressz = 0;
#else
/* IBM-PC: the type of bus_space_handle_t is u_int */
rman_set_bushandle(rv, rv->r_start);
#endif
}
if (needactivate) {
@ -329,7 +339,17 @@ nexus_activate_resource(device_t bus, device_t child, int type, int rid,
vaddr = (caddr_t) pmap_mapdev(paddr-poffs, psize+poffs) + poffs;
}
rman_set_virtual(r, vaddr);
#ifdef PC98
/* PC-98: the type of bus_space_handle_t is the structure. */
r->r_bushandle.bsh_base = (bus_addr_t) vaddr;
r->r_bushandle.bsh_iat = NULL;
r->r_bushandle.bsh_iatsz = 0;
r->r_bushandle.bsh_res = NULL;
r->r_bushandle.bsh_ressz = 0;
#else
/* IBM-PC: the type of bus_space_handle_t is u_int */
rman_set_bushandle(r, (bus_space_handle_t) vaddr);
#endif
}
return (rman_activate_resource(r));
}

File diff suppressed because it is too large Load Diff

View File

@ -69,8 +69,8 @@
*/
/* $FreeBSD$ */
#ifndef _I386_BUS_H_
#define _I386_BUS_H_
#ifndef _I386_BUS_AT386_H_
#define _I386_BUS_AT386_H_
#include <machine/cpufunc.h>
@ -1288,4 +1288,4 @@ void _bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map);
if ((dmamap) != NULL) \
_bus_dmamap_unload(dmat, dmamap)
#endif /* _I386_BUS_H_ */
#endif /* _I386_BUS_AT386_H_ */

View File

@ -69,8 +69,8 @@
*/
/* $FreeBSD$ */
#ifndef _I386_BUS_H_
#define _I386_BUS_H_
#ifndef _I386_BUS_AT386_H_
#define _I386_BUS_AT386_H_
#include <machine/cpufunc.h>
@ -1288,4 +1288,4 @@ void _bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map);
if ((dmamap) != NULL) \
_bus_dmamap_unload(dmat, dmamap)
#endif /* _I386_BUS_H_ */
#endif /* _I386_BUS_AT386_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,31 @@
/*
* Copyright (c) 1997 Justin Gibbs.
* 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,
* without modification, immediately at the beginning of the file.
* 2. The name of the author may not 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.
*
* $FreeBSD$
*/
#ifndef _I386_BUS_PIO_IND_H_
#define _I386_BUS_PIO_IND_H_
#endif /* _I386_BUS_PIO_IND_H_ */

View File

@ -62,6 +62,7 @@
#include <sys/bus.h>
#include <sys/malloc.h>
#include <machine/bus.h>
#include <sys/rman.h>
#include <machine/resource.h>
@ -132,12 +133,113 @@ isa_alloc_resource(device_t bus, device_t child, int type, int *rid,
start, end, count, flags);
}
#ifdef PC98
/*
* Indirection support. The type of bus_space_handle_t is
* defined in sys/i386/include/bus_pc98.h.
*/
struct resource *
isa_alloc_resourcev(device_t child, int type, int *rid,
bus_addr_t *res, bus_size_t count, u_int flags)
{
struct isa_device* idev = DEVTOISA(child);
struct resource_list *rl = &idev->id_resources;
device_t bus = device_get_parent(child);
bus_addr_t ioport;
struct resource *re;
struct resource **bsre;
int i, j, k, linear_cnt, ressz, bsrid;
ioport = bus_get_resource_start(child, SYS_RES_IOPORT, 0);
linear_cnt = count;
ressz = 1;
for (i = 1; i < count; ++i) {
if (res[i] > res[i - 1] + 1) {
if (i < linear_cnt)
linear_cnt = i;
++ressz;
}
}
re = isa_alloc_resource(bus, child, type, rid, ioport + res[0],
ioport + res[linear_cnt - 1], linear_cnt, flags);
if (re == NULL)
return NULL;
bsre = malloc(sizeof (struct resource *) * ressz, M_DEVBUF, M_NOWAIT);
if (bsre == NULL) {
resource_list_release(rl, bus, child, type, *rid, re);
return NULL;
}
bsre[0] = re;
for (i = linear_cnt, k = 1; i < count; i = j, k++) {
for (j = i + 1; j < count; j++) {
if (res[j] > res[j - 1] + 1)
break;
}
bsrid = *rid + k;
bsre[k] = isa_alloc_resource(bus, child, type, &bsrid,
ioport + res[i], ioport + res[j - 1], j - i, flags);
if (bsre[k] == NULL) {
for (k--; k >= 0; k--)
resource_list_release(rl, bus, child, type,
*rid + k, bsre[k]);
free(bsre, M_DEVBUF);
return NULL;
}
}
re->r_bushandle.bsh_res = bsre;
re->r_bushandle.bsh_ressz = ressz;
return re;
}
int
isa_load_resourcev(struct resource *re, bus_addr_t *res, bus_size_t count)
{
bus_addr_t *addr;
int i;
addr = malloc(sizeof (bus_addr_t) * count, M_DEVBUF, M_NOWAIT);
if (addr == NULL)
return 1;
for (i = 0; i < count; i++)
addr[i] = rman_get_start(re) + res[i];
rman_set_bustag(re, I386_BUS_SPACE_IO_IND);
re->r_bushandle.bsh_iat = addr;
re->r_bushandle.bsh_iatsz = count;
return 0;
}
#endif /* PC98 */
int
isa_release_resource(device_t bus, device_t child, int type, int rid,
struct resource *r)
{
struct isa_device* idev = DEVTOISA(child);
struct resource_list *rl = &idev->id_resources;
#ifdef PC98
/*
* Indirection support. The type of bus_space_handle_t is
* defined in sys/i386/include/bus_pc98.h.
*/
int i;
for (i = 1; i < r->r_bushandle.bsh_ressz; i++)
resource_list_release(rl, bus, child, type, rid + i,
r->r_bushandle.bsh_res[i]);
if (r->r_bushandle.bsh_res != NULL)
free(r->r_bushandle.bsh_res, M_DEVBUF);
if (r->r_bushandle.bsh_iat != NULL)
free(r->r_bushandle.bsh_iat, M_DEVBUF);
#endif
return resource_list_release(rl, bus, child, type, rid, r);
}

View File

@ -69,8 +69,8 @@
*/
/* $FreeBSD$ */
#ifndef _I386_BUS_H_
#define _I386_BUS_H_
#ifndef _I386_BUS_AT386_H_
#define _I386_BUS_AT386_H_
#include <machine/cpufunc.h>
@ -1288,4 +1288,4 @@ void _bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map);
if ((dmamap) != NULL) \
_bus_dmamap_unload(dmat, dmamap)
#endif /* _I386_BUS_H_ */
#endif /* _I386_BUS_AT386_H_ */