Lines Matching refs:mp
37 struct mem_pieces *mp = &phys_avail; in mem_pieces_find() local
39 for (i = 0; i < mp->n_regions; ++i) { in mem_pieces_find()
40 a = mp->regions[i].address; in mem_pieces_find()
41 e = a + mp->regions[i].size; in mem_pieces_find()
44 mem_pieces_remove(mp, a, size, 1); in mem_pieces_find()
57 mem_pieces_remove(struct mem_pieces *mp, unsigned int start, unsigned int size, in mem_pieces_remove() argument
65 for (i = 0, rp = mp->regions; i < mp->n_regions; ++i, ++rp) { in mem_pieces_remove()
69 if (i >= mp->n_regions) { in mem_pieces_remove()
75 for (; i < mp->n_regions && end > rp->address; ++i, ++rp) { in mem_pieces_remove()
81 mem_pieces_print(mp); in mem_pieces_remove()
88 if (mp->n_regions >= MEM_PIECES_MAX) in mem_pieces_remove()
90 for (j = mp->n_regions; j > i + 1; --j) in mem_pieces_remove()
91 mp->regions[j] = mp->regions[j-1]; in mem_pieces_remove()
92 ++mp->n_regions; in mem_pieces_remove()
102 for (j = i; j < mp->n_regions - 1; ++j) in mem_pieces_remove()
103 mp->regions[j] = mp->regions[j+1]; in mem_pieces_remove()
104 --mp->n_regions; in mem_pieces_remove()
113 mem_pieces_print(struct mem_pieces *mp) in mem_pieces_print() argument
117 for (i = 0; i < mp->n_regions; ++i) in mem_pieces_print()
118 printk(" [%x, %x)", mp->regions[i].address, in mem_pieces_print()
119 mp->regions[i].address + mp->regions[i].size); in mem_pieces_print()
128 mem_pieces_append(struct mem_pieces *mp, unsigned int start, unsigned int size) in mem_pieces_append() argument
132 if (mp->n_regions >= MEM_PIECES_MAX) in mem_pieces_append()
134 rp = &mp->regions[mp->n_regions++]; in mem_pieces_append()
141 mem_pieces_sort(struct mem_pieces *mp) in mem_pieces_sort() argument
146 for (i = 1; i < mp->n_regions; ++i) { in mem_pieces_sort()
147 a = mp->regions[i].address; in mem_pieces_sort()
148 s = mp->regions[i].size; in mem_pieces_sort()
150 if (a >= mp->regions[j].address) in mem_pieces_sort()
152 mp->regions[j+1] = mp->regions[j]; in mem_pieces_sort()
154 mp->regions[j+1].address = a; in mem_pieces_sort()
155 mp->regions[j+1].size = s; in mem_pieces_sort()
160 mem_pieces_coalesce(struct mem_pieces *mp) in mem_pieces_coalesce() argument
166 for (i = 0; i < mp->n_regions; i = j) { in mem_pieces_coalesce()
167 a = mp->regions[i].address; in mem_pieces_coalesce()
168 s = mp->regions[i].size; in mem_pieces_coalesce()
169 for (j = i + 1; j < mp->n_regions in mem_pieces_coalesce()
170 && mp->regions[j].address - a <= s; ++j) { in mem_pieces_coalesce()
171 ns = mp->regions[j].address + mp->regions[j].size - a; in mem_pieces_coalesce()
175 mp->regions[d].address = a; in mem_pieces_coalesce()
176 mp->regions[d].size = s; in mem_pieces_coalesce()
179 mp->n_regions = d; in mem_pieces_coalesce()