xref: /qemu/include/hw/char/riscv_htif.h (revision 8be545ba5a315a9aaf7307f143a4a7926a6e605c)
150336067SMichael Clark /*
250336067SMichael Clark  * QEMU RISCV Host Target Interface (HTIF) Emulation
350336067SMichael Clark  *
450336067SMichael Clark  * Copyright (c) 2016-2017 Sagar Karandikar, sagark@eecs.berkeley.edu
550336067SMichael Clark  * Copyright (c) 2017-2018 SiFive, Inc.
650336067SMichael Clark  *
750336067SMichael Clark  * This program is free software; you can redistribute it and/or modify it
850336067SMichael Clark  * under the terms and conditions of the GNU General Public License,
950336067SMichael Clark  * version 2 or later, as published by the Free Software Foundation.
1050336067SMichael Clark  *
1150336067SMichael Clark  * This program is distributed in the hope it will be useful, but WITHOUT
1250336067SMichael Clark  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1350336067SMichael Clark  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
1450336067SMichael Clark  * more details.
1550336067SMichael Clark  *
1650336067SMichael Clark  * You should have received a copy of the GNU General Public License along with
1750336067SMichael Clark  * this program.  If not, see <http://www.gnu.org/licenses/>.
1850336067SMichael Clark  */
1950336067SMichael Clark 
2050336067SMichael Clark #ifndef HW_RISCV_HTIF_H
2150336067SMichael Clark #define HW_RISCV_HTIF_H
2250336067SMichael Clark 
2350336067SMichael Clark #include "chardev/char.h"
2450336067SMichael Clark #include "chardev/char-fe.h"
25*8be545baSRichard Henderson #include "system/memory.h"
2650336067SMichael Clark 
2750336067SMichael Clark #define TYPE_HTIF_UART "riscv.htif.uart"
2850336067SMichael Clark 
2950336067SMichael Clark typedef struct HTIFState {
3050336067SMichael Clark     int allow_tohost;
3150336067SMichael Clark     int fromhost_inprogress;
3250336067SMichael Clark 
331237c2d6SBin Meng     uint64_t tohost;
341237c2d6SBin Meng     uint64_t fromhost;
3550336067SMichael Clark     hwaddr tohost_offset;
3650336067SMichael Clark     hwaddr fromhost_offset;
3750336067SMichael Clark     MemoryRegion mmio;
3850336067SMichael Clark 
3950336067SMichael Clark     CharBackend chr;
4050336067SMichael Clark     uint64_t pending_read;
4150336067SMichael Clark } HTIFState;
4250336067SMichael Clark 
4366247edcSWeiwei Li extern const char *sig_file;
4466247edcSWeiwei Li extern uint8_t line_size;
4566247edcSWeiwei Li 
4650336067SMichael Clark /* HTIF symbol callback */
4750336067SMichael Clark void htif_symbol_callback(const char *st_name, int st_info, uint64_t st_value,
4850336067SMichael Clark     uint64_t st_size);
4950336067SMichael Clark 
5050336067SMichael Clark /* legacy pre qom */
511237c2d6SBin Meng HTIFState *htif_mm_init(MemoryRegion *address_space, Chardev *chr,
5271d68c48SBin Meng                         uint64_t nonelf_base, bool custom_base);
5350336067SMichael Clark 
5450336067SMichael Clark #endif
55