xref: /openbmc/qemu/include/hw/char/riscv_htif.h (revision a9fe9e191b4305b88c356a1ed9ac3baf89eb18aa)
170eb9f9cSBin Meng /*
270eb9f9cSBin Meng  * QEMU RISCV Host Target Interface (HTIF) Emulation
370eb9f9cSBin Meng  *
470eb9f9cSBin Meng  * Copyright (c) 2016-2017 Sagar Karandikar, sagark@eecs.berkeley.edu
570eb9f9cSBin Meng  * Copyright (c) 2017-2018 SiFive, Inc.
670eb9f9cSBin Meng  *
770eb9f9cSBin Meng  * This program is free software; you can redistribute it and/or modify it
870eb9f9cSBin Meng  * under the terms and conditions of the GNU General Public License,
970eb9f9cSBin Meng  * version 2 or later, as published by the Free Software Foundation.
1070eb9f9cSBin Meng  *
1170eb9f9cSBin Meng  * This program is distributed in the hope it will be useful, but WITHOUT
1270eb9f9cSBin Meng  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1370eb9f9cSBin Meng  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
1470eb9f9cSBin Meng  * more details.
1570eb9f9cSBin Meng  *
1670eb9f9cSBin Meng  * You should have received a copy of the GNU General Public License along with
1770eb9f9cSBin Meng  * this program.  If not, see <http://www.gnu.org/licenses/>.
1870eb9f9cSBin Meng  */
1970eb9f9cSBin Meng 
2070eb9f9cSBin Meng #ifndef HW_RISCV_HTIF_H
2170eb9f9cSBin Meng #define HW_RISCV_HTIF_H
2270eb9f9cSBin Meng 
2370eb9f9cSBin Meng #include "chardev/char.h"
2470eb9f9cSBin Meng #include "chardev/char-fe.h"
2570eb9f9cSBin Meng #include "exec/memory.h"
2670eb9f9cSBin Meng 
2770eb9f9cSBin Meng #define TYPE_HTIF_UART "riscv.htif.uart"
2870eb9f9cSBin Meng 
2970eb9f9cSBin Meng typedef struct HTIFState {
3070eb9f9cSBin Meng     int allow_tohost;
3170eb9f9cSBin Meng     int fromhost_inprogress;
3270eb9f9cSBin Meng 
331237c2d6SBin Meng     uint64_t tohost;
341237c2d6SBin Meng     uint64_t fromhost;
3570eb9f9cSBin Meng     hwaddr tohost_offset;
3670eb9f9cSBin Meng     hwaddr fromhost_offset;
3770eb9f9cSBin Meng     MemoryRegion mmio;
3870eb9f9cSBin Meng 
3970eb9f9cSBin Meng     CharBackend chr;
4070eb9f9cSBin Meng     uint64_t pending_read;
4170eb9f9cSBin Meng } HTIFState;
4270eb9f9cSBin Meng 
43*66247edcSWeiwei Li extern const char *sig_file;
44*66247edcSWeiwei Li extern uint8_t line_size;
45*66247edcSWeiwei Li 
4670eb9f9cSBin Meng /* HTIF symbol callback */
4770eb9f9cSBin Meng void htif_symbol_callback(const char *st_name, int st_info, uint64_t st_value,
4870eb9f9cSBin Meng     uint64_t st_size);
4970eb9f9cSBin Meng 
5070eb9f9cSBin Meng /* legacy pre qom */
511237c2d6SBin Meng HTIFState *htif_mm_init(MemoryRegion *address_space, Chardev *chr,
5271d68c48SBin Meng                         uint64_t nonelf_base, bool custom_base);
5370eb9f9cSBin Meng 
5470eb9f9cSBin Meng #endif
55