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