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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
// license:GPL-2.0+
// copyright-holders:Segher Boessenkool,Ryan Holtz
/*****************************************************************************
SunPlus µ'nSP emulator
Copyright 2008-2017 Segher Boessenkool <segher@kernel.crashing.org>
Licensed under the terms of the GNU GPL, version 2
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
Ported to MAME framework by Ryan Holtz
*****************************************************************************/
#ifndef MAME_CPU_UNSP_UNSP_H
#define MAME_CPU_UNSP_UNSP_H
#pragma once
#define UNSP_LOG_OPCODES (0)
enum
{
UNSP_SP = 1,
UNSP_R1,
UNSP_R2,
UNSP_R3,
UNSP_R4,
UNSP_BP,
UNSP_SR,
UNSP_PC,
UNSP_GPR_COUNT = UNSP_PC,
UNSP_IRQ_EN,
UNSP_FIQ_EN,
UNSP_IRQ,
UNSP_FIQ,
#if UNSP_LOG_OPCODES
UNSP_SB,
UNSP_LOG_OPS
#else
UNSP_SB
#endif
};
enum
{
UNSP_FIQ_LINE = 0,
UNSP_IRQ0_LINE,
UNSP_IRQ1_LINE,
UNSP_IRQ2_LINE,
UNSP_IRQ3_LINE,
UNSP_IRQ4_LINE,
UNSP_IRQ5_LINE,
UNSP_IRQ6_LINE,
UNSP_IRQ7_LINE,
UNSP_BRK_LINE,
UNSP_NUM_LINES
};
class unsp_device : public cpu_device
{
public:
// construction/destruction
unsp_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
void set_timer_interval(int timer, uint32_t interval);
uint8_t get_csb();
protected:
// device-level overrides
virtual void device_start() override;
virtual void device_reset() override;
// device_execute_interface overrides
virtual uint32_t execute_min_cycles() const override { return 5; }
virtual uint32_t execute_max_cycles() const override { return 5; }
virtual uint32_t execute_input_lines() const override { return 0; }
virtual void execute_run() override;
virtual void execute_set_input(int inputnum, int state) override;
// device_memory_interface overrides
virtual space_config_vector memory_space_config() const override;
// device_state_interface overrides
virtual void state_import(const device_state_entry &entry) override;
virtual void state_export(const device_state_entry &entry) override;
virtual void state_string_export(const device_state_entry &entry, std::string &str) const override;
// device_disasm_interface overrides
virtual std::unique_ptr<util::disasm_interface> create_disassembler() override;
private:
void add_lpc(const int32_t offset);
inline void execute_one(const uint16_t op);
address_space_config m_program_config;
uint16_t m_r[16];
bool m_enable_irq;
bool m_enable_fiq;
bool m_irq;
bool m_fiq;
uint16_t m_curirq;
uint16_t m_sirq;
uint8_t m_sb;
uint8_t m_saved_sb[3];
address_space *m_program;
int m_icount;
uint32_t m_debugger_temp;
#if UNSP_LOG_OPCODES
uint32_t m_log_ops;
#endif
void unimplemented_opcode(uint16_t op);
inline uint16_t read16(uint32_t address);
inline void write16(uint32_t address, uint16_t data);
inline void update_nz(uint32_t value);
inline void update_sc(uint32_t value, uint16_t r0, uint16_t r1);
inline void push(uint16_t value, uint16_t *reg);
inline uint16_t pop(uint16_t *reg);
inline void trigger_fiq();
inline void trigger_irq(int line);
inline void check_irqs();
};
DECLARE_DEVICE_TYPE(UNSP, unsp_device)
#endif // MAME_CPU_UNSP_UNSP_H
|