11cf4323eSThomas Huth /*
21cf4323eSThomas Huth * libqos fw_cfg support
31cf4323eSThomas Huth *
41cf4323eSThomas Huth * Copyright IBM, Corp. 2012-2013
51cf4323eSThomas Huth *
61cf4323eSThomas Huth * Authors:
71cf4323eSThomas Huth * Anthony Liguori <aliguori@us.ibm.com>
81cf4323eSThomas Huth *
91cf4323eSThomas Huth * This work is licensed under the terms of the GNU GPL, version 2 or later.
101cf4323eSThomas Huth * See the COPYING file in the top-level directory.
111cf4323eSThomas Huth */
121cf4323eSThomas Huth
131cf4323eSThomas Huth #ifndef LIBQOS_FW_CFG_H
141cf4323eSThomas Huth #define LIBQOS_FW_CFG_H
151cf4323eSThomas Huth
16*907b5105SMarc-André Lureau #include "../libqtest.h"
171cf4323eSThomas Huth
181cf4323eSThomas Huth typedef struct QFWCFG QFWCFG;
191cf4323eSThomas Huth
201cf4323eSThomas Huth struct QFWCFG
211cf4323eSThomas Huth {
221cf4323eSThomas Huth uint64_t base;
231cf4323eSThomas Huth QTestState *qts;
241cf4323eSThomas Huth void (*select)(QFWCFG *fw_cfg, uint16_t key);
251cf4323eSThomas Huth void (*read)(QFWCFG *fw_cfg, void *data, size_t len);
261cf4323eSThomas Huth };
271cf4323eSThomas Huth
281cf4323eSThomas Huth void qfw_cfg_select(QFWCFG *fw_cfg, uint16_t key);
291cf4323eSThomas Huth void qfw_cfg_read_data(QFWCFG *fw_cfg, void *data, size_t len);
301cf4323eSThomas Huth void qfw_cfg_get(QFWCFG *fw_cfg, uint16_t key, void *data, size_t len);
311cf4323eSThomas Huth uint16_t qfw_cfg_get_u16(QFWCFG *fw_cfg, uint16_t key);
321cf4323eSThomas Huth uint32_t qfw_cfg_get_u32(QFWCFG *fw_cfg, uint16_t key);
331cf4323eSThomas Huth uint64_t qfw_cfg_get_u64(QFWCFG *fw_cfg, uint16_t key);
341cf4323eSThomas Huth size_t qfw_cfg_get_file(QFWCFG *fw_cfg, const char *filename,
351cf4323eSThomas Huth void *data, size_t buflen);
361cf4323eSThomas Huth
371cf4323eSThomas Huth QFWCFG *mm_fw_cfg_init(QTestState *qts, uint64_t base);
381cf4323eSThomas Huth void mm_fw_cfg_uninit(QFWCFG *fw_cfg);
391cf4323eSThomas Huth QFWCFG *io_fw_cfg_init(QTestState *qts, uint16_t base);
401cf4323eSThomas Huth void io_fw_cfg_uninit(QFWCFG *fw_cfg);
411cf4323eSThomas Huth
pc_fw_cfg_init(QTestState * qts)421cf4323eSThomas Huth static inline QFWCFG *pc_fw_cfg_init(QTestState *qts)
431cf4323eSThomas Huth {
441cf4323eSThomas Huth return io_fw_cfg_init(qts, 0x510);
451cf4323eSThomas Huth }
461cf4323eSThomas Huth
pc_fw_cfg_uninit(QFWCFG * fw_cfg)471cf4323eSThomas Huth static inline void pc_fw_cfg_uninit(QFWCFG *fw_cfg)
481cf4323eSThomas Huth {
491cf4323eSThomas Huth io_fw_cfg_uninit(fw_cfg);
501cf4323eSThomas Huth }
511cf4323eSThomas Huth
5277c24259SPan Nengyuan G_DEFINE_AUTOPTR_CLEANUP_FUNC(QFWCFG, mm_fw_cfg_uninit)
5377c24259SPan Nengyuan
541cf4323eSThomas Huth #endif
55