PICSimLab - Programmable IC Simulator Laboratory 0.9.3
PICSimLab - API
Loading...
Searching...
No Matches
qemu.h
1/* ########################################################################
2
3 PICSimLab - Programmable IC Simulator Laboratory
4
5 ########################################################################
6
7 Copyright (c) : 2021-2026 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
31#define qemu_mutex_lock_iothread_impl bql_lock_impl
32#define qemu_mutex_unlock_iothread bql_unlock
33
34#define qemu_mutex_lock_iothread() qemu_mutex_lock_iothread_impl(__FILE__, __LINE__)
35
36typedef uint64_t hwaddr;
37typedef enum {
38 QEMU_CLOCK_REALTIME = 0,
39 QEMU_CLOCK_VIRTUAL = 1,
40 QEMU_CLOCK_HOST = 2,
41 QEMU_CLOCK_VIRTUAL_RT = 3,
42 QEMU_CLOCK_MAX
43} QEMUClockType;
44
45typedef struct QEMUTimer QEMUTimer;
46typedef void QEMUTimerCB(void* opaque);
47typedef struct QEMUTimerList QEMUTimerList;
48typedef struct QEMUTimerListGroup QEMUTimerListGroup;
49
50struct QEMUTimer {
51 int64_t expire_time; // in nanoseconds
52 QEMUTimerList* timer_list;
53 QEMUTimerCB* cb;
54 void* opaque;
55 QEMUTimer* next;
56 int attributes;
57 int scale;
58};
59
60typedef struct {
61 QEMUTimer* qtimer;
62 int64_t timeout;
63 int64_t last;
65
66extern void (*qemu_init)(int, char**, const char**);
67extern void (*qemu_main_loop)(void);
68extern void (*qemu_cleanup)(void);
69
70extern void (*qmp_quit)(Error** errp);
71extern void (*qmp_stop)(Error** errp);
72extern void (*qmp_system_reset)(Error** errp);
73extern void (*qmp_pmemsave)(int64_t val, int64_t size, const char* filename, Error** errp);
74extern void (*qmp_memsave)(int64_t val, int64_t size, const char* filename, Error** errp);
75extern void (*qmp_cont)(Error** errp);
76
77extern void (*qemu_mutex_lock_iothread_impl)(const char* file, int line);
78extern void (*qemu_mutex_unlock_iothread)(void);
79
80extern void (*qemu_picsimlab_register_callbacks)(void* arg);
81extern void (*qemu_picsimlab_set_pin)(int pin, int value);
82extern void (*qemu_picsimlab_set_apin)(int chn, int value);
83extern int (*qemu_picsimlab_flash_dump)(int64_t offset, void* buf, int bytes);
84extern void (*qemu_picsimlab_uart_receive)(const int id, const uint8_t* buf, int size);
85
86extern int64_t (*qemu_clock_get_ns)(QEMUClockType type);
87
88extern void (*timer_init_full)(QEMUTimer* ts, QEMUTimerListGroup* timer_list_group, QEMUClockType type, int scale,
89 int attributes, QEMUTimerCB* cb, void* opaque);
90
91extern void (*timer_mod_ns)(QEMUTimer* ts, int64_t expire_time);
92
93extern uint32_t* (*qemu_picsimlab_get_internals)(int cfg);
94
95extern uint32_t (*qemu_picsimlab_get_TIOCM)(void);
96
97typedef struct {
98 void (*picsimlab_write_pin)(int pin, int value);
99 void (*picsimlab_dir_pin)(int pin, int value);
100 int (*picsimlab_i2c_event)(const uint8_t id, const uint8_t addr, const uint16_t event);
101 uint8_t (*picsimlab_spi_event)(const uint8_t id, const uint16_t event);
102 void (*picsimlab_uart_tx_event)(const uint8_t id, const uint8_t value);
103 const short int* pinmap;
104 void (*picsimlab_rmt_event)(const uint8_t channel, const uint32_t config0, const uint32_t value);
106
107enum i2c_event {
108 I2C_START_RECV,
109 I2C_START_SEND,
110 I2C_START_SEND_ASYNC,
111 I2C_FINISH,
112 I2C_NACK, /* Masker NACKed a receive byte. */
113 I2C_WRITE,
114 I2C_READ
115};
116
117#define QEMU_INTERNAL_STRAP 0
118#define QEMU_INTERNAL_GPIO_IN_SEL 1
119#define QEMU_INTERNAL_GPIO_OUT_SEL 2
120#define QEMU_INTERNAL_IOMUX_GPIOS 3
121#define QEMU_INTERNAL_LEDC_CHANNEL_CONF 4
122#define QEMU_INTERNAL_LEDC_TIMER_FREQ 5
123#define QEMU_INTERNAL_LEDC_CHANNEL_DUTY 6
124#define QEMU_INTERNAL_UART0_BAUD 7
125#define QEMU_INTERNAL_UART1_BAUD 8
126#define QEMU_INTERNAL_UART2_BAUD 9
127
128#define QEMU_EXTRA_PIN_IN_CFG 1
129#define QEMU_EXTRA_PIN_OUT_CFG 2
130#define QEMU_EXTRA_PIN_IOMUX_CFG 4
131#define QEMU_EXTRA_PIN_LEDC_CFG 5
132}
Definition qemu.h:50
Definition qemu.h:97
Definition qemu.h:60