162306a36Sopenharmony_ci/* SPDX-License-Identifier: BSD-3-Clause */
262306a36Sopenharmony_ci#ifndef _LINUX_FW_CFG_H
362306a36Sopenharmony_ci#define _LINUX_FW_CFG_H
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#include <linux/types.h>
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#define FW_CFG_ACPI_DEVICE_ID	"QEMU0002"
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci/* selector key values for "well-known" fw_cfg entries */
1062306a36Sopenharmony_ci#define FW_CFG_SIGNATURE	0x00
1162306a36Sopenharmony_ci#define FW_CFG_ID		0x01
1262306a36Sopenharmony_ci#define FW_CFG_UUID		0x02
1362306a36Sopenharmony_ci#define FW_CFG_RAM_SIZE		0x03
1462306a36Sopenharmony_ci#define FW_CFG_NOGRAPHIC	0x04
1562306a36Sopenharmony_ci#define FW_CFG_NB_CPUS		0x05
1662306a36Sopenharmony_ci#define FW_CFG_MACHINE_ID	0x06
1762306a36Sopenharmony_ci#define FW_CFG_KERNEL_ADDR	0x07
1862306a36Sopenharmony_ci#define FW_CFG_KERNEL_SIZE	0x08
1962306a36Sopenharmony_ci#define FW_CFG_KERNEL_CMDLINE	0x09
2062306a36Sopenharmony_ci#define FW_CFG_INITRD_ADDR	0x0a
2162306a36Sopenharmony_ci#define FW_CFG_INITRD_SIZE	0x0b
2262306a36Sopenharmony_ci#define FW_CFG_BOOT_DEVICE	0x0c
2362306a36Sopenharmony_ci#define FW_CFG_NUMA		0x0d
2462306a36Sopenharmony_ci#define FW_CFG_BOOT_MENU	0x0e
2562306a36Sopenharmony_ci#define FW_CFG_MAX_CPUS		0x0f
2662306a36Sopenharmony_ci#define FW_CFG_KERNEL_ENTRY	0x10
2762306a36Sopenharmony_ci#define FW_CFG_KERNEL_DATA	0x11
2862306a36Sopenharmony_ci#define FW_CFG_INITRD_DATA	0x12
2962306a36Sopenharmony_ci#define FW_CFG_CMDLINE_ADDR	0x13
3062306a36Sopenharmony_ci#define FW_CFG_CMDLINE_SIZE	0x14
3162306a36Sopenharmony_ci#define FW_CFG_CMDLINE_DATA	0x15
3262306a36Sopenharmony_ci#define FW_CFG_SETUP_ADDR	0x16
3362306a36Sopenharmony_ci#define FW_CFG_SETUP_SIZE	0x17
3462306a36Sopenharmony_ci#define FW_CFG_SETUP_DATA	0x18
3562306a36Sopenharmony_ci#define FW_CFG_FILE_DIR		0x19
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci#define FW_CFG_FILE_FIRST	0x20
3862306a36Sopenharmony_ci#define FW_CFG_FILE_SLOTS_MIN	0x10
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci#define FW_CFG_WRITE_CHANNEL	0x4000
4162306a36Sopenharmony_ci#define FW_CFG_ARCH_LOCAL	0x8000
4262306a36Sopenharmony_ci#define FW_CFG_ENTRY_MASK	(~(FW_CFG_WRITE_CHANNEL | FW_CFG_ARCH_LOCAL))
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci#define FW_CFG_INVALID		0xffff
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ci/* width in bytes of fw_cfg control register */
4762306a36Sopenharmony_ci#define FW_CFG_CTL_SIZE		0x02
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci/* fw_cfg "file name" is up to 56 characters (including terminating nul) */
5062306a36Sopenharmony_ci#define FW_CFG_MAX_FILE_PATH	56
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci/* size in bytes of fw_cfg signature */
5362306a36Sopenharmony_ci#define FW_CFG_SIG_SIZE 4
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci/* FW_CFG_ID bits */
5662306a36Sopenharmony_ci#define FW_CFG_VERSION		0x01
5762306a36Sopenharmony_ci#define FW_CFG_VERSION_DMA	0x02
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci/* fw_cfg file directory entry type */
6062306a36Sopenharmony_cistruct fw_cfg_file {
6162306a36Sopenharmony_ci	__be32 size;
6262306a36Sopenharmony_ci	__be16 select;
6362306a36Sopenharmony_ci	__u16 reserved;
6462306a36Sopenharmony_ci	char name[FW_CFG_MAX_FILE_PATH];
6562306a36Sopenharmony_ci};
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci/* FW_CFG_DMA_CONTROL bits */
6862306a36Sopenharmony_ci#define FW_CFG_DMA_CTL_ERROR	0x01
6962306a36Sopenharmony_ci#define FW_CFG_DMA_CTL_READ	0x02
7062306a36Sopenharmony_ci#define FW_CFG_DMA_CTL_SKIP	0x04
7162306a36Sopenharmony_ci#define FW_CFG_DMA_CTL_SELECT	0x08
7262306a36Sopenharmony_ci#define FW_CFG_DMA_CTL_WRITE	0x10
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci#define FW_CFG_DMA_SIGNATURE    0x51454d5520434647ULL /* "QEMU CFG" */
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci/* Control as first field allows for different structures selected by this
7762306a36Sopenharmony_ci * field, which might be useful in the future
7862306a36Sopenharmony_ci */
7962306a36Sopenharmony_cistruct fw_cfg_dma_access {
8062306a36Sopenharmony_ci	__be32 control;
8162306a36Sopenharmony_ci	__be32 length;
8262306a36Sopenharmony_ci	__be64 address;
8362306a36Sopenharmony_ci};
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ci#define FW_CFG_VMCOREINFO_FILENAME "etc/vmcoreinfo"
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci#define FW_CFG_VMCOREINFO_FORMAT_NONE 0x0
8862306a36Sopenharmony_ci#define FW_CFG_VMCOREINFO_FORMAT_ELF 0x1
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_cistruct fw_cfg_vmcoreinfo {
9162306a36Sopenharmony_ci	__le16 host_format;
9262306a36Sopenharmony_ci	__le16 guest_format;
9362306a36Sopenharmony_ci	__le32 size;
9462306a36Sopenharmony_ci	__le64 paddr;
9562306a36Sopenharmony_ci};
9662306a36Sopenharmony_ci
9762306a36Sopenharmony_ci#endif
98