Lines Matching +full:string +full:- +full:array +full:- +full:property
30 #include "system/address-spaces.h"
33 #include "hw/qdev-properties.h"
35 #include "migration/qemu-file-types.h"
38 #include "qemu/error-report.h"
40 #include "qemu/config-file.h"
43 #include "hw/acpi/aml-build.h"
75 * Returns: The stringified name if the selector refers to a well-known
140 filename, err->message); in read_splashfile()
187 if (current_machine->boot_config.has_splash_time) { in fw_cfg_bootsplash()
188 int64_t bst_val = current_machine->boot_config.splash_time; in fw_cfg_bootsplash()
193 error_report("splash-time is invalid," in fw_cfg_bootsplash()
199 fw_cfg_add_file(s, "etc/boot-menu-wait", in fw_cfg_bootsplash()
204 if (current_machine->boot_config.splash) { in fw_cfg_bootsplash()
205 const char *boot_splash_filename = current_machine->boot_config.splash; in fw_cfg_bootsplash()
235 uint64_t rt_val = -1; in fw_cfg_reboot()
238 if (current_machine->boot_config.has_reboot_timeout) { in fw_cfg_reboot()
239 rt_val = current_machine->boot_config.reboot_timeout; in fw_cfg_reboot()
242 if (rt_val > 0xffff && rt_val != (uint64_t)-1) { in fw_cfg_reboot()
244 "it should be a value between -1 and 65535"); in fw_cfg_reboot()
250 fw_cfg_add_file(s, "etc/boot-fail-wait", g_memdup(&rt_le32, 4), 4); in fw_cfg_reboot()
260 return s->file_slots; in fw_cfg_file_slots()
274 s->cur_offset = 0; in fw_cfg_select()
276 s->cur_entry = FW_CFG_INVALID; in fw_cfg_select()
279 s->cur_entry = key; in fw_cfg_select()
283 e = &s->entries[arch][key & FW_CFG_ENTRY_MASK]; in fw_cfg_select()
284 if (e->select_cb) { in fw_cfg_select()
285 e->select_cb(e->callback_opaque); in fw_cfg_select()
296 int arch = !!(s->cur_entry & FW_CFG_ARCH_LOCAL); in fw_cfg_data_read()
297 FWCfgEntry *e = (s->cur_entry == FW_CFG_INVALID) ? NULL : in fw_cfg_data_read()
298 &s->entries[arch][s->cur_entry & FW_CFG_ENTRY_MASK]; in fw_cfg_data_read()
302 if (s->cur_entry != FW_CFG_INVALID && e->data && s->cur_offset < e->len) { in fw_cfg_data_read()
304 * expected to contain a string preserving portion of the item in fw_cfg_data_read()
306 * In technical terms, we're composing the host-endian representation in fw_cfg_data_read()
307 * of the big endian interpretation of the fw_cfg string. in fw_cfg_data_read()
310 value = (value << 8) | e->data[s->cur_offset++]; in fw_cfg_data_read()
311 } while (--size && s->cur_offset < e->len); in fw_cfg_data_read()
313 * left-shifting, to add the appropriate number of padding zeros in fw_cfg_data_read()
330 fw_cfg_write(s, value >> (8 * --i)); in fw_cfg_data_mem_write()
344 dma_addr = s->dma_addr; in fw_cfg_dma_transfer()
345 s->dma_addr = 0; in fw_cfg_dma_transfer()
347 if (dma_memory_read(s->dma_as, dma_addr, in fw_cfg_dma_transfer()
349 stl_be_dma(s->dma_as, dma_addr + offsetof(FWCfgDmaAccess, control), in fw_cfg_dma_transfer()
362 arch = !!(s->cur_entry & FW_CFG_ARCH_LOCAL); in fw_cfg_dma_transfer()
363 e = (s->cur_entry == FW_CFG_INVALID) ? NULL : in fw_cfg_dma_transfer()
364 &s->entries[arch][s->cur_entry & FW_CFG_ENTRY_MASK]; in fw_cfg_dma_transfer()
382 if (s->cur_entry == FW_CFG_INVALID || !e->data || in fw_cfg_dma_transfer()
383 s->cur_offset >= e->len) { in fw_cfg_dma_transfer()
390 if (dma_memory_set(s->dma_as, dma.address, 0, len, in fw_cfg_dma_transfer()
399 if (dma.length <= (e->len - s->cur_offset)) { in fw_cfg_dma_transfer()
402 len = (e->len - s->cur_offset); in fw_cfg_dma_transfer()
409 if (dma_memory_write(s->dma_as, dma.address, in fw_cfg_dma_transfer()
410 &e->data[s->cur_offset], len, in fw_cfg_dma_transfer()
416 if (!e->allow_write || in fw_cfg_dma_transfer()
418 dma_memory_read(s->dma_as, dma.address, in fw_cfg_dma_transfer()
419 &e->data[s->cur_offset], len, in fw_cfg_dma_transfer()
422 } else if (e->write_cb) { in fw_cfg_dma_transfer()
423 e->write_cb(e->callback_opaque, s->cur_offset, len); in fw_cfg_dma_transfer()
427 s->cur_offset += len; in fw_cfg_dma_transfer()
431 dma.length -= len; in fw_cfg_dma_transfer()
435 stl_be_dma(s->dma_as, dma_addr + offsetof(FWCfgDmaAccess, control), in fw_cfg_dma_transfer()
445 return extract64(FW_CFG_DMA_SIGNATURE, (8 - addr - size) * 8, size * 8); in fw_cfg_dma_mem_read()
456 s->dma_addr = value << 32; in fw_cfg_dma_mem_write()
459 s->dma_addr |= value; in fw_cfg_dma_mem_write()
463 s->dma_addr = value; in fw_cfg_dma_mem_write()
604 return s->dma_enabled; in fw_cfg_dma_enabled()
612 mr_aligned = QEMU_IS_ALIGNED(s->table_mr_size, qemu_real_host_page_size()) && in fw_cfg_acpi_mr_restore()
613 QEMU_IS_ALIGNED(s->linker_mr_size, qemu_real_host_page_size()) && in fw_cfg_acpi_mr_restore()
614 QEMU_IS_ALIGNED(s->rsdp_mr_size, qemu_real_host_page_size()); in fw_cfg_acpi_mr_restore()
615 return s->acpi_mr_restore && !mr_aligned; in fw_cfg_acpi_mr_restore()
628 ptr = s->entries[arch][key].data; in fw_cfg_update_mr()
639 assert(s->files); in fw_cfg_acpi_mr_restore_post_load()
641 index = be32_to_cpu(s->files->count); in fw_cfg_acpi_mr_restore_post_load()
644 if (!strcmp(s->files->f[i].name, ACPI_BUILD_TABLE_FILE)) { in fw_cfg_acpi_mr_restore_post_load()
645 fw_cfg_update_mr(s, FW_CFG_FILE_FIRST + i, s->table_mr_size); in fw_cfg_acpi_mr_restore_post_load()
646 } else if (!strcmp(s->files->f[i].name, ACPI_BUILD_LOADER_FILE)) { in fw_cfg_acpi_mr_restore_post_load()
647 fw_cfg_update_mr(s, FW_CFG_FILE_FIRST + i, s->linker_mr_size); in fw_cfg_acpi_mr_restore_post_load()
648 } else if (!strcmp(s->files->f[i].name, ACPI_BUILD_RSDP_FILE)) { in fw_cfg_acpi_mr_restore_post_load()
649 fw_cfg_update_mr(s, FW_CFG_FILE_FIRST + i, s->rsdp_mr_size); in fw_cfg_acpi_mr_restore_post_load()
708 assert(s->entries[arch][key].data == NULL); /* avoid key conflict */ in fw_cfg_add_bytes_callback()
710 s->entries[arch][key].data = data; in fw_cfg_add_bytes_callback()
711 s->entries[arch][key].len = (uint32_t)len; in fw_cfg_add_bytes_callback()
712 s->entries[arch][key].select_cb = select_cb; in fw_cfg_add_bytes_callback()
713 s->entries[arch][key].write_cb = write_cb; in fw_cfg_add_bytes_callback()
714 s->entries[arch][key].callback_opaque = callback_opaque; in fw_cfg_add_bytes_callback()
715 s->entries[arch][key].allow_write = !read_only; in fw_cfg_add_bytes_callback()
729 ptr = s->entries[arch][key].data; in fw_cfg_modify_bytes_read()
730 s->entries[arch][key].data = data; in fw_cfg_modify_bytes_read()
731 s->entries[arch][key].len = len; in fw_cfg_modify_bytes_read()
732 s->entries[arch][key].allow_write = false; in fw_cfg_modify_bytes_read()
821 * Any sub-page size update to these table MRs will be lost during migration,
822 * as we use aligned size in ram_load_precopy() -> qemu_ram_resize() path.
829 s->table_mr_size = len; in fw_cfg_acpi_mr_save()
831 s->linker_mr_size = len; in fw_cfg_acpi_mr_save()
833 s->rsdp_mr_size = len; in fw_cfg_acpi_mr_save()
847 if (!s->files) { in fw_cfg_add_file_callback()
849 s->files = g_malloc0(dsize); in fw_cfg_add_file_callback()
850 fw_cfg_add_bytes(s, FW_CFG_FILE_DIR, s->files, dsize); in fw_cfg_add_file_callback()
853 count = be32_to_cpu(s->files->count); in fw_cfg_add_file_callback()
858 index > 0 && strcmp(filename, s->files->f[index - 1].name) < 0; in fw_cfg_add_file_callback()
859 index--) in fw_cfg_add_file_callback()
866 * index and "i - 1" is the one being copied from, thus the in fw_cfg_add_file_callback()
869 for (i = count; i > index; i--) { in fw_cfg_add_file_callback()
870 s->files->f[i] = s->files->f[i - 1]; in fw_cfg_add_file_callback()
871 s->files->f[i].select = cpu_to_be16(FW_CFG_FILE_FIRST + i); in fw_cfg_add_file_callback()
872 s->entries[0][FW_CFG_FILE_FIRST + i] = in fw_cfg_add_file_callback()
873 s->entries[0][FW_CFG_FILE_FIRST + i - 1]; in fw_cfg_add_file_callback()
874 s->entry_order[i] = s->entry_order[i - 1]; in fw_cfg_add_file_callback()
877 memset(&s->files->f[index], 0, sizeof(FWCfgFile)); in fw_cfg_add_file_callback()
878 memset(&s->entries[0][FW_CFG_FILE_FIRST + index], 0, sizeof(FWCfgEntry)); in fw_cfg_add_file_callback()
880 pstrcpy(s->files->f[index].name, sizeof(s->files->f[index].name), filename); in fw_cfg_add_file_callback()
883 strcmp(s->files->f[index].name, s->files->f[i].name) == 0) { in fw_cfg_add_file_callback()
885 s->files->f[index].name); in fw_cfg_add_file_callback()
895 s->files->f[index].size = cpu_to_be32(len); in fw_cfg_add_file_callback()
896 s->files->f[index].select = cpu_to_be16(FW_CFG_FILE_FIRST + index); in fw_cfg_add_file_callback()
897 s->entry_order[index] = order; in fw_cfg_add_file_callback()
898 trace_fw_cfg_add_file(s, index, s->files->f[index].name, len); in fw_cfg_add_file_callback()
900 s->files->count = cpu_to_be32(count+1); in fw_cfg_add_file_callback()
916 assert(s->files); in fw_cfg_modify_file()
918 index = be32_to_cpu(s->files->count); in fw_cfg_modify_file()
921 if (strcmp(filename, s->files->f[i].name) == 0) { in fw_cfg_modify_file()
924 s->files->f[i].size = cpu_to_be32(len); in fw_cfg_modify_file()
943 GByteArray *array; in fw_cfg_add_file_from_generator() local
958 array = klass->get_data(obj, errp); in fw_cfg_add_file_from_generator()
959 if (*errp || !array) { in fw_cfg_add_file_from_generator()
962 size = array->len; in fw_cfg_add_file_from_generator()
963 fw_cfg_add_file(s, filename, g_byte_array_free(array, FALSE), size); in fw_cfg_add_file_from_generator()
980 ptr = fw_cfg_modify_file(s, "bios-geometry", (uint8_t *)buf, len); in fw_cfg_machine_reset()
990 static const Property fw_cfg_properties[] = {
991 DEFINE_PROP_BOOL("acpi-mr-restore", FWCfgState, acpi_mr_restore, true),
1007 fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)!machine->enable_graphics); in fw_cfg_common_realize()
1008 …fw_cfg_add_i16(s, FW_CFG_BOOT_MENU, (uint16_t)(machine->boot_config.has_menu && machine->boot_conf… in fw_cfg_common_realize()
1012 if (s->dma_enabled) { in fw_cfg_common_realize()
1018 s->machine_ready.notify = fw_cfg_machine_ready; in fw_cfg_common_realize()
1019 qemu_add_machine_init_done_notifier(&s->machine_ready); in fw_cfg_common_realize()
1043 memory_region_add_subregion(iomem, iobase, &ios->comb_iomem); in fw_cfg_init_io_dma()
1047 if (s->dma_enabled) { in fw_cfg_init_io_dma()
1049 s->dma_as = dma_as; in fw_cfg_init_io_dma()
1050 s->dma_addr = 0; in fw_cfg_init_io_dma()
1051 memory_region_add_subregion(iomem, dma_iobase, &s->dma_iomem); in fw_cfg_init_io_dma()
1082 if (s->dma_enabled) { in fw_cfg_init_mem_wide()
1083 s->dma_as = dma_as; in fw_cfg_init_mem_wide()
1084 s->dma_addr = 0; in fw_cfg_init_mem_wide()
1109 size_t size = -1; in load_image_to_fw_cfg()
1121 if (size == (size_t)-1) { in load_image_to_fw_cfg()
1142 dc->vmsd = &vmstate_fw_cfg; in fw_cfg_class_init()
1168 file_slots_max = (UINT16_MAX & FW_CFG_ENTRY_MASK) - FW_CFG_FILE_FIRST + 1; in fw_cfg_file_slots_allocate()
1175 s->entries[0] = g_new0(FWCfgEntry, fw_cfg_max_entry(s)); in fw_cfg_file_slots_allocate()
1176 s->entries[1] = g_new0(FWCfgEntry, fw_cfg_max_entry(s)); in fw_cfg_file_slots_allocate()
1177 s->entry_order = g_new0(int, fw_cfg_max_entry(s)); in fw_cfg_file_slots_allocate()
1180 static const Property fw_cfg_io_properties[] = {
1183 DEFINE_PROP_UINT16("x-file-slots", FWCfgIoState, parent_obj.file_slots,
1197 /* when using port i/o, the 8-bit data register ALWAYS overlaps in fw_cfg_io_realize()
1198 * with half of the 16-bit control register. Hence, the total size in fw_cfg_io_realize()
1200 memory_region_init_io(&s->comb_iomem, OBJECT(s), &fw_cfg_comb_mem_ops, in fw_cfg_io_realize()
1203 if (FW_CFG(s)->dma_enabled) { in fw_cfg_io_realize()
1204 memory_region_init_io(&FW_CFG(s)->dma_iomem, OBJECT(s), in fw_cfg_io_realize()
1216 dc->realize = fw_cfg_io_realize; in fw_cfg_io_class_init()
1228 static const Property fw_cfg_mem_properties[] = {
1229 DEFINE_PROP_UINT32("data_width", FWCfgMemState, data_width, -1),
1232 DEFINE_PROP_UINT16("x-file-slots", FWCfgMemState, parent_obj.file_slots,
1248 memory_region_init_io(&s->ctl_iomem, OBJECT(s), &fw_cfg_ctl_mem_ops, in fw_cfg_mem_realize()
1250 sysbus_init_mmio(sbd, &s->ctl_iomem); in fw_cfg_mem_realize()
1252 if (s->data_width > data_ops->valid.max_access_size) { in fw_cfg_mem_realize()
1253 s->wide_data_ops = *data_ops; in fw_cfg_mem_realize()
1255 s->wide_data_ops.valid.max_access_size = s->data_width; in fw_cfg_mem_realize()
1256 s->wide_data_ops.impl.max_access_size = s->data_width; in fw_cfg_mem_realize()
1257 data_ops = &s->wide_data_ops; in fw_cfg_mem_realize()
1259 memory_region_init_io(&s->data_iomem, OBJECT(s), data_ops, FW_CFG(s), in fw_cfg_mem_realize()
1260 "fwcfg.data", data_ops->valid.max_access_size); in fw_cfg_mem_realize()
1261 sysbus_init_mmio(sbd, &s->data_iomem); in fw_cfg_mem_realize()
1263 if (FW_CFG(s)->dma_enabled) { in fw_cfg_mem_realize()
1264 memory_region_init_io(&FW_CFG(s)->dma_iomem, OBJECT(s), in fw_cfg_mem_realize()
1267 sysbus_init_mmio(sbd, &FW_CFG(s)->dma_iomem); in fw_cfg_mem_realize()
1277 dc->realize = fw_cfg_mem_realize; in fw_cfg_mem_class_init()