summaryrefslogtreecommitdiff
path: root/include/hw/riscv/mta1_mkdf.h
blob: d555792c7b40fa0bb60c3c19908c8fb2178b5071 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
 * QEMU RISC-V Board Compatible with Mullvad MTA1-MKDF platform
 *
 * Copyright (c) 2022 Mullvad VPN AB
 *
 * Provides a board compatible with the Mullvad MTA1-MKDF platform:
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2 or later, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef HW_MTA1_MKDF_H
#define HW_MTA1_MKDF_H

#include "hw/boards.h"
#include "hw/riscv/riscv_hart.h"
#include "qom/object.h"
#include "chardev/char-fe.h"

#include "hw/riscv/mta1_mkdf_mem.h"

#define MTA1_MKDF_RX_FIFO_SIZE 16

typedef struct MTA1MKDFState {
    /*< private >*/
    MachineState parent_obj;

    /*< public >*/
    RISCVHartArrayState cpus;
    MemoryRegion rom;
    MemoryRegion mmio;

    CharBackend fifo_chr;
    char *fifo_chr_name;
    uint8_t fifo_rx[MTA1_MKDF_RX_FIFO_SIZE];
    uint8_t fifo_rx_len;
    bool app_mode;
    uint32_t app_addr;
    uint32_t app_size;
    uint32_t uds[8]; // 32 bytes
    bool block_uds[8];
    uint32_t uda[4]; // 16 bytes
    uint32_t led;
    uint32_t cdi[8]; // 32 bytes
    uint32_t udi[2]; // 8 bytes
} MTA1MKDFState;

#define TYPE_MTA1_MKDF_MACHINE MACHINE_TYPE_NAME("mta1_mkdf")
#define MTA1_MKDF_MACHINE(obj) \
    OBJECT_CHECK(MTA1MKDFState, (obj), TYPE_MTA1_MKDF_MACHINE)

enum {
    MTA1_MKDF_ROM,
    MTA1_MKDF_RAM,
    MTA1_MKDF_MMIO,
};

#endif