xref: /qemu/include/hw/nvram/fw_cfg.h (revision a4c0d1deb785611c96a455f65ec032976b00b36f)
13cce6243Sblueswir1 #ifndef FW_CFG_H
23cce6243Sblueswir1 #define FW_CFG_H
33cce6243Sblueswir1 
41dfe5057SHu Tao #ifndef NO_QEMU_PROTOS
51dfe5057SHu Tao #include <stdint.h>
61dfe5057SHu Tao #include <stddef.h>
71dfe5057SHu Tao 
81dfe5057SHu Tao #include "exec/hwaddr.h"
945936c8bSMichael S. Tsirkin #include "qemu/typedefs.h"
101dfe5057SHu Tao #endif
111dfe5057SHu Tao 
123cce6243Sblueswir1 #define FW_CFG_SIGNATURE        0x00
133cce6243Sblueswir1 #define FW_CFG_ID               0x01
14084a197aSblueswir1 #define FW_CFG_UUID             0x02
15905fdcb5Sblueswir1 #define FW_CFG_RAM_SIZE         0x03
16905fdcb5Sblueswir1 #define FW_CFG_NOGRAPHIC        0x04
17905fdcb5Sblueswir1 #define FW_CFG_NB_CPUS          0x05
18905fdcb5Sblueswir1 #define FW_CFG_MACHINE_ID       0x06
197e12f656Sblueswir1 #define FW_CFG_KERNEL_ADDR      0x07
207e12f656Sblueswir1 #define FW_CFG_KERNEL_SIZE      0x08
217e12f656Sblueswir1 #define FW_CFG_KERNEL_CMDLINE   0x09
227e12f656Sblueswir1 #define FW_CFG_INITRD_ADDR      0x0a
237e12f656Sblueswir1 #define FW_CFG_INITRD_SIZE      0x0b
247e12f656Sblueswir1 #define FW_CFG_BOOT_DEVICE      0x0c
2511c2fd3eSaliguori #define FW_CFG_NUMA             0x0d
2695387491SJan Kiszka #define FW_CFG_BOOT_MENU        0x0e
276be68d7eSJes Sorensen #define FW_CFG_MAX_CPUS         0x0f
2877873196SAlexander Graf #define FW_CFG_KERNEL_ENTRY     0x10
2977873196SAlexander Graf #define FW_CFG_KERNEL_DATA      0x11
3077873196SAlexander Graf #define FW_CFG_INITRD_DATA      0x12
3157a46d05SAlexander Graf #define FW_CFG_CMDLINE_ADDR     0x13
3257a46d05SAlexander Graf #define FW_CFG_CMDLINE_SIZE     0x14
3357a46d05SAlexander Graf #define FW_CFG_CMDLINE_DATA     0x15
3457a46d05SAlexander Graf #define FW_CFG_SETUP_ADDR       0x16
3557a46d05SAlexander Graf #define FW_CFG_SETUP_SIZE       0x17
3657a46d05SAlexander Graf #define FW_CFG_SETUP_DATA       0x18
37abe147e0SGerd Hoffmann #define FW_CFG_FILE_DIR         0x19
38abe147e0SGerd Hoffmann 
39abe147e0SGerd Hoffmann #define FW_CFG_FILE_FIRST       0x20
40abe147e0SGerd Hoffmann #define FW_CFG_FILE_SLOTS       0x10
41abe147e0SGerd Hoffmann #define FW_CFG_MAX_ENTRY        (FW_CFG_FILE_FIRST+FW_CFG_FILE_SLOTS)
423cce6243Sblueswir1 
433cce6243Sblueswir1 #define FW_CFG_WRITE_CHANNEL    0x4000
443cce6243Sblueswir1 #define FW_CFG_ARCH_LOCAL       0x8000
453cce6243Sblueswir1 #define FW_CFG_ENTRY_MASK       ~(FW_CFG_WRITE_CHANNEL | FW_CFG_ARCH_LOCAL)
463cce6243Sblueswir1 
473cce6243Sblueswir1 #define FW_CFG_INVALID          0xffff
483cce6243Sblueswir1 
4935c12e60SMichael S. Tsirkin #define FW_CFG_MAX_FILE_PATH    56
5035c12e60SMichael S. Tsirkin 
513cce6243Sblueswir1 #ifndef NO_QEMU_PROTOS
52abe147e0SGerd Hoffmann typedef struct FWCfgFile {
53abe147e0SGerd Hoffmann     uint32_t  size;        /* file size */
54abe147e0SGerd Hoffmann     uint16_t  select;      /* write this to 0x510 to read it */
55abe147e0SGerd Hoffmann     uint16_t  reserved;
5635c12e60SMichael S. Tsirkin     char      name[FW_CFG_MAX_FILE_PATH];
57abe147e0SGerd Hoffmann } FWCfgFile;
58abe147e0SGerd Hoffmann 
59abe147e0SGerd Hoffmann typedef struct FWCfgFiles {
60abe147e0SGerd Hoffmann     uint32_t  count;
61abe147e0SGerd Hoffmann     FWCfgFile f[];
62abe147e0SGerd Hoffmann } FWCfgFiles;
63abe147e0SGerd Hoffmann 
64*a4c0d1deSMarc Marí /* Control as first field allows for different structures selected by this
65*a4c0d1deSMarc Marí  * field, which might be useful in the future
66*a4c0d1deSMarc Marí  */
67*a4c0d1deSMarc Marí typedef struct FWCfgDmaAccess {
68*a4c0d1deSMarc Marí     uint32_t control;
69*a4c0d1deSMarc Marí     uint32_t length;
70*a4c0d1deSMarc Marí     uint64_t address;
71*a4c0d1deSMarc Marí } QEMU_PACKED FWCfgDmaAccess;
72*a4c0d1deSMarc Marí 
733cce6243Sblueswir1 typedef void (*FWCfgCallback)(void *opaque, uint8_t *data);
74d87072ceSMichael S. Tsirkin typedef void (*FWCfgReadCallback)(void *opaque, uint32_t offset);
753cce6243Sblueswir1 
76089da572SMarkus Armbruster void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, void *data, size_t len);
7744687f75SMarkus Armbruster void fw_cfg_add_string(FWCfgState *s, uint16_t key, const char *value);
784cad3867SMarkus Armbruster void fw_cfg_add_i16(FWCfgState *s, uint16_t key, uint16_t value);
791edd34b6SGabriel L. Somlo void fw_cfg_modify_i16(FWCfgState *s, uint16_t key, uint16_t value);
804cad3867SMarkus Armbruster void fw_cfg_add_i32(FWCfgState *s, uint16_t key, uint32_t value);
814cad3867SMarkus Armbruster void fw_cfg_add_i64(FWCfgState *s, uint16_t key, uint64_t value);
82089da572SMarkus Armbruster void fw_cfg_add_file(FWCfgState *s, const char *filename, void *data,
83089da572SMarkus Armbruster                      size_t len);
84d87072ceSMichael S. Tsirkin void fw_cfg_add_file_callback(FWCfgState *s, const char *filename,
85d87072ceSMichael S. Tsirkin                               FWCfgReadCallback callback, void *callback_opaque,
86d87072ceSMichael S. Tsirkin                               void *data, size_t len);
87bdbb5b17SGonglei void *fw_cfg_modify_file(FWCfgState *s, const char *filename, void *data,
88bdbb5b17SGonglei                          size_t len);
89*a4c0d1deSMarc Marí FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_t dma_iobase,
90*a4c0d1deSMarc Marí                                 AddressSpace *dma_as);
915712db6aSLaszlo Ersek FWCfgState *fw_cfg_init_io(uint32_t iobase);
925712db6aSLaszlo Ersek FWCfgState *fw_cfg_init_mem(hwaddr ctl_addr, hwaddr data_addr);
93*a4c0d1deSMarc Marí FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr,
94*a4c0d1deSMarc Marí                                  hwaddr data_addr, uint32_t data_width,
95*a4c0d1deSMarc Marí                                  hwaddr dma_addr, AddressSpace *dma_as);
963cce6243Sblueswir1 
97600c60b7SMichael S. Tsirkin FWCfgState *fw_cfg_find(void);
98600c60b7SMichael S. Tsirkin 
993cce6243Sblueswir1 #endif /* NO_QEMU_PROTOS */
1003cce6243Sblueswir1 
1013cce6243Sblueswir1 #endif
102