-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathleon3.h
More file actions
58 lines (47 loc) · 1.47 KB
/
leon3.h
File metadata and controls
58 lines (47 loc) · 1.47 KB
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
/*
Reset 后硬件状态:
- PC/NPC 一般指向 TrapTable
- PSR: S=1, ET=0, CWP=0
- WIM
- TBR = 0
软件初始化:
- TrapTable
- TBR (如果允许修改), 但 reset 始终位于 0x0000
- WIM 配置
- 所有全局 / 本地 / SP / Y 寄存器均不确定.
- 实时使 PSR.ET = 1, 否则永不响应.
*/
#pragma once
#include "ucc.h"
#include <filesystem>
namespace fs = std::filesystem;
class Leon3 : public ucc {
public:
enum class Reg : int {
pc = UC_SPARC_REG_PC,
};
enum class CsReg : int {
};
// 实现 irqmp
// irq_ack
// set_pil_in
// irq_manager
// hw_init, machine_init
private:
static constexpr uint64_t RAM_BASE = 0x40000000;
static constexpr size_t RAM_SIZE = 0x100000; // 1 MB
static constexpr uint64_t ROM_BASE = 0x00000000;
static constexpr size_t ROM_SIZE = 0x2000; // 8 KB
// BM3803 片上外设区域 (AHB I/O)
static constexpr uint64_t PERIPH_BASE = 0x80000000;
static constexpr size_t PERIPH_SIZE = 0x2000; // 8 KB
static constexpr uint64_t MMIO_BASE = 0x20000000;
static constexpr size_t MMIO_SIZE = 0x20000000; // 512 MB
void map_memory() {
mem_map(RAM_BASE, RAM_SIZE, UC_PROT_ALL);
mem_map(ROM_BASE, ROM_SIZE, UC_PROT_READ | UC_PROT_EXEC);
mem_map(PERIPH_BASE, PERIPH_SIZE, UC_PROT_ALL);
mem_map(MMIO_BASE, MMIO_SIZE, UC_PROT_ALL);
}
};
void leon3_elf_bootload(Leon3& uc, const fs::path& elf_path);