PICSimLab - Programmable IC Simulator Laboratory 0.9.2
PICSimLab - API
Loading...
Searching...
No Matches
qemu.h
1/* ########################################################################
2
3 PICSimLab - Programmable IC Simulator Laboratory
4
5 ########################################################################
6
7 Copyright (c) : 2021-2024 Luis Claudio GambĂ´a Lopes <lcgamboa@yahoo.com>
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
12 any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
23 For e-mail suggestions : lcgamboa@yahoo.com
24 ######################################################################## */
25
26#include <stdint.h>
27
28extern "C" {
29#define Error char
30#define qemu_mutex_lock_iothread() qemu_mutex_lock_iothread_impl(__FILE__, __LINE__)
31
32typedef uint64_t hwaddr;
33typedef enum {
34 QEMU_CLOCK_REALTIME = 0,
35 QEMU_CLOCK_VIRTUAL = 1,
36 QEMU_CLOCK_HOST = 2,
37 QEMU_CLOCK_VIRTUAL_RT = 3,
38 QEMU_CLOCK_MAX
39} QEMUClockType;
40
41typedef struct QEMUTimer QEMUTimer;
42typedef void QEMUTimerCB(void* opaque);
43typedef struct QEMUTimerList QEMUTimerList;
44typedef struct QEMUTimerListGroup QEMUTimerListGroup;
45
46struct QEMUTimer {
47 int64_t expire_time; // in nanoseconds
48 QEMUTimerList* timer_list;
49 QEMUTimerCB* cb;
50 void* opaque;
51 QEMUTimer* next;
52 int attributes;
53 int scale;
54};
55
56typedef struct {
57 QEMUTimer* qtimer;
58 int64_t timeout;
59 int64_t last;
61
62extern void (*qemu_init)(int, char**, const char**);
63extern void (*qemu_main_loop)(void);
64extern void (*qemu_cleanup)(void);
65
66extern void (*qmp_quit)(Error** errp);
67extern void (*qmp_stop)(Error** errp);
68extern void (*qmp_system_reset)(Error** errp);
69extern void (*qmp_pmemsave)(int64_t val, int64_t size, const char* filename, Error** errp);
70extern void (*qmp_memsave)(int64_t val, int64_t size, const char* filename, Error** errp);
71extern void (*qmp_cont)(Error** errp);
72
73extern void (*qemu_mutex_lock_iothread_impl)(const char* file, int line);
74extern void (*qemu_mutex_unlock_iothread)(void);
75
76extern void (*qemu_picsimlab_register_callbacks)(void* arg);
77extern void (*qemu_picsimlab_set_pin)(int pin, int value);
78extern void (*qemu_picsimlab_set_apin)(int chn, int value);
79extern int (*qemu_picsimlab_flash_dump)(int64_t offset, void* buf, int bytes);
80extern void (*qemu_picsimlab_uart_receive)(const int id, const uint8_t* buf, int size);
81
82extern int64_t (*qemu_clock_get_ns)(QEMUClockType type);
83
84extern void (*timer_init_full)(QEMUTimer* ts, QEMUTimerListGroup* timer_list_group, QEMUClockType type, int scale,
85 int attributes, QEMUTimerCB* cb, void* opaque);
86
87extern void (*timer_mod_ns)(QEMUTimer* ts, int64_t expire_time);
88
89extern uint32_t* (*qemu_picsimlab_get_internals)(int cfg);
90
91extern uint32_t (*qemu_picsimlab_get_TIOCM)(void);
92
93typedef struct {
94 void (*picsimlab_write_pin)(int pin, int value);
95 void (*picsimlab_dir_pin)(int pin, int value);
96 int (*picsimlab_i2c_event)(const uint8_t id, const uint8_t addr, const uint16_t event);
97 uint8_t (*picsimlab_spi_event)(const uint8_t id, const uint16_t event);
98 void (*picsimlab_uart_tx_event)(const uint8_t id, const uint8_t value);
99 const short int* pinmap;
100 void (*picsimlab_rmt_event)(const uint8_t channel, const uint32_t config0, const uint32_t value);
102
103enum i2c_event {
104 I2C_START_RECV,
105 I2C_START_SEND,
106 I2C_START_SEND_ASYNC,
107 I2C_FINISH,
108 I2C_NACK, /* Masker NACKed a receive byte. */
109 I2C_WRITE,
110 I2C_READ
111};
112
113#define QEMU_INTERNAL_STRAP 0
114#define QEMU_INTERNAL_GPIO_IN_SEL 1
115#define QEMU_INTERNAL_GPIO_OUT_SEL 2
116#define QEMU_INTERNAL_IOMUX_GPIOS 3
117#define QEMU_INTERNAL_LEDC_CHANNEL_CONF 4
118#define QEMU_INTERNAL_LEDC_TIMER_FREQ 5
119#define QEMU_INTERNAL_LEDC_CHANNEL_DUTY 6
120#define QEMU_INTERNAL_UART0_BAUD 7
121#define QEMU_INTERNAL_UART1_BAUD 8
122#define QEMU_INTERNAL_UART2_BAUD 9
123
124#define QEMU_EXTRA_PIN_IN_CFG 1
125#define QEMU_EXTRA_PIN_OUT_CFG 2
126#define QEMU_EXTRA_PIN_IOMUX_CFG 4
127#define QEMU_EXTRA_PIN_LEDC_CFG 5
128}
Definition qemu.h:46
Definition qemu.h:93
Definition qemu.h:56