Lines Matching defs:rm

107 static int int_rman_release_resource(struct rman *rm, struct resource_i *r);
122 rman_init(struct rman *rm)
132 if (rm->rm_start == 0 && rm->rm_end == 0)
133 rm->rm_end = ~0;
134 if (rm->rm_type == RMAN_UNINIT)
136 if (rm->rm_type == RMAN_GAUGE)
139 TAILQ_INIT(&rm->rm_list);
140 rm->rm_mtx = malloc(sizeof *rm->rm_mtx, M_RMAN, M_NOWAIT | M_ZERO);
141 if (rm->rm_mtx == NULL)
143 mtx_init(rm->rm_mtx, "rman", NULL, MTX_DEF);
146 TAILQ_INSERT_TAIL(&rman_head, rm, rm_link);
152 rman_manage_region(struct rman *rm, rman_res_t start, rman_res_t end)
158 rm->rm_descr, start, end);
159 if (start < rm->rm_start || end > rm->rm_end)
166 r->r_rm = rm;
168 mtx_lock(rm->rm_mtx);
171 TAILQ_FOREACH(s, &rm->rm_list, r_link) {
180 TAILQ_INSERT_TAIL(&rm->rm_list, r, r_link);
207 TAILQ_REMOVE(&rm->rm_list, t, r_link);
219 TAILQ_INSERT_AFTER(&rm->rm_list, s, r, r_link);
225 mtx_unlock(rm->rm_mtx);
230 rman_init_from_resource(struct rman *rm, struct resource *r)
234 if ((rv = rman_init(rm)) != 0)
236 return (rman_manage_region(rm, r->__r_i->r_start, r->__r_i->r_end));
240 rman_fini(struct rman *rm)
244 mtx_lock(rm->rm_mtx);
245 TAILQ_FOREACH(r, &rm->rm_list, r_link) {
247 mtx_unlock(rm->rm_mtx);
256 while (!TAILQ_EMPTY(&rm->rm_list)) {
257 r = TAILQ_FIRST(&rm->rm_list);
258 TAILQ_REMOVE(&rm->rm_list, r, r_link);
261 mtx_unlock(rm->rm_mtx);
263 TAILQ_REMOVE(&rman_head, rm, rm_link);
265 mtx_destroy(rm->rm_mtx);
266 free(rm->rm_mtx, M_RMAN);
272 rman_first_free_region(struct rman *rm, rman_res_t *start, rman_res_t *end)
276 mtx_lock(rm->rm_mtx);
277 TAILQ_FOREACH(r, &rm->rm_list, r_link) {
281 mtx_unlock(rm->rm_mtx);
285 mtx_unlock(rm->rm_mtx);
290 rman_last_free_region(struct rman *rm, rman_res_t *start, rman_res_t *end)
294 mtx_lock(rm->rm_mtx);
295 TAILQ_FOREACH_REVERSE(r, &rm->rm_list, resource_head, r_link) {
299 mtx_unlock(rm->rm_mtx);
303 mtx_unlock(rm->rm_mtx);
312 struct rman *rm;
331 rm = r->r_rm;
332 mtx_lock(rm->rm_mtx);
334 TAILQ_FOREACH(s, &rm->rm_list, r_link) {
354 mtx_unlock(rm->rm_mtx);
359 mtx_unlock(rm->rm_mtx);
374 TAILQ_REMOVE(&rm->rm_list, s, r_link);
384 TAILQ_REMOVE(&rm->rm_list, t, r_link);
389 mtx_unlock(rm->rm_mtx);
400 new->r_rm = rm;
401 mtx_lock(rm->rm_mtx);
409 mtx_unlock(rm->rm_mtx);
415 new->r_rm = rm;
416 mtx_lock(rm->rm_mtx);
423 TAILQ_INSERT_AFTER(&rm->rm_list, r, new, r_link);
424 mtx_unlock(rm->rm_mtx);
432 rman_reserve_resource(struct rman *rm, rman_res_t start, rman_res_t end,
442 "device %s\n", __func__, rm->rm_descr, start, end, count, flags,
450 mtx_lock(rm->rm_mtx);
452 r = TAILQ_FIRST(&rm->rm_list);
459 for (r = TAILQ_FIRST(&rm->rm_list);
543 rv->r_rm = rm;
563 r->r_rm = rm;
565 TAILQ_INSERT_AFTER(&rm->rm_list, s, rv,
567 TAILQ_INSERT_AFTER(&rm->rm_list, rv, r,
582 TAILQ_INSERT_AFTER(&rm->rm_list, s, rv,
613 rv->r_rm = rm;
637 mtx_unlock(rm->rm_mtx);
645 struct rman *rm;
648 rm = r->r_rm;
649 mtx_lock(rm->rm_mtx);
651 mtx_unlock(rm->rm_mtx);
658 struct rman *rm;
660 rm = r->__r_i->r_rm;
661 mtx_lock(rm->rm_mtx);
663 mtx_unlock(rm->rm_mtx);
668 int_rman_release_resource(struct rman *rm, struct resource_i *r)
691 TAILQ_REMOVE(&rm->rm_list, r, r_link);
726 TAILQ_REMOVE(&rm->rm_list, r, r_link);
727 TAILQ_REMOVE(&rm->rm_list, t, r_link);
734 TAILQ_REMOVE(&rm->rm_list, r, r_link);
740 TAILQ_REMOVE(&rm->rm_list, r, r_link);
766 struct rman *rm;
769 rm = r->r_rm;
770 mtx_lock(rm->rm_mtx);
771 rv = int_rman_release_resource(rm, r);
772 mtx_unlock(rm->rm_mtx);
935 rman_is_region_manager(const struct resource *r, const struct rman *rm)
938 return (r->__r_i->r_rm == rm);
953 struct rman *rm;
972 TAILQ_FOREACH(rm, &rman_head, rm_link) {
977 if (rm == NULL)
986 urm.rm_handle = (uintptr_t)rm;
987 if (rm->rm_descr != NULL)
988 strlcpy(urm.rm_descr, rm->rm_descr, RM_TEXTLEN);
989 urm.rm_start = rm->rm_start;
990 urm.rm_size = rm->rm_end - rm->rm_start + 1;
991 urm.rm_type = rm->rm_type;
1000 mtx_lock(rm->rm_mtx);
1001 TAILQ_FOREACH(res, &rm->rm_list, r_link) {
1012 mtx_unlock(rm->rm_mtx);
1037 mtx_unlock(rm->rm_mtx);
1048 dump_rman_header(struct rman *rm)
1054 rm, rm->rm_descr, (rman_res_t)rm->rm_start, (rman_res_t)rm->rm_end);
1058 dump_rman(struct rman *rm)
1065 TAILQ_FOREACH(r, &rm->rm_list, r_link) {
1094 struct rman *rm;
1096 TAILQ_FOREACH(rm, &rman_head, rm_link) {
1097 dump_rman_header(rm);
1103 struct rman *rm;
1105 TAILQ_FOREACH(rm, &rman_head, rm_link) {
1106 dump_rman_header(rm);
1107 dump_rman(rm);