2 * Copyright (c) 1996, 1998 University of Utah and the Flux Group.
5 * This file is part of the Flux OSKit. The OSKit is free software, also known
6 * as "open source;" you can redistribute it and/or modify it under the terms
7 * of the GNU General Public License (GPL), version 2, as published by the Free
8 * Software Foundation (FSF). To explore alternate licensing terms, contact
9 * the University of Utah at csl-dist@cs.utah.edu or +1-801-585-3271.
11 * The OSKit is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GPL for more details. You should have
14 * received a copy of the GPL along with the OSKit; see the file COPYING. If
15 * not, write to the FSF, 59 Temple Place #330, Boston, MA 02111-1307, USA.
21 * One-time initialization for AMM
26 * Initialize the given amm structure, and associates the specified
27 * flags and entry with the entire supported address range 0 through
30 * The flags parameter is the address range flags word to associate
31 * initially with the entire address space.
33 * The entry parameter allows the client to provide the initial amm_entry
34 * node which will initially be associated with the entire address space;
35 * this way the client can allocate a structure larger than the basic
36 * amm_entry and store additional attribute data in the extended structure.
37 * If the client supplies the init_entry, it must have initialized any
38 * client-private data in that entry, but the amm will initialize the
39 * amm-private part (the actual struct amm_entry). If entry is NULL,
40 * the amm will call amm_alloc_entry to allocate a struct amm_entry and
43 * If the client wants to perform allocation or deallocation (or whatever)
44 * over only a subset of the full possible (32- or 64-bit) address range,
45 * then it can set up the init_entry to represent "invalid"
46 * addresses rather than "free" addresses, and then later call
47 * amm_modify_range() to create appropriate "free" region(s).
50 amm_init_gen(struct amm *amm, int flags, struct amm_entry *entry,
51 struct amm_entry *(*af)(struct amm *, vm_offset_t, vm_size_t, int),
52 void (*ff)(struct amm *, struct amm_entry *),
53 int (*sf)(struct amm *, struct amm_entry *, vm_offset_t,
54 struct amm_entry **, struct amm_entry **),
55 int (*jf)(struct amm *, struct amm_entry *,
56 struct amm_entry *, struct amm_entry **))
64 entry = amm_alloc_entry(amm, AMM_MINADDR,
65 AMM_MAXADDR - AMM_MINADDR, flags);
66 assert(entry); /* XXX */
68 entry->start = AMM_MINADDR;
69 entry->end = AMM_MAXADDR;
74 amm->hint = &amm->nodes;
76 amm->stats.lookups = amm->stats.hits = amm->stats.entriesscanned = 0;
82 * XXX these could just be parameters to the init routine rather than seperate
83 * calls but we want to keep the amm_init interface simple.
85 * XXX these (at least the alloc function) must be part of the init call
86 * since init wants to allocate a node.
89 amm_set_alloc_func(struct amm *amm,
96 amm_set_free_func(struct amm *amm,
97 void (*ff)(struct amm *, struct amm_entry *))
103 amm_set_split_func(struct amm *amm,
104 int (*sf)(struct amm *, struct amm_entry *, vm_offset_t,
105 struct amm_entry **, struct amm_entry **))
111 amm_set_join_func(struct amm *amm,
112 int (*jf)(struct amm *, struct amm_entry *,
113 struct amm_entry *, struct amm_entry **))