Lines Matching refs:mem_rngs
50 static inline size_t get_mem_rngs_size(struct crash_mem *mem_rngs) in get_mem_rngs_size() argument
54 if (!mem_rngs) in get_mem_rngs_size()
58 (mem_rngs->max_nr_ranges * sizeof(struct range))); in get_mem_rngs_size()
79 struct crash_mem *mem_rngs = *mem_ranges; in __add_mem_range() local
81 if (!mem_rngs || (mem_rngs->nr_ranges == mem_rngs->max_nr_ranges)) { in __add_mem_range()
82 mem_rngs = realloc_mem_ranges(mem_ranges); in __add_mem_range()
83 if (!mem_rngs) in __add_mem_range()
87 mem_rngs->ranges[mem_rngs->nr_ranges].start = base; in __add_mem_range()
88 mem_rngs->ranges[mem_rngs->nr_ranges].end = base + size - 1; in __add_mem_range()
90 base, base + size - 1, mem_rngs->nr_ranges); in __add_mem_range()
91 mem_rngs->nr_ranges++; in __add_mem_range()
103 static void __merge_memory_ranges(struct crash_mem *mem_rngs) in __merge_memory_ranges() argument
108 if (!mem_rngs) in __merge_memory_ranges()
112 ranges = &(mem_rngs->ranges[0]); in __merge_memory_ranges()
113 for (i = 1; i < mem_rngs->nr_ranges; i++) { in __merge_memory_ranges()
124 mem_rngs->nr_ranges = idx + 1; in __merge_memory_ranges()
146 void sort_memory_ranges(struct crash_mem *mem_rngs, bool merge) in sort_memory_ranges() argument
150 if (!mem_rngs) in sort_memory_ranges()
154 sort(&(mem_rngs->ranges[0]), mem_rngs->nr_ranges, in sort_memory_ranges()
155 sizeof(mem_rngs->ranges[0]), rngcmp, NULL); in sort_memory_ranges()
158 __merge_memory_ranges(mem_rngs); in sort_memory_ranges()
162 for (i = 0; i < mem_rngs->nr_ranges; i++) { in sort_memory_ranges()
164 mem_rngs->ranges[i].start, in sort_memory_ranges()
165 mem_rngs->ranges[i].end); in sort_memory_ranges()
179 struct crash_mem *mem_rngs = *mem_ranges; in realloc_mem_ranges() local
183 size = get_mem_rngs_size(mem_rngs); in realloc_mem_ranges()
184 nr_ranges = mem_rngs ? mem_rngs->nr_ranges : 0; in realloc_mem_ranges()
187 mem_rngs = krealloc(*mem_ranges, size, GFP_KERNEL); in realloc_mem_ranges()
188 if (!mem_rngs) { in realloc_mem_ranges()
194 mem_rngs->nr_ranges = nr_ranges; in realloc_mem_ranges()
195 mem_rngs->max_nr_ranges = get_max_nr_ranges(size); in realloc_mem_ranges()
196 *mem_ranges = mem_rngs; in realloc_mem_ranges()
198 return mem_rngs; in realloc_mem_ranges()
214 struct crash_mem *mem_rngs = *mem_ranges; in add_mem_range() local
223 if (!mem_rngs || !(mem_rngs->nr_ranges)) in add_mem_range()
226 for (i = 0; i < mem_rngs->nr_ranges; i++) { in add_mem_range()
227 mstart = mem_rngs->ranges[i].start; in add_mem_range()
228 mend = mem_rngs->ranges[i].end; in add_mem_range()
231 mem_rngs->ranges[i].start = base; in add_mem_range()
233 mem_rngs->ranges[i].end = end; in add_mem_range()
640 struct crash_mem *mem_rngs = *mem_ranges; in remove_mem_range() local
651 for (i = 0; i < mem_rngs->nr_ranges; i++) { in remove_mem_range()
652 mstart = mem_rngs->ranges[i].start; in remove_mem_range()
653 mend = mem_rngs->ranges[i].end; in remove_mem_range()
667 for (; i < mem_rngs->nr_ranges - 1; i++) { in remove_mem_range()
668 mem_rngs->ranges[i].start = mem_rngs->ranges[i+1].start; in remove_mem_range()
669 mem_rngs->ranges[i].end = mem_rngs->ranges[i+1].end; in remove_mem_range()
671 mem_rngs->nr_ranges--; in remove_mem_range()
681 mem_rngs->ranges[i].start = end + 1; in remove_mem_range()
691 mem_rngs->ranges[i].end = base - 1; in remove_mem_range()
700 mem_rngs->ranges[i].end = base - 1; in remove_mem_range()
701 size = mem_rngs->ranges[i].end - end; in remove_mem_range()