Lines Matching +full:0 +full:ms
53 return 0; in memory_device_addr_sort()
68 return 0; in memory_device_build_list()
85 static unsigned int get_reserved_memslots(MachineState *ms) in get_reserved_memslots() argument
87 if (ms->device_memory->used_memslots > in get_reserved_memslots()
88 ms->device_memory->required_memslots) { in get_reserved_memslots()
90 return 0; in get_reserved_memslots()
92 return ms->device_memory->required_memslots - in get_reserved_memslots()
93 ms->device_memory->used_memslots; in get_reserved_memslots()
99 return 0; in memory_devices_get_reserved_memslots()
113 static unsigned int memory_device_memslot_decision_limit(MachineState *ms, in memory_device_memslot_decision_limit() argument
116 const unsigned int reserved = get_reserved_memslots(ms); in memory_device_memslot_decision_limit()
141 ms->device_memory->required_memslots) { in memory_device_memslot_decision_limit()
145 ms->device_memory->required_memslots; in memory_device_memslot_decision_limit()
159 if (size == ms->maxram_size - ms->ram_size) { in memory_device_memslot_decision_limit()
167 available_space = ms->maxram_size - ms->ram_size - in memory_device_memslot_decision_limit()
168 ms->device_memory->used_region_size; in memory_device_memslot_decision_limit()
173 static void memory_device_check_addable(MachineState *ms, MemoryDeviceState *md, in memory_device_check_addable() argument
177 const uint64_t used_region_size = ms->device_memory->used_region_size; in memory_device_check_addable()
179 const unsigned int reserved_memslots = get_reserved_memslots(ms); in memory_device_check_addable()
187 memslot_limit = memory_device_memslot_decision_limit(ms, mr); in memory_device_check_addable()
205 used_region_size + size > ms->maxram_size - ms->ram_size) { in memory_device_check_addable()
206 error_setg(errp, "not enough space, currently 0x%" PRIx64 in memory_device_check_addable()
207 " in use of total space for memory devices 0x" RAM_ADDR_FMT, in memory_device_check_addable()
208 used_region_size, ms->maxram_size - ms->ram_size); in memory_device_check_addable()
214 static uint64_t memory_device_get_free_addr(MachineState *ms, in memory_device_get_free_addr() argument
222 range_init_nofail(&as, ms->device_memory->base, in memory_device_get_free_addr()
223 memory_region_size(&ms->device_memory->mr)); in memory_device_get_free_addr()
227 warn_report("the alignment (0x%" PRIx64 ") exceeds the expected" in memory_device_get_free_addr()
234 error_setg(errp, "address must be aligned to 0x%" PRIx64 " bytes", in memory_device_get_free_addr()
236 return 0; in memory_device_get_free_addr()
241 error_setg(errp, "can't add memory device [0x%" PRIx64 ":0x%" PRIx64 in memory_device_get_free_addr()
242 "], usable range for memory devices [0x%" PRIx64 ":0x%" in memory_device_get_free_addr()
245 return 0; in memory_device_get_free_addr()
250 return 0; in memory_device_get_free_addr()
255 object_child_foreach(OBJECT(ms), memory_device_build_list, &list); in memory_device_get_free_addr()
335 return 0; in memory_device_plugged_size()
340 uint64_t size = 0; in get_plugged_memory_size()
347 void memory_device_pre_plug(MemoryDeviceState *md, MachineState *ms, in memory_device_pre_plug() argument
352 uint64_t addr, align = 0; in memory_device_pre_plug()
360 if (!ms->device_memory) { in memory_device_pre_plug()
372 memory_device_check_addable(ms, md, mr, &local_err); in memory_device_pre_plug()
386 error_setg(errp, "backend memory size must be multiple of 0x%" in memory_device_pre_plug()
396 addr = memory_device_get_free_addr(ms, !addr ? NULL : &addr, align, in memory_device_pre_plug()
410 void memory_device_plug(MemoryDeviceState *md, MachineState *ms) in memory_device_plug() argument
429 g_assert(ms->device_memory); in memory_device_plug()
431 ms->device_memory->used_region_size += memory_region_size(mr); in memory_device_plug()
432 ms->device_memory->required_memslots += memslots; in memory_device_plug()
434 ms->device_memory->memslot_auto_decision_active++; in memory_device_plug()
437 memory_region_add_subregion(&ms->device_memory->mr, in memory_device_plug()
438 addr - ms->device_memory->base, mr); in memory_device_plug()
442 void memory_device_unplug(MemoryDeviceState *md, MachineState *ms) in memory_device_unplug() argument
457 g_assert(ms->device_memory); in memory_device_unplug()
459 memory_region_del_subregion(&ms->device_memory->mr, mr); in memory_device_unplug()
462 ms->device_memory->memslot_auto_decision_active--; in memory_device_unplug()
464 ms->device_memory->used_region_size -= memory_region_size(mr); in memory_device_unplug()
465 ms->device_memory->required_memslots -= memslots; in memory_device_unplug()
479 return 0; in memory_device_get_region_size()
529 void machine_memory_devices_init(MachineState *ms, hwaddr base, uint64_t size) in machine_memory_devices_init() argument
532 g_assert(!ms->device_memory); in machine_memory_devices_init()
533 ms->device_memory = g_new0(DeviceMemoryState, 1); in machine_memory_devices_init()
534 ms->device_memory->base = base; in machine_memory_devices_init()
536 memory_region_init(&ms->device_memory->mr, OBJECT(ms), "device-memory", in machine_memory_devices_init()
538 address_space_init(&ms->device_memory->as, &ms->device_memory->mr, in machine_memory_devices_init()
540 memory_region_add_subregion(get_system_memory(), ms->device_memory->base, in machine_memory_devices_init()
541 &ms->device_memory->mr); in machine_memory_devices_init()
544 ms->device_memory->listener.region_add = memory_devices_region_add; in machine_memory_devices_init()
545 ms->device_memory->listener.region_del = memory_devices_region_del; in machine_memory_devices_init()
546 memory_listener_register(&ms->device_memory->listener, in machine_memory_devices_init()
547 &ms->device_memory->as); in machine_memory_devices_init()