Replace resource map usage with extent maps.

This commit is contained in:
thorpej 2002-09-25 19:30:22 +00:00
parent 7216eba62a
commit da13a0afc7
5 changed files with 80 additions and 52 deletions

View File

@ -1,7 +1,7 @@
/* $NetBSD: autoconf.c,v 1.57 2002/04/17 20:40:30 gmcgarry Exp $ */
/* $NetBSD: autoconf.c,v 1.58 2002/09/25 19:30:22 thorpej Exp $ */
/*-
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
* Copyright (c) 1996, 1997, 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -99,7 +99,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.57 2002/04/17 20:40:30 gmcgarry Exp $");
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.58 2002/09/25 19:30:22 thorpej Exp $");
#include "hil.h"
#include "dvbox.h"
@ -121,12 +121,14 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.57 2002/04/17 20:40:30 gmcgarry Exp $
#include <sys/device.h>
#include <sys/disklabel.h>
#include <sys/malloc.h>
#include <sys/map.h>
#include <sys/extent.h>
#include <sys/mount.h>
#include <sys/queue.h>
#include <sys/reboot.h>
#include <sys/tty.h>
#include <uvm/uvm_extern.h>
#include <dev/cons.h>
#include <machine/autoconf.h>
@ -165,9 +167,6 @@ extern int dnkbdcnattach(bus_space_tag_t, bus_addr_t);
int dio_scan(int (*func)(bus_space_tag_t, bus_addr_t, int));
int dio_scode_probe(int, int (*func)(bus_space_tag_t, bus_addr_t, int));
/* XXX must be allocated statically because of early console init */
struct map extiomap[EIOMAPSIZE/16];
extern caddr_t internalhpib;
extern char *extiobase;
@ -178,6 +177,16 @@ int booted_partition;
/* How we were booted. */
u_int bootdev;
/*
* Extent map to manage the external I/O (DIO/DIO-II) space. We
* allocate storate for 8 regions in the map. extio_ex_malloc_safe
* will indicate that it's safe to use malloc() to dynamically allocate
* region descriptors in case we run out.
*/
static long extio_ex_storage[EXTENT_FIXED_STORAGE_SIZE(8) / sizeof(long)];
struct extent *extio_ex;
int extio_ex_malloc_safe;
/*
* This information is built during the autoconfig process.
* A little explanation about the way this works is in order.
@ -915,6 +924,20 @@ dio_scode_probe(scode, func)
* Mapping functions
**********************************************************************/
/*
* Initialize the external I/O extent map.
*/
void
iomap_init(void)
{
/* extiobase is initialized by pmap_bootstrap(). */
extio_ex = extent_create("extio", (u_long) extiobase,
(u_long) extiobase + (ptoa(EIOMAPSIZE) - 1), M_DEVBUF,
(caddr_t) extio_ex_storage, sizeof(extio_ex_storage),
EX_NOCOALESCE|EX_NOWAIT);
}
/*
* Allocate/deallocate a cache-inhibited range of kernel virtual address
* space mapping the indicated physical address range [pa - pa+size)
@ -924,20 +947,22 @@ iomap(pa, size)
caddr_t pa;
int size;
{
int ix, npf;
caddr_t kva;
u_long kva;
int error;
#ifdef DEBUG
if (((int)pa & PGOFSET) || (size & PGOFSET))
panic("iomap: unaligned");
#endif
npf = btoc(size);
ix = rmalloc(extiomap, npf);
if (ix == 0)
return(0);
kva = extiobase + ctob(ix-1);
physaccess(kva, pa, size, PG_RW|PG_CI);
return(kva);
error = extent_alloc(extio_ex, size, PAGE_SIZE, 0,
EX_FAST | EX_NOWAIT | (extio_ex_malloc_safe ? EX_MALLOCOK : 0),
&kva);
if (error)
return (0);
physaccess((caddr_t) kva, pa, size, PG_RW|PG_CI);
return ((caddr_t) kva);
}
/*
@ -948,15 +973,16 @@ iounmap(kva, size)
caddr_t kva;
int size;
{
int ix;
#ifdef DEBUG
if (((int)kva & PGOFSET) || (size & PGOFSET))
panic("iounmap: unaligned");
if (kva < extiobase || kva >= extiobase + ctob(EIOMAPSIZE))
if (kva < extiobase || kva >= extiobase + ptoa(EIOMAPSIZE))
panic("iounmap: bad address");
#endif
physunaccess(kva, size);
ix = btoc(kva - extiobase) + 1;
rmfree(extiomap, btoc(size), ix);
if (extent_free(extio_ex, (u_long) kva, size,
EX_NOWAIT | (extio_ex_malloc_safe ? EX_MALLOCOK : 0)))
printf("iounmap: kva %p size 0x%x: can't free region\n",
kva, size);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus_space.c,v 1.4 2002/03/15 05:55:37 gmcgarry Exp $ */
/* $NetBSD: bus_space.c,v 1.5 2002/09/25 19:30:22 thorpej Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -41,18 +41,18 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.4 2002/03/15 05:55:37 gmcgarry Exp $");
__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.5 2002/09/25 19:30:22 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/map.h>
#include <sys/extent.h>
#include <machine/autoconf.h>
#include <machine/bus.h>
#include <uvm/uvm_extern.h>
extern struct map extiomap[];
extern caddr_t extiobase;
extern char *extiobase;
extern int *nofault;
/* ARGSUSED */
@ -64,8 +64,8 @@ bus_space_map(t, bpa, size, flags, bshp)
int flags;
bus_space_handle_t *bshp;
{
int idx, npgs;
caddr_t kva;
u_long kva;
int error;
if (t == HP300_BUS_SPACE_INTIO) {
/*
@ -80,19 +80,19 @@ bus_space_map(t, bpa, size, flags, bshp)
panic("bus_space_map: bad space tag");
/*
* Allocate virtual address space from the extio resource map.
* Allocate virtual address space from the extio extent map.
*/
size = m68k_round_page(size);
npgs = btoc(size);
idx = rmalloc(extiomap, npgs);
if (idx == 0)
return (ENOMEM);
kva = extiobase + ctob(idx - 1);
error = extent_alloc(extio_ex, size, PAGE_SIZE, 0,
EX_FAST | EX_NOWAIT | (extio_ex_malloc_safe ? EX_MALLOCOK : 0),
&kva);
if (error)
return (error);
/*
* Map the range. The range is always cache-inhibited on the hp300.
*/
physaccess(kva, (caddr_t)bpa, size, PG_RW|PG_CI);
physaccess((caddr_t)kva, (caddr_t)bpa, size, PG_RW|PG_CI);
/*
* All done.
@ -139,7 +139,6 @@ bus_space_unmap(t, bsh, size)
bus_space_handle_t bsh;
bus_size_t size;
{
int idx;
if (t == HP300_BUS_SPACE_INTIO) {
/*
@ -158,7 +157,7 @@ bus_space_unmap(t, bsh, size)
if (bsh & PGOFSET)
panic("bus_space_unmap: unaligned");
if ((caddr_t)bsh < extiobase ||
(caddr_t)bsh >= (extiobase + ctob(EIOMAPSIZE)))
(caddr_t)bsh >= (extiobase + ptoa(EIOMAPSIZE)))
panic("bus_space_unmap: bad bus space handle");
#endif
@ -168,10 +167,12 @@ bus_space_unmap(t, bsh, size)
physunaccess((caddr_t)bsh, size);
/*
* Free it from the extio resource map.
* Free it from the extio extent map.
*/
idx = btoc((caddr_t)bsh - extiobase) + 1;
rmfree(extiomap, btoc(size), idx);
if (extent_free(extio_ex, (u_long) bsh, size,
EX_NOWAIT | (extio_ex_malloc_safe ? EX_MALLOCOK : 0)))
printf("bus_space_unmap: kva 0x%lx size 0x%lx: "
"can't free region\n", (u_long) bsh, size);
}
/* ARGSUSED */

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.26 2002/09/22 05:48:46 gmcgarry Exp $
# $NetBSD: genassym.cf,v 1.27 2002/09/25 19:30:22 thorpej Exp $
#
# Copyright (c) 1982, 1990, 1993
@ -41,7 +41,6 @@ endif
include <sys/param.h>
include <sys/buf.h>
include <sys/map.h>
include <sys/proc.h>
include <sys/mbuf.h>
include <sys/msgbuf.h>

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.161 2002/09/19 10:38:01 ragge Exp $ */
/* $NetBSD: machdep.c,v 1.162 2002/09/25 19:30:22 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.161 2002/09/19 10:38:01 ragge Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.162 2002/09/25 19:30:22 thorpej Exp $");
#include "opt_ddb.h"
#include "opt_compat_hpux.h"
@ -61,7 +61,6 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.161 2002/09/19 10:38:01 ragge Exp $");
#include <sys/kernel.h>
#include <sys/device.h>
#include <sys/malloc.h>
#include <sys/map.h>
#include <sys/mbuf.h>
#include <sys/mount.h>
#include <sys/msgbuf.h>
@ -241,12 +240,11 @@ hp300_init()
void
consinit()
{
extern struct map extiomap[];
/*
* Initialize the DIO resource map.
* Initialize the external I/O extent map.
*/
rminit(extiomap, (long)EIOMAPSIZE, (long)1, "extio", EIOMAPSIZE/16);
iomap_init();
/*
* Initialize the console before we print anything out.

View File

@ -1,7 +1,7 @@
/* $NetBSD: autoconf.h,v 1.7 2001/12/14 08:29:25 gmcgarry Exp $ */
/* $NetBSD: autoconf.h,v 1.8 2002/09/25 19:30:23 thorpej Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
* Copyright (c) 1996, 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -37,7 +37,11 @@
*/
#ifdef _KERNEL
void hp300_cninit __P((void));
caddr_t iomap __P((caddr_t, int));
void iounmap __P((caddr_t, int));
void hp300_cninit(void);
void iomap_init(void);
caddr_t iomap(caddr_t, int);
void iounmap(caddr_t, int);
extern struct extent *extio_ex;
extern int extio_ex_malloc_safe;
#endif /* _KERNEL */