diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2002-01-18 02:11:13 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2002-01-18 02:11:13 +0000 |
commit | a9c91ebb13f59ebb258d3e98811d98c22d668c29 (patch) | |
tree | 5e65306e7daee03726a2287b31fec12a7bbc526e | |
parent | a3d90b21625c1c3814871997a4e8f46a1e1b77c7 (diff) |
Resource map code is not used anymore. Long live the extent code!
-rw-r--r-- | sys/conf/files | 3 | ||||
-rw-r--r-- | sys/kern/subr_rmap.c | 234 | ||||
-rw-r--r-- | sys/sys/map.h | 87 |
3 files changed, 1 insertions, 323 deletions
diff --git a/sys/conf/files b/sys/conf/files index fe292932daa..82e285d350d 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1,4 +1,4 @@ -# $OpenBSD: files,v 1.234 2001/12/19 08:58:05 art Exp $ +# $OpenBSD: files,v 1.235 2002/01/18 02:11:08 miod Exp $ # $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 @@ -493,7 +493,6 @@ file kern/subr_log.c file kern/subr_pool.c file kern/subr_prf.c file kern/subr_prof.c -file kern/subr_rmap.c file kern/subr_userconf.c boot_config file kern/subr_xxx.c file kern/sys_generic.c diff --git a/sys/kern/subr_rmap.c b/sys/kern/subr_rmap.c deleted file mode 100644 index c15f13c24c1..00000000000 --- a/sys/kern/subr_rmap.c +++ /dev/null @@ -1,234 +0,0 @@ -/* $OpenBSD: subr_rmap.c,v 1.4 1999/01/11 01:29:17 niklas Exp $ */ -/* $NetBSD: subr_rmap.c,v 1.11 1996/03/16 23:17:11 christos Exp $ */ - -/* - * Copyright (C) 1992, 1994 Wolfgang Solfrank. - * Copyright (C) 1992, 1994 TooLs GmbH. - * 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 TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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. - */ - -#include <sys/param.h> -#include <sys/map.h> -#include <sys/systm.h> - -/* - * Resource allocation map handling. - * - * Code derived from usage in ../vm/swap_pager.c and ../vm/vm_swap.c - * and the (corrected due to the above) comments in ../sys/map.h. - * - * Assume small maps. Keep it sorted by addr with free mapents last. - */ - -/* - * Initialize a resource map. - * The map is called "name", and has nelem-1 - * slots (the first one is reused to describe the map). - * Initially it manages the address range starting at - * addr with size size. - */ -void -rminit(mp, size, addr, name, nelem) - struct map *mp; - long size, addr; - char *name; - int nelem; -{ - struct mapent *ep; - -#ifdef DIAGNOSTIC - /* mapsize had better be at least 2 */ - if (nelem < 2 || addr <= 0 || size < 0) - panic("rminit %s",name); -#endif - - mp->m_name = name; - mp->m_limit = (struct mapent *)mp + nelem; - - /* initially the first entry describes all free space */ - ep = (struct mapent *)mp + 1; - ep->m_size = size; - ep->m_addr = addr; - /* the remaining slots are unused (indicated by m_addr == 0) */ - while (++ep < mp->m_limit) - ep->m_addr = 0; -} - -/* - * Allocate space out of a resource map. - * Try to find an exact match. Otherwise get the space from - * the smallest slot. - */ -long -rmalloc(mp, size) - struct map *mp; - long size; -{ - struct mapent *ep, *fp; - long addr; - - /* first check arguments */ -#ifdef DIAGNOSTIC - if (size < 0) - panic("rmalloc %s", mp->m_name); -#endif - if (size <= 0) - return 0; - - fp = 0; - /* try to find the smallest fit */ - for (ep = (struct mapent *)mp + 1; ep < mp->m_limit; ep++) { - if (!ep->m_addr) { - /* unused slots terminate the list */ - break; - } - if (ep->m_size == size) { - /* found exact match, use it, ... */ - addr = ep->m_addr; - /* copy over the remaining slots ... */ - ovbcopy(ep + 1,ep,(char *)mp->m_limit - (char *)(ep + 1)); - /* and mark the last slot as unused */ - mp->m_limit[-1].m_addr = 0; - return addr; - } - if (ep->m_size > size - && (!fp - || fp->m_size > ep->m_size)) { - /* found a larger slot, remember the smallest of these */ - fp = ep; - } - } - if (fp) { - /* steal requested size from a larger slot */ - addr = fp->m_addr; - fp->m_addr += size; - fp->m_size -= size; - return addr; - } - return 0; -} - -/* - * Free (or add) space to a resource map. - * If there aren't enough slots in the map to describe the free space, - * drop the smallest slot. - */ -void -rmfree(mp, size, addr) - struct map *mp; - long size, addr; -{ - struct mapent *ep, *fp; - -#ifdef DIAGNOSTIC - /* first check arguments */ - if (size <= 0 || addr <= 0) - panic("rmfree %s", mp->m_name); -#endif - - while (1) { - fp = 0; - - for (ep = (struct mapent *)mp + 1; ep < mp->m_limit; ep++) { - if (!ep->m_addr) { - /* unused slots terminate the list */ - break; - } - if (ep->m_addr + ep->m_size == addr) { - /* this slot ends just with the address to free */ - ep->m_size += size; /* increase size of slot */ - if (ep < mp->m_limit - && ep[1].m_addr - && (addr += size) >= ep[1].m_addr) { -#ifdef DIAGNOSTIC - /* overlapping frees? */ - if (addr > ep[1].m_addr) - panic("rmfree %s", mp->m_name); -#endif - /* the next slot is now contiguous, so join ... */ - ep->m_size += ep[1].m_size; - ovbcopy(ep + 2, ep + 1, - (char *)mp->m_limit - (char *)(ep + 2)); - /* and mark the last slot as unused */ - mp->m_limit[-1].m_addr = 0; - } - return; - } - if (addr + size == ep->m_addr) { - /* range to free is contiguous to this slot */ - ep->m_addr = addr; - ep->m_size += size; - return; - } - if (addr < ep->m_addr - && !mp->m_limit[-1].m_addr) { - /* insert entry into list keeping it sorted on m_addr */ - ovbcopy(ep,ep + 1,(char *)(mp->m_limit - 1) - (char *)ep); - ep->m_addr = addr; - ep->m_size = size; - return; - } - if (!fp || fp->m_size > ep->m_size) { - /* find the slot with the smallest size to drop */ - fp = ep; - } - } - if (ep != (struct mapent *)mp + 1 - && ep[-1].m_addr + ep[-1].m_size == addr) { - /* range to free is contiguous to the last used slot */ - (--ep)->m_size += size; - return; - } - if (ep != mp->m_limit) { - /* use empty slot for range to free */ - ep->m_addr = addr; - ep->m_size = size; - return; - } - /* - * The range to free isn't contiguous to any free space, - * and there is no free slot available, so we are sorry, - * but we have to loose some space. - * fp points to the slot with the smallest size - */ - if (fp->m_size > size) { - /* range to free is smaller, so drop that */ - printf("rmfree: map '%s' loses space (%ld)\n", - mp->m_name, size); - return; - } else { - /* drop the smallest slot in the list */ - printf("rmfree: map '%s' loses space (%ld)\n", - mp->m_name, fp->m_size); - ovbcopy(fp + 1, fp, - (char *)(mp->m_limit - 1) - (char *)fp); - mp->m_limit[-1].m_addr = 0; - /* now retry */ - } - } -} diff --git a/sys/sys/map.h b/sys/sys/map.h deleted file mode 100644 index a476f19f54e..00000000000 --- a/sys/sys/map.h +++ /dev/null @@ -1,87 +0,0 @@ -/* $OpenBSD: map.h,v 1.3 1999/05/22 21:22:33 weingart Exp $ */ -/* $NetBSD: map.h,v 1.10 1995/09/15 05:32:45 jtc Exp $ */ - -/*- - * Copyright (c) 1982, 1986, 1993 - * The Regents of the University of California. All rights reserved. - * (c) UNIX System Laboratories, Inc. - * All or some portions of this file are derived from material licensed - * to the University of California by American Telephone and Telegraph - * Co. or Unix System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * 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 the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)map.h 8.3 (Berkeley) 1/26/94 - */ - -/* - * Resource allocation maps. - * - * Associated routines manage sub-allocation of an address space using - * an array of segment descriptors. The first element of this array - * is a map structure, describing the arrays extent and the name - * of the controlled object. Each additional structure represents - * a free segment of the address space. - * - * A call to rminit initializes a resource map. Later on, rmfree may be used - * to free some more address space for the map. Subsequent calls to rmalloc - * and rmfree allocate and free space in the resource map. If the resource - * map becomes too fragmented to be described in the available space, - * then some of the resource is discarded. This may lead to critical - * shortages, but is better than not checking (as the previous versions - * of these routines did) or giving up and calling panic(). The routines - * could use linked lists and call a memory allocator when they run - * out of space, but that would not solve the out of space problem when - * called at interrupt time. - * - * N.B.: The address 0 in the resource address space is not available - * as it is used internally by the resource map routines. - */ - -#ifndef _SYS_MAP_H_ -#define _SYS_MAP_H_ - -struct map { - struct mapent *m_limit; /* first slot beyond map */ - char *m_name; /* name of resource, for messages */ -}; - -struct mapent { - long m_size; /* size of this segment of the map */ - long m_addr; /* start of segment */ -}; - -#ifdef _KERNEL - -long rmalloc __P((struct map *, long)); -void rmfree __P((struct map *, long, long)); -void rminit __P((struct map *, long, long, char *, int)); -#endif /* _KERNEL */ -#endif /* _SYS_MAP_H_ */ |