fw_cfg.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * (C) Copyright 2015 Miao Yan <yanmiaobest@gmail.com>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #ifndef __FW_CFG__
  7. #define __FW_CFG__
  8. #define FW_CONTROL_PORT 0x510
  9. #define FW_DATA_PORT 0x511
  10. #define FW_DMA_PORT_LOW 0x514
  11. #define FW_DMA_PORT_HIGH 0x518
  12. enum qemu_fwcfg_items {
  13. FW_CFG_SIGNATURE = 0x00,
  14. FW_CFG_ID = 0x01,
  15. FW_CFG_UUID = 0x02,
  16. FW_CFG_RAM_SIZE = 0x03,
  17. FW_CFG_NOGRAPHIC = 0x04,
  18. FW_CFG_NB_CPUS = 0x05,
  19. FW_CFG_MACHINE_ID = 0x06,
  20. FW_CFG_KERNEL_ADDR = 0x07,
  21. FW_CFG_KERNEL_SIZE = 0x08,
  22. FW_CFG_KERNEL_CMDLINE = 0x09,
  23. FW_CFG_INITRD_ADDR = 0x0a,
  24. FW_CFG_INITRD_SIZE = 0x0b,
  25. FW_CFG_BOOT_DEVICE = 0x0c,
  26. FW_CFG_NUMA = 0x0d,
  27. FW_CFG_BOOT_MENU = 0x0e,
  28. FW_CFG_MAX_CPUS = 0x0f,
  29. FW_CFG_KERNEL_ENTRY = 0x10,
  30. FW_CFG_KERNEL_DATA = 0x11,
  31. FW_CFG_INITRD_DATA = 0x12,
  32. FW_CFG_CMDLINE_ADDR = 0x13,
  33. FW_CFG_CMDLINE_SIZE = 0x14,
  34. FW_CFG_CMDLINE_DATA = 0x15,
  35. FW_CFG_SETUP_ADDR = 0x16,
  36. FW_CFG_SETUP_SIZE = 0x17,
  37. FW_CFG_SETUP_DATA = 0x18,
  38. FW_CFG_FILE_DIR = 0x19,
  39. FW_CFG_FILE_FIRST = 0x20,
  40. FW_CFG_WRITE_CHANNEL = 0x4000,
  41. FW_CFG_ARCH_LOCAL = 0x8000,
  42. FW_CFG_INVALID = 0xffff,
  43. };
  44. #define FW_CFG_FILE_SLOTS 0x10
  45. #define FW_CFG_MAX_ENTRY (FW_CFG_FILE_FIRST + FW_CFG_FILE_SLOTS)
  46. #define FW_CFG_ENTRY_MASK ~(FW_CFG_WRITE_CHANNEL | FW_CFG_ARCH_LOCAL)
  47. #define FW_CFG_MAX_FILE_PATH 56
  48. #define QEMU_FW_CFG_SIGNATURE (('Q' << 24) | ('E' << 16) | ('M' << 8) | 'U')
  49. #define FW_CFG_DMA_ERROR (1 << 0)
  50. #define FW_CFG_DMA_READ (1 << 1)
  51. #define FW_CFG_DMA_SKIP (1 << 2)
  52. #define FW_CFG_DMA_SELECT (1 << 3)
  53. #define FW_CFG_DMA_ENABLED (1 << 1)
  54. struct fw_cfg_file {
  55. __be32 size;
  56. __be16 select;
  57. __be16 reserved;
  58. char name[FW_CFG_MAX_FILE_PATH];
  59. };
  60. struct fw_cfg_files {
  61. __be32 count;
  62. struct fw_cfg_file files[];
  63. };
  64. struct fw_cfg_dma_access {
  65. __be32 control;
  66. __be32 length;
  67. __be64 address;
  68. };
  69. /**
  70. * Initialize QEMU fw_cfg interface
  71. */
  72. void qemu_fwcfg_init(void);
  73. /**
  74. * Get system cpu number
  75. *
  76. * @return: cpu number in system
  77. */
  78. int qemu_fwcfg_online_cpus(void);
  79. #endif