summaryrefslogtreecommitdiffstats
path: root/emulator/hardware.h
blob: c5257eb4868c3e4dad4c9da4ff1fc92453d76ab4 (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
#ifndef AVREMU_HARDWARE_H_
#define AVREMU_HARDWARE_H_

#include "util.h"
#include "pinout.h"

#include <stdlib.h>


struct avr_memory;
typedef void (*avr_io_setup_func_t)(struct avr_memory *mem);



/* The type of the microcontroller to emulate. */
enum avr_setup_type {
	AVR_ATMEGA8,
	AVR_ATMEGA168,
	//TODO
	AVR_NR_TYPES,
};

struct avr_setup {
	/* The device type */
	enum avr_setup_type type;
	/* Physical device pinout configuration. */
	const struct avr_device_pinout *pinout;
	/* Size of the memory data space including
	 * the register file, IO, MMIO and SRAM. */
	size_t memory_size;
	/* The offset where the general purpose SRAM starts. */
	size_t sram_offset;
	/* The offset of the stack pointer in the IO space. */
	uint8_t sp_offset;
	/* Using a 22 bit PC */
	bool pc_22bit;
	/* Size of the flash memory. */
	size_t flash_size;
	/* Size of the EEPROM memory. */
	size_t eeprom_size;
	/* Maximum CPU frequency in HZ. */
	size_t max_hz;
	/* Function to setup the virtual->physical IO map
	 * and initialize the peripheral IO devices. */
	avr_io_setup_func_t io_setup;

	/* Pointer to the memory data space (regs, IO, MMIO, SRAM) */
	uint8_t *memory_data;//FIXME this should be moved to struct avr_memory.
};

extern struct avr_setup active_setup;

int avr_do_setup(enum avr_setup_type type);
void avr_do_cleanup(void);


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