arch_avr_device.h Source File

yasimavr: arch_avr_device.h Source File
yasimavr
Loading...
Searching...
No Matches
arch_avr_device.h
Go to the documentation of this file.
1/*
2 * arch_avr_device.h
3 *
4 * Copyright 2021-2025 Clement Savergne <csavergne@yahoo.com>
5
6 This file is part of yasim-avr.
7
8 yasim-avr is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 yasim-avr is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with yasim-avr. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22//=======================================================================================
23
24#ifndef __YASIMAVR_AVR_DEVICE_H__
25#define __YASIMAVR_AVR_DEVICE_H__
26
27#include "arch_avr_globals.h"
28#include "core/sim_core.h"
29#include "core/sim_device.h"
30#include "core/sim_interrupt.h"
31#include "core/sim_types.h"
32#include "core/sim_memory.h"
33
35
36
37//=======================================================================================
38//Variant configuration structure. Nothing to add compared to generic ones
39//so we just use typedef
40
52
57
58
59//=======================================================================================
65
66public:
67
70 NVM_EEPROM = NVM_ArchDefined,
71 NVM_Lockbit = NVM_ArchDefined + 1,
72 };
73
74 explicit ArchAVR_Core(const ArchAVR_CoreConfig& config);
75
76protected:
77
78 virtual uint8_t cpu_read_data(mem_addr_t data_addr) override;
79 virtual void cpu_write_data(mem_addr_t data_addr, uint8_t value) override;
80
81 virtual void dbg_read_data(mem_addr_t start, uint8_t* buf, mem_addr_t len) override;
82 virtual void dbg_write_data(mem_addr_t start, const uint8_t* buf, mem_addr_t len) override;
83
84private:
85
86 NonVolatileMemory m_eeprom;
87 NonVolatileMemory m_lockbit;
88
89friend class ArchAVR_Device;
90
91};
92
93
94//=======================================================================================
99
100public:
101
102 //Definitions for the memory section manager
104 Section_AppRWW = 0,
107 Section_Count
108 };
109
111 Access_RWW = 0x04,
112 Access_IntDisabled = 0x08,
113 };
114
115 explicit ArchAVR_Device(const ArchAVR_DeviceConfig& config);
116 virtual ~ArchAVR_Device();
117
118protected:
119
120 virtual bool core_ctlreq(ctlreq_id_t req, ctlreq_data_t* reqdata) override;
121
123 virtual bool program(const Firmware& firmware) override;
124
125 virtual flash_addr_t reset_vector() override;
126
127private:
128
129 ArchAVR_Core m_core_impl;
130 MemorySectionManager m_sections;
131
132};
133
134
136
137#endif //__YASIMAVR_AVR_DEVICE_H__
DeviceConfiguration ArchAVR_DeviceConfig
Configuration structure for ArchXT_Core.
Definition arch_avr_device.h:56
#define AVR_ARCHAVR_PUBLIC_API
Definition arch_avr_globals.h:46
Implementation of a CPU core for AVR series The main addition is to handle the address mapping in dat...
Definition arch_avr_device.h:64
Implementation of a MCU for AVR series.
Definition arch_avr_device.h:98
FlashSectionFlags
Definition arch_avr_device.h:110
FlashSection
Definition arch_avr_device.h:103
@ Section_AppNRWW
Definition arch_avr_device.h:105
@ Section_Boot
Definition arch_avr_device.h:106
Implementation of a NVM controller for AVR series.
Definition arch_avr_nvm.h:87
AVR core generic model.
Definition sim_core.h:96
virtual uint8_t cpu_read_data(mem_addr_t data_addr)=0
virtual void cpu_write_data(mem_addr_t data_addr, uint8_t value)=0
@ NVM_ArchDefined
Definition sim_core.h:113
virtual void dbg_read_data(mem_addr_t start, uint8_t *buf, mem_addr_t len)=0
virtual void dbg_write_data(mem_addr_t start, const uint8_t *buf, mem_addr_t len)=0
Basic AVR device model.
Definition sim_device.h:61
Definition sim_firmware.h:53
Memory section management.
Definition sim_memory.h:124
Non-volatile memory model.
Definition sim_memory.h:42
int ctlreq_id_t
Definition sim_peripheral.h:111
#define YASIMAVR_BEGIN_NAMESPACE
Definition sim_globals.h:58
#define YASIMAVR_END_NAMESPACE
Definition sim_globals.h:59
unsigned long flash_addr_t
Definition sim_types.h:42
unsigned long mem_addr_t
Definition sim_types.h:41
Definition arch_avr_device.h:41
flash_addr_t flash_page_size
Definition arch_avr_device.h:44
mem_addr_t eepromsize
Definition arch_avr_device.h:43
constexpr flash_addr_t flash_page_count() const
Definition arch_avr_device.h:46
Definition sim_config.h:37
flash_addr_t flashsize
Definition sim_config.h:52
Definition sim_config.h:66
Definition sim_peripheral.h:237