162306a36Sopenharmony_ciWhat:		/sys/firmware/qemu_fw_cfg/
262306a36Sopenharmony_ciDate:		August 2015
362306a36Sopenharmony_ciContact:	Gabriel Somlo <somlo@cmu.edu>
462306a36Sopenharmony_ciDescription:
562306a36Sopenharmony_ci		Several different architectures supported by QEMU (x86, arm,
662306a36Sopenharmony_ci		sun4*, ppc/mac) are provisioned with a firmware configuration
762306a36Sopenharmony_ci		(fw_cfg) device, originally intended as a way for the host to
862306a36Sopenharmony_ci		provide configuration data to the guest firmware. Starting
962306a36Sopenharmony_ci		with QEMU v2.4, arbitrary fw_cfg file entries may be specified
1062306a36Sopenharmony_ci		by the user on the command line, which makes fw_cfg additionally
1162306a36Sopenharmony_ci		useful as an out-of-band, asynchronous mechanism for providing
1262306a36Sopenharmony_ci		configuration data to the guest userspace.
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci		The authoritative guest-side hardware interface documentation
1562306a36Sopenharmony_ci		to the fw_cfg device can be found in "docs/specs/fw_cfg.rst"
1662306a36Sopenharmony_ci		in the QEMU source tree, or online at:
1762306a36Sopenharmony_ci		https://qemu-project.gitlab.io/qemu/specs/fw_cfg.html
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci		**SysFS fw_cfg Interface**
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci		The fw_cfg sysfs interface described in this document is only
2262306a36Sopenharmony_ci		intended to display discoverable blobs (i.e., those registered
2362306a36Sopenharmony_ci		with the file directory), as there is no way to determine the
2462306a36Sopenharmony_ci		presence or size of "legacy" blobs (with selector keys between
2562306a36Sopenharmony_ci		0x0002 and 0x0018) programmatically.
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci		All fw_cfg information is shown under:
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci			/sys/firmware/qemu_fw_cfg/
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci		The only legacy blob displayed is the fw_cfg device revision:
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci			/sys/firmware/qemu_fw_cfg/rev
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci		**Discoverable fw_cfg blobs by selector key**
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci		All discoverable blobs listed in the fw_cfg file directory are
3862306a36Sopenharmony_ci		displayed as entries named after their unique selector key
3962306a36Sopenharmony_ci		value, e.g.:
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci			/sys/firmware/qemu_fw_cfg/by_key/32
4262306a36Sopenharmony_ci			/sys/firmware/qemu_fw_cfg/by_key/33
4362306a36Sopenharmony_ci			/sys/firmware/qemu_fw_cfg/by_key/34
4462306a36Sopenharmony_ci			...
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ci		Each such fw_cfg sysfs entry has the following values exported
4762306a36Sopenharmony_ci		as attributes:
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci		====	  ====================================================
5062306a36Sopenharmony_ci		name	  The 56-byte nul-terminated ASCII string used as the
5162306a36Sopenharmony_ci			  blob's 'file name' in the fw_cfg directory.
5262306a36Sopenharmony_ci		size	  The length of the blob, as given in the fw_cfg
5362306a36Sopenharmony_ci			  directory.
5462306a36Sopenharmony_ci		key	  The value of the blob's selector key as given in the
5562306a36Sopenharmony_ci			  fw_cfg directory. This value is the same as used in
5662306a36Sopenharmony_ci			  the parent directory name.
5762306a36Sopenharmony_ci		raw	  The raw bytes of the blob, obtained by selecting the
5862306a36Sopenharmony_ci			  entry via the control register, and reading a number
5962306a36Sopenharmony_ci			  of bytes equal to the blob size from the data
6062306a36Sopenharmony_ci			  register.
6162306a36Sopenharmony_ci		====	  ====================================================
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci		**Listing fw_cfg blobs by file name**
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci		While the fw_cfg device does not impose any specific naming
6662306a36Sopenharmony_ci		convention on the blobs registered in the file directory,
6762306a36Sopenharmony_ci		QEMU developers have traditionally used path name semantics
6862306a36Sopenharmony_ci		to give each blob a descriptive name. For example::
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci			"bootorder"
7162306a36Sopenharmony_ci			"genroms/kvmvapic.bin"
7262306a36Sopenharmony_ci			"etc/e820"
7362306a36Sopenharmony_ci			"etc/boot-fail-wait"
7462306a36Sopenharmony_ci			"etc/system-states"
7562306a36Sopenharmony_ci			"etc/table-loader"
7662306a36Sopenharmony_ci			"etc/acpi/rsdp"
7762306a36Sopenharmony_ci			"etc/acpi/tables"
7862306a36Sopenharmony_ci			"etc/smbios/smbios-tables"
7962306a36Sopenharmony_ci			"etc/smbios/smbios-anchor"
8062306a36Sopenharmony_ci			...
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ci		In addition to the listing by unique selector key described
8362306a36Sopenharmony_ci		above, the fw_cfg sysfs driver also attempts to build a tree
8462306a36Sopenharmony_ci		of directories matching the path name components of fw_cfg
8562306a36Sopenharmony_ci		blob names, ending in symlinks to the by_key entry for each
8662306a36Sopenharmony_ci		"basename", as illustrated below (assume current directory is
8762306a36Sopenharmony_ci		/sys/firmware)::
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ci		    qemu_fw_cfg/by_name/bootorder -> ../by_key/38
9062306a36Sopenharmony_ci		    qemu_fw_cfg/by_name/etc/e820 -> ../../by_key/35
9162306a36Sopenharmony_ci		    qemu_fw_cfg/by_name/etc/acpi/rsdp -> ../../../by_key/41
9262306a36Sopenharmony_ci		    ...
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci		Construction of the directory tree and symlinks is done on a
9562306a36Sopenharmony_ci		"best-effort" basis, as there is no guarantee that components
9662306a36Sopenharmony_ci		of fw_cfg blob names are always "well behaved". I.e., there is
9762306a36Sopenharmony_ci		the possibility that a symlink (basename) will conflict with
9862306a36Sopenharmony_ci		a dirname component of another fw_cfg blob, in which case the
9962306a36Sopenharmony_ci		creation of the offending /sys/firmware/qemu_fw_cfg/by_name
10062306a36Sopenharmony_ci		entry will be skipped.
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_ci		The authoritative list of entries will continue to be found
10362306a36Sopenharmony_ci		under the /sys/firmware/qemu_fw_cfg/by_key directory.
104