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" 2550336067SMichael Clark #include "exec/memory.h" 2650336067SMichael Clark #include "target/riscv/cpu.h" 2750336067SMichael Clark 2850336067SMichael Clark #define TYPE_HTIF_UART "riscv.htif.uart" 2950336067SMichael Clark 3050336067SMichael Clark typedef struct HTIFState { 3150336067SMichael Clark int allow_tohost; 3250336067SMichael Clark int fromhost_inprogress; 3350336067SMichael Clark 3450336067SMichael Clark hwaddr tohost_offset; 3550336067SMichael Clark hwaddr fromhost_offset; 3650336067SMichael Clark uint64_t tohost_size; 3750336067SMichael Clark uint64_t fromhost_size; 3850336067SMichael Clark MemoryRegion mmio; 3950336067SMichael Clark MemoryRegion *address_space; 4050336067SMichael Clark MemoryRegion *main_mem; 4150336067SMichael Clark void *main_mem_ram_ptr; 4250336067SMichael Clark 4350336067SMichael Clark CPURISCVState *env; 4450336067SMichael Clark CharBackend chr; 4550336067SMichael Clark uint64_t pending_read; 4650336067SMichael Clark } HTIFState; 4750336067SMichael Clark 4850336067SMichael Clark extern const VMStateDescription vmstate_htif; 4950336067SMichael Clark extern const MemoryRegionOps htif_io_ops; 5050336067SMichael Clark 5150336067SMichael Clark /* HTIF symbol callback */ 5250336067SMichael Clark void htif_symbol_callback(const char *st_name, int st_info, uint64_t st_value, 5350336067SMichael Clark uint64_t st_size); 5450336067SMichael Clark 55*8d8897acSAnup Patel /* Check if HTIF uses ELF symbols */ 56*8d8897acSAnup Patel bool htif_uses_elf_symbols(void); 57*8d8897acSAnup Patel 5850336067SMichael Clark /* legacy pre qom */ 5950336067SMichael Clark HTIFState *htif_mm_init(MemoryRegion *address_space, MemoryRegion *main_mem, 60*8d8897acSAnup Patel CPURISCVState *env, Chardev *chr, uint64_t nonelf_base); 6150336067SMichael Clark 6250336067SMichael Clark #endif 63