Lines Matching +full:qemu +full:- +full:user +full:- +full:static

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
54 static TAILQ_HEAD(e820_table, e820_element) e820_table = TAILQ_HEAD_INITIALIZER(
57 static struct e820_element *
67 element->base = base; in e820_element_alloc()
68 element->end = end; in e820_element_alloc()
69 element->type = type; in e820_element_alloc()
74 static const char *
102 element->base, element->end, in e820_dump_table()
103 e820_get_type_name(element->type)); in e820_dump_table()
109 static struct qemu_fwcfg_item *
131 fwcfg_item->size = count * sizeof(struct e820_entry); in e820_get_fwcfg_item()
132 fwcfg_item->data = calloc(count, sizeof(struct e820_entry)); in e820_get_fwcfg_item()
133 if (fwcfg_item->data == NULL) { in e820_get_fwcfg_item()
139 entries = (struct e820_entry *)fwcfg_item->data; in e820_get_fwcfg_item()
143 entry->base = element->base; in e820_get_fwcfg_item()
144 entry->length = element->end - element->base; in e820_get_fwcfg_item()
145 entry->type = element->type; in e820_get_fwcfg_item()
153 static int
174 if (element->end > base) { in e820_add_entry()
195 assert(end >= element->base); in e820_add_entry()
205 * address is not allocatable, don't panic. The user may have a fallback and in e820_add_entry()
206 * tries to allocate another address. This is true for the GVT-d emulation in e820_add_entry()
210 if (element == NULL || element->type != E820_TYPE_MEMORY || in e820_add_entry()
211 (base < element->base || end > element->end)) in e820_add_entry()
214 if (base == element->base && end == element->end) { in e820_add_entry()
219 * [ 0x1000, 0x4000] RAM <-- element in e820_add_entry()
226 } else if (base == element->base) { in e820_add_entry()
233 * [ 0x1000, 0x4000] RAM <-- element in e820_add_entry()
236 * [ 0x2000, 0x4000] RAM <-- element in e820_add_entry()
239 element->base = end; in e820_add_entry()
240 } else if (end == element->end) { in e820_add_entry()
247 * [ 0x1000, 0x4000] RAM <-- element in e820_add_entry()
249 * [ 0x1000, 0x3000] RAM <-- element in e820_add_entry()
253 element->end = base; in e820_add_entry()
261 * [ 0x1000, 0x4000] RAM <-- element in e820_add_entry()
265 * [ 0x3000, 0x4000] RAM <-- element in e820_add_entry()
267 ram_element = e820_element_alloc(element->base, base, in e820_add_entry()
274 element->base = end; in e820_add_entry()
283 sib_element->type == new_element->type && in e820_add_entry()
284 sib_element->end == new_element->base) { in e820_add_entry()
285 new_element->base = sib_element->base; in e820_add_entry()
296 sib_element->type == new_element->type && in e820_add_entry()
297 sib_element->base == new_element->end) { in e820_add_entry()
299 new_element->end = sib_element->end; in e820_add_entry()
307 static int
320 if (element->end > base) { in e820_add_memory_hole()
325 if (element == NULL || end <= element->base) { in e820_add_memory_hole()
331 assert(element->type == E820_TYPE_MEMORY); in e820_add_memory_hole()
333 if (base == element->base) { in e820_add_memory_hole()
342 element->base = end; in e820_add_memory_hole()
343 } else if (end == element->end) { in e820_add_memory_hole()
352 element->end = base; in e820_add_memory_hole()
358 * [ 0x1000, 0x4000] RAM <-- element in e820_add_memory_hole()
361 * [ 0x3000, 0x4000] RAM <-- element in e820_add_memory_hole()
363 ram_element = e820_element_alloc(element->base, base, in e820_add_memory_hole()
369 element->base = end; in e820_add_memory_hole()
375 static uint64_t
384 end = MIN(max_address, element->end); in e820_alloc_highest()
385 base = roundup2(element->base, alignment); in e820_alloc_highest()
388 * If end - length == 0, we would allocate memory at address 0. This in e820_alloc_highest()
392 if (element->type != E820_TYPE_MEMORY || end < base || in e820_alloc_highest()
393 end - base < length || end - length == 0) { in e820_alloc_highest()
397 address = rounddown2(end - length, alignment); in e820_alloc_highest()
409 static uint64_t
418 end = element->end; in e820_alloc_lowest()
419 base = MAX(min_address, roundup2(element->base, alignment)); in e820_alloc_lowest()
426 if (element->type != E820_TYPE_MEMORY || end < base || in e820_alloc_lowest()
427 end - base < length || base == 0) { in e820_alloc_lowest()
447 assert((address & (alignment - 1)) == 0); in e820_alloc()
523 e820_fwcfg_item->size, e820_fwcfg_item->data); in e820_finalize()
525 warnx("could not add qemu fwcfg etc/e820"); in e820_finalize()
526 free(e820_fwcfg_item->data); in e820_finalize()