Lines Matching defs:rm

113 static int int_rman_release_resource(struct rman *rm, struct resource_i *r);
128 rman_init(struct rman *rm)
138 if (rm->rm_start == 0 && rm->rm_end == 0)
139 rm->rm_end = ~0;
140 if (rm->rm_type == RMAN_UNINIT)
142 if (rm->rm_type == RMAN_GAUGE)
145 TAILQ_INIT(&rm->rm_list);
146 rm->rm_mtx = malloc(sizeof *rm->rm_mtx, M_RMAN, M_NOWAIT | M_ZERO);
147 if (rm->rm_mtx == NULL)
149 mtx_init(rm->rm_mtx, "rman", NULL, MTX_DEF);
152 TAILQ_INSERT_TAIL(&rman_head, rm, rm_link);
158 rman_manage_region(struct rman *rm, rman_res_t start, rman_res_t end)
164 rm->rm_descr, start, end));
165 if (start < rm->rm_start || end > rm->rm_end)
172 r->r_rm = rm;
174 mtx_lock(rm->rm_mtx);
177 TAILQ_FOREACH(s, &rm->rm_list, r_link) {
186 TAILQ_INSERT_TAIL(&rm->rm_list, r, r_link);
213 TAILQ_REMOVE(&rm->rm_list, t, r_link);
225 TAILQ_INSERT_AFTER(&rm->rm_list, s, r, r_link);
231 mtx_unlock(rm->rm_mtx);
236 rman_init_from_resource(struct rman *rm, struct resource *r)
240 if ((rv = rman_init(rm)) != 0)
242 return (rman_manage_region(rm, r->__r_i->r_start, r->__r_i->r_end));
246 rman_fini(struct rman *rm)
250 mtx_lock(rm->rm_mtx);
251 TAILQ_FOREACH(r, &rm->rm_list, r_link) {
253 mtx_unlock(rm->rm_mtx);
262 while (!TAILQ_EMPTY(&rm->rm_list)) {
263 r = TAILQ_FIRST(&rm->rm_list);
264 TAILQ_REMOVE(&rm->rm_list, r, r_link);
267 mtx_unlock(rm->rm_mtx);
269 TAILQ_REMOVE(&rman_head, rm, rm_link);
271 mtx_destroy(rm->rm_mtx);
272 free(rm->rm_mtx, M_RMAN);
278 rman_first_free_region(struct rman *rm, rman_res_t *start, rman_res_t *end)
282 mtx_lock(rm->rm_mtx);
283 TAILQ_FOREACH(r, &rm->rm_list, r_link) {
287 mtx_unlock(rm->rm_mtx);
291 mtx_unlock(rm->rm_mtx);
296 rman_last_free_region(struct rman *rm, rman_res_t *start, rman_res_t *end)
300 mtx_lock(rm->rm_mtx);
301 TAILQ_FOREACH_REVERSE(r, &rm->rm_list, resource_head, r_link) {
305 mtx_unlock(rm->rm_mtx);
309 mtx_unlock(rm->rm_mtx);
318 struct rman *rm;
337 rm = r->r_rm;
338 mtx_lock(rm->rm_mtx);
340 TAILQ_FOREACH(s, &rm->rm_list, r_link) {
360 mtx_unlock(rm->rm_mtx);
365 mtx_unlock(rm->rm_mtx);
380 TAILQ_REMOVE(&rm->rm_list, s, r_link);
390 TAILQ_REMOVE(&rm->rm_list, t, r_link);
395 mtx_unlock(rm->rm_mtx);
406 new->r_rm = rm;
407 mtx_lock(rm->rm_mtx);
415 mtx_unlock(rm->rm_mtx);
421 new->r_rm = rm;
422 mtx_lock(rm->rm_mtx);
429 TAILQ_INSERT_AFTER(&rm->rm_list, r, new, r_link);
430 mtx_unlock(rm->rm_mtx);
438 rman_reserve_resource_bound(struct rman *rm, rman_res_t start, rman_res_t end,
449 "length %#jx, flags %x, device %s\n", rm->rm_descr, start, end,
456 mtx_lock(rm->rm_mtx);
458 r = TAILQ_FIRST(&rm->rm_list);
465 for (r = TAILQ_FIRST(&rm->rm_list);
555 rv->r_rm = rm;
575 r->r_rm = rm;
577 TAILQ_INSERT_AFTER(&rm->rm_list, s, rv,
579 TAILQ_INSERT_AFTER(&rm->rm_list, rv, r,
594 TAILQ_INSERT_AFTER(&rm->rm_list, s, rv,
626 rv->r_rm = rm;
650 mtx_unlock(rm->rm_mtx);
655 rman_reserve_resource(struct rman *rm, rman_res_t start, rman_res_t end,
659 return (rman_reserve_resource_bound(rm, start, end, count, 0, flags,
667 struct rman *rm;
670 rm = r->r_rm;
671 mtx_lock(rm->rm_mtx);
673 mtx_unlock(rm->rm_mtx);
680 struct rman *rm;
682 rm = r->__r_i->r_rm;
683 mtx_lock(rm->rm_mtx);
685 mtx_unlock(rm->rm_mtx);
690 int_rman_release_resource(struct rman *rm, struct resource_i *r)
713 TAILQ_REMOVE(&rm->rm_list, r, r_link);
748 TAILQ_REMOVE(&rm->rm_list, r, r_link);
749 TAILQ_REMOVE(&rm->rm_list, t, r_link);
756 TAILQ_REMOVE(&rm->rm_list, r, r_link);
762 TAILQ_REMOVE(&rm->rm_list, r, r_link);
788 struct rman *rm;
791 rm = r->r_rm;
792 mtx_lock(rm->rm_mtx);
793 rv = int_rman_release_resource(rm, r);
794 mtx_unlock(rm->rm_mtx);
964 rman_is_region_manager(struct resource *r, struct rman *rm)
967 return (r->__r_i->r_rm == rm);
982 struct rman *rm;
1001 TAILQ_FOREACH(rm, &rman_head, rm_link) {
1006 if (rm == NULL)
1015 urm.rm_handle = (uintptr_t)rm;
1016 if (rm->rm_descr != NULL)
1017 strlcpy(urm.rm_descr, rm->rm_descr, RM_TEXTLEN);
1018 urm.rm_start = rm->rm_start;
1019 urm.rm_size = rm->rm_end - rm->rm_start + 1;
1020 urm.rm_type = rm->rm_type;
1029 mtx_lock(rm->rm_mtx);
1030 TAILQ_FOREACH(res, &rm->rm_list, r_link) {
1041 mtx_unlock(rm->rm_mtx);
1066 mtx_unlock(rm->rm_mtx);
1076 dump_rman_header(struct rman *rm)
1082 rm, rm->rm_descr, (rman_res_t)rm->rm_start, (rman_res_t)rm->rm_end);
1086 dump_rman(struct rman *rm)
1093 TAILQ_FOREACH(r, &rm->rm_list, r_link) {
1122 struct rman *rm;
1124 TAILQ_FOREACH(rm, &rman_head, rm_link) {
1125 dump_rman_header(rm);
1131 struct rman *rm;
1133 TAILQ_FOREACH(rm, &rman_head, rm_link) {
1134 dump_rman_header(rm);
1135 dump_rman(rm);