Lines Matching defs:rm

112 static int int_rman_release_resource(struct rman *rm, struct resource_i *r);
127 rman_init(struct rman *rm)
137 if (rm->rm_start == 0 && rm->rm_end == 0)
138 rm->rm_end = ~0;
139 if (rm->rm_type == RMAN_UNINIT)
141 if (rm->rm_type == RMAN_GAUGE)
144 TAILQ_INIT(&rm->rm_list);
145 rm->rm_mtx = malloc(sizeof *rm->rm_mtx, M_RMAN, M_NOWAIT | M_ZERO);
146 if (rm->rm_mtx == NULL)
148 mtx_init(rm->rm_mtx, "rman", NULL, MTX_DEF);
151 TAILQ_INSERT_TAIL(&rman_head, rm, rm_link);
157 rman_manage_region(struct rman *rm, rman_res_t start, rman_res_t end)
163 rm->rm_descr, start, end));
164 if (start < rm->rm_start || end > rm->rm_end)
171 r->r_rm = rm;
173 mtx_lock(rm->rm_mtx);
176 TAILQ_FOREACH(s, &rm->rm_list, r_link) {
185 TAILQ_INSERT_TAIL(&rm->rm_list, r, r_link);
212 TAILQ_REMOVE(&rm->rm_list, t, r_link);
224 TAILQ_INSERT_AFTER(&rm->rm_list, s, r, r_link);
230 mtx_unlock(rm->rm_mtx);
235 rman_init_from_resource(struct rman *rm, struct resource *r)
239 if ((rv = rman_init(rm)) != 0)
241 return (rman_manage_region(rm, r->__r_i->r_start, r->__r_i->r_end));
245 rman_fini(struct rman *rm)
249 mtx_lock(rm->rm_mtx);
250 TAILQ_FOREACH(r, &rm->rm_list, r_link) {
252 mtx_unlock(rm->rm_mtx);
261 while (!TAILQ_EMPTY(&rm->rm_list)) {
262 r = TAILQ_FIRST(&rm->rm_list);
263 TAILQ_REMOVE(&rm->rm_list, r, r_link);
266 mtx_unlock(rm->rm_mtx);
268 TAILQ_REMOVE(&rman_head, rm, rm_link);
270 mtx_destroy(rm->rm_mtx);
271 free(rm->rm_mtx, M_RMAN);
277 rman_first_free_region(struct rman *rm, rman_res_t *start, rman_res_t *end)
281 mtx_lock(rm->rm_mtx);
282 TAILQ_FOREACH(r, &rm->rm_list, r_link) {
286 mtx_unlock(rm->rm_mtx);
290 mtx_unlock(rm->rm_mtx);
295 rman_last_free_region(struct rman *rm, rman_res_t *start, rman_res_t *end)
299 mtx_lock(rm->rm_mtx);
300 TAILQ_FOREACH_REVERSE(r, &rm->rm_list, resource_head, r_link) {
304 mtx_unlock(rm->rm_mtx);
308 mtx_unlock(rm->rm_mtx);
317 struct rman *rm;
336 rm = r->r_rm;
337 mtx_lock(rm->rm_mtx);
339 TAILQ_FOREACH(s, &rm->rm_list, r_link) {
359 mtx_unlock(rm->rm_mtx);
364 mtx_unlock(rm->rm_mtx);
379 TAILQ_REMOVE(&rm->rm_list, s, r_link);
389 TAILQ_REMOVE(&rm->rm_list, t, r_link);
394 mtx_unlock(rm->rm_mtx);
405 new->r_rm = rm;
406 mtx_lock(rm->rm_mtx);
414 mtx_unlock(rm->rm_mtx);
420 new->r_rm = rm;
421 mtx_lock(rm->rm_mtx);
428 TAILQ_INSERT_AFTER(&rm->rm_list, r, new, r_link);
429 mtx_unlock(rm->rm_mtx);
437 rman_reserve_resource_bound(struct rman *rm, rman_res_t start, rman_res_t end,
448 "length %#jx, flags %x, device %s\n", rm->rm_descr, start, end,
455 mtx_lock(rm->rm_mtx);
457 r = TAILQ_FIRST(&rm->rm_list);
464 for (r = TAILQ_FIRST(&rm->rm_list);
554 rv->r_rm = rm;
574 r->r_rm = rm;
576 TAILQ_INSERT_AFTER(&rm->rm_list, s, rv,
578 TAILQ_INSERT_AFTER(&rm->rm_list, rv, r,
593 TAILQ_INSERT_AFTER(&rm->rm_list, s, rv,
625 rv->r_rm = rm;
649 mtx_unlock(rm->rm_mtx);
654 rman_reserve_resource(struct rman *rm, rman_res_t start, rman_res_t end,
658 return (rman_reserve_resource_bound(rm, start, end, count, 0, flags,
666 struct rman *rm;
669 rm = r->r_rm;
670 mtx_lock(rm->rm_mtx);
672 mtx_unlock(rm->rm_mtx);
679 struct rman *rm;
681 rm = r->__r_i->r_rm;
682 mtx_lock(rm->rm_mtx);
684 mtx_unlock(rm->rm_mtx);
689 int_rman_release_resource(struct rman *rm, struct resource_i *r)
712 TAILQ_REMOVE(&rm->rm_list, r, r_link);
747 TAILQ_REMOVE(&rm->rm_list, r, r_link);
748 TAILQ_REMOVE(&rm->rm_list, t, r_link);
755 TAILQ_REMOVE(&rm->rm_list, r, r_link);
761 TAILQ_REMOVE(&rm->rm_list, r, r_link);
787 struct rman *rm;
790 rm = r->r_rm;
791 mtx_lock(rm->rm_mtx);
792 rv = int_rman_release_resource(rm, r);
793 mtx_unlock(rm->rm_mtx);
949 rman_is_region_manager(struct resource *r, struct rman *rm)
952 return (r->__r_i->r_rm == rm);
967 struct rman *rm;
986 TAILQ_FOREACH(rm, &rman_head, rm_link) {
991 if (rm == NULL)
1000 urm.rm_handle = (uintptr_t)rm;
1001 if (rm->rm_descr != NULL)
1002 strlcpy(urm.rm_descr, rm->rm_descr, RM_TEXTLEN);
1003 urm.rm_start = rm->rm_start;
1004 urm.rm_size = rm->rm_end - rm->rm_start + 1;
1005 urm.rm_type = rm->rm_type;
1014 mtx_lock(rm->rm_mtx);
1015 TAILQ_FOREACH(res, &rm->rm_list, r_link) {
1026 mtx_unlock(rm->rm_mtx);
1051 mtx_unlock(rm->rm_mtx);
1061 dump_rman_header(struct rman *rm)
1067 rm, rm->rm_descr, (rman_res_t)rm->rm_start, (rman_res_t)rm->rm_end);
1071 dump_rman(struct rman *rm)
1078 TAILQ_FOREACH(r, &rm->rm_list, r_link) {
1107 struct rman *rm;
1109 TAILQ_FOREACH(rm, &rman_head, rm_link) {
1110 dump_rman_header(rm);
1116 struct rman *rm;
1118 TAILQ_FOREACH(rm, &rman_head, rm_link) {
1119 dump_rman_header(rm);
1120 dump_rman(rm);