summaryrefslogtreecommitdiffstats
path: root/emulator/avr8emu_private.h
blob: 98ca9010e8348688249c7a098619ab74a0be49c3 (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
#ifndef AVR8EMU_LIBRARY_PRIVATE_H_
#define AVR8EMU_LIBRARY_PRIVATE_H_

#include "util.h"
#include "avr8emu.h"

#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <stdarg.h>


struct avr8emu {
	/* Type of microcontroller we are emulating. */
	enum avr_setup_type type;
	/* Pipes for communication with the worker. */
	int message_to_worker;		/* Result is received in result_from_worker */
	int result_from_worker;		/* Result for message_to_worker */
	int message_from_worker;	/* Has no result pipe */
	/* Pipe for receiving error and status messages from the worker. */
	int error_pipe;
	/* The worker process PID. */
	pid_t worker_pid;
	/* Callbacks to the emulator controller. */
	const struct avr8emu_callbacks *callback;
};

struct avr8emu_worker {
	/* Type of microcontroller we are emulating. */
	enum avr_setup_type type;
	/* Pipes for communication with the host. */
	int message_to_host;	/* Has no result pipe */
	int message_from_host;	/* Result is send through result_to_host */
	int result_to_host;	/* Result for message_from_host */
	/* Pipe for sending error and status messages to the host. */
	int error_pipe;
	/* True, if the microcontroller is initialized. */
	bool initialized;
};

#define AVR8EMU_MAX_MSG_SIZE	(1024 * 8)

/* Message from host to worker. */
enum avr8emu_worker_message {
	WORKERMSG_INIT,
	WORKERMSG_RESET,
};


/* Messaging to the host. (From worker). This is reentrant safe, so it
 * can be called from multiple worker threads. */
enum avr8emu_host_message {
	HOSTMSG_PORTIO,		/* I/O access to an I/O port. */
};

void send_host_message(enum avr8emu_host_message msg,
		       const void *payload, uint32_t payload_len);


#endif /* AVR8EMU_LIBRARY_PRIVATE_H_ */
bues.ch cgit interface