xref: /original-bsd/sys/sys/map.h (revision f737e041)
1 /*-
2  * Copyright (c) 1982, 1986, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  * (c) UNIX System Laboratories, Inc.
5  * All or some portions of this file are derived from material licensed
6  * to the University of California by American Telephone and Telegraph
7  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8  * the permission of UNIX System Laboratories, Inc.
9  *
10  * %sccs.include.redist.c%
11  *
12  *	@(#)map.h	8.3 (Berkeley) 01/26/94
13  */
14 
15 /*
16  * Resource allocation maps.
17  *
18  * Associated routines manage sub-allocation of an address space using
19  * an array of segment descriptors.  The first element of this array
20  * is a map structure, describing the arrays extent and the name
21  * of the controlled object.  Each additional structure represents
22  * a free segment of the address space.
23  *
24  * A call to rminit initializes a resource map and may also be used
25  * to free some address space for the map.  Subsequent calls to rmalloc
26  * and rmfree allocate and free space in the resource map.  If the resource
27  * map becomes too fragmented to be described in the available space,
28  * then some of the resource is discarded.  This may lead to critical
29  * shortages, but is better than not checking (as the previous versions
30  * of these routines did) or giving up and calling panic().  The routines
31  * could use linked lists and call a memory allocator when they run
32  * out of space, but that would not solve the out of space problem when
33  * called at interrupt time.
34  *
35  * N.B.: The address 0 in the resource address space is not available
36  * as it is used internally by the resource map routines.
37  */
38 struct map {
39 	struct	mapent *m_limit;	/* address of last slot in map */
40 	char	*m_name;		/* name of resource, for messages */
41 };
42 
43 struct mapent {
44 	long	m_size;			/* size of this segment of the map */
45 	long	m_addr;			/* start of segment */
46 };
47 
48 #ifdef KERNEL
49 #define	ARGMAPSIZE	16
50 struct	map *kmemmap, *mbmap, *swapmap;
51 int	nswapmap;
52 
53 long	rmalloc __P((struct map *, long));
54 void	rmfree __P((struct map *, long, long));
55 void	rminit __P((struct map *, long, long, char *, int));
56 #endif
57