Lines Matching +full:sig +full:- +full:dir
7 * sysfs (read-only, under "/sys/firmware/qemu_fw_cfg/...").
46 /* fw_cfg revision attribute, in /sys/firmware/qemu_fw_cfg top-level dir. */
80 u32 ctrl = be32_to_cpu(READ_ONCE(d->control)); in fw_cfg_wait_for_control()
82 /* do not reorder the read to d->control */ in fw_cfg_wait_for_control()
99 ret = -ENOMEM; in fw_cfg_dma_transfer()
119 if (be32_to_cpu(READ_ONCE(d->control)) & FW_CFG_DMA_CTL_ERROR) { in fw_cfg_dma_transfer()
120 ret = -EIO; in fw_cfg_dma_transfer()
130 /* read chunk of given fw_cfg blob (caller responsible for sanity-check) */
134 u32 glk = -1U; in fw_cfg_read_blob()
145 return -EINVAL; in fw_cfg_read_blob()
150 while (pos-- > 0) in fw_cfg_read_blob()
160 /* write chunk of given fw_cfg blob (caller responsible for sanity-check) */
164 u32 glk = -1U; in fw_cfg_write_blob()
175 return -EINVAL; in fw_cfg_write_blob()
212 /* arch-specific ctrl & data register offsets are not available in ACPI, DT */
236 char sig[FW_CFG_SIG_SIZE]; in fw_cfg_do_platform_probe() local
246 return -EINVAL; in fw_cfg_do_platform_probe()
248 fw_cfg_p_base = range->start; in fw_cfg_do_platform_probe()
254 return -EBUSY; in fw_cfg_do_platform_probe()
258 return -EFAULT; in fw_cfg_do_platform_probe()
263 return -EBUSY; in fw_cfg_do_platform_probe()
267 return -EFAULT; in fw_cfg_do_platform_probe()
276 fw_cfg_reg_ctrl = fw_cfg_dev_base + ctrl->start; in fw_cfg_do_platform_probe()
277 fw_cfg_reg_data = fw_cfg_dev_base + data->start; in fw_cfg_do_platform_probe()
279 /* use architecture-specific offsets */ in fw_cfg_do_platform_probe()
285 fw_cfg_reg_dma = fw_cfg_dev_base + dma->start; in fw_cfg_do_platform_probe()
292 if (fw_cfg_read_blob(FW_CFG_SIGNATURE, sig, in fw_cfg_do_platform_probe()
294 memcmp(sig, "QEMU", FW_CFG_SIG_SIZE) != 0) { in fw_cfg_do_platform_probe()
296 return -ENODEV; in fw_cfg_do_platform_probe()
330 return -ENOMEM; in fw_cfg_write_vmcoreinfo()
338 * don't know what else to format - host may ignore ours in fw_cfg_write_vmcoreinfo()
340 ret = fw_cfg_write_blob(be16_to_cpu(f->select), data, in fw_cfg_write_vmcoreinfo()
375 list_add_tail(&entry->list, &fw_cfg_entry_cache); in fw_cfg_sysfs_cache_enlist()
382 list_del(&entry->list); in fw_cfg_sysfs_cache_delist()
392 kobject_del(&entry->kobj); in fw_cfg_sysfs_cache_cleanup()
393 kobject_put(&entry->kobj); in fw_cfg_sysfs_cache_cleanup()
397 /* per-entry attributes and show methods */
407 return sprintf(buf, "%u\n", e->size); in fw_cfg_sysfs_show_size()
412 return sprintf(buf, "%u\n", e->select); in fw_cfg_sysfs_show_key()
417 return sprintf(buf, "%s\n", e->name); in fw_cfg_sysfs_show_name()
439 return attr->show(entry, buf); in fw_cfg_sysfs_attr_show()
461 /* raw-read method and attribute */
468 if (pos > entry->size) in fw_cfg_sysfs_read_raw()
469 return -EINVAL; in fw_cfg_sysfs_read_raw()
471 if (count > entry->size - pos) in fw_cfg_sysfs_read_raw()
472 count = entry->size - pos; in fw_cfg_sysfs_read_raw()
474 return fw_cfg_read_blob(entry->select, buf, pos, count); in fw_cfg_sysfs_read_raw()
484 * in 'name', starting with sysfs kset/folder 'dir'; At the end, create
486 * NOTE: We do this on a best-effort basis, since 'name' is not guaranteed
487 * to be a well-behaved path name. Whenever a symlink vs. kset directory
492 static int fw_cfg_build_symlink(struct kset *dir, in fw_cfg_build_symlink() argument
500 if (!dir || !target || !name || !*name) in fw_cfg_build_symlink()
501 return -EINVAL; in fw_cfg_build_symlink()
506 return -ENOMEM; in fw_cfg_build_symlink()
513 ret = sysfs_create_link(&dir->kobj, target, tok); in fw_cfg_build_symlink()
517 /* does the current dir contain an item named after tok ? */ in fw_cfg_build_symlink()
518 ko = kset_find_obj(dir, tok); in fw_cfg_build_symlink()
523 /* ko MUST be a kset - we're about to use it as one ! */ in fw_cfg_build_symlink()
524 if (ko->ktype != dir->kobj.ktype) { in fw_cfg_build_symlink()
525 ret = -EINVAL; in fw_cfg_build_symlink()
530 dir = to_kset(ko); in fw_cfg_build_symlink()
535 ret = -ENOMEM; in fw_cfg_build_symlink()
538 subdir->kobj.kset = dir; in fw_cfg_build_symlink()
539 subdir->kobj.ktype = dir->kobj.ktype; in fw_cfg_build_symlink()
540 ret = kobject_set_name(&subdir->kobj, "%s", tok); in fw_cfg_build_symlink()
552 dir = subdir; in fw_cfg_build_symlink()
566 list_for_each_entry_safe(k, next, &kset->list, entry) in fw_cfg_kset_unregister_recursive()
568 if (k->ktype == kset->kobj.ktype) in fw_cfg_kset_unregister_recursive()
575 /* kobjects & kset representing top-level, by_key, and by_name folders */
588 strcmp(f->name, FW_CFG_VMCOREINFO_FILENAME) == 0 && in fw_cfg_register_file()
598 return -ENOMEM; in fw_cfg_register_file()
601 entry->size = be32_to_cpu(f->size); in fw_cfg_register_file()
602 entry->select = be16_to_cpu(f->select); in fw_cfg_register_file()
603 strscpy(entry->name, f->name, FW_CFG_MAX_FILE_PATH); in fw_cfg_register_file()
606 err = kobject_init_and_add(&entry->kobj, &fw_cfg_sysfs_entry_ktype, in fw_cfg_register_file()
607 fw_cfg_sel_ko, "%d", entry->select); in fw_cfg_register_file()
612 err = sysfs_create_bin_file(&entry->kobj, &fw_cfg_sysfs_attr_raw); in fw_cfg_register_file()
617 fw_cfg_build_symlink(fw_cfg_fname_kset, &entry->kobj, entry->name); in fw_cfg_register_file()
624 kobject_del(&entry->kobj); in fw_cfg_register_file()
626 kobject_put(&entry->kobj); in fw_cfg_register_file()
636 struct fw_cfg_file *dir; in fw_cfg_register_dir_entries() local
647 dir = kmalloc(dir_size, GFP_KERNEL); in fw_cfg_register_dir_entries()
648 if (!dir) in fw_cfg_register_dir_entries()
649 return -ENOMEM; in fw_cfg_register_dir_entries()
651 ret = fw_cfg_read_blob(FW_CFG_FILE_DIR, dir, in fw_cfg_register_dir_entries()
657 ret = fw_cfg_register_file(&dir[i]); in fw_cfg_register_dir_entries()
663 kfree(dir); in fw_cfg_register_dir_entries()
667 /* unregister top-level or by_key folder */
680 * a subdirectory named after e.g. pdev->id, then hang per-device in fw_cfg_sysfs_probe()
682 * one fw_cfg device exist system-wide, so if one was already found in fw_cfg_sysfs_probe()
686 return -EBUSY; in fw_cfg_sysfs_probe()
689 err = -ENOMEM; in fw_cfg_sysfs_probe()
702 /* get revision number, add matching top-level attribute */ in fw_cfg_sysfs_probe()
746 { .compatible = "qemu,fw-cfg-mmio", },
806 /* only one fw_cfg device can exist system-wide, so if one in fw_cfg_cmdline_set()
813 return -EINVAL; in fw_cfg_cmdline_set()
833 return -EINVAL; in fw_cfg_cmdline_set()
836 res[0].end = base + size - 1; in fw_cfg_cmdline_set()
837 res[0].flags = !strcmp(kp->name, "mmio") ? IORESOURCE_MEM : in fw_cfg_cmdline_set()
871 (!strcmp(kp->name, "mmio") ^ in fw_cfg_cmdline_get()
872 (fw_cfg_cmdline_dev->resource[0].flags == IORESOURCE_MEM))) in fw_cfg_cmdline_get()
875 switch (fw_cfg_cmdline_dev->num_resources) { in fw_cfg_cmdline_get()
878 resource_size(&fw_cfg_cmdline_dev->resource[0]), in fw_cfg_cmdline_get()
879 fw_cfg_cmdline_dev->resource[0].start); in fw_cfg_cmdline_get()
882 resource_size(&fw_cfg_cmdline_dev->resource[0]), in fw_cfg_cmdline_get()
883 fw_cfg_cmdline_dev->resource[0].start, in fw_cfg_cmdline_get()
884 fw_cfg_cmdline_dev->resource[1].start, in fw_cfg_cmdline_get()
885 fw_cfg_cmdline_dev->resource[2].start); in fw_cfg_cmdline_get()
888 resource_size(&fw_cfg_cmdline_dev->resource[0]), in fw_cfg_cmdline_get()
889 fw_cfg_cmdline_dev->resource[0].start, in fw_cfg_cmdline_get()
890 fw_cfg_cmdline_dev->resource[1].start, in fw_cfg_cmdline_get()
891 fw_cfg_cmdline_dev->resource[2].start, in fw_cfg_cmdline_get()
892 fw_cfg_cmdline_dev->resource[3].start); in fw_cfg_cmdline_get()
897 fw_cfg_cmdline_dev->num_resources); in fw_cfg_cmdline_get()
918 return -ENOMEM; in fw_cfg_sysfs_init()