Lines Matching defs:map

157  * _nsc_rmmap_init (nsc_rmmap_t *map, char *name, int nslot,
159 * Initialise a global resource map.
162 * Returns TRUE if the map was successfully created. Otherwise
166 * Initialises a global resource map. If the map already exists
170 _nsc_rmmap_init(nsc_rmmap_t *map, char *name,
181 nvmap = _nsc_global_nvmemmap_lookup(map);
183 if (!map->size)
184 map->size = size;
185 if (!map->inuse)
186 map->inuse = nslot;
187 if (!map->offset)
188 map->offset = offset;
190 if (!map->name[0])
191 (void) strncpy(map->name, name, _NSC_MAXNAME);
195 (void) nsc_commit_mem(map, nvmap,
199 if (strncmp(map->name, name, _NSC_MAXNAME) ||
200 (uint32_t)size != map->size || (int32_t)offset != map->offset) {
212 * _nsc_rmmap_alloc (nsc_rmmap_t *map, char *name,
214 * Allocate entry in a global resource map.
222 * Allocates an entry in the global resource map. If the entry
226 _nsc_rmmap_alloc(nsc_rmmap_t *map, char *name, size_t size, void (*alloc)())
228 int i, nslot = map[0].inuse;
238 nvmap = _nsc_global_nvmemmap_lookup(map);
241 if (!map[i].inuse || !map[i].size)
243 if (strncmp(map[i].name, name, _NSC_MAXNAME))
245 if ((uint32_t)size == map[i].size) {
246 map[i].inuse |= (1 << nsc_node_id());
248 (void) nsc_commit_mem(&map[i], &nvmap[i],
252 return (map[i].offset);
259 offset = map[0].offset;
261 while ((int32_t)offset < (map[0].offset + map[0].size)) {
262 if (_nsc_rmmap_inuse(map, &offset, &want))
272 if (!map[i].inuse || !map[i].size)
278 bzero(&map[i], sizeof (map[i]));
279 (void) strncpy(map[i].name, name, _NSC_MAXNAME);
281 map[i].size = size;
282 map[i].offset = offset;
283 map[i].inuse = (1 << nsc_node_id());
284 if (nvmap) { /* update the map and hdr dirty bit. */
285 (void) nsc_commit_mem(&map[i], &nvmap[i],
303 * _nsc_rmmap_free (nsc_rmmap_t *map, char *name)
304 * Free entry in a global resource map.
307 * Frees an entry in the global resource map.
310 _nsc_rmmap_free(nsc_rmmap_t *map, char *name, nsc_mem_t *mp)
312 int i, nslot = map[0].inuse;
317 nvmap = _nsc_global_nvmemmap_lookup(map);
320 if (!map[i].inuse || !map[i].size)
322 if (strncmp(map[i].name, name, _NSC_MAXNAME))
325 map[i].inuse &= ~(1 << nsc_node_id());
332 map[i].inuse |= (1 << nsc_node_id());
335 (void) nsc_commit_mem(&map[i], &nvmap[i],
350 * _nsc_rmmap_size (nsc_rmmap_t *map, char *name)
351 * Find size of area in map.
354 * Returns the size of the specified area in the map,
358 _nsc_rmmap_size(nsc_rmmap_t *map, char *name)
360 int i, nslot = map[0].inuse;
366 if (!map[i].inuse || !map[i].size)
369 if (strncmp(map[i].name, name, _NSC_MAXNAME) == 0) {
370 size = map[i].size;
382 * _nsc_rmmap_avail (nsc_rmmap_t *map)
383 * Find available space in global resource map.
387 * the global resource map.
390 _nsc_rmmap_avail(nsc_rmmap_t *map)
398 offset = map[0].offset;
400 while ((int32_t)offset < (map[0].offset + map[0].size))
401 if (!_nsc_rmmap_inuse(map, &offset, &size)) {
415 * _nsc_rmmap_inuse (nsc_rmmap_t *map, ulong_t *offsetp, size_t *sizep)
416 * Check if a section of the map is in use.
429 * Checks the specified global map to determine if any part
433 _nsc_rmmap_inuse(nsc_rmmap_t *map, ulong_t *offsetp, size_t *sizep)
439 nslot = map[0].inuse;
440 avail = map[0].offset + map[0].size - offset;
443 if (!map[i].size || !map[i].inuse)
445 if ((int32_t)(offset + size) > map[i].offset &&
446 (int32_t)offset < (map[i].offset + map[i].size)) {
447 (*offsetp) = map[i].offset + map[i].size;
451 if (map[i].offset >= (int32_t)offset)
452 if (avail > map[i].offset - offset)
453 avail = map[i].offset - offset;