mirror of
https://github.com/dingusdev/dingusppc.git
synced 2026-12-01 06:23:18 -10:00
Compare commits
155
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e1a0adde8b | ||
|
|
c25ad96e3a | ||
|
|
e63f928a3c | ||
|
|
7b1ea17fb8 | ||
|
|
240ec95a74 | ||
|
|
ee45291533 | ||
|
|
f813aed1ce | ||
|
|
a62954d1a7 | ||
|
|
30582cfb05 | ||
|
|
355738d42b | ||
|
|
749e296796 | ||
|
|
e4d9cb95b4 | ||
|
|
98c7e224fe | ||
|
|
ac0faf78fd | ||
|
|
f08554758b | ||
|
|
b302014ee1 | ||
|
|
210199db1c | ||
|
|
d48eefceb0 | ||
|
|
394fdd00f0 | ||
|
|
78f62c8db8 | ||
|
|
a64b000459 | ||
|
|
1da7cb1c2f | ||
|
|
49b8c4c39f | ||
|
|
bf4ee72c0f | ||
|
|
3124b10eaa | ||
|
|
47969d9d50 | ||
|
|
c0a06a88c7 | ||
|
|
ab5f7071ce | ||
|
|
f42b239713 | ||
|
|
bfc51b8967 | ||
|
|
9c66a56a65 | ||
|
|
cea889bde5 | ||
|
|
78696aa822 | ||
|
|
1f8a76e534 | ||
|
|
d22f926a8a | ||
|
|
1c95619aa4 | ||
|
|
81ebc40158 | ||
|
|
1bf4073fa7 | ||
|
|
ab59a34604 | ||
|
|
31323e7bf1 | ||
|
|
05658ad5c5 | ||
|
|
a593a4a73e | ||
|
|
99972307dc | ||
|
|
d7fb49166f | ||
|
|
0bca7bc743 | ||
|
|
10a3fa5984 | ||
|
|
d98929f24c | ||
|
|
2ab6a94795 | ||
|
|
818f982c75 | ||
|
|
e72b571069 | ||
|
|
2a92ce78f5 | ||
|
|
b512702fbb | ||
|
|
47fca9f4ff | ||
|
|
ee8c912397 | ||
|
|
3fd422008e | ||
|
|
bce4c98475 | ||
|
|
b45b0a8df4 | ||
|
|
b8af8d387c | ||
|
|
84075c5988 | ||
|
|
35919802f3 | ||
|
|
6b3a399015 | ||
|
|
80b763ecc3 | ||
|
|
85d5b10f61 | ||
|
|
5057792d4d | ||
|
|
a1d945a61f | ||
|
|
46425faaa9 | ||
|
|
4479387580 | ||
|
|
f355fb0dfe | ||
|
|
b759f25d87 | ||
|
|
f1e56cd353 | ||
|
|
04899d6528 | ||
|
|
bd7c424989 | ||
|
|
aa17bf06de | ||
|
|
6d2872a07f | ||
|
|
c12561074c | ||
|
|
bf92b04d6c | ||
|
|
7e93d2d169 | ||
|
|
2bb35dc613 | ||
|
|
26aa452c57 | ||
|
|
7a55a81186 | ||
|
|
c9359592d7 | ||
|
|
bf55aa50ce | ||
|
|
564c43c907 | ||
|
|
31bc6f79e5 | ||
|
|
e4c84c5f80 | ||
|
|
2d90aff408 | ||
|
|
820da037da | ||
|
|
00f38133e9 | ||
|
|
e231dc4dec | ||
|
|
549cb2284c | ||
|
|
d41287c320 | ||
|
|
b38b1731a0 | ||
|
|
1d807d10e9 | ||
|
|
08fa2f887d | ||
|
|
04280ecda4 | ||
|
|
f4b5ac2d16 | ||
|
|
c8e2a4d921 | ||
|
|
f6dc704aff | ||
|
|
b3f2a6cf20 | ||
|
|
ad44ce8ce4 | ||
|
|
4b13af6691 | ||
|
|
a941836a4d | ||
|
|
5a0a7b12e4 | ||
|
|
0835e6f9f4 | ||
|
|
d279ada718 | ||
|
|
e1849a2bfd | ||
|
|
362cfcbc83 | ||
|
|
6c093e141b | ||
|
|
aeac232e12 | ||
|
|
0ce96ffc12 | ||
|
|
ef6f2a40c8 | ||
|
|
3fbf0ddaa4 | ||
|
|
6572bf8ce3 | ||
|
|
f27b8ba1be | ||
|
|
f53a7cce32 | ||
|
|
e7eb1c8a66 | ||
|
|
e707d1f27a | ||
|
|
9a2303c495 | ||
|
|
6154b7cbe2 | ||
|
|
ffc7de4715 | ||
|
|
97339e4ce4 | ||
|
|
fc89fec3e6 | ||
|
|
15986a4e4f | ||
|
|
d56520d22a | ||
|
|
42f1871c84 | ||
|
|
f65f9b9845 | ||
|
|
f415a63b76 | ||
|
|
50e661f804 | ||
|
|
7ffafdc007 | ||
|
|
96875a1278 | ||
|
|
6766ca8647 | ||
|
|
fc13f6870b | ||
|
|
27d389c36a | ||
|
|
625e474c03 | ||
|
|
116a65ce77 | ||
|
|
c6116fcc88 | ||
|
|
86ce9b0bb1 | ||
|
|
6ca5b738d5 | ||
|
|
f660efcd54 | ||
|
|
5f826d6a9d | ||
|
|
873f8632e4 | ||
|
|
af7c22e7b3 | ||
|
|
28ec650e4f | ||
|
|
329bcc68b1 | ||
|
|
b3eb1f6419 | ||
|
|
2132922c7b | ||
|
|
9915c15086 | ||
|
|
6df1c7dd9d | ||
|
|
ec9987aab6 | ||
|
|
34e0ba84f1 | ||
|
|
d23f21b391 | ||
|
|
6696248158 | ||
|
|
02c8c8cde0 | ||
|
|
64a5a17df0 | ||
|
|
a649a688e7 |
No files matched your search
+1
-3
@@ -114,8 +114,7 @@ include_directories("${PROJECT_SOURCE_DIR}"
|
||||
platform_glob(SOURCES "${PROJECT_SOURCE_DIR}/*.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/*.c"
|
||||
"${PROJECT_SOURCE_DIR}/*.hpp"
|
||||
"${PROJECT_SOURCE_DIR}/*.h"
|
||||
"${PROJECT_SOURCE_DIR}/*.include")
|
||||
"${PROJECT_SOURCE_DIR}/*.h")
|
||||
|
||||
if (APPLE)
|
||||
platform_glob(APPLE_SOURCES "${PROJECT_SOURCE_DIR}/*.m")
|
||||
@@ -185,7 +184,6 @@ if (DPPC_BUILD_BENCHMARKS)
|
||||
file(GLOB BENCH_SOURCES "${PROJECT_SOURCE_DIR}/benchmark/*.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/cpu/ppc/*.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/cpu/ppc/*.h"
|
||||
"${PROJECT_SOURCE_DIR}/cpu/ppc/*.include"
|
||||
)
|
||||
add_executable(bench1 ${BENCH_SOURCES} $<TARGET_OBJECTS:core>
|
||||
# $<TARGET_OBJECTS:cpu_ppc>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
- maximumspatium
|
||||
- joevt
|
||||
- mihaip
|
||||
- kkaisershot
|
||||
|
||||
## NT4/PPC fork
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ emulation. To build the tests, use the following terminal commands:
|
||||
```
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DPPC_BUILD_PPC_TESTS=True ..
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DDPPC_BUILD_PPC_TESTS=True ..
|
||||
make testppc
|
||||
```
|
||||
|
||||
|
||||
@@ -28,8 +28,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#include <debugger/debugger.h>
|
||||
|
||||
#if defined(PPC_BENCHMARKS)
|
||||
void ppc_exception_handler(Except_Type exception_type, uint32_t srr1_bits) {
|
||||
uint32_t ppc_exception_handler(Except_Type exception_type, uint32_t srr1_bits, uint32_t exec_flags) {
|
||||
power_on = false;
|
||||
power_off_reason = po_benchmark_exception;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -42,7 +44,7 @@ uint32_t cs_code[] = {
|
||||
0x80C30008, 0x7CA50114, 0x80E3000C, 0x7CA53114, 0x85030010, 0x7CA53914,
|
||||
0x4200FFE0, 0x7CA54114, 0x70800002, 0x41E20010, 0xA0030004, 0x38630002,
|
||||
0x7CA50114, 0x70800001, 0x41E20010, 0x88030004, 0x5400402E, 0x7CA50114,
|
||||
0x7C650194, 0x4E800020
|
||||
0x7C650194, /* 0x4E800020 */ 0x00005AF0
|
||||
};
|
||||
|
||||
constexpr uint32_t test_size = 0x8000; // 0x7FFFFFFC is the max
|
||||
@@ -75,7 +77,7 @@ int main(int argc, char** argv) {
|
||||
|
||||
/* load executable code into RAM at address 0 */
|
||||
for (i = 0; i < sizeof(cs_code) / sizeof(cs_code[0]); i++) {
|
||||
mmu_write_vmem<uint32_t>(i * 4, 0, cs_code[i]);
|
||||
mmu_write_vmem<uint32_t>(0, i * 4, cs_code[i]);
|
||||
}
|
||||
|
||||
srand(0xCAFEBABE);
|
||||
@@ -85,7 +87,7 @@ int main(int argc, char** argv) {
|
||||
bool did_lf = false;
|
||||
for (i = 0; i < test_size; i++) {
|
||||
uint8_t val = rand() % 256;
|
||||
mmu_write_vmem<uint8_t>(0x1000 + i, 0, val);
|
||||
mmu_write_vmem<uint8_t>(0, 0x1000+i, val);
|
||||
if (i < 64) {
|
||||
printf("%02x", val);
|
||||
did_lf = false;
|
||||
@@ -104,7 +106,7 @@ int main(int argc, char** argv) {
|
||||
ppc_state.gpr[3] = 0x1000; // buf
|
||||
ppc_state.gpr[4] = test_size; // len
|
||||
ppc_state.gpr[5] = 0; // sum
|
||||
enter_debugger();
|
||||
DppcDebugger::get_instance()->enter_debugger();
|
||||
#endif
|
||||
|
||||
ppc_state.pc = 0;
|
||||
|
||||
@@ -53,6 +53,9 @@ public:
|
||||
|
||||
// Calls all connected slots.
|
||||
void emit(Args... args) {
|
||||
if (!_is_enabled) {
|
||||
return;
|
||||
}
|
||||
for (auto const& it : _slots) {
|
||||
it.second(args...);
|
||||
}
|
||||
@@ -66,9 +69,22 @@ public:
|
||||
_slots.clear();
|
||||
}
|
||||
|
||||
void disable() {
|
||||
_is_enabled = false;
|
||||
}
|
||||
|
||||
void enable() {
|
||||
_is_enabled = true;
|
||||
}
|
||||
|
||||
bool is_enabled() {
|
||||
return _is_enabled;
|
||||
}
|
||||
|
||||
private:
|
||||
mutable std::map<int, std::function<void(Args...)>> _slots;
|
||||
mutable unsigned int _current_id { 0 };
|
||||
mutable bool _is_enabled { true };
|
||||
};
|
||||
|
||||
#endif // CORE_SIGNAL_H
|
||||
@@ -35,11 +35,19 @@ public:
|
||||
uint32_t window_id;
|
||||
};
|
||||
|
||||
enum : uint16_t {
|
||||
// Standard SDL window event types are uint8_t's, we add our own custom
|
||||
// events after that.
|
||||
WINDOW_SCALE_QUALITY_TOGGLE = 1 << 8,
|
||||
};
|
||||
|
||||
enum : uint32_t {
|
||||
MOUSE_EVENT_MOTION = 1 << 0,
|
||||
MOUSE_EVENT_BUTTON = 1 << 1,
|
||||
KEYBOARD_EVENT_DOWN = 1 << 0,
|
||||
KEYBOARD_EVENT_UP = 1 << 1,
|
||||
GAMEPAD_EVENT_DOWN = 1 << 0,
|
||||
GAMEPAD_EVENT_UP = 1 << 1,
|
||||
};
|
||||
|
||||
class MouseEvent {
|
||||
@@ -65,6 +73,36 @@ public:
|
||||
uint16_t keys_state;
|
||||
};
|
||||
|
||||
/* AppleJack bits 3-7 are supported but unused */
|
||||
enum GamepadButton : uint8_t {
|
||||
Red = 14,
|
||||
Green = 15,
|
||||
Yellow = 9,
|
||||
Blue = 8,
|
||||
|
||||
FrontLeft = 0,
|
||||
FrontMiddle = 1,
|
||||
FrontRight = 2,
|
||||
|
||||
LeftTrigger = 17,
|
||||
RightTrigger = 16,
|
||||
|
||||
Up = 10,
|
||||
Down = 13,
|
||||
Left = 11,
|
||||
Right = 12,
|
||||
};
|
||||
|
||||
class GamepadEvent {
|
||||
public:
|
||||
GamepadEvent() = default;
|
||||
~GamepadEvent() = default;
|
||||
|
||||
uint32_t gamepad_id;
|
||||
uint32_t flags;
|
||||
uint8_t button;
|
||||
};
|
||||
|
||||
class EventManager {
|
||||
public:
|
||||
static EventManager* get_instance() {
|
||||
@@ -91,6 +129,11 @@ public:
|
||||
_keyboard_signal.connect_method(inst, func);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void add_gamepad_handler(T* inst, void (T::*func)(const GamepadEvent&)) {
|
||||
_gamepad_signal.connect_method(inst, func);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void add_post_handler(T *inst, void (T::*func)()) {
|
||||
_post_signal.connect_method(inst, func);
|
||||
@@ -103,6 +146,11 @@ public:
|
||||
_post_signal.disconnect_all();
|
||||
}
|
||||
|
||||
void disable_input_handlers() {
|
||||
_mouse_signal.disable();
|
||||
_keyboard_signal.disable();
|
||||
}
|
||||
|
||||
private:
|
||||
static EventManager* event_manager;
|
||||
EventManager() {}; // private constructor to implement a singleton
|
||||
@@ -110,6 +158,7 @@ private:
|
||||
CoreSignal<const WindowEvent&> _window_signal;
|
||||
CoreSignal<const MouseEvent&> _mouse_signal;
|
||||
CoreSignal<const KeyboardEvent&> _keyboard_signal;
|
||||
CoreSignal<const GamepadEvent&> _gamepad_signal;
|
||||
CoreSignal<> _post_signal;
|
||||
|
||||
uint64_t events_captured = 0;
|
||||
|
||||
+58
-2
@@ -54,14 +54,24 @@ void EventManager::poll_events()
|
||||
|
||||
case SDL_KEYDOWN:
|
||||
case SDL_KEYUP: {
|
||||
// Internal shortcuts to trigger mouse grab, intentionally not
|
||||
// sent to the host.
|
||||
// Internal shortcuts, intentionally not sent to the host.
|
||||
// Control-G: mouse grab
|
||||
if (event.key.keysym.sym == SDLK_g && SDL_GetModState() & KMOD_LCTRL) {
|
||||
if (event.type == SDL_KEYUP) {
|
||||
toggle_mouse_grab(event.key);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Control-S: scale quality
|
||||
if (event.key.keysym.sym == SDLK_s && SDL_GetModState() & KMOD_LCTRL) {
|
||||
if (event.type == SDL_KEYUP) {
|
||||
WindowEvent we;
|
||||
we.sub_type = WINDOW_SCALE_QUALITY_TOGGLE;
|
||||
we.window_id = event.window.windowID;
|
||||
this->_window_signal.emit(we);
|
||||
}
|
||||
return;
|
||||
}
|
||||
int key_code = get_sdl_event_key_code(event.key);
|
||||
if (key_code != -1) {
|
||||
KeyboardEvent ke;
|
||||
@@ -130,6 +140,52 @@ void EventManager::poll_events()
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_CONTROLLERBUTTONDOWN: {
|
||||
GamepadEvent ge;
|
||||
switch (event.cbutton.button) {
|
||||
case SDL_CONTROLLER_BUTTON_BACK: ge.button = GamepadButton::FrontLeft; break;
|
||||
case SDL_CONTROLLER_BUTTON_GUIDE: ge.button = GamepadButton::FrontMiddle; break;
|
||||
case SDL_CONTROLLER_BUTTON_START: ge.button = GamepadButton::FrontRight; break;
|
||||
case SDL_CONTROLLER_BUTTON_Y: ge.button = GamepadButton::Blue; break;
|
||||
case SDL_CONTROLLER_BUTTON_X: ge.button = GamepadButton::Yellow; break;
|
||||
case SDL_CONTROLLER_BUTTON_DPAD_UP: ge.button = GamepadButton::Up; break;
|
||||
case SDL_CONTROLLER_BUTTON_DPAD_LEFT: ge.button = GamepadButton::Left; break;
|
||||
case SDL_CONTROLLER_BUTTON_DPAD_RIGHT: ge.button = GamepadButton::Right; break;
|
||||
case SDL_CONTROLLER_BUTTON_DPAD_DOWN: ge.button = GamepadButton::Down; break;
|
||||
case SDL_CONTROLLER_BUTTON_A: ge.button = GamepadButton::Red; break;
|
||||
case SDL_CONTROLLER_BUTTON_B: ge.button = GamepadButton::Green; break;
|
||||
case SDL_CONTROLLER_BUTTON_RIGHTSHOULDER: ge.button = GamepadButton::RightTrigger; break;
|
||||
case SDL_CONTROLLER_BUTTON_LEFTSHOULDER: ge.button = GamepadButton::LeftTrigger; break;
|
||||
}
|
||||
ge.gamepad_id = event.cbutton.which;
|
||||
ge.flags = GAMEPAD_EVENT_DOWN;
|
||||
this->_gamepad_signal.emit(ge);
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_CONTROLLERBUTTONUP: {
|
||||
GamepadEvent ge;
|
||||
switch (event.cbutton.button) {
|
||||
case SDL_CONTROLLER_BUTTON_BACK: ge.button = GamepadButton::FrontLeft; break;
|
||||
case SDL_CONTROLLER_BUTTON_GUIDE: ge.button = GamepadButton::FrontMiddle; break;
|
||||
case SDL_CONTROLLER_BUTTON_START: ge.button = GamepadButton::FrontRight; break;
|
||||
case SDL_CONTROLLER_BUTTON_Y: ge.button = GamepadButton::Blue; break;
|
||||
case SDL_CONTROLLER_BUTTON_X: ge.button = GamepadButton::Yellow; break;
|
||||
case SDL_CONTROLLER_BUTTON_DPAD_UP: ge.button = GamepadButton::Up; break;
|
||||
case SDL_CONTROLLER_BUTTON_DPAD_LEFT: ge.button = GamepadButton::Left; break;
|
||||
case SDL_CONTROLLER_BUTTON_DPAD_RIGHT: ge.button = GamepadButton::Right; break;
|
||||
case SDL_CONTROLLER_BUTTON_DPAD_DOWN: ge.button = GamepadButton::Down; break;
|
||||
case SDL_CONTROLLER_BUTTON_A: ge.button = GamepadButton::Red; break;
|
||||
case SDL_CONTROLLER_BUTTON_B: ge.button = GamepadButton::Green; break;
|
||||
case SDL_CONTROLLER_BUTTON_RIGHTSHOULDER: ge.button = GamepadButton::RightTrigger; break;
|
||||
case SDL_CONTROLLER_BUTTON_LEFTSHOULDER: ge.button = GamepadButton::LeftTrigger; break;
|
||||
}
|
||||
ge.gamepad_id = event.cbutton.which;
|
||||
ge.flags = GAMEPAD_EVENT_UP;
|
||||
this->_gamepad_signal.emit(ge);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
unhandled_events++;
|
||||
}
|
||||
|
||||
+6
-8
@@ -31,8 +31,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#include <vector>
|
||||
#include <mutex>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define NS_PER_SEC 1000000000
|
||||
#define USEC_PER_SEC 1000000
|
||||
#define NS_PER_USEC 1000
|
||||
@@ -42,7 +40,7 @@ using namespace std;
|
||||
#define USECS_TO_NSECS(us) (us) * NS_PER_USEC
|
||||
#define MSECS_TO_NSECS(ms) (ms) * NS_PER_MSEC
|
||||
|
||||
typedef function<void()> timer_cb;
|
||||
typedef std::function<void()> timer_cb;
|
||||
|
||||
/** Extend std::priority_queue as suggested here:
|
||||
https://stackoverflow.com/a/36711682
|
||||
@@ -101,7 +99,7 @@ typedef struct TimerInfo {
|
||||
// Custom comparator for sorting our timer queue in ascending order
|
||||
class MyGtComparator {
|
||||
public:
|
||||
bool operator()(const shared_ptr<TimerInfo>& l, const shared_ptr<TimerInfo>& r) {
|
||||
bool operator()(const std::shared_ptr<TimerInfo>& l, const std::shared_ptr<TimerInfo>& r) {
|
||||
return l.get()->timeout_ns > r.get()->timeout_ns;
|
||||
}
|
||||
};
|
||||
@@ -116,7 +114,7 @@ public:
|
||||
};
|
||||
|
||||
// callback for retrieving current time
|
||||
void set_time_now_cb(const function<uint64_t()> &cb) {
|
||||
void set_time_now_cb(const std::function<uint64_t()> &cb) {
|
||||
this->get_time_now = cb;
|
||||
};
|
||||
|
||||
@@ -142,10 +140,10 @@ private:
|
||||
TimerManager(){}; // private constructor to implement a singleton
|
||||
|
||||
// timer queue
|
||||
my_priority_queue<shared_ptr<TimerInfo>, vector<shared_ptr<TimerInfo>>, MyGtComparator> timer_queue;
|
||||
my_priority_queue<std::shared_ptr<TimerInfo>, std::vector<std::shared_ptr<TimerInfo>>, MyGtComparator> timer_queue;
|
||||
|
||||
function<uint64_t()> get_time_now;
|
||||
function<void()> notify_timer_changes;
|
||||
std::function<uint64_t()> get_time_now;
|
||||
std::function<void()> notify_timer_changes;
|
||||
|
||||
std::atomic<uint32_t> id{0};
|
||||
bool cb_active = false; // true if a timer callback is executing // FIXME: Do we need this? It gets written in main thread and read in audio thread.
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
|
||||
// such as names of functions and macros.
|
||||
// For more information see https://go.microsoft.com/fwlink/?linkid=865984
|
||||
#define OPCODEREC(op, __VA_ARGS__) template <field_rc rec> void dppc_interpreter::ppc_##op(uint32_t instr) { __VA_ARGS__ }
|
||||
#define OPCODESHIFT(op, __VA_ARGS__) template <field_shift shift> void dppc_interpreter::ppc_##op(uint32_t instr) { __VA_ARGS__ }
|
||||
#define OPCODEOVREC(op, __VA_ARGS__) template <field_rc rec, field_ov ov> void dppc_interpreter::ppc_##op(uint32_t instr) { __VA_ARGS__ }
|
||||
#define OPCODE(op, __VA_ARGS__) void dppc_interpreter::ppc_##op(uint32_t instr) {##__VA_ARGS__ }
|
||||
#define OPCODECARRY(op, __VA_ARGS__) template <field_carry carry, field_rc rec, field_ov ov> void dppc_interpreter::ppc_##op(uint32_t instr) { __VA_ARGS__ }
|
||||
#define POWEROPCODEREC(op, __VA_ARGS__) template <field_rc rec> void dppc_interpreter::power_##op(uint32_t instr) { __VA_ARGS__ }
|
||||
#define POWEROPCODEOVREC(op, __VA_ARGS__) template <field_rc rec, field_ov ov> void dppc_interpreter::power_##op(uint32_t instr) { __VA_ARGS__ }
|
||||
#define OPCODELOGIC(op, __VA_ARGS__) template <logical_fun logical_op, field_rc rec> void dppc_interpreter::ppc_##op(uint32_t instr) { __VA_ARGS__ }
|
||||
#define OPCODELKAA(op, __VA_ARGS__) template <field_lk l, field_aa a> void dppc_interpreter::ppc_##op(uint32_t instr) { __VA_ARGS__ }
|
||||
#define OPCODE601L(op, __VA_ARGS__) template <field_lk l, field_601 for601, field_rc rec> void dppc_interpreter::ppc_##op(uint32_t instr) { __VA_ARGS__ }
|
||||
#define POWEROPCODE(op, __VA_ARGS__) void dppc_interpreter::power_##op(uint32_t instr) {##__VA_ARGS__ }
|
||||
#define OPCODEMEM(op, __VA_ARGS__) template <class T> void dppc_interpreter::ppc_##op(uint32_t instr) { __VA_ARGS__ }
|
||||
#define OPCODESHIFTREC(op, __VA_ARGS__) template <field_direction isleft, field_rc rec > void dppc_interpreter::ppc_##op(uint32_t instr) { __VA_ARGS__ }
|
||||
#define OPCODE601REC(op, __VA_ARGS__) template <field_601 for601, field_rc rec> void dppc_interpreter::ppc_##op(uint32_t instr) { __VA_ARGS__ }
|
||||
#define OPCODEEXTSIGN(op, __VA_ARGS__) template <class T, field_rc rec> void dppc_interpreter::ppc_##op(uint32_t instr) { __VA_ARGS__ }
|
||||
#define ppc_store_iresult_reg(reg, ppc_result) ppc_state.gpr[reg] = ppc_result
|
||||
#define ppc_set_xer(entry) ppc_state.spr[SPR::XER] |= entry#define OPCODEL(op, __VA_ARGS__) template <field_lk l> void dppc_interpreter::ppc_##op(uint32_t instr) { __VA_ARGS__ } template void dppc_interpreter::ppc_##op<LK0>(uint32_t instr); template void dppc_interpreter::ppc_##op<LK1>(uint32_t instr);
|
||||
#define OPCODEL(op, __VA_ARGS__) template <field_lk l> void dppc_interpreter::ppc_##op(uint32_t instr)
|
||||
@@ -3,7 +3,12 @@ include_directories("${PROJECT_SOURCE_DIR}"
|
||||
|
||||
file(GLOB SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/*.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/*.include"
|
||||
)
|
||||
|
||||
# The use of volatile is deprecated, but we still need it to avoid function
|
||||
# parameters being clobbered when using setjmp/longjmp.
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
add_compile_options(-Wno-deprecated-volatile)
|
||||
endif()
|
||||
|
||||
add_library(cpu_ppc OBJECT ${SOURCES})
|
||||
+667
-3
@@ -23,7 +23,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// Any shared opcodes are in ppcopcodes.cpp
|
||||
|
||||
#include "ppcemu.h"
|
||||
#include "ppcdecodemacros.h"
|
||||
#include "ppcmacros.h"
|
||||
#include "ppcmmu.h"
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -34,5 +34,669 @@ static inline uint32_t power_rot_mask(unsigned rot_mb, unsigned rot_me) {
|
||||
return ((rot_mb <= rot_me) ? m2 & m1 : m1 | m2);
|
||||
}
|
||||
|
||||
#include "ppcopmacros.h"
|
||||
#include "poweropcodes.include"
|
||||
template <field_rc rec, field_ov ov>
|
||||
uint32_t dppc_interpreter::power_abs(uint32_t opcode) {
|
||||
uint32_t ppc_result_d;
|
||||
ppc_grab_regsda(opcode);
|
||||
if (ppc_result_a == 0x80000000) {
|
||||
ppc_result_d = ppc_result_a;
|
||||
if (ov)
|
||||
ppc_state.spr[SPR::XER] |= XER::SO | XER::OV;
|
||||
} else {
|
||||
ppc_result_d = (int32_t(ppc_result_a) < 0) ? -ppc_result_a : ppc_result_a;
|
||||
if (ov)
|
||||
ppc_state.spr[SPR::XER] &= ~XER::OV;
|
||||
}
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_d);
|
||||
|
||||
ppc_store_iresult_reg(reg_d, ppc_result_d);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template uint32_t dppc_interpreter::power_abs<RC0, OV0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_abs<RC0, OV1>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_abs<RC1, OV0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_abs<RC1, OV1>(uint32_t opcode);
|
||||
|
||||
uint32_t dppc_interpreter::power_clcs(uint32_t opcode) {
|
||||
uint32_t ppc_result_d;
|
||||
ppc_grab_da(opcode);
|
||||
switch (reg_a & 15) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 0xC: //instruction cache line size
|
||||
case 0xD: //data cache line size
|
||||
case 0xE: //minimum line size
|
||||
case 0xF: //maximum line size
|
||||
ppc_result_d = is_601 ? 0x40 : 0x20; break;
|
||||
case 4:
|
||||
case 5:
|
||||
case 6: ppc_result_d = 0x20; break;
|
||||
case 7: ppc_result_d = is_601 ? 1 : 0; break;
|
||||
case 8:
|
||||
case 9: ppc_result_d = is_601 ? 8 : 4; break;
|
||||
case 0xA:
|
||||
case 0xB: ppc_result_d = is_601 ? 0x8000 : 0x4000; break;
|
||||
}
|
||||
|
||||
ppc_store_iresult_reg(reg_d, ppc_result_d);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <field_rc rec, field_ov ov>
|
||||
uint32_t dppc_interpreter::power_div(uint32_t opcode) {
|
||||
uint32_t ppc_result_d;
|
||||
ppc_grab_regsdab(opcode);
|
||||
|
||||
int64_t dividend = (uint64_t(ppc_result_a) << 32) | ppc_state.spr[SPR::MQ];
|
||||
int32_t divisor = ppc_result_b;
|
||||
int64_t quotient;
|
||||
int32_t remainder;
|
||||
|
||||
if (dividend == -0x80000000 && divisor == -1) {
|
||||
remainder = 0;
|
||||
ppc_result_d = 0x80000000U; // -2^31 aka INT32_MIN
|
||||
if (ov)
|
||||
ppc_state.spr[SPR::XER] |= XER::SO | XER::OV;
|
||||
} else if (!divisor) {
|
||||
remainder = 0;
|
||||
ppc_result_d = 0x80000000U; // -2^31 aka INT32_MIN
|
||||
if (ov)
|
||||
ppc_state.spr[SPR::XER] |= XER::SO | XER::OV;
|
||||
} else {
|
||||
quotient = dividend / divisor;
|
||||
remainder = dividend % divisor;
|
||||
ppc_result_d = uint32_t(quotient);
|
||||
if (ov) {
|
||||
if (((quotient >> 31) + 1) & ~1) {
|
||||
ppc_state.spr[SPR::XER] |= XER::SO | XER::OV;
|
||||
} else {
|
||||
ppc_state.spr[SPR::XER] &= ~XER::OV;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(remainder);
|
||||
|
||||
ppc_store_iresult_reg(reg_d, ppc_result_d);
|
||||
ppc_state.spr[SPR::MQ] = remainder;
|
||||
return 0;
|
||||
}
|
||||
|
||||
template uint32_t dppc_interpreter::power_div<RC0, OV0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_div<RC0, OV1>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_div<RC1, OV0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_div<RC1, OV1>(uint32_t opcode);
|
||||
|
||||
template <field_rc rec, field_ov ov>
|
||||
uint32_t dppc_interpreter::power_divs(uint32_t opcode) {
|
||||
uint32_t ppc_result_d;
|
||||
int32_t remainder;
|
||||
ppc_grab_regsdab(opcode);
|
||||
|
||||
if (!ppc_result_b) { // handle the "anything / 0" case
|
||||
ppc_result_d = -1;
|
||||
remainder = ppc_result_a;
|
||||
if (ov)
|
||||
ppc_state.spr[SPR::XER] |= XER::SO | XER::OV;
|
||||
} else if (ppc_result_a == 0x80000000U && ppc_result_b == 0xFFFFFFFFU) {
|
||||
ppc_result_d = 0x80000000U;
|
||||
remainder = 0;
|
||||
if (ov)
|
||||
ppc_state.spr[SPR::XER] |= XER::SO | XER::OV;
|
||||
} else { // normal signed devision
|
||||
ppc_result_d = int32_t(ppc_result_a) / int32_t(ppc_result_b);
|
||||
remainder = (int32_t(ppc_result_a) % int32_t(ppc_result_b));
|
||||
if (ov)
|
||||
ppc_state.spr[SPR::XER] &= ~XER::OV;
|
||||
}
|
||||
if (rec)
|
||||
ppc_changecrf0(remainder);
|
||||
|
||||
ppc_store_iresult_reg(reg_d, ppc_result_d);
|
||||
ppc_state.spr[SPR::MQ] = remainder;
|
||||
return 0;
|
||||
}
|
||||
|
||||
template uint32_t dppc_interpreter::power_divs<RC0, OV0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_divs<RC0, OV1>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_divs<RC1, OV0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_divs<RC1, OV1>(uint32_t opcode);
|
||||
|
||||
template <field_rc rec, field_ov ov>
|
||||
uint32_t dppc_interpreter::power_doz(uint32_t opcode) {
|
||||
ppc_grab_regsdab(opcode);
|
||||
uint32_t ppc_result_d = (int32_t(ppc_result_a) < int32_t(ppc_result_b)) ?
|
||||
ppc_result_b - ppc_result_a : 0;
|
||||
|
||||
if (ov) {
|
||||
if (int32_t(ppc_result_d) < 0) {
|
||||
ppc_state.spr[SPR::XER] |= XER::SO | XER::OV;
|
||||
} else {
|
||||
ppc_state.spr[SPR::XER] &= ~XER::OV;
|
||||
}
|
||||
}
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_d);
|
||||
|
||||
ppc_store_iresult_reg(reg_d, ppc_result_d);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template uint32_t dppc_interpreter::power_doz<RC0, OV0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_doz<RC0, OV1>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_doz<RC1, OV0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_doz<RC1, OV1>(uint32_t opcode);
|
||||
|
||||
uint32_t dppc_interpreter::power_dozi(uint32_t opcode) {
|
||||
uint32_t ppc_result_d;
|
||||
ppc_grab_regsdasimm(opcode);
|
||||
if (((int32_t)ppc_result_a) > simm) {
|
||||
ppc_result_d = 0;
|
||||
} else {
|
||||
ppc_result_d = simm - ppc_result_a;
|
||||
}
|
||||
ppc_store_iresult_reg(reg_d, ppc_result_d);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <field_rc rec>
|
||||
uint32_t dppc_interpreter::power_lscbx(uint32_t opcode) {
|
||||
ppc_grab_regsdab(opcode);
|
||||
uint32_t ea = ppc_result_b + (reg_a ? ppc_result_a : 0);
|
||||
|
||||
uint32_t bytes_to_load = (ppc_state.spr[SPR::XER] & 0x7F);
|
||||
uint32_t bytes_remaining = bytes_to_load;
|
||||
uint8_t matching_byte = (uint8_t)(ppc_state.spr[SPR::XER] >> 8);
|
||||
uint32_t ppc_result_d = 0;
|
||||
bool is_match = false;
|
||||
|
||||
// for storing each byte
|
||||
uint8_t shift_amount = 24;
|
||||
|
||||
while (bytes_remaining > 0) {
|
||||
uint8_t return_value = mmu_read_vmem<uint8_t>(opcode, ea);
|
||||
|
||||
ppc_result_d |= return_value << shift_amount;
|
||||
if (!shift_amount) {
|
||||
if (reg_d != reg_a && reg_d != reg_b)
|
||||
ppc_store_iresult_reg(reg_d, ppc_result_d);
|
||||
reg_d = (reg_d + 1) & 0x1F;
|
||||
ppc_result_d = 0;
|
||||
shift_amount = 24;
|
||||
} else {
|
||||
shift_amount -= 8;
|
||||
}
|
||||
|
||||
ea++;
|
||||
bytes_remaining--;
|
||||
|
||||
if (return_value == matching_byte) {
|
||||
is_match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// store partially loaded register if any
|
||||
if (shift_amount != 24 && reg_d != reg_a && reg_d != reg_b)
|
||||
ppc_store_iresult_reg(reg_d, ppc_result_d);
|
||||
|
||||
ppc_state.spr[SPR::XER] = (ppc_state.spr[SPR::XER] & ~0x7F) | (bytes_to_load - bytes_remaining);
|
||||
|
||||
if (rec) {
|
||||
ppc_state.cr =
|
||||
(ppc_state.cr & 0x0FFFFFFFUL) |
|
||||
(is_match ? CRx_bit::CR_EQ : 0) |
|
||||
((ppc_state.spr[SPR::XER] & XER::SO) >> 3);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
template uint32_t dppc_interpreter::power_lscbx<RC0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_lscbx<RC1>(uint32_t opcode);
|
||||
|
||||
template <field_rc rec>
|
||||
uint32_t dppc_interpreter::power_maskg(uint32_t opcode) {
|
||||
ppc_grab_regssab(opcode);
|
||||
uint32_t mask_start = ppc_result_d & 0x1F;
|
||||
uint32_t mask_end = ppc_result_b & 0x1F;
|
||||
uint32_t insert_mask = 0;
|
||||
|
||||
if (mask_start < (mask_end + 1)) {
|
||||
insert_mask = power_rot_mask(mask_start, mask_end);
|
||||
}
|
||||
else if (mask_start == (mask_end + 1)) {
|
||||
insert_mask = 0xFFFFFFFF;
|
||||
}
|
||||
else {
|
||||
insert_mask = ~(power_rot_mask(mask_end + 1, mask_start - 1));
|
||||
}
|
||||
|
||||
ppc_result_a = insert_mask;
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template uint32_t dppc_interpreter::power_maskg<RC0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_maskg<RC1>(uint32_t opcode);
|
||||
|
||||
template <field_rc rec>
|
||||
uint32_t dppc_interpreter::power_maskir(uint32_t opcode) {
|
||||
ppc_grab_regssab(opcode);
|
||||
ppc_result_a = (ppc_result_a & ~ppc_result_b) | (ppc_result_d & ppc_result_b);
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template uint32_t dppc_interpreter::power_maskir<RC0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_maskir<RC1>(uint32_t opcode);
|
||||
|
||||
template <field_rc rec, field_ov ov>
|
||||
uint32_t dppc_interpreter::power_mul(uint32_t opcode) {
|
||||
ppc_grab_regsdab(opcode);
|
||||
int64_t product = int64_t(int32_t(ppc_result_a)) * int32_t(ppc_result_b);
|
||||
uint32_t ppc_result_d = uint32_t(uint64_t(product) >> 32);
|
||||
ppc_state.spr[SPR::MQ] = uint32_t(product);
|
||||
|
||||
if (ov) {
|
||||
if (uint64_t(product >> 31) + 1 & ~1) {
|
||||
ppc_state.spr[SPR::XER] |= XER::SO | XER::OV;
|
||||
} else {
|
||||
ppc_state.spr[SPR::XER] &= ~XER::OV;
|
||||
}
|
||||
}
|
||||
if (rec)
|
||||
ppc_changecrf0(uint32_t(product));
|
||||
|
||||
ppc_store_iresult_reg(reg_d, ppc_result_d);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template uint32_t dppc_interpreter::power_mul<RC0, OV0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_mul<RC0, OV1>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_mul<RC1, OV0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_mul<RC1, OV1>(uint32_t opcode);
|
||||
|
||||
template <field_rc rec, field_ov ov>
|
||||
uint32_t dppc_interpreter::power_nabs(uint32_t opcode) {
|
||||
ppc_grab_regsda(opcode);
|
||||
uint32_t ppc_result_d = (int32_t(ppc_result_a) < 0) ? ppc_result_a : -ppc_result_a;
|
||||
|
||||
if (ov)
|
||||
ppc_state.spr[SPR::XER] &= ~XER::OV;
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_d);
|
||||
|
||||
ppc_store_iresult_reg(reg_d, ppc_result_d);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template uint32_t dppc_interpreter::power_nabs<RC0, OV0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_nabs<RC0, OV1>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_nabs<RC1, OV0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_nabs<RC1, OV1>(uint32_t opcode);
|
||||
|
||||
uint32_t dppc_interpreter::power_rlmi(uint32_t opcode) {
|
||||
ppc_grab_regssab(opcode);
|
||||
unsigned rot_mb = (opcode >> 6) & 0x1F;
|
||||
unsigned rot_me = (opcode >> 1) & 0x1F;
|
||||
unsigned rot_sh = ppc_result_b & 0x1F;
|
||||
|
||||
uint32_t r = rot_sh ? ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh))) : ppc_result_d;
|
||||
uint32_t mask = power_rot_mask(rot_mb, rot_me);
|
||||
|
||||
ppc_result_a = ((r & mask) | (ppc_result_a & ~mask));
|
||||
|
||||
if ((opcode & 0x01) == 1)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <field_rc rec>
|
||||
uint32_t dppc_interpreter::power_rrib(uint32_t opcode) {
|
||||
ppc_grab_regssab(opcode);
|
||||
unsigned rot_sh = ppc_result_b & 0x1F;
|
||||
|
||||
if (int32_t(ppc_result_d) < 0) {
|
||||
ppc_result_a |= (0x80000000U >> rot_sh);
|
||||
} else {
|
||||
ppc_result_a &= ~(0x80000000U >> rot_sh);
|
||||
}
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template uint32_t dppc_interpreter::power_rrib<RC0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_rrib<RC1>(uint32_t opcode);
|
||||
|
||||
template <field_rc rec>
|
||||
uint32_t dppc_interpreter::power_sle(uint32_t opcode) {
|
||||
ppc_grab_regssab(opcode);
|
||||
unsigned rot_sh = ppc_result_b & 0x1F;
|
||||
|
||||
ppc_result_a = ppc_result_d << rot_sh;
|
||||
ppc_state.spr[SPR::MQ] = rot_sh ? ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh))) : ppc_result_d;
|
||||
|
||||
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template uint32_t dppc_interpreter::power_sle<RC0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_sle<RC1>(uint32_t opcode);
|
||||
|
||||
template <field_rc rec>
|
||||
uint32_t dppc_interpreter::power_sleq(uint32_t opcode) {
|
||||
ppc_grab_regssab(opcode);
|
||||
unsigned rot_sh = ppc_result_b & 0x1F;
|
||||
uint32_t r = rot_sh ? ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh))) : ppc_result_d;
|
||||
uint32_t mask = power_rot_mask(0, 31 - rot_sh);
|
||||
|
||||
ppc_result_a = ((r & mask) | (ppc_state.spr[SPR::MQ] & ~mask));
|
||||
ppc_state.spr[SPR::MQ] = r;
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template uint32_t dppc_interpreter::power_sleq<RC0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_sleq<RC1>(uint32_t opcode);
|
||||
|
||||
template <field_rc rec>
|
||||
uint32_t dppc_interpreter::power_sliq(uint32_t opcode) {
|
||||
ppc_grab_regssash(opcode);
|
||||
|
||||
ppc_result_a = ppc_result_d << rot_sh;
|
||||
ppc_state.spr[SPR::MQ] = rot_sh ? ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh))) : ppc_result_d;
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template uint32_t dppc_interpreter::power_sliq<RC0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_sliq<RC1>(uint32_t opcode);
|
||||
|
||||
template <field_rc rec>
|
||||
uint32_t dppc_interpreter::power_slliq(uint32_t opcode) {
|
||||
ppc_grab_regssash(opcode);
|
||||
uint32_t r = rot_sh ? ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh))) : ppc_result_d;
|
||||
uint32_t mask = power_rot_mask(0, 31 - rot_sh);
|
||||
|
||||
ppc_result_a = ((r & mask) | (ppc_state.spr[SPR::MQ] & ~mask));
|
||||
ppc_state.spr[SPR::MQ] = r;
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template uint32_t dppc_interpreter::power_slliq<RC0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_slliq<RC1>(uint32_t opcode);
|
||||
|
||||
template <field_rc rec>
|
||||
uint32_t dppc_interpreter::power_sllq(uint32_t opcode) {
|
||||
ppc_grab_regssab(opcode);
|
||||
unsigned rot_sh = ppc_result_b & 0x1F;
|
||||
|
||||
if (ppc_result_b & 0x20) {
|
||||
ppc_result_a = ppc_state.spr[SPR::MQ] & (-1U << rot_sh);
|
||||
} else {
|
||||
ppc_result_a = ((ppc_result_d << rot_sh) | (ppc_state.spr[SPR::MQ] & ((1U << rot_sh) - 1)));
|
||||
}
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template uint32_t dppc_interpreter::power_sllq<RC0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_sllq<RC1>(uint32_t opcode);
|
||||
|
||||
template <field_rc rec>
|
||||
uint32_t dppc_interpreter::power_slq(uint32_t opcode) {
|
||||
ppc_grab_regssab(opcode);
|
||||
unsigned rot_sh = ppc_result_b & 0x1F;
|
||||
|
||||
if (ppc_result_b & 0x20) {
|
||||
ppc_result_a = 0;
|
||||
} else {
|
||||
ppc_result_a = ppc_result_d << rot_sh;
|
||||
}
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_state.spr[SPR::MQ] = rot_sh ? ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh))) : ppc_result_d;
|
||||
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template uint32_t dppc_interpreter::power_slq<RC0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_slq<RC1>(uint32_t opcode);
|
||||
|
||||
template <field_rc rec>
|
||||
uint32_t dppc_interpreter::power_sraiq(uint32_t opcode) {
|
||||
ppc_grab_regssash(opcode);
|
||||
uint32_t mask = (1U << rot_sh) - 1;
|
||||
ppc_result_a = (int32_t)ppc_result_d >> rot_sh;
|
||||
ppc_state.spr[SPR::MQ] = rot_sh ? ((ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh))) : ppc_result_d;
|
||||
|
||||
if ((int32_t(ppc_result_d) < 0) && (ppc_result_d & mask)) {
|
||||
ppc_state.spr[SPR::XER] |= XER::CA;
|
||||
} else {
|
||||
ppc_state.spr[SPR::XER] &= ~XER::CA;
|
||||
}
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template uint32_t dppc_interpreter::power_sraiq<RC0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_sraiq<RC1>(uint32_t opcode);
|
||||
|
||||
template <field_rc rec>
|
||||
uint32_t dppc_interpreter::power_sraq(uint32_t opcode) {
|
||||
ppc_grab_regssab(opcode);
|
||||
unsigned rot_sh = ppc_result_b & 0x1F;
|
||||
uint32_t mask = (ppc_result_b & 0x20) ? -1 : (1U << rot_sh) - 1;
|
||||
ppc_result_a = (int32_t)ppc_result_d >> ((ppc_result_b & 0x20) ? 31 : rot_sh);
|
||||
ppc_state.spr[SPR::MQ] = rot_sh ? ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh))) : ppc_result_d;
|
||||
|
||||
if ((int32_t(ppc_result_d) < 0) && (ppc_result_d & mask)) {
|
||||
ppc_state.spr[SPR::XER] |= XER::CA;
|
||||
} else {
|
||||
ppc_state.spr[SPR::XER] &= ~XER::CA;
|
||||
}
|
||||
|
||||
ppc_state.spr[SPR::MQ] = rot_sh ? ((ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh))) : ppc_result_d;
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template uint32_t dppc_interpreter::power_sraq<RC0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_sraq<RC1>(uint32_t opcode);
|
||||
|
||||
template <field_rc rec>
|
||||
uint32_t dppc_interpreter::power_sre(uint32_t opcode) {
|
||||
ppc_grab_regssab(opcode);
|
||||
|
||||
unsigned rot_sh = ppc_result_b & 0x1F;
|
||||
ppc_result_a = ppc_result_d >> rot_sh;
|
||||
|
||||
ppc_state.spr[SPR::MQ] = rot_sh ? ((ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh))) : ppc_result_d;
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template uint32_t dppc_interpreter::power_sre<RC0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_sre<RC1>(uint32_t opcode);
|
||||
|
||||
template <field_rc rec>
|
||||
uint32_t dppc_interpreter::power_srea(uint32_t opcode) {
|
||||
ppc_grab_regssab(opcode);
|
||||
unsigned rot_sh = ppc_result_b & 0x1F;
|
||||
ppc_result_a = (int32_t)ppc_result_d >> rot_sh;
|
||||
uint32_t r = (rot_sh ? ((ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh))) : ppc_result_d);
|
||||
uint32_t mask = -1U >> rot_sh;
|
||||
|
||||
if ((int32_t(ppc_result_d) < 0) && (r & ~mask)) {
|
||||
ppc_state.spr[SPR::XER] |= XER::CA;
|
||||
} else {
|
||||
ppc_state.spr[SPR::XER] &= ~XER::CA;
|
||||
}
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
||||
ppc_state.spr[SPR::MQ] = r;
|
||||
return 0;
|
||||
}
|
||||
|
||||
template uint32_t dppc_interpreter::power_srea<RC0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_srea<RC1>(uint32_t opcode);
|
||||
|
||||
template <field_rc rec>
|
||||
uint32_t dppc_interpreter::power_sreq(uint32_t opcode) {
|
||||
ppc_grab_regssab(opcode);
|
||||
unsigned rot_sh = ppc_result_b & 0x1F;
|
||||
uint32_t mask = -1U >> rot_sh;
|
||||
|
||||
ppc_result_a = (ppc_result_d >> rot_sh) | (ppc_state.spr[SPR::MQ] & ~mask);
|
||||
ppc_state.spr[SPR::MQ] = rot_sh ? ((ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh))) : ppc_result_d;
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template uint32_t dppc_interpreter::power_sreq<RC0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_sreq<RC1>(uint32_t opcode);
|
||||
|
||||
template <field_rc rec>
|
||||
uint32_t dppc_interpreter::power_sriq(uint32_t opcode) {
|
||||
ppc_grab_regssash(opcode);
|
||||
ppc_result_a = ppc_result_d >> rot_sh;
|
||||
ppc_state.spr[SPR::MQ] = rot_sh ? ((ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh))) : ppc_result_d;
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template uint32_t dppc_interpreter::power_sriq<RC0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_sriq<RC1>(uint32_t opcode);
|
||||
|
||||
template <field_rc rec>
|
||||
uint32_t dppc_interpreter::power_srliq(uint32_t opcode) {
|
||||
ppc_grab_regssash(opcode);
|
||||
uint32_t r = rot_sh ? ((ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh))) : ppc_result_d;
|
||||
unsigned mask = power_rot_mask(rot_sh, 31);
|
||||
|
||||
ppc_result_a = ((r & mask) | (ppc_state.spr[SPR::MQ] & ~mask));
|
||||
ppc_state.spr[SPR::MQ] = r;
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template uint32_t dppc_interpreter::power_srliq<RC0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_srliq<RC1>(uint32_t opcode);
|
||||
|
||||
template <field_rc rec>
|
||||
uint32_t dppc_interpreter::power_srlq(uint32_t opcode) {
|
||||
ppc_grab_regssab(opcode);
|
||||
unsigned rot_sh = ppc_result_b & 0x1F;
|
||||
uint32_t r = rot_sh ? ((ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh))) : ppc_result_d;
|
||||
unsigned mask = power_rot_mask(rot_sh, 31);
|
||||
|
||||
if (ppc_result_b & 0x20) {
|
||||
ppc_result_a = (ppc_state.spr[SPR::MQ] & mask);
|
||||
} else {
|
||||
ppc_result_a = ((r & mask) | (ppc_state.spr[SPR::MQ] & ~mask));
|
||||
}
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template uint32_t dppc_interpreter::power_srlq<RC0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_srlq<RC1>(uint32_t opcode);
|
||||
|
||||
template <field_rc rec>
|
||||
uint32_t dppc_interpreter::power_srq(uint32_t opcode) {
|
||||
ppc_grab_regssab(opcode);
|
||||
unsigned rot_sh = ppc_result_b & 0x1F;
|
||||
|
||||
if (ppc_result_b & 0x20) {
|
||||
ppc_result_a = 0;
|
||||
} else {
|
||||
ppc_result_a = ppc_result_d >> rot_sh;
|
||||
}
|
||||
|
||||
ppc_state.spr[SPR::MQ] = rot_sh ? ((ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh))) : ppc_result_d;
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_store_iresult_reg(reg_a, ppc_result_a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template uint32_t dppc_interpreter::power_srq<RC0>(uint32_t opcode);
|
||||
template uint32_t dppc_interpreter::power_srq<RC1>(uint32_t opcode);
|
||||
@@ -1,531 +0,0 @@
|
||||
POWEROPCODEOVREC (abs, 31, 360,
|
||||
uint32_t ppc_result_d;
|
||||
ppc_grab_regsda(instr);
|
||||
if (ppc_result_a == 0x80000000) {
|
||||
ppc_result_d = ppc_result_a;
|
||||
if (ov)
|
||||
ppc_set_xer(XER::SO | XER::OV);
|
||||
} else {
|
||||
ppc_result_d = (int32_t(ppc_result_a) < 0) ? -ppc_result_a : ppc_result_a;
|
||||
if (ov)
|
||||
ppc_unset_xer(XER::OV);
|
||||
}
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_d);
|
||||
|
||||
ppc_state.gpr[reg_d] = ppc_result_d;
|
||||
)
|
||||
|
||||
POWEROPCODE31 (clcs, 31, 531,
|
||||
ppc_grab_da(instr);
|
||||
uint32_t ppc_result_d = 0;
|
||||
|
||||
switch (reg_a) {
|
||||
case 12: //instruction cache line size
|
||||
case 13: //data cache line size
|
||||
case 14: //minimum line size
|
||||
case 15: //maximum line size
|
||||
default:
|
||||
ppc_result_d = is_601 ? 64 : 32; break;
|
||||
case 7:
|
||||
case 23:
|
||||
ppc_result_d = is_601 ? 64 : 0; break;
|
||||
case 8:
|
||||
case 9:
|
||||
case 24:
|
||||
case 25:
|
||||
ppc_result_d = is_601 ? 64 : 4; break;
|
||||
case 10:
|
||||
case 11:
|
||||
case 26:
|
||||
case 27:
|
||||
ppc_result_d = is_601 ? 64 : 0x4000; break;
|
||||
}
|
||||
|
||||
ppc_state.gpr[reg_d] = ppc_result_d;
|
||||
)
|
||||
|
||||
POWEROPCODEOVREC (div, 31, 331,
|
||||
uint32_t ppc_result_d;
|
||||
ppc_grab_regsdab(instr);
|
||||
|
||||
int64_t dividend = (uint64_t(ppc_result_a) << 32) | ppc_state.spr[SPR::MQ];
|
||||
int32_t divisor = ppc_result_b;
|
||||
int64_t quotient;
|
||||
int32_t remainder;
|
||||
|
||||
if (dividend == -0x80000000 && divisor == -1) {
|
||||
remainder = 0;
|
||||
ppc_result_d = 0x80000000U; // -2^31 aka INT32_MIN
|
||||
if (ov)
|
||||
ppc_set_xer(XER::SO | XER::OV);
|
||||
} else if (!divisor) {
|
||||
remainder = 0;
|
||||
ppc_result_d = 0x80000000U; // -2^31 aka INT32_MIN
|
||||
if (ov)
|
||||
ppc_set_xer(XER::SO | XER::OV);
|
||||
} else {
|
||||
quotient = dividend / divisor;
|
||||
remainder = dividend % divisor;
|
||||
ppc_result_d = uint32_t(quotient);
|
||||
if (ov) {
|
||||
if (((quotient >> 31) + 1) & ~1) {
|
||||
ppc_set_xer(XER::SO | XER::OV);
|
||||
} else {
|
||||
ppc_unset_xer(XER::OV);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(remainder);
|
||||
|
||||
ppc_state.gpr[reg_d] = ppc_result_d;
|
||||
power_store_mq(remainder);
|
||||
)
|
||||
|
||||
POWEROPCODEOVREC (divs, 31, 363,
|
||||
uint32_t ppc_result_d;
|
||||
int32_t remainder;
|
||||
ppc_grab_regsdab(instr);
|
||||
|
||||
if (!ppc_result_b) { // handle the "anything / 0" case
|
||||
ppc_result_d = -1;
|
||||
remainder = ppc_result_a;
|
||||
if (ov)
|
||||
ppc_set_xer(XER::SO | XER::OV);
|
||||
} else if (ppc_result_a == 0x80000000U && ppc_result_b == 0xFFFFFFFFU) {
|
||||
ppc_result_d = 0x80000000U;
|
||||
remainder = 0;
|
||||
if (ov)
|
||||
ppc_set_xer(XER::SO | XER::OV);
|
||||
} else { // normal signed devision
|
||||
ppc_result_d = int32_t(ppc_result_a) / int32_t(ppc_result_b);
|
||||
remainder = (int32_t(ppc_result_a) % int32_t(ppc_result_b));
|
||||
if (ov)
|
||||
ppc_unset_xer(XER::OV);
|
||||
}
|
||||
if (rec)
|
||||
ppc_changecrf0(remainder);
|
||||
|
||||
ppc_state.gpr[reg_d] = ppc_result_d;
|
||||
power_store_mq(remainder);;
|
||||
)
|
||||
|
||||
POWEROPCODEOVREC (doz, 31, 264,
|
||||
ppc_grab_regsdab(instr);
|
||||
uint32_t ppc_result_d = (int32_t(ppc_result_a) < int32_t(ppc_result_b)) ?
|
||||
ppc_result_b - ppc_result_a : 0;
|
||||
|
||||
if (ov) {
|
||||
if (int32_t(ppc_result_d) < 0) {
|
||||
ppc_set_xer(XER::SO | XER::OV);
|
||||
} else {
|
||||
ppc_unset_xer(XER::OV);
|
||||
}
|
||||
}
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_d);
|
||||
|
||||
ppc_state.gpr[reg_d] = ppc_result_d;
|
||||
)
|
||||
|
||||
POWEROPCODE (dozi, , 9,
|
||||
ppc_grab_regsdasimm(instr);
|
||||
uint32_t ppc_result_d = 0;
|
||||
if (((int32_t)ppc_result_a) > simm) {
|
||||
ppc_result_d = 0;
|
||||
}
|
||||
else {
|
||||
ppc_result_d = simm - ppc_result_a;
|
||||
}
|
||||
ppc_state.gpr[reg_d] = ppc_result_d;
|
||||
)
|
||||
|
||||
POWEROPCODEREC (lscbx, 31, 277,
|
||||
ppc_grab_regsdab(instr);
|
||||
uint32_t ea = ppc_result_b + (reg_a ? ppc_result_a : 0);
|
||||
|
||||
uint32_t bytes_to_load = (ppc_state.spr[SPR::XER] & 0x7F);
|
||||
uint32_t bytes_remaining = bytes_to_load;
|
||||
uint8_t matching_byte = (uint8_t)(ppc_state.spr[SPR::XER] >> 8);
|
||||
uint32_t ppc_result_d = 0;
|
||||
bool is_match = false;
|
||||
|
||||
// for storing each byte
|
||||
uint8_t shift_amount = 24;
|
||||
|
||||
while (bytes_remaining > 0) {
|
||||
uint8_t return_value = mmu_read_vmem<uint8_t>(ea, instr);
|
||||
|
||||
ppc_result_d |= return_value << shift_amount;
|
||||
if (!shift_amount) {
|
||||
if (reg_d != reg_a && reg_d != reg_b) {
|
||||
ppc_state.gpr[reg_d] = ppc_result_d;
|
||||
}
|
||||
reg_d = (reg_d + 1) & 0x1F;
|
||||
ppc_result_d = 0;
|
||||
shift_amount = 24;
|
||||
} else {
|
||||
shift_amount -= 8;
|
||||
}
|
||||
|
||||
ea++;
|
||||
bytes_remaining--;
|
||||
|
||||
if (return_value == matching_byte) {
|
||||
is_match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// store partially loaded register if any
|
||||
if (shift_amount != 24 && reg_d != reg_a && reg_d != reg_b) {
|
||||
ppc_state.gpr[reg_d] = ppc_result_d;
|
||||
}
|
||||
|
||||
ppc_state.spr[SPR::XER] = (ppc_state.spr[SPR::XER] & ~0x7F) | (bytes_to_load - bytes_remaining);
|
||||
|
||||
if (rec) { \
|
||||
ppc_state.cr = \
|
||||
(ppc_state.cr & 0x0FFFFFFFUL) | \
|
||||
(is_match ? CRx_bit::CR_EQ : 0) | \
|
||||
((ppc_state.spr[SPR::XER] & XER::SO) >> 3);
|
||||
}
|
||||
)
|
||||
|
||||
POWEROPCODEREC (maskg, 31, 29,
|
||||
ppc_grab_regssab(instr);
|
||||
uint32_t mask_start = ppc_result_d & 0x1F;
|
||||
uint32_t mask_end = ppc_result_b & 0x1F;
|
||||
uint32_t insert_mask = 0;
|
||||
|
||||
if (mask_start < (mask_end + 1)) {
|
||||
insert_mask = power_rot_mask(mask_start, mask_end);
|
||||
}
|
||||
else if (mask_start == (mask_end + 1)) {
|
||||
insert_mask = 0xFFFFFFFF;
|
||||
}
|
||||
else {
|
||||
insert_mask = ~(power_rot_mask(mask_end + 1, mask_start - 1));
|
||||
}
|
||||
|
||||
ppc_result_a = insert_mask;
|
||||
|
||||
if (rec){
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
}
|
||||
|
||||
ppc_state.gpr[reg_a] = ppc_result_a;
|
||||
)
|
||||
|
||||
POWEROPCODEREC (maskir, 31, 541,
|
||||
ppc_grab_regssab(instr);
|
||||
ppc_result_a = (ppc_result_a & ~ppc_result_b) | (ppc_result_d & ppc_result_b);
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_state.gpr[reg_a] = ppc_result_a;
|
||||
)
|
||||
|
||||
POWEROPCODEOVREC (mul, 31, 107,
|
||||
ppc_grab_regsdab(instr);
|
||||
int64_t product = int64_t(int32_t(ppc_result_a)) * int32_t(ppc_result_b);
|
||||
uint32_t ppc_result_d = uint32_t(uint64_t(product) >> 32);
|
||||
ppc_state.spr[SPR::MQ] = uint32_t(product);
|
||||
|
||||
if (ov) {
|
||||
if (uint64_t(product >> 31) + 1 & ~1) {
|
||||
ppc_set_xer(XER::SO | XER::OV);
|
||||
} else {
|
||||
ppc_unset_xer(XER::OV);
|
||||
}
|
||||
}
|
||||
if (rec)
|
||||
ppc_changecrf0(uint32_t(product));
|
||||
ppc_state.gpr[reg_d] = ppc_result_d;
|
||||
)
|
||||
|
||||
POWEROPCODEOVREC (nabs, 31, 488,
|
||||
ppc_grab_regsda(instr);
|
||||
uint32_t ppc_result_d = (int32_t(ppc_result_a) < 0) ? ppc_result_a : -ppc_result_a;
|
||||
|
||||
if (ov)
|
||||
ppc_unset_xer(XER::OV);
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_d);
|
||||
|
||||
ppc_state.gpr[reg_d] = ppc_result_d;
|
||||
)
|
||||
|
||||
POWEROPCODE (rlmi, , 22,
|
||||
ppc_grab_regssab(instr);
|
||||
unsigned rot_mb = (instr >> 6) & 0x1F;
|
||||
unsigned rot_me = (instr >> 1) & 0x1F;
|
||||
unsigned rot_sh = ppc_result_b & 0x1F;
|
||||
|
||||
uint32_t r = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh)));
|
||||
uint32_t mask = power_rot_mask(rot_mb, rot_me);
|
||||
|
||||
ppc_result_a = ((r & mask) | (ppc_result_a & ~mask));
|
||||
|
||||
if ((instr & 0x01) == 1)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_state.gpr[reg_a] = ppc_result_a;
|
||||
)
|
||||
|
||||
POWEROPCODEREC (rrib, 31, 537,
|
||||
ppc_grab_regssab(instr);
|
||||
unsigned rot_sh = ppc_result_b & 0x1F;
|
||||
|
||||
if (int32_t(ppc_result_d) < 0) {
|
||||
ppc_result_a |= (0x80000000U >> rot_sh);
|
||||
} else {
|
||||
ppc_result_a &= ~(0x80000000U >> rot_sh);
|
||||
}
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_state.gpr[reg_a] = ppc_result_a;
|
||||
)
|
||||
|
||||
POWEROPCODEREC (sle, 31, 153,
|
||||
ppc_grab_regssab(instr);
|
||||
unsigned rot_sh = ppc_result_b & 0x1F;
|
||||
|
||||
ppc_result_a = ppc_result_d << rot_sh;
|
||||
ppc_state.spr[SPR::MQ] = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh)));
|
||||
|
||||
ppc_state.gpr[reg_a] = ppc_result_a;
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_state.gpr[reg_a] = ppc_result_a;
|
||||
)
|
||||
|
||||
POWEROPCODEREC (sleq, 31, 217,
|
||||
ppc_grab_regssab(instr);
|
||||
unsigned rot_sh = ppc_result_b & 0x1F;
|
||||
uint32_t r = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh)));
|
||||
uint32_t mask = power_rot_mask(0, 31 - rot_sh);
|
||||
|
||||
ppc_result_a = ((r & mask) | (ppc_state.spr[SPR::MQ] & ~mask));
|
||||
ppc_state.spr[SPR::MQ] = r;
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_state.gpr[reg_a] = ppc_result_a;
|
||||
)
|
||||
|
||||
POWEROPCODEREC (sliq, 31, 184,
|
||||
ppc_grab_regssash(instr);
|
||||
|
||||
ppc_result_a = ppc_result_d << rot_sh;
|
||||
ppc_state.spr[SPR::MQ] = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh)));
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_state.gpr[reg_a] = ppc_result_a;
|
||||
)
|
||||
|
||||
POWEROPCODEREC (slliq, 31, 248,
|
||||
ppc_grab_regssash(instr);
|
||||
uint32_t r = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh)));
|
||||
uint32_t mask = power_rot_mask(0, 31 - rot_sh);
|
||||
|
||||
ppc_result_a = ((r & mask) | (ppc_state.spr[SPR::MQ] & ~mask));
|
||||
ppc_state.spr[SPR::MQ] = r;
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_state.gpr[reg_a] = ppc_result_a;
|
||||
)
|
||||
|
||||
POWEROPCODEREC (sllq, 31, 216,
|
||||
ppc_grab_regssab(instr);
|
||||
unsigned rot_sh = ppc_result_b & 0x1F;
|
||||
|
||||
if (ppc_result_b & 0x20) {
|
||||
ppc_result_a = ppc_state.spr[SPR::MQ] & (-1U << rot_sh);
|
||||
} else {
|
||||
ppc_result_a = ((ppc_result_d << rot_sh) | (ppc_state.spr[SPR::MQ] & ((1 << rot_sh) - 1)));
|
||||
}
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_state.gpr[reg_a] = ppc_result_a;
|
||||
)
|
||||
|
||||
POWEROPCODEREC (slq, 31, 152,
|
||||
ppc_grab_regssab(instr);
|
||||
unsigned rot_sh = ppc_result_b & 0x1F;
|
||||
|
||||
if (ppc_result_b & 0x20) {
|
||||
ppc_result_a = 0;
|
||||
} else {
|
||||
ppc_result_a = ppc_result_d << rot_sh;
|
||||
}
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_state.spr[SPR::MQ] = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh)));
|
||||
ppc_state.gpr[reg_a] = ppc_result_a;
|
||||
)
|
||||
|
||||
POWEROPCODEREC (sraiq, 31, 952,
|
||||
ppc_grab_regssash(instr);
|
||||
uint32_t mask = (1 << rot_sh) - 1;
|
||||
ppc_result_a = (int32_t)ppc_result_d >> rot_sh;
|
||||
ppc_state.spr[SPR::MQ] = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh));
|
||||
|
||||
if ((int32_t(ppc_result_d) < 0) && (ppc_result_d & mask)) {
|
||||
ppc_state.spr[SPR::XER] |= XER::CA;
|
||||
} else {
|
||||
ppc_state.spr[SPR::XER] &= ~XER::CA;
|
||||
}
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_state.gpr[reg_a] = ppc_result_a;
|
||||
)
|
||||
|
||||
POWEROPCODEREC (sraq, 31, 920,
|
||||
ppc_grab_regssab(instr);
|
||||
unsigned rot_sh = ppc_result_b & 0x1F;
|
||||
uint32_t mask = (ppc_result_b & 0x20) ? -1 : (1 << rot_sh) - 1;
|
||||
ppc_result_a = (int32_t)ppc_result_d >> ((ppc_result_b & 0x20) ? 31 : rot_sh);
|
||||
ppc_state.spr[SPR::MQ] = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh)));
|
||||
|
||||
if ((int32_t(ppc_result_d) < 0) && (ppc_result_d & mask)) {
|
||||
ppc_state.spr[SPR::XER] |= XER::CA;
|
||||
} else {
|
||||
ppc_state.spr[SPR::XER] &= ~XER::CA;
|
||||
}
|
||||
|
||||
ppc_state.spr[SPR::MQ] = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh));
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_state.gpr[reg_a] = ppc_result_a;
|
||||
)
|
||||
|
||||
POWEROPCODEREC (sre, 31, 665,
|
||||
ppc_grab_regssab(instr);
|
||||
|
||||
unsigned rot_sh = ppc_result_b & 0x1F;
|
||||
ppc_result_a = ppc_result_d >> rot_sh;
|
||||
|
||||
ppc_state.spr[SPR::MQ] = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh));
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_state.gpr[reg_a] = ppc_result_a;
|
||||
)
|
||||
|
||||
POWEROPCODEREC (srea, 31, 921,
|
||||
ppc_grab_regssab(instr);
|
||||
unsigned rot_sh = ppc_result_b & 0x1F;
|
||||
ppc_result_a = (int32_t)ppc_result_d >> rot_sh;
|
||||
uint32_t r = ((ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh)));
|
||||
uint32_t mask = -1U >> rot_sh;
|
||||
|
||||
if ((int32_t(ppc_result_d) < 0) && (r & ~mask)) {
|
||||
ppc_state.spr[SPR::XER] |= XER::CA;
|
||||
} else {
|
||||
ppc_state.spr[SPR::XER] &= ~XER::CA;
|
||||
}
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_state.gpr[reg_a] = ppc_result_a;
|
||||
ppc_state.spr[SPR::MQ] = r;
|
||||
)
|
||||
|
||||
POWEROPCODEREC (sreq, 31, 729,
|
||||
ppc_grab_regssab(instr);
|
||||
unsigned rot_sh = ppc_result_b & 0x1F;
|
||||
uint32_t mask = -1U >> rot_sh;
|
||||
|
||||
ppc_result_a = (ppc_result_d >> rot_sh) | (ppc_state.spr[SPR::MQ] & ~mask);
|
||||
ppc_state.spr[SPR::MQ] = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh));
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_state.gpr[reg_a] = ppc_result_a;
|
||||
)
|
||||
|
||||
POWEROPCODEREC (sriq, 31, 696,
|
||||
ppc_grab_regssash(instr);
|
||||
ppc_result_a = ppc_result_d >> rot_sh;
|
||||
ppc_state.spr[SPR::MQ] = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh));
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_state.gpr[reg_a] = ppc_result_a;
|
||||
)
|
||||
|
||||
POWEROPCODEREC (srliq, 31, 760,
|
||||
ppc_grab_regssash(instr);
|
||||
uint32_t r = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh));
|
||||
unsigned mask = power_rot_mask(rot_sh, 31);
|
||||
|
||||
ppc_result_a = ((r & mask) | (ppc_state.spr[SPR::MQ] & ~mask));
|
||||
ppc_state.spr[SPR::MQ] = r;
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_state.gpr[reg_a] = ppc_result_a;
|
||||
)
|
||||
|
||||
POWEROPCODEREC (srlq, 31, 728,
|
||||
ppc_grab_regssab(instr);
|
||||
unsigned rot_sh = ppc_result_b & 0x1F;
|
||||
uint32_t r = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh));
|
||||
unsigned mask = power_rot_mask(rot_sh, 31);
|
||||
|
||||
if (ppc_result_b & 0x20) {
|
||||
ppc_result_a = (ppc_state.spr[SPR::MQ] & mask);
|
||||
} else {
|
||||
ppc_result_a = ((r & mask) | (ppc_state.spr[SPR::MQ] & ~mask));
|
||||
}
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_state.gpr[reg_a] = ppc_result_a;
|
||||
)
|
||||
|
||||
POWEROPCODEREC (srq, 31, 664,
|
||||
ppc_grab_regssab(instr);
|
||||
unsigned rot_sh = ppc_result_b & 0x1F;
|
||||
|
||||
if (ppc_result_b & 0x20) {
|
||||
ppc_result_a = 0;
|
||||
} else {
|
||||
ppc_result_a = ppc_result_d >> rot_sh;
|
||||
}
|
||||
|
||||
ppc_state.spr[SPR::MQ] = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh));
|
||||
|
||||
if (rec)
|
||||
ppc_changecrf0(ppc_result_a);
|
||||
|
||||
ppc_state.gpr[reg_a] = ppc_result_a;
|
||||
)
|
||||
+228
-24
@@ -47,7 +47,7 @@ enum EXEC_MODE:uint32_t {
|
||||
|
||||
enum endian_switch { big_end = 0, little_end = 1 };
|
||||
|
||||
typedef void (*PPCOpcode)(uint32_t);
|
||||
typedef uint32_t (*PPCOpcode)(uint32_t opcode);
|
||||
|
||||
union FPR_storage {
|
||||
double dbl64_r; // double floating-point representation
|
||||
@@ -299,8 +299,6 @@ enum Exc_Cause : uint32_t {
|
||||
TRAP = 1 << (31 - 14),
|
||||
};
|
||||
|
||||
extern unsigned exec_flags;
|
||||
|
||||
extern jmp_buf exc_env;
|
||||
|
||||
enum Po_Cause : int {
|
||||
@@ -317,6 +315,7 @@ enum Po_Cause : int {
|
||||
po_enter_debugger,
|
||||
po_entered_debugger,
|
||||
po_signal_interrupt,
|
||||
po_benchmark_exception
|
||||
};
|
||||
|
||||
extern bool power_on;
|
||||
@@ -325,12 +324,17 @@ extern bool int_pin;
|
||||
extern bool dec_exception_pending;
|
||||
|
||||
extern bool is_601; // For PowerPC 601 Emulation
|
||||
extern bool include_601; // For non-PowerPC 601 emulation with 601 extras (matches Mac OS 9 environment which can emulate MPC 601 instructions)
|
||||
extern bool is_altivec; // For Altivec Emulation
|
||||
extern bool is_64bit; // For PowerPC G5 Emulation
|
||||
|
||||
// Make execution deterministic (ignore external input, used a fixed date, etc.)
|
||||
extern bool is_deterministic;
|
||||
|
||||
// Important Addressing Integers
|
||||
extern uint32_t ppc_next_instruction_address;
|
||||
|
||||
inline uint32_t ppc_set_cur_instruction(const uint8_t* ptr) {
|
||||
inline uint32_t ppc_read_instruction(const uint8_t* ptr) {
|
||||
return READ_DWORD_BE_A(ptr);
|
||||
}
|
||||
|
||||
@@ -395,29 +399,30 @@ typedef enum {
|
||||
IS601,
|
||||
} field_601;
|
||||
|
||||
// Placeholder value for cases where we don't have a currently-executing instruction.
|
||||
constexpr uint32_t NO_OPCODE = 0;
|
||||
|
||||
// Function prototypes
|
||||
extern void ppc_cpu_init(MemCtrlBase* mem_ctrl, uint32_t cpu_version, bool include_601, uint64_t tb_freq);
|
||||
extern void ppc_mmu_init();
|
||||
|
||||
void ppc_illegalop(uint32_t null_val=0);
|
||||
void ppc_fpu_off();
|
||||
uint32_t ppc_illegalop(uint32_t opcode);
|
||||
void ppc_assert_int();
|
||||
void ppc_release_int();
|
||||
|
||||
void initialize_ppc_opcode_tables(bool include_601);
|
||||
|
||||
extern double fp_return_double(uint32_t reg);
|
||||
extern uint64_t fp_return_uint64(uint32_t reg);
|
||||
void initialize_ppc_opcode_table();
|
||||
|
||||
void ppc_changecrf0(uint32_t set_result);
|
||||
void set_host_rounding_mode(uint8_t mode);
|
||||
void update_fpscr(uint32_t new_fpscr);
|
||||
|
||||
/* Exception handlers. */
|
||||
void ppc_exception_handler(Except_Type exception_type, uint32_t srr1_bits);
|
||||
[[noreturn]] void dbg_exception_handler(Except_Type exception_type, uint32_t srr1_bits);
|
||||
void ppc_floating_point_exception(uint32_t instr);
|
||||
void ppc_alignment_exception(uint32_t ea, uint32_t instr);
|
||||
uint32_t ppc_exception_handler(
|
||||
Except_Type exception_type, uint32_t srr1_bits, uint32_t exec_flags = 0);
|
||||
[[noreturn]] uint32_t dbg_exception_handler(
|
||||
Except_Type exception_type, uint32_t srr1_bits, uint32_t exec_flags);
|
||||
void ppc_floating_point_exception(uint32_t opcode);
|
||||
void ppc_alignment_exception(uint32_t opcode, uint32_t ea);
|
||||
|
||||
// MEMORY DECLARATIONS
|
||||
extern MemCtrlBase* mem_ctrl_instance;
|
||||
@@ -425,9 +430,217 @@ extern MemCtrlBase* mem_ctrl_instance;
|
||||
extern void add_ctx_sync_action(const std::function<void()> &);
|
||||
extern void do_ctx_sync(void);
|
||||
|
||||
// The functions used by the PowerPC processor
|
||||
|
||||
namespace dppc_interpreter {
|
||||
template <field_lk l, field_601 for601> extern uint32_t ppc_bcctr(uint32_t opcode);
|
||||
template <field_lk l> extern uint32_t ppc_bclr(uint32_t opcode);
|
||||
extern uint32_t ppc_crand(uint32_t opcode);
|
||||
extern uint32_t ppc_crandc(uint32_t opcode);
|
||||
extern uint32_t ppc_creqv(uint32_t opcode);
|
||||
extern uint32_t ppc_crnand(uint32_t opcode);
|
||||
extern uint32_t ppc_crnor(uint32_t opcode);
|
||||
extern uint32_t ppc_cror(uint32_t opcode);
|
||||
extern uint32_t ppc_crorc(uint32_t opcode);
|
||||
extern uint32_t ppc_crxor(uint32_t opcode);
|
||||
extern uint32_t ppc_isync(uint32_t opcode);
|
||||
|
||||
template <logical_fun logical_op, field_rc rec> extern uint32_t ppc_logical(uint32_t opcode);
|
||||
|
||||
template <field_carry carry, field_rc rec, field_ov ov> extern uint32_t ppc_add(uint32_t opcode);
|
||||
template <field_rc rec, field_ov ov> extern uint32_t ppc_adde(uint32_t opcode);
|
||||
template <field_rc rec, field_ov ov> extern uint32_t ppc_addme(uint32_t opcode);
|
||||
template <field_rc rec, field_ov ov> extern uint32_t ppc_addze(uint32_t opcode);
|
||||
extern uint32_t ppc_cmp(uint32_t opcode);
|
||||
extern uint32_t ppc_cmpl(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_cntlzw(uint32_t opcode);
|
||||
extern uint32_t ppc_dcbf(uint32_t opcode);
|
||||
extern uint32_t ppc_dcbi(uint32_t opcode);
|
||||
extern uint32_t ppc_dcbst(uint32_t opcode);
|
||||
extern uint32_t ppc_dcbt(uint32_t opcode);
|
||||
extern uint32_t ppc_dcbtst(uint32_t opcode);
|
||||
extern uint32_t ppc_dcbz(uint32_t opcode);
|
||||
template <field_rc rec, field_ov ov> extern uint32_t ppc_divw(uint32_t opcode);
|
||||
template <field_rc rec, field_ov ov> extern uint32_t ppc_divwu(uint32_t opcode);
|
||||
extern uint32_t ppc_eciwx(uint32_t opcode);
|
||||
extern uint32_t ppc_ecowx(uint32_t opcode);
|
||||
extern uint32_t ppc_eieio(uint32_t opcode);
|
||||
template <class T, field_rc rec>extern uint32_t ppc_exts(uint32_t opcode);
|
||||
extern uint32_t ppc_icbi(uint32_t opcode);
|
||||
extern uint32_t ppc_mftb(uint32_t opcode);
|
||||
extern uint32_t ppc_lhaux(uint32_t opcode);
|
||||
extern uint32_t ppc_lhax(uint32_t opcode);
|
||||
extern uint32_t ppc_lhbrx(uint32_t opcode);
|
||||
extern uint32_t ppc_lwarx(uint32_t opcode);
|
||||
extern uint32_t ppc_lwbrx(uint32_t opcode);
|
||||
template <class T> extern uint32_t ppc_lzx(uint32_t opcode);
|
||||
template <class T> extern uint32_t ppc_lzux(uint32_t opcode);
|
||||
extern uint32_t ppc_mcrxr(uint32_t opcode);
|
||||
extern uint32_t ppc_mfcr(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_mulhwu(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_mulhw(uint32_t opcode);
|
||||
template <field_rc rec, field_ov ov> extern uint32_t ppc_mullw(uint32_t opcode);
|
||||
template <field_rc rec, field_ov ov> extern uint32_t ppc_neg(uint32_t opcode);
|
||||
template <field_direction shift, field_rc rec> extern uint32_t ppc_shift(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_sraw(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_srawi(uint32_t opcode);
|
||||
template <class T> extern uint32_t ppc_stx(uint32_t opcode);
|
||||
template <class T> extern uint32_t ppc_stux(uint32_t opcode);
|
||||
extern uint32_t ppc_stfiwx(uint32_t opcode);
|
||||
extern uint32_t ppc_sthbrx(uint32_t opcode);
|
||||
extern uint32_t ppc_stwcx(uint32_t opcode);
|
||||
extern uint32_t ppc_stwbrx(uint32_t opcode);
|
||||
template <field_carry carry, field_rc rec, field_ov ov> extern uint32_t ppc_subf(uint32_t opcode);
|
||||
template <field_rc rec, field_ov ov> extern uint32_t ppc_subfe(uint32_t opcode);
|
||||
template <field_rc rec, field_ov ov> extern uint32_t ppc_subfme(uint32_t opcode);
|
||||
template <field_rc rec, field_ov ov> extern uint32_t ppc_subfze(uint32_t opcode);
|
||||
extern uint32_t ppc_sync(uint32_t opcode);
|
||||
extern uint32_t ppc_tlbia(uint32_t opcode);
|
||||
extern uint32_t ppc_tlbie(uint32_t opcode);
|
||||
extern uint32_t ppc_tlbli(uint32_t opcode);
|
||||
extern uint32_t ppc_tlbld(uint32_t opcode);
|
||||
extern uint32_t ppc_tlbsync(uint32_t opcode);
|
||||
extern uint32_t ppc_tw(uint32_t opcode);
|
||||
|
||||
extern uint32_t ppc_lswi(uint32_t opcode);
|
||||
extern uint32_t ppc_lswx(uint32_t opcode);
|
||||
extern uint32_t ppc_stswi(uint32_t opcode);
|
||||
extern uint32_t ppc_stswx(uint32_t opcode);
|
||||
|
||||
extern uint32_t ppc_mfsr(uint32_t opcode);
|
||||
extern uint32_t ppc_mfsrin(uint32_t opcode);
|
||||
extern uint32_t ppc_mtsr(uint32_t opcode);
|
||||
extern uint32_t ppc_mtsrin(uint32_t opcode);
|
||||
|
||||
extern uint32_t ppc_mcrf(uint32_t opcode);
|
||||
extern uint32_t ppc_mtcrf(uint32_t opcode);
|
||||
extern uint32_t ppc_mfmsr(uint32_t opcode);
|
||||
extern uint32_t ppc_mfspr(uint32_t opcode);
|
||||
extern uint32_t ppc_mtmsr(uint32_t opcode);
|
||||
extern uint32_t ppc_mtspr(uint32_t opcode);
|
||||
|
||||
template <field_rc rec> extern uint32_t ppc_mtfsb0(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_mtfsb1(uint32_t opcode);
|
||||
extern uint32_t ppc_mcrfs(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_fmr(uint32_t opcode);
|
||||
template <field_601 for601, field_rc rec> extern uint32_t ppc_mffs(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_mtfsf(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_mtfsfi(uint32_t opcode);
|
||||
|
||||
template <field_shift shift> extern uint32_t ppc_addi(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_addic(uint32_t opcode);
|
||||
template <field_shift shift> extern uint32_t ppc_andirc(uint32_t opcode);
|
||||
template <field_lk l, field_aa a> extern uint32_t ppc_b(uint32_t opcode);
|
||||
template <field_lk l, field_aa a> extern uint32_t ppc_bc(uint32_t opcode);
|
||||
extern uint32_t ppc_cmpi(uint32_t opcode);
|
||||
extern uint32_t ppc_cmpli(uint32_t opcode);
|
||||
template <class T> extern uint32_t ppc_lz(uint32_t opcode);
|
||||
template <class T> extern uint32_t ppc_lzu(uint32_t opcode);
|
||||
extern uint32_t ppc_lha(uint32_t opcode);
|
||||
extern uint32_t ppc_lhau(uint32_t opcode);
|
||||
extern uint32_t ppc_lmw(uint32_t opcode);
|
||||
extern uint32_t ppc_mulli(uint32_t opcode);
|
||||
template <field_shift shift> extern uint32_t ppc_ori(uint32_t opcode);
|
||||
extern uint32_t ppc_rfi(uint32_t opcode);
|
||||
extern uint32_t ppc_rlwimi(uint32_t opcode);
|
||||
extern uint32_t ppc_rlwinm(uint32_t opcode);
|
||||
extern uint32_t ppc_rlwnm(uint32_t opcode);
|
||||
extern uint32_t ppc_sc(uint32_t opcode);
|
||||
template <class T> extern uint32_t ppc_st(uint32_t opcode);
|
||||
template <class T> extern uint32_t ppc_stu(uint32_t opcode);
|
||||
extern uint32_t ppc_stmw(uint32_t opcode);
|
||||
extern uint32_t ppc_subfic(uint32_t opcode);
|
||||
extern uint32_t ppc_twi(uint32_t opcode);
|
||||
template <field_shift shift> extern uint32_t ppc_xori(uint32_t opcode);
|
||||
|
||||
extern uint32_t ppc_lfs(uint32_t opcode);
|
||||
extern uint32_t ppc_lfsu(uint32_t opcode);
|
||||
extern uint32_t ppc_lfsx(uint32_t opcode);
|
||||
extern uint32_t ppc_lfsux(uint32_t opcode);
|
||||
extern uint32_t ppc_lfd(uint32_t opcode);
|
||||
extern uint32_t ppc_lfdu(uint32_t opcode);
|
||||
extern uint32_t ppc_lfdx(uint32_t opcode);
|
||||
extern uint32_t ppc_lfdux(uint32_t opcode);
|
||||
extern uint32_t ppc_stfs(uint32_t opcode);
|
||||
extern uint32_t ppc_stfsu(uint32_t opcode);
|
||||
extern uint32_t ppc_stfsx(uint32_t opcode);
|
||||
extern uint32_t ppc_stfsux(uint32_t opcode);
|
||||
extern uint32_t ppc_stfd(uint32_t opcode);
|
||||
extern uint32_t ppc_stfdu(uint32_t opcode);
|
||||
extern uint32_t ppc_stfdx(uint32_t opcode);
|
||||
extern uint32_t ppc_stfdux(uint32_t opcode);
|
||||
|
||||
template <field_rc rec> extern uint32_t ppc_fadd(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_fsub(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_fmul(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_fdiv(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_fadds(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_fsubs(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_fmuls(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_fdivs(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_fmadd(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_fmsub(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_fnmadd(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_fnmsub(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_fmadds(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_fmsubs(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_fnmadds(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_fnmsubs(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_fabs(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_fnabs(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_fneg(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_fsel(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_fres(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_fsqrts(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_fsqrt(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_frsqrte(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_frsp(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_fctiw(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t ppc_fctiwz(uint32_t opcode);
|
||||
|
||||
extern uint32_t ppc_fcmpo(uint32_t opcode);
|
||||
extern uint32_t ppc_fcmpu(uint32_t opcode);
|
||||
|
||||
// Power-specific instructions
|
||||
template <field_rc rec, field_ov ov> extern uint32_t power_abs(uint32_t opcode);
|
||||
extern uint32_t power_clcs(uint32_t opcode);
|
||||
template <field_rc rec, field_ov ov> extern uint32_t power_div(uint32_t opcode);
|
||||
template <field_rc rec, field_ov ov> extern uint32_t power_divs(uint32_t opcode);
|
||||
template <field_rc rec, field_ov ov> extern uint32_t power_doz(uint32_t opcode);
|
||||
extern uint32_t power_dozi(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t power_lscbx(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t power_maskg(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t power_maskir(uint32_t opcode);
|
||||
template <field_rc rec, field_ov ov> extern uint32_t power_mul(uint32_t opcode);
|
||||
template <field_rc rec, field_ov ov> extern uint32_t power_nabs(uint32_t opcode);
|
||||
extern uint32_t power_rlmi(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t power_rrib(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t power_sle(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t power_sleq(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t power_sliq(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t power_slliq(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t power_sllq(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t power_slq(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t power_sraiq(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t power_sraq(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t power_sre(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t power_srea(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t power_sreq(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t power_sriq(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t power_srliq(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t power_srlq(uint32_t opcode);
|
||||
template <field_rc rec> extern uint32_t power_srq(uint32_t opcode);
|
||||
} // namespace dppc_interpreter
|
||||
|
||||
// AltiVec instructions
|
||||
|
||||
// 64-bit instructions
|
||||
|
||||
// G5+ instructions
|
||||
|
||||
extern uint64_t get_virt_time_ns(void);
|
||||
|
||||
extern void ppc_main_opcode(uint32_t instr);
|
||||
extern uint32_t ppc_main_opcode(uint32_t opcode);
|
||||
extern void ppc_exec(void);
|
||||
extern void ppc_exec_single(void);
|
||||
extern void ppc_exec_until(uint32_t goal_addr);
|
||||
@@ -438,13 +651,4 @@ void print_fprs(void); /* print content of the floating-point
|
||||
uint64_t get_reg(std::string reg_name); /* get content of the register reg_name */
|
||||
void set_reg(std::string reg_name, uint64_t val); /* set reg_name to val */
|
||||
|
||||
// The functions used by the PowerPC processor
|
||||
#include "ppcmacros_prototypes.h"
|
||||
|
||||
namespace dppc_interpreter {
|
||||
#include "ppcopcodes.include"
|
||||
#include "poweropcodes.include"
|
||||
#include "ppcfpopcodes.include"
|
||||
} // namespace dppc_interpreter
|
||||
|
||||
#endif /* PPCEMU_H */
|
||||
+31
-28
@@ -32,7 +32,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
jmp_buf exc_env; /* Global exception environment. */
|
||||
|
||||
#if !defined(PPC_TESTS) && !defined(PPC_BENCHMARKS)
|
||||
void ppc_exception_handler(Except_Type exception_type, uint32_t srr1_bits) {
|
||||
uint32_t ppc_exception_handler(Except_Type exception_type, uint32_t srr1_bits, uint32_t exec_flags) {
|
||||
#ifdef CPU_PROFILING
|
||||
exceptions_processed++;
|
||||
#endif
|
||||
@@ -135,10 +135,12 @@ void ppc_exception_handler(Except_Type exception_type, uint32_t srr1_bits) {
|
||||
if (exception_type != Except_Type::EXC_EXT_INT && exception_type != Except_Type::EXC_DECR) {
|
||||
longjmp(exc_env, 2); /* return to the main execution loop. */
|
||||
}
|
||||
|
||||
return exec_flags;
|
||||
}
|
||||
#endif
|
||||
|
||||
[[noreturn]] void dbg_exception_handler(Except_Type exception_type, uint32_t srr1_bits) {
|
||||
[[noreturn]] uint32_t dbg_exception_handler(Except_Type exception_type, uint32_t srr1_bits, uint32_t exec_flags) {
|
||||
std::string exc_descriptor;
|
||||
|
||||
switch (exception_type) {
|
||||
@@ -196,16 +198,17 @@ void ppc_exception_handler(Except_Type exception_type, uint32_t srr1_bits) {
|
||||
throw std::invalid_argument(exc_descriptor);
|
||||
}
|
||||
|
||||
void ppc_floating_point_exception(uint32_t instr) {
|
||||
LOG_F(ERROR, "Floating point exception at 0x%08x for instruction 0x%08x", ppc_state.pc, instr);
|
||||
void ppc_floating_point_exception(uint32_t opcode) {
|
||||
LOG_F(ERROR, "Floating point exception at 0x%08x for instruction 0x%08x",
|
||||
ppc_state.pc, opcode);
|
||||
// mmu_exception_handler(Except_Type::EXC_PROGRAM, Exc_Cause::FPU_EXCEPTION);
|
||||
}
|
||||
|
||||
void ppc_alignment_exception(uint32_t ea, uint32_t instr)
|
||||
void ppc_alignment_exception(uint32_t opcode, uint32_t ea)
|
||||
{
|
||||
uint32_t dsisr;
|
||||
|
||||
switch (instr & 0xfc000000) {
|
||||
switch (opcode & 0xfc000000) {
|
||||
case 0x80000000: // lwz
|
||||
case 0x90000000: // stw
|
||||
case 0xa0000000: // lhz
|
||||
@@ -227,11 +230,11 @@ void ppc_alignment_exception(uint32_t ea, uint32_t instr)
|
||||
case 0xd4000000: // stfsu
|
||||
case 0xdc000000: // stfdu
|
||||
// indirect with immediate index
|
||||
dsisr = ((instr >> 12) & 0x00004000) // bit 17 — Set to bit 5 of the instruction.
|
||||
| ((instr >> 17) & 0x00003c00); // bits 18–21 - set to bits 1–4 of the instruction.
|
||||
dsisr = ((opcode >> 12) & 0x00004000) // bit 17 — Set to bit 5 of the instruction.
|
||||
| ((opcode >> 17) & 0x00003c00); // bits 18–21 - set to bits 1–4 of the instruction.
|
||||
break;
|
||||
case 0x7c000000:
|
||||
switch (instr & 0xfc0007ff) {
|
||||
switch (opcode & 0xfc0007ff) {
|
||||
case 0x7c000028: // lwarx (invalid form - bits 15-21 of DSISR are identical to those of lwz)
|
||||
case 0x7c0002aa: // lwax (64-bit only)
|
||||
case 0x7c00042a: // lswx
|
||||
@@ -265,12 +268,12 @@ void ppc_alignment_exception(uint32_t ea, uint32_t instr)
|
||||
case 0x7c00056e: // stfsux
|
||||
case 0x7c0005ee: // stfdux
|
||||
indirect_with_index:
|
||||
dsisr = ((instr << 14) & 0x00018000) // bits 15–16 - set to bits 29–30 of the instruction.
|
||||
| ((instr << 8) & 0x00004000) // bit 17 - set to bit 25 of the instruction.
|
||||
| ((instr << 3) & 0x00003c00); // bits 18–21 - set to bits 21–24 of the instruction.
|
||||
dsisr = ((opcode << 14) & 0x00018000) // bits 15–16 - set to bits 29–30 of the instruction.
|
||||
| ((opcode << 8) & 0x00004000) // bit 17 - set to bit 25 of the instruction.
|
||||
| ((opcode << 3) & 0x00003c00); // bits 18–21 - set to bits 21–24 of the instruction.
|
||||
break;
|
||||
case 0x7c0007ec:
|
||||
if ((instr & 0xffe007ff) == 0x7c0007ec) // dcbz
|
||||
if ((opcode & 0xffe007ff) == 0x7c0007ec) // dcbz
|
||||
goto indirect_with_index;
|
||||
/* fallthrough */
|
||||
default:
|
||||
@@ -281,34 +284,34 @@ indirect_with_index:
|
||||
unexpected_instruction:
|
||||
dsisr = 0;
|
||||
LOG_F(ERROR, "Alignment exception from unexpected instruction 0x%08x",
|
||||
instr);
|
||||
opcode);
|
||||
}
|
||||
|
||||
// bits 22–26 - Set to bits 6–10 (source or destination) of the instruction.
|
||||
// Undefined for dcbz.
|
||||
dsisr |= ((instr >> 16) & 0x000003e0);
|
||||
dsisr |= ((opcode >> 16) & 0x000003e0);
|
||||
|
||||
if ((instr & 0xfc000000) == 0xb8000000) { // lmw
|
||||
if ((opcode & 0xfc000000) == 0xb8000000) { // lmw
|
||||
LOG_F(ERROR, "Alignment exception from instruction 0x%08x (lmw). "
|
||||
"What to set DSISR bits 27-31?", instr);
|
||||
// dsisr |= ((instr >> ?) & 0x0000001f); // bits 27–31
|
||||
}
|
||||
else if ((instr & 0xfc0007ff) == 0x7c0004aa) { // lswi
|
||||
"What to set DSISR bits 27-31?", opcode);
|
||||
// dsisr |= ((opcode >> ?) & 0x0000001f); // bits 27–31
|
||||
}
|
||||
else if ((opcode & 0xfc0007ff) == 0x7c0004aa) { // lswi
|
||||
LOG_F(ERROR, "Alignment exception from instruction 0x%08x (lswi). "
|
||||
"What to set DSISR bits 27-31?", instr);
|
||||
// dsisr |= ((instr >> ?) & 0x0000001f); // bits 27–31
|
||||
}
|
||||
else if ((instr & 0xfc0007ff) == 0x7c00042a) { // lswx
|
||||
"What to set DSISR bits 27-31?", opcode);
|
||||
// dsisr |= ((opcode >> ?) & 0x0000001f); // bits 27–31
|
||||
}
|
||||
else if ((opcode & 0xfc0007ff) == 0x7c00042a) { // lswx
|
||||
LOG_F(ERROR, "Alignment exception from instruction 0x%08x (lswx). "
|
||||
"What to set DSISR bits 27-31?", instr);
|
||||
// dsisr |= ((instr >> ?) & 0x0000001f); // bits 27–31
|
||||
"What to set DSISR bits 27-31?", opcode);
|
||||
// dsisr |= ((opcode >> ?) & 0x0000001f); // bits 27–31
|
||||
}
|
||||
else {
|
||||
// bits 27–31 - Set to bits 11–15 of the instruction (rA)
|
||||
dsisr |= ((instr >> 16) & 0x0000001f);
|
||||
dsisr |= ((opcode >> 16) & 0x0000001f);
|
||||
}
|
||||
|
||||
ppc_state.spr[SPR::DSISR] = dsisr;
|
||||
ppc_state.spr[SPR::DAR] = ea;
|
||||
ppc_exception_handler(Except_Type::EXC_ALIGNMENT, 0x0);
|
||||
ppc_exception_handler(Except_Type::EXC_ALIGNMENT, 0x0, 0);
|
||||
}
|
||||
+392
-342
@@ -24,7 +24,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#include "ppcemu.h"
|
||||
#include "ppcmmu.h"
|
||||
#include "ppcdisasm.h"
|
||||
#include "ppcoptablemacros.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
@@ -57,6 +56,9 @@ using namespace dppc_interpreter;
|
||||
MemCtrlBase* mem_ctrl_instance = 0;
|
||||
|
||||
bool is_601 = false;
|
||||
bool include_601 = false;
|
||||
|
||||
bool is_deterministic = false;
|
||||
|
||||
bool power_on = false;
|
||||
Po_Cause power_off_reason = po_enter_debugger;
|
||||
@@ -65,7 +67,6 @@ SetPRS ppc_state;
|
||||
|
||||
uint32_t ppc_next_instruction_address; // Used for branching, setting up the NIA
|
||||
|
||||
unsigned exec_flags; // execution control flags
|
||||
// FIXME: exec_timer is read by main thread ppc_main_opcode;
|
||||
// written by audio dbdma DMAChannel::update_irq .. add_immediate_timer
|
||||
volatile bool exec_timer;
|
||||
@@ -178,39 +179,21 @@ public:
|
||||
|
||||
#endif
|
||||
|
||||
/** Opcode lookup tables. */
|
||||
|
||||
/** Primary opcode (bits 0...5) lookup table. */
|
||||
static PPCOpcode OpcodeGrabber[64];
|
||||
|
||||
/** Lookup tables for branch instructions. */
|
||||
static PPCOpcode Opcode16Grabber[4]; // bcla
|
||||
|
||||
static PPCOpcode Opcode18Grabber[4]; // bla
|
||||
|
||||
/** Instructions decoding tables for integer,
|
||||
single floating-point, and double-floating point ops respectively */
|
||||
|
||||
static PPCOpcode Opcode19Grabber[2048];
|
||||
static PPCOpcode Opcode31Grabber[2048];
|
||||
static PPCOpcode Opcode59Grabber[64];
|
||||
static PPCOpcode Opcode63Grabber[2048];
|
||||
/** Opcode lookup table, indexed by
|
||||
primary opcode (bits 0...5) and modifier (bits 21...31). */
|
||||
static PPCOpcode OpcodeGrabber[64 * 2048];
|
||||
|
||||
/** Exception helpers. */
|
||||
|
||||
void ppc_illegalop(uint32_t null_val) {
|
||||
ppc_exception_handler(Except_Type::EXC_PROGRAM, Exc_Cause::ILLEGAL_OP);
|
||||
}
|
||||
|
||||
void ppc_fpu_off() {
|
||||
ppc_exception_handler(Except_Type::EXC_PROGRAM, Exc_Cause::FPU_OFF);
|
||||
uint32_t ppc_illegalop(uint32_t opcode) {
|
||||
return ppc_exception_handler(Except_Type::EXC_PROGRAM, Exc_Cause::ILLEGAL_OP, 0);
|
||||
}
|
||||
|
||||
void ppc_assert_int() {
|
||||
int_pin = true;
|
||||
if (ppc_state.msr & MSR::EE) {
|
||||
LOG_F(5, "CPU ExtIntHandler called");
|
||||
ppc_exception_handler(Except_Type::EXC_EXT_INT, 0);
|
||||
ppc_exception_handler(Except_Type::EXC_EXT_INT, 0, 0);
|
||||
} else {
|
||||
LOG_F(5, "CPU IRQ ignored!");
|
||||
}
|
||||
@@ -222,128 +205,16 @@ void ppc_release_int() {
|
||||
|
||||
/** Opcode decoding functions. */
|
||||
|
||||
static void ppc_opcode16(uint32_t subop, uint32_t instr) {
|
||||
Opcode16Grabber[instr & 3](instr);
|
||||
}
|
||||
|
||||
static void ppc_opcode18(uint32_t instr) {
|
||||
Opcode18Grabber[instr & 3](instr);
|
||||
}
|
||||
|
||||
template<field_601 for601>
|
||||
void ppc_opcode19(uint32_t instr) {
|
||||
uint16_t subop_grab = instr & 0x7FF;
|
||||
|
||||
switch (subop_grab) {
|
||||
case 0:
|
||||
ppc_mcrf(instr);
|
||||
break;
|
||||
case 32:
|
||||
ppc_bclr<LK0>(instr);
|
||||
break;
|
||||
case 33:
|
||||
ppc_bclr<LK1>(instr);
|
||||
break;
|
||||
case 66:
|
||||
ppc_crnor(instr);
|
||||
break;
|
||||
case 100:
|
||||
ppc_rfi(instr);
|
||||
break;
|
||||
case 258:
|
||||
ppc_crandc(instr);
|
||||
break;
|
||||
case 300:
|
||||
ppc_isync(instr);
|
||||
break;
|
||||
case 386:
|
||||
ppc_crxor(instr);
|
||||
break;
|
||||
case 450:
|
||||
ppc_crnand(instr);
|
||||
break;
|
||||
case 514:
|
||||
ppc_crand(instr);
|
||||
break;
|
||||
case 578:
|
||||
ppc_creqv(instr);
|
||||
break;
|
||||
case 834:
|
||||
ppc_crorc(instr);
|
||||
break;
|
||||
case 898:
|
||||
ppc_cror(instr);
|
||||
break;
|
||||
case 1056:
|
||||
ppc_bcctr<LK0, for601>(instr);
|
||||
break;
|
||||
case 1057:
|
||||
ppc_bcctr<LK1, for601>(instr);
|
||||
break;
|
||||
default:
|
||||
ppc_illegalop();
|
||||
}
|
||||
}
|
||||
|
||||
template void ppc_opcode19<NOT601>(uint32_t);
|
||||
template void ppc_opcode19<IS601>(uint32_t);
|
||||
|
||||
void ppc_opcode31(uint32_t instr) {
|
||||
}
|
||||
|
||||
void ppc_opcode59(uint32_t instr) {
|
||||
uint16_t subop_grab = instr & 0x3FUL;
|
||||
Opcode59Grabber[subop_grab](instr);
|
||||
}
|
||||
|
||||
void ppc_opcode63(uint32_t instr) {
|
||||
uint16_t subop_grab = instr & 0x7FFUL;
|
||||
Opcode63Grabber[subop_grab](instr);
|
||||
}
|
||||
|
||||
/* Dispatch using main opcode */
|
||||
void ppc_main_opcode(uint32_t instr) {
|
||||
/* Dispatch using primary and modifier opcode */
|
||||
uint32_t ppc_main_opcode(uint32_t opcode)
|
||||
{
|
||||
#ifdef CPU_PROFILING
|
||||
num_executed_instrs++;
|
||||
#if defined(CPU_PROFILING_OPS)
|
||||
num_opcodes[instr]++;
|
||||
num_opcodes[opcode]++;
|
||||
#endif
|
||||
#endif
|
||||
uint32_t opcode = (instr >> 26) & 63;
|
||||
switch (opcode) {
|
||||
case 16:
|
||||
Opcode16Grabber[instr & 3](instr);
|
||||
break;
|
||||
case 18:
|
||||
Opcode16Grabber[instr & 3](instr);
|
||||
break;
|
||||
case 19:
|
||||
if (is_601)
|
||||
ppc_opcode19<IS601>(instr);
|
||||
else
|
||||
ppc_opcode19<NOT601>(instr);
|
||||
break;
|
||||
case 31:
|
||||
uint16_t subop_grab = instr & 0x7FFUL;
|
||||
Opcode31Grabber[subop_grab](instr);
|
||||
break;
|
||||
case 59:
|
||||
uint16_t subop_grab = instr & 0x7FFUL;
|
||||
Opcode31Grabber[subop_grab](instr);
|
||||
break;
|
||||
case 63:
|
||||
uint16_t subop_grab = instr & 0x7FFUL;
|
||||
Opcode31Grabber[subop_grab](instr);
|
||||
break;
|
||||
default:
|
||||
OpcodeGrabber[opcode](instr);
|
||||
}
|
||||
|
||||
#ifdef CPU_PROFILING
|
||||
uint32_t load_chk = (instr >> 26);
|
||||
if ((load_chk > 31) && (load_chk < 59))
|
||||
num_int_loads++;
|
||||
#endif
|
||||
return OpcodeGrabber[(opcode >> 15 & 0x1F800) | (opcode & 0x7FF)](opcode);
|
||||
}
|
||||
|
||||
static long long cpu_now_ns() {
|
||||
@@ -382,60 +253,68 @@ static void force_cycle_counter_reload()
|
||||
exec_timer = true;
|
||||
}
|
||||
|
||||
/** Execute PPC code as long as power is on. */
|
||||
// inner interpreter loop
|
||||
static void ppc_exec_inner()
|
||||
{
|
||||
uint64_t max_cycles;
|
||||
uint32_t page_start, eb_start, eb_end;
|
||||
uint8_t* pc_real;
|
||||
uint32_t instr = 0;
|
||||
uint32_t i_params[5] = {0};
|
||||
double f_params[4] = {0};
|
||||
typedef enum {
|
||||
main,
|
||||
until,
|
||||
debug,
|
||||
} ppc_exec_type_t;
|
||||
|
||||
max_cycles = 0;
|
||||
// inner interpreter loop
|
||||
template <ppc_exec_type_t exec_type>
|
||||
static void ppc_exec_inner(uint32_t start_addr, uint32_t size)
|
||||
{
|
||||
uint64_t max_cycles = 0;
|
||||
uint32_t page_start, eb_start, eb_end = 0;
|
||||
uint32_t opcode;
|
||||
uint32_t exec_flags; // execution control flags
|
||||
uint8_t* pc_real;
|
||||
|
||||
while (power_on) {
|
||||
// define boundaries of the next execution block
|
||||
// max execution block length = one memory page
|
||||
eb_start = ppc_state.pc;
|
||||
page_start = eb_start & PPC_PAGE_MASK;
|
||||
eb_end = page_start + PPC_PAGE_SIZE - 1;
|
||||
exec_flags = 0;
|
||||
if (exec_type == debug)
|
||||
if (ppc_state.pc >= start_addr && ppc_state.pc < start_addr + size)
|
||||
break;
|
||||
|
||||
pc_real = mmu_translate_imem(eb_start);
|
||||
instr = ppc_set_cur_instruction(pc_real);
|
||||
|
||||
// interpret execution block
|
||||
while (power_on && ppc_state.pc < eb_end) {
|
||||
ppc_main_opcode(instr);
|
||||
if (g_icycles++ >= max_cycles || exec_timer) {
|
||||
max_cycles = process_events();
|
||||
}
|
||||
|
||||
if (exec_flags) {
|
||||
// define next execution block
|
||||
eb_start = ppc_next_instruction_address;
|
||||
if (!(exec_flags & EXEF_RFI) && (eb_start & PPC_PAGE_MASK) == page_start) {
|
||||
pc_real += (int)eb_start - (int)ppc_state.pc;
|
||||
instr = ppc_set_cur_instruction(pc_real);
|
||||
} else {
|
||||
page_start = eb_start & PPC_PAGE_MASK;
|
||||
eb_end = page_start + PPC_PAGE_SIZE - 1;
|
||||
pc_real = mmu_translate_imem(eb_start);
|
||||
instr = ppc_set_cur_instruction(pc_real);
|
||||
}
|
||||
ppc_state.pc = eb_start;
|
||||
exec_flags = 0;
|
||||
} else {
|
||||
ppc_state.pc += 4;
|
||||
pc_real += 4;
|
||||
instr = ppc_set_cur_instruction(pc_real);
|
||||
}
|
||||
if (ppc_state.pc >= eb_end) {
|
||||
// define boundaries of the next execution block
|
||||
// max execution block length = one memory page
|
||||
eb_start = ppc_state.pc;
|
||||
page_start = eb_start & PPC_PAGE_MASK;
|
||||
eb_end = page_start + PPC_PAGE_SIZE - 1;
|
||||
pc_real = mmu_translate_imem(eb_start);
|
||||
}
|
||||
|
||||
opcode = ppc_read_instruction(pc_real);
|
||||
exec_flags = ppc_main_opcode(opcode);
|
||||
if (g_icycles++ >= max_cycles || exec_timer)
|
||||
max_cycles = process_events();
|
||||
|
||||
if (exec_flags) {
|
||||
// define next execution block
|
||||
eb_start = ppc_next_instruction_address;
|
||||
if (!(exec_flags & EXEF_RFI) && (eb_start & PPC_PAGE_MASK) == page_start) {
|
||||
pc_real += (int)eb_start - (int)ppc_state.pc;
|
||||
} else {
|
||||
page_start = eb_start & PPC_PAGE_MASK;
|
||||
eb_end = page_start + PPC_PAGE_SIZE - 1;
|
||||
pc_real = mmu_translate_imem(eb_start);
|
||||
}
|
||||
ppc_state.pc = eb_start;
|
||||
} else { [[likely]]
|
||||
ppc_state.pc += 4;
|
||||
pc_real += 4;
|
||||
}
|
||||
|
||||
if (exec_type == until)
|
||||
if (ppc_state.pc == start_addr)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** Execute PPC code as long as power is on. */
|
||||
|
||||
// inner interpreter loop
|
||||
template void ppc_exec_inner<main>(uint32_t start_addr, uint32_t size);
|
||||
|
||||
// outer interpreter loop
|
||||
void ppc_exec()
|
||||
{
|
||||
@@ -446,33 +325,30 @@ void ppc_exec()
|
||||
}
|
||||
|
||||
while (power_on) {
|
||||
ppc_exec_inner();
|
||||
ppc_exec_inner<main>(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/** Execute one PPC instruction. */
|
||||
void ppc_exec_single()
|
||||
{
|
||||
uint32_t exec_flags = 0;
|
||||
|
||||
if (setjmp(exc_env)) {
|
||||
// process low-level exceptions
|
||||
//LOG_F(9, "PPC-EXEC: low_level exception raised!");
|
||||
ppc_state.pc = ppc_next_instruction_address;
|
||||
exec_flags = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
mmu_translate_imem(ppc_state.pc);
|
||||
|
||||
uint8_t* pc_real = mmu_translate_imem(ppc_state.pc);
|
||||
uint32_t instr = ppc_set_cur_instruction(pc_real);
|
||||
ppc_main_opcode(instr);
|
||||
|
||||
uint32_t opcode = ppc_read_instruction(pc_real);
|
||||
exec_flags = ppc_main_opcode(opcode);
|
||||
g_icycles++;
|
||||
process_events();
|
||||
|
||||
if (exec_flags) {
|
||||
ppc_state.pc = ppc_next_instruction_address;
|
||||
exec_flags = 0;
|
||||
} else {
|
||||
ppc_state.pc += 4;
|
||||
}
|
||||
@@ -481,58 +357,7 @@ void ppc_exec_single()
|
||||
/** Execute PPC code until goal_addr is reached. */
|
||||
|
||||
// inner interpreter loop
|
||||
static void ppc_exec_until_inner(const uint32_t goal_addr)
|
||||
{
|
||||
uint64_t max_cycles;
|
||||
uint32_t page_start, eb_start, eb_end;
|
||||
uint8_t* pc_real;
|
||||
uint32_t instr;
|
||||
|
||||
max_cycles = 0;
|
||||
|
||||
do {
|
||||
// define boundaries of the next execution block
|
||||
// max execution block length = one memory page
|
||||
eb_start = ppc_state.pc;
|
||||
page_start = eb_start & PPC_PAGE_MASK;
|
||||
eb_end = page_start + PPC_PAGE_SIZE - 1;
|
||||
exec_flags = 0;
|
||||
|
||||
pc_real = mmu_translate_imem(eb_start);
|
||||
instr = ppc_set_cur_instruction(pc_real);
|
||||
|
||||
// interpret execution block
|
||||
while (power_on && ppc_state.pc < eb_end) {
|
||||
ppc_main_opcode(instr);
|
||||
if (g_icycles++ >= max_cycles || exec_timer) {
|
||||
max_cycles = process_events();
|
||||
}
|
||||
|
||||
if (exec_flags) {
|
||||
// define next execution block
|
||||
eb_start = ppc_next_instruction_address;
|
||||
if (!(exec_flags & EXEF_RFI) && (eb_start & PPC_PAGE_MASK) == page_start) {
|
||||
pc_real += (int)eb_start - (int)ppc_state.pc;
|
||||
instr = ppc_set_cur_instruction(pc_real);
|
||||
} else {
|
||||
page_start = eb_start & PPC_PAGE_MASK;
|
||||
eb_end = page_start + PPC_PAGE_SIZE - 1;
|
||||
pc_real = mmu_translate_imem(eb_start);
|
||||
instr = ppc_set_cur_instruction(pc_real);
|
||||
}
|
||||
ppc_state.pc = eb_start;
|
||||
exec_flags = 0;
|
||||
} else {
|
||||
ppc_state.pc += 4;
|
||||
pc_real += 4;
|
||||
instr = ppc_set_cur_instruction(pc_real);
|
||||
}
|
||||
|
||||
if (ppc_state.pc == goal_addr)
|
||||
break;
|
||||
}
|
||||
} while (power_on && ppc_state.pc != goal_addr);
|
||||
}
|
||||
template void ppc_exec_inner<until>(uint32_t start_addr, uint32_t size);
|
||||
|
||||
// outer interpreter loop
|
||||
void ppc_exec_until(volatile uint32_t goal_addr)
|
||||
@@ -543,64 +368,17 @@ void ppc_exec_until(volatile uint32_t goal_addr)
|
||||
ppc_state.pc = ppc_next_instruction_address;
|
||||
}
|
||||
|
||||
do {
|
||||
ppc_exec_until_inner(goal_addr);
|
||||
} while (power_on && ppc_state.pc != goal_addr);
|
||||
while (power_on) {
|
||||
ppc_exec_inner<until>(goal_addr, 0);
|
||||
if (ppc_state.pc == goal_addr)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** Execute PPC code until control is reached the specified region. */
|
||||
|
||||
// inner interpreter loop
|
||||
static void ppc_exec_dbg_inner(const uint32_t start_addr, const uint32_t size)
|
||||
{
|
||||
uint64_t max_cycles;
|
||||
uint32_t page_start, eb_start, eb_end;
|
||||
uint8_t* pc_real;
|
||||
uint32_t instr = 0;
|
||||
|
||||
max_cycles = 0;
|
||||
|
||||
while (power_on && (ppc_state.pc < start_addr || ppc_state.pc >= start_addr + size)) {
|
||||
// define boundaries of the next execution block
|
||||
// max execution block length = one memory page
|
||||
eb_start = ppc_state.pc;
|
||||
page_start = eb_start & PPC_PAGE_MASK;
|
||||
eb_end = page_start + PPC_PAGE_SIZE - 1;
|
||||
exec_flags = 0;
|
||||
|
||||
pc_real = mmu_translate_imem(eb_start);
|
||||
instr = ppc_set_cur_instruction(pc_real);
|
||||
|
||||
// interpret execution block
|
||||
while (power_on && (ppc_state.pc < start_addr || ppc_state.pc >= start_addr + size)
|
||||
&& (ppc_state.pc < eb_end)) {
|
||||
ppc_main_opcode(instr);
|
||||
if (g_icycles++ >= max_cycles || exec_timer) {
|
||||
max_cycles = process_events();
|
||||
}
|
||||
|
||||
if (exec_flags) {
|
||||
// define next execution block
|
||||
eb_start = ppc_next_instruction_address;
|
||||
if (!(exec_flags & EXEF_RFI) && (eb_start & PPC_PAGE_MASK) == page_start) {
|
||||
pc_real += (int)eb_start - (int)ppc_state.pc;
|
||||
instr = ppc_set_cur_instruction(pc_real);
|
||||
} else {
|
||||
page_start = eb_start & PPC_PAGE_MASK;
|
||||
eb_end = page_start + PPC_PAGE_SIZE - 1;
|
||||
pc_real = mmu_translate_imem(eb_start);
|
||||
instr = ppc_set_cur_instruction(pc_real);
|
||||
}
|
||||
ppc_state.pc = eb_start;
|
||||
exec_flags = 0;
|
||||
} else {
|
||||
ppc_state.pc += 4;
|
||||
pc_real += 4;
|
||||
instr = ppc_set_cur_instruction(pc_real);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
template void ppc_exec_inner<debug>(uint32_t start_addr, uint32_t size);
|
||||
|
||||
// outer interpreter loop
|
||||
void ppc_exec_dbg(volatile uint32_t start_addr, volatile uint32_t size)
|
||||
@@ -612,7 +390,7 @@ void ppc_exec_dbg(volatile uint32_t start_addr, volatile uint32_t size)
|
||||
}
|
||||
|
||||
while (power_on && (ppc_state.pc < start_addr || ppc_state.pc >= start_addr + size)) {
|
||||
ppc_exec_dbg_inner(start_addr, size);
|
||||
ppc_exec_inner<debug>(start_addr, size);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -622,73 +400,346 @@ Opcode table macros:
|
||||
- o is for overflow (OV).
|
||||
- c is for carry CARRY0/CARRY1. It also works for other options:
|
||||
SHFT0/SHFT1, RIGHT0/LEFT1, uint8_t/uint16_t/uint32_t, and int8_t/int16_t.
|
||||
- a is for absolute address (AA).
|
||||
- l is for link register (LK).
|
||||
- r is for raw (adding custom entries to the table)
|
||||
*/
|
||||
|
||||
#define OP(opcode, fn) \
|
||||
do { \
|
||||
OpcodeGrabber[opcode] = fn; \
|
||||
for (uint32_t mod = 0; mod < 2048; mod++) { \
|
||||
OpcodeGrabber[((opcode) << 11) | mod] = fn; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define OPX(opcode, subopcode, fn) \
|
||||
do { \
|
||||
opcode ## Grabber[((subopcode)<<1)] = fn; \
|
||||
OpcodeGrabber[((opcode) << 11) | ((subopcode)<<1)] = fn; \
|
||||
} while (0)
|
||||
|
||||
#define OPXd(opcode, subopcode, fn) \
|
||||
do { \
|
||||
opcode ## Grabber[((subopcode)<<1)] = fn<RC0>; \
|
||||
opcode ## Grabber[((subopcode)<<1)+1] = fn<RC1>; \
|
||||
OpcodeGrabber[((opcode) << 11) | ((subopcode)<<1) | 0x000] = fn<RC0>; \
|
||||
OpcodeGrabber[((opcode) << 11) | ((subopcode)<<1) | 0x001] = fn<RC1>; \
|
||||
} while (0)
|
||||
|
||||
#define OPXod(opcode, subopcode, fn) \
|
||||
do { \
|
||||
opcode ## Grabber[((subopcode)<<1)] = fn<RC0, OV0>; \
|
||||
opcode ## Grabber[((subopcode)<<1)+1] = fn<RC1, OV0>; \
|
||||
opcode ## Grabber[1024+((subopcode)<<1)] = fn<RC0, OV1>; \
|
||||
opcode ## Grabber[1024+((subopcode)<<1)+1] = fn<RC1, OV1>; \
|
||||
OpcodeGrabber[((opcode) << 11) | ((subopcode)<<1) | 0x000] = fn<RC0, OV0>; \
|
||||
OpcodeGrabber[((opcode) << 11) | ((subopcode)<<1) | 0x001] = fn<RC1, OV0>; \
|
||||
OpcodeGrabber[((opcode) << 11) | ((subopcode)<<1) | 0x400] = fn<RC0, OV1>; \
|
||||
OpcodeGrabber[((opcode) << 11) | ((subopcode)<<1) | 0x401] = fn<RC1, OV1>; \
|
||||
} while (0)
|
||||
|
||||
#define OPXdc(opcode, subopcode, fn, carry) \
|
||||
do { \
|
||||
opcode ## Grabber[((subopcode)<<1)] = fn<carry, RC0>; \
|
||||
opcode ## Grabber[((subopcode)<<1)+1] = fn<carry, RC1>; \
|
||||
OpcodeGrabber[((opcode) << 11) | ((subopcode)<<1) | 0x000] = fn<carry, RC0>; \
|
||||
OpcodeGrabber[((opcode) << 11) | ((subopcode)<<1) | 0x001] = fn<carry, RC1>; \
|
||||
} while (0)
|
||||
|
||||
#define OPXcod(opcode, subopcode, fn, carry) \
|
||||
do { \
|
||||
opcode ## Grabber[((subopcode)<<1)] = fn<carry, RC0, OV0>; \
|
||||
opcode ## Grabber[((subopcode)<<1)+1] = fn<carry, RC1, OV0>; \
|
||||
opcode ## Grabber[1024+((subopcode)<<1)] = fn<carry, RC0, OV1>; \
|
||||
opcode ## Grabber[1024+((subopcode)<<1)+1] = fn<carry, RC1, OV1>; \
|
||||
OpcodeGrabber[((opcode) << 11) | ((subopcode)<<1) | 0x000] = fn<carry, RC0, OV0>; \
|
||||
OpcodeGrabber[((opcode) << 11) | ((subopcode)<<1) | 0x001] = fn<carry, RC1, OV0>; \
|
||||
OpcodeGrabber[((opcode) << 11) | ((subopcode)<<1) | 0x400] = fn<carry, RC0, OV1>; \
|
||||
OpcodeGrabber[((opcode) << 11) | ((subopcode)<<1) | 0x401] = fn<carry, RC1, OV1>; \
|
||||
} while (0)
|
||||
|
||||
#define OP31(subopcode, fn) OPX(Opcode31, subopcode, fn)
|
||||
#define OP31d(subopcode, fn) OPXd(Opcode31, subopcode, fn)
|
||||
#define OP31od(subopcode, fn) OPXod(Opcode31, subopcode, fn)
|
||||
#define OP31dc(subopcode, fn, carry) OPXdc(Opcode31, subopcode, fn, carry)
|
||||
#define OP31cod(subopcode, fn, carry) OPXcod(Opcode31, subopcode, fn, carry)
|
||||
#define OPla(opcode, subopcode, fn) \
|
||||
do { \
|
||||
for (uint32_t mod = 0; mod < 512; mod++) { \
|
||||
OpcodeGrabber[((opcode) << 11) | (mod << 2) | (subopcode)] = fn; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define OP59d(subopcode, fn) OPXd(Opcode59, subopcode, fn)
|
||||
#define OPr(opcode, mod, fn) \
|
||||
do { \
|
||||
OpcodeGrabber[((opcode) << 11) | (mod)] = fn; \
|
||||
} while (0)
|
||||
|
||||
#define OP63(subopcode, fn) OPX(Opcode63, subopcode, fn)
|
||||
#define OP63d(subopcode, fn) OPXd(Opcode63, subopcode, fn)
|
||||
#define OP63dc(subopcode, fn, carry) OPXdc(Opcode63, subopcode, fn, carry)
|
||||
#define OP31(subopcode, fn) OPX(31, subopcode, fn)
|
||||
#define OP31d(subopcode, fn) OPXd(31, subopcode, fn)
|
||||
#define OP31od(subopcode, fn) OPXod(31, subopcode, fn)
|
||||
#define OP31dc(subopcode, fn, carry) OPXdc(31, subopcode, fn, carry)
|
||||
#define OP31cod(subopcode, fn, carry) OPXcod(31, subopcode, fn, carry)
|
||||
|
||||
inline void initialize_ppc_opcode_tables(bool include_601) {
|
||||
std::fill_n(OpcodeGrabber, 64, ppc_illegalop);
|
||||
std::fill_n(Opcode16Grabber, 3, ppc_illegalop);
|
||||
std::fill_n(Opcode18Grabber, 3, ppc_illegalop);
|
||||
std::fill_n(Opcode19Grabber, 2048, ppc_illegalop);
|
||||
std::fill_n(Opcode31Grabber, 2048, ppc_illegalop);
|
||||
std::fill_n(Opcode59Grabber, 64, ppc_illegalop);
|
||||
std::fill_n(Opcode63Grabber, 2048, ppc_illegalop);
|
||||
#define OP63(subopcode, fn) OPX(63, subopcode, fn)
|
||||
#define OP63d(subopcode, fn) OPXd(63, subopcode, fn)
|
||||
#define OP63dc(subopcode, fn, carry) OPXdc(63, subopcode, fn, carry)
|
||||
|
||||
#include "ppcopcodes.include"
|
||||
#include "poweropcodes.include"
|
||||
#include "ppcfpopcodes.include"
|
||||
#define OP59d(subopcode, fn) \
|
||||
do { \
|
||||
OPXd(59, (subopcode), fn); \
|
||||
} while (0)
|
||||
|
||||
#define OP59cd(subopcode, fn) \
|
||||
do { \
|
||||
for (uint32_t ccccc = 0; ccccc < 32; ccccc++) { \
|
||||
OPXd(59, (ccccc << 5) | (subopcode), fn); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define OP4_ccccc10xxxx(subopcode, fn) \
|
||||
do { \
|
||||
for (uint32_t ccccc = 0; ccccc < 32; ccccc++) { \
|
||||
OPr(4, (ccccc << 6) | (subopcode), fn); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
void initialize_ppc_opcode_table() {
|
||||
std::fill_n(OpcodeGrabber, 64 * 2048, ppc_illegalop);
|
||||
OP(3, ppc_twi);
|
||||
//OP(4, ppc_opcode4); - Altivec instructions not emulated yet. Uncomment once they're implemented.
|
||||
OP(7, ppc_mulli);
|
||||
OP(8, ppc_subfic);
|
||||
if (is_601 || include_601) OP(9, power_dozi);
|
||||
OP(10, ppc_cmpli);
|
||||
OP(11, ppc_cmpi);
|
||||
OP(12, ppc_addic<RC0>);
|
||||
OP(13, ppc_addic<RC1>);
|
||||
OP(14, ppc_addi<SHFT0>);
|
||||
OP(15, ppc_addi<SHFT1>);
|
||||
OP(17, ppc_sc);
|
||||
OP(20, ppc_rlwimi);
|
||||
OP(21, ppc_rlwinm);
|
||||
if (is_601 || include_601) OP(22, power_rlmi);
|
||||
OP(23, ppc_rlwnm);
|
||||
OP(24, ppc_ori<SHFT0>);
|
||||
OP(25, ppc_ori<SHFT1>);
|
||||
OP(26, ppc_xori<SHFT0>);
|
||||
OP(27, ppc_xori<SHFT1>);
|
||||
OP(28, ppc_andirc<SHFT0>);
|
||||
OP(29, ppc_andirc<SHFT1>);
|
||||
OP(32, ppc_lz<uint32_t>);
|
||||
OP(33, ppc_lzu<uint32_t>);
|
||||
OP(34, ppc_lz<uint8_t>);
|
||||
OP(35, ppc_lzu<uint8_t>);
|
||||
OP(36, ppc_st<uint32_t>);
|
||||
OP(37, ppc_stu<uint32_t>);
|
||||
OP(38, ppc_st<uint8_t>);
|
||||
OP(39, ppc_stu<uint8_t>);
|
||||
OP(40, ppc_lz<uint16_t>);
|
||||
OP(41, ppc_lzu<uint16_t>);
|
||||
OP(42, ppc_lha);
|
||||
OP(43, ppc_lhau);
|
||||
OP(44, ppc_st<uint16_t>);
|
||||
OP(45, ppc_stu<uint16_t>);
|
||||
OP(46, ppc_lmw);
|
||||
OP(47, ppc_stmw);
|
||||
OP(48, ppc_lfs);
|
||||
OP(49, ppc_lfsu);
|
||||
OP(50, ppc_lfd);
|
||||
OP(51, ppc_lfdu);
|
||||
OP(52, ppc_stfs);
|
||||
OP(53, ppc_stfsu);
|
||||
OP(54, ppc_stfd);
|
||||
OP(55, ppc_stfdu);
|
||||
|
||||
OPla(16, 0x0, (dppc_interpreter::ppc_bc<LK0, AA0>)); // bc
|
||||
OPla(16, 0x1, (dppc_interpreter::ppc_bc<LK1, AA0>)); // bcl
|
||||
OPla(16, 0x2, (dppc_interpreter::ppc_bc<LK0, AA1>)); // bca
|
||||
OPla(16, 0x3, (dppc_interpreter::ppc_bc<LK1, AA1>)); // bcla
|
||||
|
||||
OPla(18, 0x0, (dppc_interpreter::ppc_b<LK0, AA0>)); // b
|
||||
OPla(18, 0x1, (dppc_interpreter::ppc_b<LK1, AA0>)); // bl
|
||||
OPla(18, 0x2, (dppc_interpreter::ppc_b<LK0, AA1>)); // ba
|
||||
OPla(18, 0x3, (dppc_interpreter::ppc_b<LK1, AA1>)); // bla
|
||||
|
||||
OPr(19, 0, ppc_mcrf);
|
||||
OPr(19, 32, ppc_bclr<LK0>);
|
||||
OPr(19, 33, ppc_bclr<LK1>);
|
||||
OPr(19, 66, ppc_crnor);
|
||||
OPr(19, 100, ppc_rfi);
|
||||
OPr(19, 258, ppc_crandc);
|
||||
OPr(19, 300, ppc_isync);
|
||||
OPr(19, 386, ppc_crxor);
|
||||
OPr(19, 450, ppc_crnand);
|
||||
OPr(19, 514, ppc_crand);
|
||||
OPr(19, 578, ppc_creqv);
|
||||
OPr(19, 834, ppc_crorc);
|
||||
OPr(19, 898, ppc_cror);
|
||||
OPr(19, 1056, (is_601 ? ppc_bcctr<LK0, IS601> : ppc_bcctr<LK0, NOT601>));
|
||||
OPr(19, 1057, (is_601 ? ppc_bcctr<LK1, IS601> : ppc_bcctr<LK1, NOT601>));
|
||||
|
||||
OP31(0, ppc_cmp);
|
||||
OP31(4, ppc_tw);
|
||||
OP31(32, ppc_cmpl);
|
||||
|
||||
OP31cod(8, ppc_subf, CARRY1);
|
||||
OP31cod(40, ppc_subf, CARRY0);
|
||||
OP31od(104, ppc_neg);
|
||||
OP31od(136, ppc_subfe);
|
||||
OP31od(200, ppc_subfze);
|
||||
OP31od(232, ppc_subfme);
|
||||
|
||||
OP31cod(10, ppc_add, CARRY1);
|
||||
OP31od(138, ppc_adde);
|
||||
OP31od(202, ppc_addze);
|
||||
OP31od(234, ppc_addme);
|
||||
OP31cod(266, ppc_add, CARRY0);
|
||||
|
||||
OP31d(11, ppc_mulhwu);
|
||||
OP31d(75, ppc_mulhw);
|
||||
OP31od(235, ppc_mullw);
|
||||
OP31od(459, ppc_divwu);
|
||||
OP31od(491, ppc_divw);
|
||||
|
||||
OP31(20, ppc_lwarx);
|
||||
OP31(23, ppc_lzx<uint32_t>);
|
||||
OP31(55, ppc_lzux<uint32_t>);
|
||||
OP31(87, ppc_lzx<uint8_t>);
|
||||
OP31(119, ppc_lzux<uint8_t>);
|
||||
OP31(279, ppc_lzx<uint16_t>);
|
||||
OP31(311, ppc_lzux<uint16_t>);
|
||||
OP31(343, ppc_lhax);
|
||||
OP31(375, ppc_lhaux);
|
||||
OP31(533, ppc_lswx);
|
||||
OP31(534, ppc_lwbrx);
|
||||
OP31(535, ppc_lfsx);
|
||||
OP31(567, ppc_lfsux);
|
||||
OP31(597, ppc_lswi);
|
||||
OP31(599, ppc_lfdx);
|
||||
OP31(631, ppc_lfdux);
|
||||
OP31(790, ppc_lhbrx);
|
||||
|
||||
OPr(31, (150<<1) | 1, ppc_stwcx); // No Rc=0 variant.
|
||||
OP31(151, ppc_stx<uint32_t>);
|
||||
OP31(183, ppc_stux<uint32_t>);
|
||||
OP31(215, ppc_stx<uint8_t>);
|
||||
OP31(247, ppc_stux<uint8_t>);
|
||||
OP31(407, ppc_stx<uint16_t>);
|
||||
OP31(439, ppc_stux<uint16_t>);
|
||||
OP31(661, ppc_stswx);
|
||||
OP31(662, ppc_stwbrx);
|
||||
OP31(663, ppc_stfsx);
|
||||
OP31(695, ppc_stfsux);
|
||||
OP31(725, ppc_stswi);
|
||||
OP31(727, ppc_stfdx);
|
||||
OP31(759, ppc_stfdux);
|
||||
OP31(918, ppc_sthbrx);
|
||||
if (!is_601) OP31(983, ppc_stfiwx);
|
||||
|
||||
OP31(310, ppc_eciwx);
|
||||
OP31(438, ppc_ecowx);
|
||||
|
||||
OP31dc(24, ppc_shift, LEFT1); // slw
|
||||
OP31dc(28, ppc_logical, ppc_and);
|
||||
OP31dc(60, ppc_logical, ppc_andc);
|
||||
OP31dc(124, ppc_logical, ppc_nor);
|
||||
OP31dc(284, ppc_logical, ppc_eqv);
|
||||
OP31dc(316, ppc_logical, ppc_xor);
|
||||
OP31dc(412, ppc_logical, ppc_orc);
|
||||
OP31dc(444, ppc_logical, ppc_or);
|
||||
OP31dc(476, ppc_logical, ppc_nand);
|
||||
OP31dc(536, ppc_shift, RIGHT0); // srw
|
||||
OP31d(792, ppc_sraw);
|
||||
OP31d(824, ppc_srawi);
|
||||
OP31dc(922, ppc_exts, int16_t);
|
||||
OP31dc(954, ppc_exts, int8_t);
|
||||
|
||||
OP31d(26, ppc_cntlzw);
|
||||
|
||||
OP31(19, ppc_mfcr);
|
||||
OP31(83, ppc_mfmsr);
|
||||
OP31(144, ppc_mtcrf);
|
||||
OP31(146, ppc_mtmsr);
|
||||
OP31(210, ppc_mtsr);
|
||||
OP31(242, ppc_mtsrin);
|
||||
OP31(339, ppc_mfspr);
|
||||
if (!is_601) OP31(371, ppc_mftb);
|
||||
OP31(467, ppc_mtspr);
|
||||
OP31(512, ppc_mcrxr);
|
||||
OP31(595, ppc_mfsr);
|
||||
OP31(659, ppc_mfsrin);
|
||||
|
||||
OP31(54, ppc_dcbst);
|
||||
OP31(86, ppc_dcbf);
|
||||
OP31(246, ppc_dcbtst);
|
||||
OP31(278, ppc_dcbt);
|
||||
OP31(598, ppc_sync);
|
||||
OP31(470, ppc_dcbi);
|
||||
OP31(1014, ppc_dcbz);
|
||||
|
||||
if (is_601 || include_601) {
|
||||
OP31d(29, power_maskg);
|
||||
OP31od(107, power_mul);
|
||||
OP31d(152, power_slq);
|
||||
OP31d(153, power_sle);
|
||||
OP31d(184, power_sliq);
|
||||
OP31d(216, power_sllq);
|
||||
OP31d(217, power_sleq);
|
||||
OP31d(248, power_slliq);
|
||||
OP31od(264, power_doz);
|
||||
OP31d(277, power_lscbx);
|
||||
OP31od(331, power_div);
|
||||
OP31od(360, power_abs);
|
||||
OP31od(363, power_divs);
|
||||
OP31od(488, power_nabs);
|
||||
OP31(531, power_clcs);
|
||||
OP31d(537, power_rrib);
|
||||
OP31d(541, power_maskir);
|
||||
OP31d(664, power_srq);
|
||||
OP31d(665, power_sre);
|
||||
OP31d(696, power_sriq);
|
||||
OP31d(728, power_srlq);
|
||||
OP31d(729, power_sreq);
|
||||
OP31d(760, power_srliq);
|
||||
OP31d(920, power_sraq);
|
||||
OP31d(921, power_srea);
|
||||
OP31d(952, power_sraiq);
|
||||
}
|
||||
|
||||
OP31(306, ppc_tlbie);
|
||||
if (!is_601) OP31(370, ppc_tlbia);
|
||||
if (!is_601) OP31(566, ppc_tlbsync);
|
||||
OP31(854, ppc_eieio);
|
||||
OP31(982, ppc_icbi);
|
||||
if (!is_601) OP31(978, ppc_tlbld);
|
||||
if (!is_601) OP31(1010, ppc_tlbli);
|
||||
|
||||
OP59d(18, ppc_fdivs);
|
||||
OP59d(20, ppc_fsubs);
|
||||
OP59d(21, ppc_fadds);
|
||||
if (ppc_state.spr[SPR::PVR] == PPC_VER::MPC970MP) OP59d(22, ppc_fsqrts);
|
||||
if (!is_601) OP59d(24, ppc_fres);
|
||||
OP59cd(25, ppc_fmuls);
|
||||
OP59cd(28, ppc_fmsubs);
|
||||
OP59cd(29, ppc_fmadds);
|
||||
OP59cd(30, ppc_fnmsubs);
|
||||
OP59cd(31, ppc_fnmadds);
|
||||
|
||||
OP63(0, ppc_fcmpu);
|
||||
OP63d(12, ppc_frsp);
|
||||
OP63d(14, ppc_fctiw);
|
||||
OP63d(15, ppc_fctiwz);
|
||||
OP63d(18, ppc_fdiv);
|
||||
OP63d(20, ppc_fsub);
|
||||
OP63d(21, ppc_fadd);
|
||||
if (ppc_state.spr[SPR::PVR] == PPC_VER::MPC970MP) OP63d(22, ppc_fsqrt);
|
||||
if (!is_601) OP63d(26, ppc_frsqrte);
|
||||
OP63(32, ppc_fcmpo);
|
||||
OP63d(38, ppc_mtfsb1);
|
||||
OP63d(40, ppc_fneg);
|
||||
OP63(64, ppc_mcrfs);
|
||||
OP63d(70, ppc_mtfsb0);
|
||||
OP63d(72, ppc_fmr);
|
||||
OP63d(134, ppc_mtfsfi);
|
||||
OP63d(136, ppc_fnabs);
|
||||
OP63d(264, ppc_fabs);
|
||||
if (is_601) OP63dc(583, ppc_mffs, IS601); else OP63dc(583, ppc_mffs, NOT601);
|
||||
OP63d(711, ppc_mtfsf);
|
||||
|
||||
for (int i = 0; i < 1024; i += 32) {
|
||||
if (!is_601) OP63d(i + 23, ppc_fsel);
|
||||
OP63d(i + 25, ppc_fmul);
|
||||
OP63d(i + 28, ppc_fmsub);
|
||||
OP63d(i + 29, ppc_fmadd);
|
||||
OP63d(i + 30, ppc_fnmsub);
|
||||
OP63d(i + 31, ppc_fnmadd);
|
||||
}
|
||||
}
|
||||
|
||||
void ppc_cpu_init(MemCtrlBase* mem_ctrl, uint32_t cpu_version, bool include_601, uint64_t tb_freq)
|
||||
void ppc_cpu_init(MemCtrlBase* mem_ctrl, uint32_t cpu_version, bool do_include_601, uint64_t tb_freq)
|
||||
{
|
||||
mem_ctrl_instance = mem_ctrl;
|
||||
|
||||
@@ -697,8 +748,9 @@ void ppc_cpu_init(MemCtrlBase* mem_ctrl, uint32_t cpu_version, bool include_601,
|
||||
|
||||
ppc_state.spr[SPR::PVR] = cpu_version;
|
||||
is_601 = (cpu_version >> 16) == 1;
|
||||
include_601 = !is_601 & do_include_601;
|
||||
|
||||
initialize_ppc_opcode_tables(include_601);
|
||||
initialize_ppc_opcode_table();
|
||||
|
||||
// initialize emulator timers
|
||||
TimerManager::get_instance()->set_time_now_cb(&get_virt_time_ns);
|
||||
@@ -718,7 +770,6 @@ void ppc_cpu_init(MemCtrlBase* mem_ctrl, uint32_t cpu_version, bool include_601,
|
||||
tbr_freq_ghz = (tb_freq << 32) / NS_PER_SEC;
|
||||
tbr_period_ns = ((uint64_t)NS_PER_SEC << 32) / tb_freq;
|
||||
|
||||
exec_flags = 0;
|
||||
exec_timer = false;
|
||||
|
||||
timebase_counter = 0;
|
||||
@@ -745,9 +796,8 @@ void ppc_cpu_init(MemCtrlBase* mem_ctrl, uint32_t cpu_version, bool include_601,
|
||||
}
|
||||
|
||||
void print_fprs() {
|
||||
for (int i = 0; i < 32; i++) {
|
||||
for (int i = 0; i < 32; i++)
|
||||
cout << "FPR " << dec << i << " : " << ppc_state.fpr[i].dbl64_r << endl;
|
||||
}
|
||||
}
|
||||
|
||||
static map<string, int> SPRName2Num = {
|
||||
|
||||
+1271
-37
File diff suppressed because it is too large.
Load diff
@@ -1,681 +0,0 @@
|
||||
// Floating Point Arithmetic
|
||||
OPCODEREC (fadd, 63, 21,
|
||||
ppc_grab_regsfpdab(instr);
|
||||
|
||||
snan_double_check(reg_a, reg_b);
|
||||
max_double_check(val_reg_a, val_reg_b);
|
||||
|
||||
double ppc_dblresult64_d = val_reg_a + val_reg_b;
|
||||
ppc_store_dfpresult_flt(reg_d, ppc_dblresult64_d);
|
||||
fpresult_update(ppc_dblresult64_d);
|
||||
ppc_update_fex();
|
||||
|
||||
if (rec)
|
||||
ppc_update_cr1();
|
||||
)
|
||||
|
||||
OPCODEREC (fsub, 63, 20,
|
||||
ppc_grab_regsfpdab(instr);
|
||||
|
||||
snan_double_check(reg_a, reg_b);
|
||||
|
||||
double ppc_dblresult64_d = val_reg_a - val_reg_b;
|
||||
|
||||
ppc_store_dfpresult_flt(reg_d, ppc_dblresult64_d);
|
||||
fpresult_update(ppc_dblresult64_d);
|
||||
|
||||
if (rec)
|
||||
ppc_update_cr1();
|
||||
)
|
||||
|
||||
OPCODEREC (fdiv, 63, 18,
|
||||
ppc_grab_regsfpdab(instr);
|
||||
|
||||
snan_double_check(reg_a, reg_b);
|
||||
|
||||
double ppc_dblresult64_d = val_reg_a / val_reg_b;
|
||||
ppc_store_dfpresult_flt(reg_d, ppc_dblresult64_d);
|
||||
fpresult_update(ppc_dblresult64_d);
|
||||
|
||||
if (rec)
|
||||
ppc_update_cr1();
|
||||
)
|
||||
|
||||
OPCODERECF (fmul, 63, 25,
|
||||
ppc_grab_regsfpdac(instr);
|
||||
|
||||
snan_double_check(reg_a, reg_c);
|
||||
|
||||
double ppc_dblresult64_d = val_reg_a * val_reg_c;
|
||||
ppc_store_dfpresult_flt(reg_d, ppc_dblresult64_d);
|
||||
fpresult_update(ppc_dblresult64_d);
|
||||
|
||||
if (rec)
|
||||
ppc_update_cr1();
|
||||
)
|
||||
|
||||
OPCODERECF (fmadd, 63, 29,
|
||||
ppc_grab_regsfpdabc(instr);
|
||||
|
||||
snan_double_check(reg_a, reg_c);
|
||||
snan_single_check(reg_b);
|
||||
|
||||
double ppc_dblresult64_d = std::fma(val_reg_a, val_reg_c, val_reg_b);
|
||||
ppc_store_dfpresult_flt(reg_d, ppc_dblresult64_d);
|
||||
fpresult_update(ppc_dblresult64_d);
|
||||
|
||||
if (rec)
|
||||
ppc_update_cr1();
|
||||
)
|
||||
|
||||
OPCODERECF (fmsub, 63, 28,
|
||||
ppc_grab_regsfpdabc(instr);
|
||||
|
||||
snan_double_check(reg_a, reg_c);
|
||||
snan_single_check(reg_b);
|
||||
|
||||
double ppc_dblresult64_d = std::fma(val_reg_a, val_reg_c, -val_reg_b);
|
||||
ppc_store_dfpresult_flt(reg_d, ppc_dblresult64_d);
|
||||
fpresult_update(ppc_dblresult64_d);
|
||||
|
||||
if (rec)
|
||||
ppc_update_cr1();
|
||||
)
|
||||
|
||||
OPCODERECF (fnmadd, 63, 31,
|
||||
ppc_grab_regsfpdabc(instr);
|
||||
|
||||
snan_double_check(reg_a, reg_c);
|
||||
snan_single_check(reg_b);
|
||||
|
||||
double ppc_dblresult64_d = -std::fma(val_reg_a, val_reg_c, val_reg_b);
|
||||
ppc_store_dfpresult_flt(reg_d, ppc_dblresult64_d);
|
||||
fpresult_update(ppc_dblresult64_d);
|
||||
|
||||
if (rec)
|
||||
ppc_update_cr1();
|
||||
)
|
||||
|
||||
OPCODERECF (fnmsub, 63, 30,
|
||||
ppc_grab_regsfpdabc(instr);
|
||||
|
||||
snan_double_check(reg_a, reg_c);
|
||||
snan_single_check(reg_b);
|
||||
|
||||
double ppc_dblresult64_d = -std::fma(val_reg_a, val_reg_c, -val_reg_b);
|
||||
ppc_store_dfpresult_flt(reg_d, ppc_dblresult64_d);
|
||||
fpresult_update(ppc_dblresult64_d);
|
||||
|
||||
if (rec)
|
||||
ppc_update_cr1();
|
||||
)
|
||||
|
||||
OPCODEREC (fadds, 59, 21,
|
||||
ppc_grab_regsfpdab(instr);
|
||||
|
||||
snan_double_check(reg_a, reg_b);
|
||||
|
||||
double ppc_dblresult64_d = (float)(val_reg_a + val_reg_b);
|
||||
ppc_store_sfpresult_flt(reg_d, ppc_dblresult64_d);
|
||||
|
||||
fpresult_update(ppc_dblresult64_d);
|
||||
|
||||
if (rec)
|
||||
ppc_update_cr1();
|
||||
)
|
||||
|
||||
OPCODEREC (fsubs, 59, 20,
|
||||
ppc_grab_regsfpdab(instr);
|
||||
|
||||
snan_double_check(reg_a, reg_b);
|
||||
|
||||
double ppc_dblresult64_d = (float)(val_reg_a - val_reg_b);
|
||||
|
||||
ppc_store_sfpresult_flt(reg_d, ppc_dblresult64_d);
|
||||
fpresult_update(ppc_dblresult64_d);
|
||||
|
||||
if (rec)
|
||||
ppc_update_cr1();
|
||||
)
|
||||
|
||||
OPCODEREC (fdivs, 59, 18,
|
||||
ppc_grab_regsfpdab(instr);
|
||||
|
||||
snan_double_check(reg_a, reg_b);
|
||||
|
||||
double ppc_dblresult64_d = (float)(val_reg_a / val_reg_b);
|
||||
ppc_store_sfpresult_flt(reg_d, ppc_dblresult64_d);
|
||||
fpresult_update(ppc_dblresult64_d);
|
||||
|
||||
if (rec)
|
||||
ppc_update_cr1();
|
||||
)
|
||||
|
||||
OPCODEREC (fmuls, 59, 25,
|
||||
ppc_grab_regsfpdac(instr);
|
||||
|
||||
snan_double_check(reg_a, reg_c);
|
||||
|
||||
double ppc_dblresult64_d = (float)(val_reg_a * val_reg_c);
|
||||
ppc_store_sfpresult_flt(reg_d, ppc_dblresult64_d);
|
||||
fpresult_update(ppc_dblresult64_d);
|
||||
|
||||
if (rec)
|
||||
ppc_update_cr1();
|
||||
)
|
||||
|
||||
OPCODEREC (fmadds, 59, 29,
|
||||
ppc_grab_regsfpdabc(instr);
|
||||
|
||||
snan_double_check(reg_a, reg_c);
|
||||
snan_single_check(reg_b);
|
||||
|
||||
double ppc_dblresult64_d = (float)std::fma(val_reg_a, val_reg_c, val_reg_b);
|
||||
ppc_store_sfpresult_flt(reg_d, ppc_dblresult64_d);
|
||||
fpresult_update(ppc_dblresult64_d);
|
||||
|
||||
if (rec)
|
||||
ppc_update_cr1();
|
||||
)
|
||||
|
||||
OPCODEREC (fmsubs, 59, 28,
|
||||
ppc_grab_regsfpdabc(instr);
|
||||
|
||||
snan_double_check(reg_a, reg_c);
|
||||
snan_single_check(reg_b);
|
||||
|
||||
double ppc_dblresult64_d = (float)std::fma(val_reg_a, val_reg_c, -val_reg_b);
|
||||
ppc_store_sfpresult_flt(reg_d, ppc_dblresult64_d);
|
||||
fpresult_update(ppc_dblresult64_d);
|
||||
|
||||
if (rec)
|
||||
ppc_update_cr1();
|
||||
)
|
||||
|
||||
OPCODEREC (fnmadds, 59, 31,
|
||||
ppc_grab_regsfpdabc(instr);
|
||||
|
||||
snan_double_check(reg_a, reg_c);
|
||||
snan_single_check(reg_b);
|
||||
|
||||
double ppc_dblresult64_d = -(float)std::fma(val_reg_a, val_reg_c, val_reg_b);
|
||||
ppc_store_sfpresult_flt(reg_d, ppc_dblresult64_d);
|
||||
fpresult_update(ppc_dblresult64_d);
|
||||
|
||||
if (rec)
|
||||
ppc_update_cr1();
|
||||
)
|
||||
|
||||
OPCODEREC (fnmsubs, 59, 30,
|
||||
ppc_grab_regsfpdabc(instr);
|
||||
|
||||
snan_double_check(reg_a, reg_c);
|
||||
snan_single_check(reg_b);
|
||||
|
||||
double ppc_dblresult64_d = -(float)std::fma(val_reg_a, val_reg_c, -val_reg_b);
|
||||
ppc_store_sfpresult_flt(reg_d, ppc_dblresult64_d);
|
||||
fpresult_update(ppc_dblresult64_d);
|
||||
|
||||
if (rec)
|
||||
ppc_update_cr1();
|
||||
)
|
||||
|
||||
OPCODEREC (fabs, 63, 264,
|
||||
ppc_grab_regsfpdb(instr);
|
||||
|
||||
snan_single_check(reg_b);
|
||||
|
||||
double ppc_dblresult64_d = abs(GET_FPR(reg_b));
|
||||
|
||||
ppc_store_dfpresult_flt(reg_d, ppc_dblresult64_d);
|
||||
|
||||
if (rec)
|
||||
ppc_update_cr1();
|
||||
)
|
||||
|
||||
OPCODEREC(fnabs, 63, 136,
|
||||
ppc_grab_regsfpdb(instr);
|
||||
|
||||
snan_single_check(reg_b);
|
||||
|
||||
double ppc_dblresult64_d = abs(GET_FPR(reg_b));
|
||||
ppc_dblresult64_d = -ppc_dblresult64_d;
|
||||
|
||||
ppc_store_dfpresult_flt(reg_d, ppc_dblresult64_d);
|
||||
|
||||
if (rec)
|
||||
ppc_update_cr1();
|
||||
)
|
||||
|
||||
OPCODEREC(fneg, 63, 40,
|
||||
ppc_grab_regsfpdb(instr);
|
||||
|
||||
snan_single_check(reg_b);
|
||||
|
||||
double ppc_dblresult64_d = -(GET_FPR(reg_b));
|
||||
|
||||
ppc_store_dfpresult_flt(reg_d, ppc_dblresult64_d);
|
||||
|
||||
if (rec)
|
||||
ppc_update_cr1();
|
||||
)
|
||||
|
||||
OPCODERECF(fsel, 63, 23,
|
||||
ppc_grab_regsfpdabc(instr);
|
||||
|
||||
double ppc_dblresult64_d = (val_reg_a >= -0.0) ? val_reg_c : val_reg_b;
|
||||
|
||||
ppc_store_dfpresult_flt(reg_d, ppc_dblresult64_d);
|
||||
|
||||
if (rec)
|
||||
ppc_update_cr1();
|
||||
)
|
||||
|
||||
OPCODEREC(fsqrt, 63, 22,
|
||||
ppc_grab_regsfpdb(instr);
|
||||
|
||||
snan_single_check(reg_b);
|
||||
|
||||
double testd2 = (double)(GET_FPR(reg_b));
|
||||
double ppc_dblresult64_d = std::sqrt(testd2);
|
||||
ppc_store_dfpresult_flt(reg_d, ppc_dblresult64_d);
|
||||
|
||||
if (rec)
|
||||
ppc_update_cr1();
|
||||
)
|
||||
|
||||
OPCODEREC(fsqrts, 59, 22,
|
||||
ppc_grab_regsfpdb(instr);
|
||||
|
||||
snan_single_check(reg_b);
|
||||
|
||||
double testd2 = (double)(GET_FPR(reg_b));
|
||||
double ppc_dblresult64_d = (float)std::sqrt(testd2);
|
||||
ppc_store_sfpresult_flt(reg_d, ppc_dblresult64_d);
|
||||
|
||||
if (rec)
|
||||
ppc_update_cr1();
|
||||
)
|
||||
|
||||
OPCODEREC (frsqrte, 63, 26,
|
||||
ppc_grab_regsfpdb(instr);
|
||||
snan_single_check(reg_b);
|
||||
|
||||
double testd2 = (double)(GET_FPR(reg_b));
|
||||
double ppc_dblresult64_d = 1.0 / sqrt(testd2);
|
||||
ppc_store_dfpresult_flt(reg_d, ppc_dblresult64_d);
|
||||
|
||||
if (rec)
|
||||
ppc_update_cr1();
|
||||
)
|
||||
|
||||
OPCODEREC (frsp, 63, 12,
|
||||
ppc_grab_regsfpdb(instr);
|
||||
snan_single_check(reg_b);
|
||||
|
||||
double ppc_dblresult64_d = (float)(GET_FPR(reg_b));
|
||||
ppc_store_dfpresult_flt(reg_d, ppc_dblresult64_d);
|
||||
|
||||
if (rec)
|
||||
ppc_update_cr1();
|
||||
)
|
||||
|
||||
OPCODEREC (fres, 63, 24,
|
||||
ppc_grab_regsfpdb(instr);
|
||||
|
||||
snan_single_check(reg_b);
|
||||
|
||||
double start_num = GET_FPR(reg_b);
|
||||
double ppc_dblresult64_d = (float)(1.0 / start_num);
|
||||
ppc_store_dfpresult_flt(reg_d, ppc_dblresult64_d);
|
||||
|
||||
if (start_num == 0.0) {
|
||||
ppc_state.fpscr |= FPSCR::ZX;
|
||||
}
|
||||
else if (std::isnan(start_num)) {
|
||||
ppc_state.fpscr |= FPSCR::VXSNAN;
|
||||
}
|
||||
else if (std::isinf(start_num)){
|
||||
ppc_state.fpscr &= 0xFFF9FFFF;
|
||||
ppc_state.fpscr |= FPSCR::VXSNAN;
|
||||
}
|
||||
|
||||
if (rec)
|
||||
ppc_update_cr1();
|
||||
)
|
||||
|
||||
OPCODEREC (fctiw, 63, 14,
|
||||
round_to_int(instr, ppc_state.fpscr & 0x3, rec);
|
||||
)
|
||||
|
||||
OPCODEREC (fctiwz, 63, 15,
|
||||
round_to_int(instr, 1, rec);
|
||||
)
|
||||
|
||||
// Floating Point Store and Load
|
||||
|
||||
OPCODE (lfs, , 48,
|
||||
ppc_grab_regsfpdia(instr);
|
||||
uint32_t ea = int32_t(int16_t(instr));
|
||||
ea += (reg_a) ? val_reg_a : 0;
|
||||
uint32_t result = mmu_read_vmem<uint32_t>(ea, instr);
|
||||
ppc_state.fpr[reg_d].dbl64_r = *(float*)(&result);
|
||||
)
|
||||
|
||||
OPCODE (lfsu, , 49,
|
||||
ppc_grab_regsfpdia(instr);
|
||||
if (reg_a) {
|
||||
uint32_t ea = int32_t(int16_t(instr));
|
||||
ea += (reg_a) ? val_reg_a : 0;
|
||||
uint32_t result = mmu_read_vmem<uint32_t>(ea, instr);
|
||||
ppc_state.fpr[reg_d].dbl64_r = *(float*)(&result);
|
||||
ppc_state.gpr[reg_a] = ea;
|
||||
} else {
|
||||
ppc_exception_handler(Except_Type::EXC_PROGRAM, Exc_Cause::ILLEGAL_OP);
|
||||
}
|
||||
)
|
||||
|
||||
OPCODE31 (lfsx, 31, 535,
|
||||
ppc_grab_regsfpdiab(instr);
|
||||
uint32_t ea = val_reg_b + (reg_a ? val_reg_a : 0);
|
||||
uint32_t result = mmu_read_vmem<uint32_t>(ea, instr);
|
||||
ppc_state.fpr[reg_d].dbl64_r = *(float*)(&result);
|
||||
)
|
||||
|
||||
OPCODE31 (lfsux, 31, 567,
|
||||
ppc_grab_regsfpdiab(instr);
|
||||
if (reg_a) {
|
||||
uint32_t ea = val_reg_a + val_reg_b;
|
||||
uint32_t result = mmu_read_vmem<uint32_t>(ea, instr);
|
||||
ppc_state.fpr[reg_d].dbl64_r = *(float*)(&result);
|
||||
ppc_state.gpr[reg_a] = ea;
|
||||
} else {
|
||||
ppc_exception_handler(Except_Type::EXC_PROGRAM, Exc_Cause::ILLEGAL_OP);
|
||||
}
|
||||
)
|
||||
|
||||
OPCODE (lfd, , 50,
|
||||
ppc_grab_regsfpdia(instr);
|
||||
uint32_t ea = int32_t(int16_t(instr));
|
||||
ea += (reg_a) ? val_reg_a : 0;
|
||||
uint64_t ppc_result64_d = mmu_read_vmem<uint64_t>(ea, instr);
|
||||
ppc_store_dfpresult_int(reg_d, ppc_result64_d);
|
||||
)
|
||||
|
||||
OPCODE (lfdu, , 51,
|
||||
ppc_grab_regsfpdia(instr);
|
||||
if (reg_a != 0) {
|
||||
uint32_t ea = int32_t(int16_t(instr));
|
||||
ea += val_reg_a;
|
||||
uint64_t ppc_result64_d = mmu_read_vmem<uint64_t>(ea, instr);
|
||||
ppc_store_dfpresult_int(reg_d, ppc_result64_d);
|
||||
ppc_state.gpr[reg_a] = ea;
|
||||
} else {
|
||||
ppc_exception_handler(Except_Type::EXC_PROGRAM, Exc_Cause::ILLEGAL_OP);
|
||||
}
|
||||
)
|
||||
|
||||
OPCODE31 (lfdx, 31, 599,
|
||||
ppc_grab_regsfpdiab(instr);
|
||||
uint32_t ea = val_reg_b + (reg_a ? val_reg_a : 0);
|
||||
uint64_t ppc_result64_d = mmu_read_vmem<uint64_t>(ea, instr);
|
||||
ppc_store_dfpresult_int(reg_d, ppc_result64_d);
|
||||
)
|
||||
|
||||
OPCODE31 (lfdux, 31, 631,
|
||||
ppc_grab_regsfpdiab(instr);
|
||||
if (reg_a) {
|
||||
uint32_t ea = val_reg_a + val_reg_b;
|
||||
uint64_t ppc_result64_d = mmu_read_vmem<uint64_t>(ea, instr);
|
||||
ppc_store_dfpresult_int(reg_d, ppc_result64_d);
|
||||
ppc_state.gpr[reg_a] = ea;
|
||||
} else {
|
||||
ppc_exception_handler(Except_Type::EXC_PROGRAM, Exc_Cause::ILLEGAL_OP);
|
||||
}
|
||||
)
|
||||
|
||||
OPCODE (stfs, , 52,
|
||||
ppc_grab_regsfpsia(instr);
|
||||
uint32_t ea = int32_t(int16_t(instr));
|
||||
ea += (reg_a) ? val_reg_a : 0;
|
||||
float result = float(ppc_state.fpr[reg_s].dbl64_r);
|
||||
mmu_write_vmem<uint32_t>(ea, instr, *(uint32_t*)(&result));
|
||||
)
|
||||
|
||||
OPCODE (stfsu, , 53,
|
||||
ppc_grab_regsfpsia(instr);
|
||||
if (reg_a != 0) {
|
||||
uint32_t ea = int32_t(int16_t(instr));
|
||||
ea += val_reg_a;
|
||||
float result = float(ppc_state.fpr[reg_s].dbl64_r);
|
||||
mmu_write_vmem<uint32_t>(ea, instr, *(uint32_t*)(&result));
|
||||
ppc_state.gpr[reg_a] = ea;
|
||||
} else {
|
||||
ppc_exception_handler(Except_Type::EXC_PROGRAM, Exc_Cause::ILLEGAL_OP);
|
||||
}
|
||||
)
|
||||
|
||||
OPCODE31 (stfsx, 31, 663,
|
||||
ppc_grab_regsfpsiab(instr);
|
||||
uint32_t ea = val_reg_b + (reg_a ? val_reg_a : 0);
|
||||
float result = float(ppc_state.fpr[reg_s].dbl64_r);
|
||||
mmu_write_vmem<uint32_t>(ea, instr, *(uint32_t*)(&result));
|
||||
)
|
||||
|
||||
OPCODE31 (stfsux, 31, 695,
|
||||
ppc_grab_regsfpsiab(instr);
|
||||
if (reg_a) {
|
||||
uint32_t ea = val_reg_a + val_reg_b;
|
||||
float result = float(ppc_state.fpr[reg_s].dbl64_r);
|
||||
mmu_write_vmem<uint32_t>(ea, instr, *(uint32_t*)(&result));
|
||||
ppc_state.gpr[reg_a] = ea;
|
||||
} else {
|
||||
ppc_exception_handler(Except_Type::EXC_PROGRAM, Exc_Cause::ILLEGAL_OP);
|
||||
}
|
||||
)
|
||||
|
||||
OPCODE (stfd, , 54,
|
||||
ppc_grab_regsfpsia(instr);
|
||||
uint32_t ea = int32_t(int16_t(instr));
|
||||
ea += reg_a ? val_reg_a : 0;
|
||||
mmu_write_vmem<uint64_t>(ea, instr, ppc_state.fpr[reg_s].int64_r);
|
||||
)
|
||||
|
||||
OPCODE (stfdu, , 55,
|
||||
ppc_grab_regsfpsia(instr);
|
||||
if (reg_a != 0) {
|
||||
uint32_t ea = int32_t(int16_t(instr));
|
||||
ea += val_reg_a;
|
||||
mmu_write_vmem<uint64_t>(ea, instr, ppc_state.fpr[reg_s].int64_r);
|
||||
ppc_state.gpr[reg_a] = ea;
|
||||
} else {
|
||||
ppc_exception_handler(Except_Type::EXC_PROGRAM, Exc_Cause::ILLEGAL_OP);
|
||||
}
|
||||
)
|
||||
|
||||
OPCODE31 (stfdx, 31, 727,
|
||||
ppc_grab_regsfpsiab(instr);
|
||||
uint32_t ea = val_reg_b + (reg_a ? val_reg_a : 0);
|
||||
mmu_write_vmem<uint64_t>(ea, instr, ppc_state.fpr[reg_s].int64_r);
|
||||
)
|
||||
|
||||
OPCODE31 (stfdux, 31, 759,
|
||||
ppc_grab_regsfpsiab(instr);
|
||||
if (reg_a != 0) {
|
||||
uint32_t ea = val_reg_a + val_reg_b;
|
||||
mmu_write_vmem<uint64_t>(ea, instr, ppc_state.fpr[reg_s].int64_r);
|
||||
ppc_state.gpr[reg_a] = ea;
|
||||
} else {
|
||||
ppc_exception_handler(Except_Type::EXC_PROGRAM, Exc_Cause::ILLEGAL_OP);
|
||||
}
|
||||
)
|
||||
|
||||
OPCODE31 (stfiwx, 31, 983,
|
||||
ppc_grab_regsfpsiab(instr);
|
||||
uint32_t ea = val_reg_b + (reg_a ? val_reg_a : 0);
|
||||
mmu_write_vmem<uint32_t>(ea, instr, uint32_t(ppc_state.fpr[reg_s].int64_r));
|
||||
)
|
||||
|
||||
// Floating Point Register Transfer
|
||||
|
||||
OPCODEREC (fmr, 63, 72,
|
||||
ppc_grab_regsfpdb(instr);
|
||||
ppc_state.fpr[reg_d].dbl64_r = ppc_state.fpr[reg_b].dbl64_r;
|
||||
|
||||
if (rec)
|
||||
ppc_update_cr1();
|
||||
)
|
||||
|
||||
OPCODE601REC (mffs, 63, 583,
|
||||
int reg_d = (instr >> 21) & 31;
|
||||
|
||||
ppc_state.fpr[reg_d].int64_r = uint64_t(ppc_state.fpscr) | (for601 ? 0xFFFFFFFF00000000ULL : 0xFFF8000000000000ULL);
|
||||
|
||||
if (rec)
|
||||
ppc_update_cr1();
|
||||
)
|
||||
|
||||
OPCODEREC (mtfsf, 63, 711,
|
||||
ppc_grab_mtfsf(instr);
|
||||
|
||||
uint32_t cr_mask = 0;
|
||||
|
||||
if (fm == 0xFFU) { // the fast case
|
||||
cr_mask = 0xFFFFFFFFUL;
|
||||
}
|
||||
else { // the slow case
|
||||
if (fm & 0x80) cr_mask |= 0xF0000000UL;
|
||||
if (fm & 0x40) cr_mask |= 0x0F000000UL;
|
||||
if (fm & 0x20) cr_mask |= 0x00F00000UL;
|
||||
if (fm & 0x10) cr_mask |= 0x000F0000UL;
|
||||
if (fm & 0x08) cr_mask |= 0x0000F000UL;
|
||||
if (fm & 0x04) cr_mask |= 0x00000F00UL;
|
||||
if (fm & 0x02) cr_mask |= 0x000000F0UL;
|
||||
if (fm & 0x01) cr_mask |= 0x0000000FUL;
|
||||
}
|
||||
|
||||
// ensure neither FEX nor VX will be changed
|
||||
cr_mask &= ~(FPSCR::FEX | FPSCR::VX);
|
||||
|
||||
// copy FPR[reg_b] to FPSCR under control of cr_mask
|
||||
ppc_state.fpscr = (ppc_state.fpscr & ~cr_mask) | (ppc_state.fpr[reg_b].int64_r & cr_mask);
|
||||
|
||||
if (rec) {
|
||||
ppc_update_cr1();
|
||||
}
|
||||
)
|
||||
|
||||
OPCODEREC (mtfsfi, 63, 134,
|
||||
ppc_grab_mtfsfi(instr);
|
||||
|
||||
// prepare field mask and ensure that neither FEX nor VX will be changed
|
||||
uint32_t mask = (0xF0000000UL >> crf_d) & ~(FPSCR::FEX | FPSCR::VX);
|
||||
|
||||
// copy imm to FPSCR[crf_d] under control of the field mask
|
||||
ppc_state.fpscr = (ppc_state.fpscr & ~mask) | ((imm >> crf_d) & mask);
|
||||
|
||||
// Update FEX and VX according to the "usual rule"
|
||||
ppc_update_vx();
|
||||
ppc_update_fex();
|
||||
|
||||
if (rec) {
|
||||
ppc_update_cr1();
|
||||
}
|
||||
)
|
||||
|
||||
OPCODE31 (mtfsb0, 63, 70,
|
||||
int crf_d = (instr >> 21) & 0x1F;
|
||||
if (!crf_d || (crf_d > 2)) { // FEX and VX can't be explicitly cleared
|
||||
ppc_state.fpscr &= ~(0x80000000UL >> crf_d);
|
||||
}
|
||||
|
||||
if (rec)
|
||||
ppc_update_cr1();
|
||||
)
|
||||
|
||||
OPCODE31 (mtfsb1, 63, 38,
|
||||
ppc_grab_crfd(instr);
|
||||
if (!crf_d || (crf_d > 2)) { // FEX and VX can't be explicitly set
|
||||
ppc_state.fpscr |= (0x80000000UL >> crf_d);
|
||||
}
|
||||
|
||||
if (rec) {
|
||||
ppc_update_cr1();
|
||||
}
|
||||
)
|
||||
|
||||
OPCODE31 (mcrfs, 63, 64,
|
||||
ppc_grab_crfds(instr);
|
||||
ppc_state.cr = (
|
||||
(ppc_state.cr & ~(0xF0000000UL >> crf_d)) |
|
||||
(((ppc_state.fpscr << crf_s) & 0xF0000000UL) >> crf_d)
|
||||
);
|
||||
ppc_state.fpscr &= ~((0xF0000000UL >> crf_s) & (
|
||||
// keep only the FPSCR bits that can be explicitly cleared
|
||||
FPSCR::FX | FPSCR::OX |
|
||||
FPSCR::UX | FPSCR::ZX | FPSCR::XX | FPSCR::VXSNAN |
|
||||
FPSCR::VXISI | FPSCR::VXIDI | FPSCR::VXZDZ | FPSCR::VXIMZ |
|
||||
FPSCR::VXVC |
|
||||
FPSCR::VXSOFT | FPSCR::VXSQRT | FPSCR::VXCVI
|
||||
));
|
||||
)
|
||||
|
||||
// Floating Point Comparisons
|
||||
|
||||
OPCODE31 (fcmpo, 63, 32,
|
||||
ppc_grab_regsfpsab(instr);
|
||||
|
||||
uint32_t cmp_c = 0;
|
||||
|
||||
if (std::isnan(db_test_a) || std::isnan(db_test_b)) {
|
||||
cmp_c |= CRx_bit::CR_SO;
|
||||
ppc_state.fpscr |= FX | VX;
|
||||
if (check_snan(reg_a) || check_snan(reg_b)) {
|
||||
ppc_state.fpscr |= VXSNAN;
|
||||
}
|
||||
if (!(ppc_state.fpscr & FEX) || check_qnan(reg_a) || check_qnan(reg_b)) {
|
||||
ppc_state.fpscr |= VXVC;
|
||||
}
|
||||
}
|
||||
else if (db_test_a < db_test_b) {
|
||||
cmp_c |= CRx_bit::CR_LT;
|
||||
}
|
||||
else if (db_test_a > db_test_b) {
|
||||
cmp_c |= CRx_bit::CR_GT;
|
||||
}
|
||||
else {
|
||||
cmp_c |= CRx_bit::CR_EQ;
|
||||
}
|
||||
|
||||
ppc_state.fpscr &= ~VE; //kludge to pass tests
|
||||
ppc_state.fpscr = (ppc_state.fpscr & ~FPSCR::FPCC_MASK) | (cmp_c >> 16); // update FPCC
|
||||
ppc_state.cr = ((ppc_state.cr & ~(0xF0000000 >> crf_d)) | (cmp_c >> crf_d));
|
||||
|
||||
)
|
||||
|
||||
OPCODE (fcmpu, 63, 0,
|
||||
ppc_grab_regsfpsab(instr);
|
||||
|
||||
uint32_t cmp_c = 0;
|
||||
|
||||
if (std::isnan(db_test_a) || std::isnan(db_test_b)) {
|
||||
cmp_c |= CRx_bit::CR_SO;
|
||||
if (check_snan(reg_a) || check_snan(reg_b)) {
|
||||
ppc_state.fpscr |= FX | VX | VXSNAN;
|
||||
}
|
||||
}
|
||||
else if (db_test_a < db_test_b) {
|
||||
cmp_c |= CRx_bit::CR_LT;
|
||||
}
|
||||
else if (db_test_a > db_test_b) {
|
||||
cmp_c |= CRx_bit::CR_GT;
|
||||
}
|
||||
else {
|
||||
cmp_c |= CRx_bit::CR_EQ;
|
||||
}
|
||||
|
||||
ppc_state.fpscr &= ~VE; //kludge to pass tests
|
||||
ppc_state.fpscr = (ppc_state.fpscr & ~FPSCR::FPCC_MASK) | (cmp_c >> 16); // update FPCC
|
||||
ppc_state.cr = ((ppc_state.cr & ~(0xF0000000UL >> crf_d)) | (cmp_c >> crf_d));
|
||||
|
||||
)
|
||||
@@ -23,29 +23,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#define PPC_MACROS_H
|
||||
|
||||
#include <cinttypes>
|
||||
#include "ppcemu.h"
|
||||
|
||||
|
||||
#define ppc_set_cr(entry) \
|
||||
ppc_state.cr |= entry
|
||||
|
||||
#define ppc_unset_cr(entry) \
|
||||
ppc_state.cr &= ~entry
|
||||
|
||||
#define ppc_set_xer(entry) \
|
||||
ppc_state.spr[SPR::XER] |= entry
|
||||
|
||||
#define ppc_unset_xer(entry) \
|
||||
ppc_state.spr[SPR::XER] &= ~entry
|
||||
|
||||
#define power_store_mq(entry) \
|
||||
ppc_state.spr[SPR::MQ] = entry
|
||||
|
||||
#define power_store_ctr(entry) \
|
||||
ppc_state.spr[SPR::CTR] = entry
|
||||
|
||||
#define power_store_mq(entry) \
|
||||
ppc_state.spr[SPR::MQ] = entry
|
||||
|
||||
#define ppc_grab_regsdasimm(opcode) \
|
||||
int reg_d = (opcode >> 21) & 31; \
|
||||
@@ -77,10 +54,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
uint32_t uimm = uint16_t(opcode); \
|
||||
uint32_t ppc_result_a = ppc_state.gpr[reg_a];
|
||||
|
||||
#define ppc_grab_crfds(opcode) \
|
||||
int crf_d = (instr >> 21) & 0x1C; \
|
||||
int crf_s = (instr >> 16) & 0x1C;
|
||||
|
||||
#define ppc_grab_da(opcode)\
|
||||
int reg_d = (opcode >> 21) & 31;\
|
||||
int reg_a = (opcode >> 16) & 31;\
|
||||
@@ -107,7 +80,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
int reg_b = (opcode >> 11) & 31; \
|
||||
uint32_t ppc_result_d = ppc_state.gpr[reg_s]; \
|
||||
uint32_t ppc_result_a = ppc_state.gpr[reg_a]; \
|
||||
uint32_t ppc_result_b = ppc_state.gpr[reg_b];
|
||||
uint32_t ppc_result_b = ppc_state.gpr[reg_b]; \
|
||||
|
||||
#define ppc_grab_regssab_stswx(opcode) \
|
||||
int reg_s = (opcode >> 21) & 31; \
|
||||
@@ -136,45 +109,41 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#define ppc_grab_regssash(opcode) \
|
||||
int reg_s = (opcode >> 21) & 31; \
|
||||
int reg_a = (opcode >> 16) & 31; \
|
||||
int rot_sh = (opcode >> 11) & 31; \
|
||||
unsigned rot_sh = (opcode >> 11) & 31; \
|
||||
uint32_t ppc_result_d = ppc_state.gpr[reg_s]; \
|
||||
uint32_t ppc_result_a = ppc_state.gpr[reg_a];
|
||||
|
||||
#define ppc_grab_regssash_stswi(opcode) \
|
||||
int reg_s = (opcode >> 21) & 31; \
|
||||
int reg_a = (opcode >> 16) & 31; \
|
||||
int rot_sh = (opcode >> 11) & 31; \
|
||||
unsigned rot_sh = (opcode >> 11) & 31; \
|
||||
uint32_t ppc_result_a = ppc_state.gpr[reg_a];
|
||||
|
||||
#define ppc_grab_regssb(opcode) \
|
||||
int reg_s = (opcode >> 21) & 31; \
|
||||
int reg_b = (opcode >> 11) & 31; \
|
||||
uint32_t ppc_result_d = ppc_state.gpr[reg_s]; \
|
||||
uint32_t ppc_result_b = ppc_state.gpr[reg_b];
|
||||
uint32_t ppc_result_b = ppc_state.gpr[reg_b]; \
|
||||
|
||||
|
||||
#define ppc_grab_regsda(opcode) \
|
||||
int reg_d = (opcode >> 21) & 31; \
|
||||
uint32_t reg_a = (opcode >> 16) & 31; \
|
||||
uint32_t ppc_result_a = ppc_state.gpr[reg_a];
|
||||
|
||||
|
||||
#define ppc_grab_regsdb(opcode) \
|
||||
int reg_d = (opcode >> 21) & 31; \
|
||||
uint32_t reg_b = (opcode >> 11) & 31; \
|
||||
uint32_t ppc_result_b = ppc_state.gpr[reg_b];
|
||||
|
||||
#define ppc_store_iresult_reg(reg, ppc_result) \
|
||||
#define ppc_store_iresult_reg(reg, ppc_result)\
|
||||
ppc_state.gpr[reg] = ppc_result
|
||||
|
||||
#define ppc_store_sfpresult_int(reg, ppc_result64_d)\
|
||||
#define ppc_store_fpresult_int(reg, ppc_result64_d)\
|
||||
ppc_state.fpr[(reg)].int64_r = ppc_result64_d
|
||||
|
||||
#define ppc_store_sfpresult_flt(reg, ppc_dblresult64_d)\
|
||||
ppc_state.fpr[(reg)].dbl64_r = ppc_dblresult64_d
|
||||
|
||||
#define ppc_store_dfpresult_int(reg, ppc_result64_d)\
|
||||
ppc_state.fpr[(reg)].int64_r = ppc_result64_d
|
||||
|
||||
#define ppc_store_dfpresult_flt(reg, ppc_dblresult64_d)\
|
||||
#define ppc_store_fpresult_flt(reg, ppc_dblresult64_d)\
|
||||
ppc_state.fpr[(reg)].dbl64_r = ppc_dblresult64_d
|
||||
|
||||
#define ppc_grab_regsfpdb(opcode) \
|
||||
@@ -184,6 +153,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#define GET_FPR(reg) \
|
||||
ppc_state.fpr[(reg)].dbl64_r
|
||||
|
||||
#define FPR_INT(reg) \
|
||||
ppc_state.fpr[reg].int64_r
|
||||
|
||||
#define ppc_grab_regsfpdiab(opcode) \
|
||||
int reg_d = (opcode >> 21) & 31; \
|
||||
int reg_a = (opcode >> 16) & 31; \
|
||||
@@ -238,15 +210,4 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
double val_reg_b = GET_FPR(reg_b); \
|
||||
double val_reg_c = GET_FPR(reg_c);
|
||||
|
||||
#define ppc_grab_mtfsf(opcode) \
|
||||
int reg_b = (opcode >> 11) & 0x1F; \
|
||||
uint8_t fm = (opcode >> 17) & 0xFF;
|
||||
|
||||
#define ppc_grab_mtfsfi(opcode) \
|
||||
int crf_d = (opcode >> 21) & 0x1C; \
|
||||
uint32_t imm = (opcode << 16) & 0xF0000000UL;
|
||||
|
||||
#define ppc_grab_crfd(opcode) \
|
||||
int crf_d = (opcode >> 21) & 0x1C;
|
||||
|
||||
#endif // PPC_MACROS_H
|
||||
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
DingusPPC - The Experimental PowerPC Macintosh emulator
|
||||
Copyright (C) 2018-24 divingkatae and maximum
|
||||
(theweirdo) spatium
|
||||
|
||||
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#undef OPCODE
|
||||
#define OPCODE(op, grabber, number, ...) \
|
||||
void ppc_##op(uint32_t instr);
|
||||
|
||||
#undef OPCODE31
|
||||
#define OPCODE31(op, grabber, number, ...) \
|
||||
void ppc_##op(uint32_t instr);
|
||||
|
||||
#undef POWEROPCODE
|
||||
#define POWEROPCODE(op, grabber, number, ...) \
|
||||
void power_##op(uint32_t instr);
|
||||
|
||||
#undef POWEROPCODE31
|
||||
#define POWEROPCODE31(op, grabber, number, ...) \
|
||||
void power_##op(uint32_t instr);
|
||||
|
||||
#undef OPCODESHIFT
|
||||
#define OPCODESHIFT(op, grabber, number, ...) \
|
||||
template <field_shift shift> \
|
||||
void ppc_##op(uint32_t instr);
|
||||
|
||||
#undef OPCODESHIFTREC
|
||||
#define OPCODESHIFTREC(op, grabber, number, ...) \
|
||||
template <field_direction isleft, field_rc rec> \
|
||||
void ppc_##op(uint32_t instr);
|
||||
|
||||
#undef OPCODEOVREC
|
||||
#define OPCODEOVREC(op, grabber, number, ...) \
|
||||
template <field_rc rec, field_ov ov> \
|
||||
void ppc_##op(uint32_t instr);
|
||||
|
||||
#undef OPCODEEXTSIGN
|
||||
#define OPCODEEXTSIGN(op, grabber, number, ...) \
|
||||
template <class T, field_rc rec> \
|
||||
void ppc_##op(uint32_t instr);
|
||||
|
||||
#undef POWEROPCODEOVREC
|
||||
#define POWEROPCODEOVREC(op, grabber, number, ...) \
|
||||
template <field_rc rec, field_ov ov> \
|
||||
void power_##op(uint32_t instr);
|
||||
|
||||
#undef OPCODEREC
|
||||
#define OPCODEREC(op, grabber, number, ...) \
|
||||
template <field_rc rec> \
|
||||
void ppc_##op(uint32_t instr);
|
||||
|
||||
#undef OPCODERECF
|
||||
#define OPCODERECF(op, grabber, number, ...) \
|
||||
template <field_rc rec> \
|
||||
void ppc_##op(uint32_t instr);
|
||||
|
||||
#undef POWEROPCODEREC
|
||||
#define POWEROPCODEREC(op, grabber, number, ...) \
|
||||
template <field_rc rec> \
|
||||
void power_##op(uint32_t instr);
|
||||
|
||||
#undef OPCODELOGIC
|
||||
#define OPCODELOGIC(op, grabber, number, ...) \
|
||||
template <logical_fun logical_op, field_rc rec> \
|
||||
void ppc_##op(uint32_t instr);
|
||||
|
||||
#undef OPCODELKAA
|
||||
#define OPCODELKAA(op, grabber, number, ...) \
|
||||
template <field_lk l, field_aa a> \
|
||||
void ppc_##op(uint32_t instr);
|
||||
|
||||
#undef OPCODEMEM
|
||||
#define OPCODEMEM(op, grabber, number, ...) \
|
||||
template <class T> \
|
||||
void ppc_##op(uint32_t instr);
|
||||
|
||||
#undef OPCODEMEMINDEXED
|
||||
#define OPCODEMEMINDEXED(op, grabber, number, ...) \
|
||||
template <class T> \
|
||||
void ppc_##op(uint32_t instr);
|
||||
|
||||
#undef OPCODE601REC
|
||||
#define OPCODE601REC(op, grabber, number, ...) \
|
||||
template <field_601 for601, field_rc rec> \
|
||||
void ppc_##op(uint32_t instr);
|
||||
|
||||
#undef OPCODE601L
|
||||
#define OPCODE601L(op, grabber, number, ...) \
|
||||
template <field_lk l, field_601 for601> \
|
||||
void ppc_##op(uint32_t instr);
|
||||
|
||||
#undef OPCODEL
|
||||
#define OPCODEL(op, grabber, number, ...) \
|
||||
template <field_lk l> \
|
||||
void ppc_##op(uint32_t instr);
|
||||
+88
-46
@@ -36,7 +36,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
//#define TLB_PROFILING // uncomment this to enable SoftTLB profiling
|
||||
|
||||
/* pointer to exception handler to be called when a MMU exception is occurred. */
|
||||
void (*mmu_exception_handler)(Except_Type exception_type, uint32_t srr1_bits);
|
||||
uint32_t (*mmu_exception_handler)(Except_Type exception_type, uint32_t srr1_bits, uint32_t exec_flags);
|
||||
|
||||
/* pointers to BAT update functions. */
|
||||
std::function<void(uint32_t bat_reg)> ibat_update;
|
||||
@@ -250,7 +250,7 @@ static PATResult page_address_translation(uint32_t la, bool is_instr_fetch,
|
||||
|
||||
/* instruction fetch from a no-execute segment will cause ISI exception */
|
||||
if ((sr_val & 0x10000000) && is_instr_fetch) {
|
||||
mmu_exception_handler(Except_Type::EXC_ISI, 0x10000000);
|
||||
mmu_exception_handler(Except_Type::EXC_ISI, 0x10000000, 0);
|
||||
}
|
||||
|
||||
page_index = (la >> 12) & 0xFFFF;
|
||||
@@ -260,11 +260,11 @@ static PATResult page_address_translation(uint32_t la, bool is_instr_fetch,
|
||||
if (!search_pteg(calc_pteg_addr(pteg_hash1), &pte_addr, vsid, page_index, 0)) {
|
||||
if (!search_pteg(calc_pteg_addr(~pteg_hash1), &pte_addr, vsid, page_index, 1)) {
|
||||
if (is_instr_fetch) {
|
||||
mmu_exception_handler(Except_Type::EXC_ISI, 0x40000000);
|
||||
mmu_exception_handler(Except_Type::EXC_ISI, 0x40000000, 0);
|
||||
} else {
|
||||
ppc_state.spr[SPR::DSISR] = 0x40000000 | (is_write << 25);
|
||||
ppc_state.spr[SPR::DAR] = la;
|
||||
mmu_exception_handler(Except_Type::EXC_DSI, 0);
|
||||
mmu_exception_handler(Except_Type::EXC_DSI, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -282,11 +282,11 @@ static PATResult page_address_translation(uint32_t la, bool is_instr_fetch,
|
||||
// write access with PP = %11
|
||||
if ((key && (!pp || (pp == 1 && is_write))) || (pp == 3 && is_write)) {
|
||||
if (is_instr_fetch) {
|
||||
mmu_exception_handler(Except_Type::EXC_ISI, 0x08000000);
|
||||
mmu_exception_handler(Except_Type::EXC_ISI, 0x08000000, 0);
|
||||
} else {
|
||||
ppc_state.spr[SPR::DSISR] = 0x08000000 | (is_write << 25);
|
||||
ppc_state.spr[SPR::DAR] = la;
|
||||
mmu_exception_handler(Except_Type::EXC_DSI, 0);
|
||||
mmu_exception_handler(Except_Type::EXC_DSI, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -527,7 +527,7 @@ static TLBEntry* itlb2_refill(uint32_t guest_va)
|
||||
// check block protection
|
||||
// only PP = 0 (no access) causes ISI exception
|
||||
if (!bat_res.prot) {
|
||||
mmu_exception_handler(Except_Type::EXC_ISI, 0x08000000);
|
||||
mmu_exception_handler(Except_Type::EXC_ISI, 0x08000000, 0);
|
||||
}
|
||||
phys_addr = bat_res.phys;
|
||||
flags |= TLBFlags::TLBE_FROM_BAT; // tell the world we come from
|
||||
@@ -588,7 +588,7 @@ static TLBEntry* dtlb2_refill(uint32_t guest_va, int is_write, bool is_dbg = fal
|
||||
LOG_F(9, "Attempt to write to read-only region, LA=0x%08X, PC=0x%08X!", guest_va, ppc_state.pc);
|
||||
ppc_state.spr[SPR::DSISR] = 0x08000000 | (is_write << 25);
|
||||
ppc_state.spr[SPR::DAR] = guest_va;
|
||||
mmu_exception_handler(Except_Type::EXC_DSI, 0);
|
||||
mmu_exception_handler(Except_Type::EXC_DSI, 0, 0);
|
||||
}
|
||||
phys_addr = bat_res.phys;
|
||||
flags = TLBFlags::PTE_SET_C; // prevent PTE.C updates for BAT
|
||||
@@ -984,12 +984,13 @@ void mmu_pat_ctx_changed()
|
||||
|
||||
// Forward declarations.
|
||||
template <class T>
|
||||
static T read_unaligned(uint32_t guest_va, uint8_t* host_va, uint32_t instr);
|
||||
static T read_unaligned(uint32_t opcode, uint32_t guest_va, uint8_t *host_va);
|
||||
template <class T>
|
||||
static void write_unaligned(uint32_t guest_va, uint8_t* host_va, uint32_t instr, T value);
|
||||
static void write_unaligned(uint32_t opcode, uint32_t guest_va, uint8_t *host_va, T value);
|
||||
|
||||
template <class T>
|
||||
inline T mmu_read_vmem(uint32_t guest_va, uint32_t instr) {
|
||||
inline T mmu_read_vmem(uint32_t opcode, uint32_t guest_va)
|
||||
{
|
||||
TLBEntry *tlb1_entry, *tlb2_entry;
|
||||
uint8_t *host_va;
|
||||
|
||||
@@ -1032,7 +1033,7 @@ inline T mmu_read_vmem(uint32_t guest_va, uint32_t instr) {
|
||||
#endif
|
||||
if (sizeof(T) == 8) {
|
||||
if (guest_va & 3)
|
||||
ppc_alignment_exception(guest_va, instr);
|
||||
ppc_alignment_exception(opcode, guest_va);
|
||||
|
||||
return (
|
||||
((T)tlb2_entry->rgn_desc->devobj->read(tlb2_entry->rgn_desc->start,
|
||||
@@ -1059,7 +1060,7 @@ inline T mmu_read_vmem(uint32_t guest_va, uint32_t instr) {
|
||||
|
||||
// handle unaligned memory accesses
|
||||
if (sizeof(T) > 1 && (guest_va & (sizeof(T) - 1))) {
|
||||
return read_unaligned<T>(guest_va, host_va, instr);
|
||||
return read_unaligned<T>(opcode, guest_va, host_va);
|
||||
}
|
||||
|
||||
// handle aligned memory accesses
|
||||
@@ -1076,13 +1077,14 @@ inline T mmu_read_vmem(uint32_t guest_va, uint32_t instr) {
|
||||
}
|
||||
|
||||
// explicitely instantiate all required mmu_read_vmem variants
|
||||
template uint8_t mmu_read_vmem<uint8_t>(uint32_t guest_va, uint32_t instr);
|
||||
template uint16_t mmu_read_vmem<uint16_t>(uint32_t guest_va, uint32_t instr);
|
||||
template uint32_t mmu_read_vmem<uint32_t>(uint32_t guest_va, uint32_t instr);
|
||||
template uint64_t mmu_read_vmem<uint64_t>(uint32_t guest_va, uint32_t instr);
|
||||
template uint8_t mmu_read_vmem<uint8_t>(uint32_t opcode, uint32_t guest_va);
|
||||
template uint16_t mmu_read_vmem<uint16_t>(uint32_t opcode, uint32_t guest_va);
|
||||
template uint32_t mmu_read_vmem<uint32_t>(uint32_t opcode, uint32_t guest_va);
|
||||
template uint64_t mmu_read_vmem<uint64_t>(uint32_t opcode, uint32_t guest_va);
|
||||
|
||||
template <class T>
|
||||
inline void mmu_write_vmem(uint32_t guest_va, uint32_t instr, T value) {
|
||||
inline void mmu_write_vmem(uint32_t opcode, uint32_t guest_va, T value)
|
||||
{
|
||||
TLBEntry *tlb1_entry, *tlb2_entry;
|
||||
uint8_t *host_va;
|
||||
|
||||
@@ -1097,7 +1099,7 @@ inline void mmu_write_vmem(uint32_t guest_va, uint32_t instr, T value) {
|
||||
if (!(tlb1_entry->flags & TLBFlags::PAGE_WRITABLE)) {
|
||||
ppc_state.spr[SPR::DSISR] = 0x08000000 | (1 << 25);
|
||||
ppc_state.spr[SPR::DAR] = guest_va;
|
||||
mmu_exception_handler(Except_Type::EXC_DSI, 0);
|
||||
mmu_exception_handler(Except_Type::EXC_DSI, 0, 0);
|
||||
}
|
||||
if (!(tlb1_entry->flags & TLBFlags::PTE_SET_C)) {
|
||||
// perform full page address translation to update PTE.C bit
|
||||
@@ -1134,7 +1136,7 @@ inline void mmu_write_vmem(uint32_t guest_va, uint32_t instr, T value) {
|
||||
if (!(tlb2_entry->flags & TLBFlags::PAGE_WRITABLE)) {
|
||||
ppc_state.spr[SPR::DSISR] = 0x08000000 | (1 << 25);
|
||||
ppc_state.spr[SPR::DAR] = guest_va;
|
||||
mmu_exception_handler(Except_Type::EXC_DSI, 0);
|
||||
mmu_exception_handler(Except_Type::EXC_DSI, 0, 0);
|
||||
}
|
||||
|
||||
if (!(tlb2_entry->flags & TLBFlags::PTE_SET_C)) {
|
||||
@@ -1153,7 +1155,7 @@ inline void mmu_write_vmem(uint32_t guest_va, uint32_t instr, T value) {
|
||||
#endif
|
||||
if (sizeof(T) == 8) {
|
||||
if (guest_va & 3)
|
||||
ppc_alignment_exception(guest_va, instr);
|
||||
ppc_alignment_exception(opcode, guest_va);
|
||||
|
||||
tlb2_entry->rgn_desc->devobj->write(tlb2_entry->rgn_desc->start,
|
||||
static_cast<uint32_t>(guest_va - tlb2_entry->dev_base_va),
|
||||
@@ -1176,7 +1178,7 @@ inline void mmu_write_vmem(uint32_t guest_va, uint32_t instr, T value) {
|
||||
|
||||
// handle unaligned memory accesses
|
||||
if (sizeof(T) > 1 && (guest_va & (sizeof(T) - 1))) {
|
||||
write_unaligned<T>(guest_va, host_va, instr, value);
|
||||
write_unaligned<T>(opcode, guest_va, host_va, value);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1198,16 +1200,17 @@ inline void mmu_write_vmem(uint32_t guest_va, uint32_t instr, T value) {
|
||||
}
|
||||
|
||||
// explicitely instantiate all required mmu_write_vmem variants
|
||||
template void mmu_write_vmem<uint8_t>(uint32_t guest_va, uint32_t instr, uint8_t value);
|
||||
template void mmu_write_vmem<uint16_t>(uint32_t guest_va, uint32_t instr, uint16_t value);
|
||||
template void mmu_write_vmem<uint32_t>(uint32_t guest_va, uint32_t instr, uint32_t value);
|
||||
template void mmu_write_vmem<uint64_t>(uint32_t guest_va, uint32_t instr, uint64_t value);
|
||||
template void mmu_write_vmem<uint8_t> (uint32_t opcode, uint32_t guest_va, uint8_t value);
|
||||
template void mmu_write_vmem<uint16_t>(uint32_t opcode, uint32_t guest_va, uint16_t value);
|
||||
template void mmu_write_vmem<uint32_t>(uint32_t opcode, uint32_t guest_va, uint32_t value);
|
||||
template void mmu_write_vmem<uint64_t>(uint32_t opcode, uint32_t guest_va, uint64_t value);
|
||||
|
||||
template <class T>
|
||||
static T read_unaligned(uint32_t guest_va, uint8_t* host_va, uint32_t instr) {
|
||||
static T read_unaligned(uint32_t opcode, uint32_t guest_va, uint8_t *host_va)
|
||||
{
|
||||
if ((sizeof(T) == 8) && (guest_va & 3)) {
|
||||
#ifndef PPC_TESTS
|
||||
ppc_alignment_exception(guest_va, instr);
|
||||
ppc_alignment_exception(opcode, guest_va);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1222,7 +1225,7 @@ static T read_unaligned(uint32_t guest_va, uint8_t* host_va, uint32_t instr) {
|
||||
// Because such accesses suffer a performance penalty, they will be
|
||||
// presumably very rare so don't waste time optimizing the code below.
|
||||
for (int i = 0; i < sizeof(T); guest_va++, i++) {
|
||||
result = (result << 8) | mmu_read_vmem<uint8_t>(guest_va, instr);
|
||||
result = (result << 8) | mmu_read_vmem<uint8_t>(opcode, guest_va);
|
||||
}
|
||||
} else {
|
||||
#ifdef MMU_PROFILING
|
||||
@@ -1243,16 +1246,16 @@ static T read_unaligned(uint32_t guest_va, uint8_t* host_va, uint32_t instr) {
|
||||
}
|
||||
|
||||
// explicitely instantiate all required read_unaligned variants
|
||||
template uint16_t read_unaligned<uint16_t>(uint32_t guest_va, uint8_t* host_va, uint32_t instr);
|
||||
template uint32_t read_unaligned<uint32_t>(uint32_t guest_va, uint8_t* host_va, uint32_t instr);
|
||||
template uint64_t read_unaligned<uint64_t>(uint32_t guest_va, uint8_t* host_va, uint32_t instr);
|
||||
template uint16_t read_unaligned<uint16_t>(uint32_t opcode, uint32_t guest_va, uint8_t *host_va);
|
||||
template uint32_t read_unaligned<uint32_t>(uint32_t opcode, uint32_t guest_va, uint8_t *host_va);
|
||||
template uint64_t read_unaligned<uint64_t>(uint32_t opcode, uint32_t guest_va, uint8_t *host_va);
|
||||
|
||||
template <class T>
|
||||
static void write_unaligned(uint32_t guest_va, uint8_t *host_va, uint32_t instr, T value)
|
||||
static void write_unaligned(uint32_t opcode, uint32_t guest_va, uint8_t *host_va, T value)
|
||||
{
|
||||
if ((sizeof(T) == 8) && (guest_va & 3)) {
|
||||
#ifndef PPC_TESTS
|
||||
ppc_alignment_exception(guest_va, instr);
|
||||
ppc_alignment_exception(opcode, guest_va);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1268,7 +1271,7 @@ static void write_unaligned(uint32_t guest_va, uint8_t *host_va, uint32_t instr,
|
||||
uint32_t shift = (sizeof(T) - 1) * 8;
|
||||
|
||||
for (int i = 0; i < sizeof(T); shift -= 8, guest_va++, i++) {
|
||||
mmu_write_vmem<uint8_t>(guest_va, instr, ((value >> shift) & 0xFF));
|
||||
mmu_write_vmem<uint8_t>(opcode, guest_va, (value >> shift) & 0xFF);
|
||||
}
|
||||
} else {
|
||||
#ifdef MMU_PROFILING
|
||||
@@ -1292,12 +1295,9 @@ static void write_unaligned(uint32_t guest_va, uint8_t *host_va, uint32_t instr,
|
||||
}
|
||||
|
||||
// explicitely instantiate all required write_unaligned variants
|
||||
template void write_unaligned<uint16_t>(
|
||||
uint32_t guest_va, uint8_t* host_va, uint32_t instr, uint16_t value);
|
||||
template void write_unaligned<uint32_t>(
|
||||
uint32_t guest_va, uint8_t* host_va, uint32_t instr, uint32_t value);
|
||||
template void write_unaligned<uint64_t>(
|
||||
uint32_t guest_va, uint8_t* host_va, uint32_t instr, uint64_t value);
|
||||
template void write_unaligned<uint16_t>(uint32_t opcode, uint32_t guest_va, uint8_t *host_va, uint16_t value);
|
||||
template void write_unaligned<uint32_t>(uint32_t opcode, uint32_t guest_va, uint8_t *host_va, uint32_t value);
|
||||
template void write_unaligned<uint64_t>(uint32_t opcode, uint32_t guest_va, uint8_t *host_va, uint64_t value);
|
||||
|
||||
|
||||
/* MMU profiling. */
|
||||
@@ -1437,19 +1437,19 @@ uint64_t mem_read_dbg(uint32_t virt_addr, uint32_t size) {
|
||||
try {
|
||||
switch (size) {
|
||||
case 1:
|
||||
ret_val = mmu_read_vmem<uint8_t>(virt_addr, 0);
|
||||
ret_val = mmu_read_vmem<uint8_t>(NO_OPCODE, virt_addr);
|
||||
break;
|
||||
case 2:
|
||||
ret_val = mmu_read_vmem<uint16_t>(virt_addr, 0);
|
||||
ret_val = mmu_read_vmem<uint16_t>(NO_OPCODE, virt_addr);
|
||||
break;
|
||||
case 4:
|
||||
ret_val = mmu_read_vmem<uint32_t>(virt_addr, 0);
|
||||
ret_val = mmu_read_vmem<uint32_t>(NO_OPCODE, virt_addr);
|
||||
break;
|
||||
case 8:
|
||||
ret_val = mmu_read_vmem<uint64_t>(virt_addr, 0);
|
||||
ret_val = mmu_read_vmem<uint64_t>(NO_OPCODE, virt_addr);
|
||||
break;
|
||||
default:
|
||||
ret_val = mmu_read_vmem<uint8_t>(virt_addr, 0);
|
||||
ret_val = mmu_read_vmem<uint8_t>(NO_OPCODE, virt_addr);
|
||||
}
|
||||
} catch (std::invalid_argument& exc) {
|
||||
/* restore MMU-related CPU state */
|
||||
@@ -1469,6 +1469,48 @@ uint64_t mem_read_dbg(uint32_t virt_addr, uint32_t size) {
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
void mem_write_dbg(uint32_t virt_addr, uint64_t value, int size) {
|
||||
uint32_t save_dsisr, save_dar;
|
||||
uint64_t ret_val;
|
||||
|
||||
// save MMU-related CPU state
|
||||
save_dsisr = ppc_state.spr[SPR::DSISR];
|
||||
save_dar = ppc_state.spr[SPR::DAR];
|
||||
mmu_exception_handler = dbg_exception_handler;
|
||||
|
||||
try {
|
||||
switch (size) {
|
||||
case 1:
|
||||
mmu_write_vmem<uint8_t>(NO_OPCODE, virt_addr, value);
|
||||
break;
|
||||
case 2:
|
||||
mmu_write_vmem<uint16_t>(NO_OPCODE, virt_addr, value);
|
||||
break;
|
||||
case 4:
|
||||
mmu_write_vmem<uint32_t>(NO_OPCODE, virt_addr, uint32_t(value));
|
||||
break;
|
||||
case 8:
|
||||
mmu_write_vmem<uint64_t>(NO_OPCODE, virt_addr, value);
|
||||
break;
|
||||
default:
|
||||
mmu_write_vmem<uint8_t>(NO_OPCODE, virt_addr, value);
|
||||
}
|
||||
} catch (std::invalid_argument& exc) {
|
||||
// restore MMU-related CPU state
|
||||
mmu_exception_handler = ppc_exception_handler;
|
||||
ppc_state.spr[SPR::DSISR] = save_dsisr;
|
||||
ppc_state.spr[SPR::DAR] = save_dar;
|
||||
|
||||
// rethrow MMU exception
|
||||
throw exc;
|
||||
}
|
||||
|
||||
// restore MMU-related CPU state
|
||||
mmu_exception_handler = ppc_exception_handler;
|
||||
ppc_state.spr[SPR::DSISR] = save_dsisr;
|
||||
ppc_state.spr[SPR::DAR] = save_dar;
|
||||
}
|
||||
|
||||
bool mmu_translate_dbg(uint32_t guest_va, uint32_t &guest_pa) {
|
||||
uint32_t save_dsisr, save_dar;
|
||||
bool is_mapped;
|
||||
|
||||
+3
-2
@@ -126,12 +126,13 @@ extern void mmu_pat_ctx_changed();
|
||||
extern void tlb_flush_entry(uint32_t ea);
|
||||
|
||||
extern uint64_t mem_read_dbg(uint32_t virt_addr, uint32_t size);
|
||||
extern void mem_write_dbg(uint32_t virt_addr, uint64_t value, int size);
|
||||
uint8_t *mmu_translate_imem(uint32_t vaddr, uint32_t *paddr = nullptr);
|
||||
bool mmu_translate_dbg(uint32_t guest_va, uint32_t &guest_pa);
|
||||
|
||||
template <class T>
|
||||
extern T mmu_read_vmem(uint32_t guest_va, uint32_t instr);
|
||||
extern T mmu_read_vmem(uint32_t opcode, uint32_t guest_va);
|
||||
template <class T>
|
||||
extern void mmu_write_vmem(uint32_t guest_va, uint32_t instr, T value);
|
||||
extern void mmu_write_vmem(uint32_t opcode, uint32_t guest_va, T value);
|
||||
|
||||
#endif // PPCMMU_H
|
||||
+1967
-11
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,209 +0,0 @@
|
||||
/*
|
||||
DingusPPC - The Experimental PowerPC Macintosh emulator
|
||||
Copyright (C) 2018-24 divingkatae and maximum
|
||||
(theweirdo) spatium
|
||||
|
||||
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#undef OPCODE
|
||||
#define OPCODE(op, grabber, number, ...) \
|
||||
void dppc_interpreter::ppc_##op(uint32_t instr) { \
|
||||
__VA_ARGS__ \
|
||||
}
|
||||
|
||||
#undef OPCODE31
|
||||
#define OPCODE31(op, grabber, number, ...) \
|
||||
void dppc_interpreter::ppc_##op(uint32_t instr) { \
|
||||
__VA_ARGS__ \
|
||||
}
|
||||
|
||||
#undef POWEROPCODE
|
||||
#define POWEROPCODE(op, grabber, number, ...) \
|
||||
void dppc_interpreter::power_##op(uint32_t instr) { \
|
||||
__VA_ARGS__ \
|
||||
}
|
||||
|
||||
#undef POWEROPCODE31
|
||||
#define POWEROPCODE31(op, grabber, number, ...) \
|
||||
void dppc_interpreter::power_##op(uint32_t instr) { \
|
||||
__VA_ARGS__ \
|
||||
}
|
||||
|
||||
#undef OPCODESHIFT
|
||||
#define OPCODESHIFT(op, grabber, number, ...) \
|
||||
template <field_shift shift> \
|
||||
void dppc_interpreter::ppc_##op(uint32_t instr) { \
|
||||
__VA_ARGS__ \
|
||||
} \
|
||||
template void dppc_interpreter::ppc_##op<SHFT0>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<SHFT1>(uint32_t instr);
|
||||
|
||||
#undef OPCODESHIFTREC
|
||||
#define OPCODESHIFTREC(op, grabber, number, ...) \
|
||||
template <field_direction isleft, field_rc rec> \
|
||||
void dppc_interpreter::ppc_##op(uint32_t instr) { \
|
||||
__VA_ARGS__ \
|
||||
} \
|
||||
template void dppc_interpreter::ppc_##op<RIGHT0, RC0>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<LEFT1, RC0>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<RIGHT0, RC1>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<LEFT1, RC1>(uint32_t instr);
|
||||
|
||||
#undef OPCODEOVREC
|
||||
#define OPCODEOVREC(op, grabber, number, ...) \
|
||||
template <field_rc rec, field_ov ov> \
|
||||
void dppc_interpreter::ppc_##op(uint32_t instr) { \
|
||||
__VA_ARGS__ \
|
||||
} \
|
||||
template void dppc_interpreter::ppc_##op<RC0, OV0>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<RC1, OV0>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<RC0, OV1>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<RC1, OV1>(uint32_t instr);
|
||||
|
||||
#undef OPCODEEXTSIGN
|
||||
#define OPCODEEXTSIGN(op, grabber, number, ...) \
|
||||
template <class T, field_rc rec> \
|
||||
void dppc_interpreter::ppc_##op(uint32_t instr) { \
|
||||
__VA_ARGS__ \
|
||||
} \
|
||||
template void dppc_interpreter::ppc_##op<int8_t, RC0>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<int16_t, RC0>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<int8_t, RC1>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<int16_t, RC1>(uint32_t instr);
|
||||
|
||||
#undef POWEROPCODEOVREC
|
||||
#define POWEROPCODEOVREC(op, grabber, number, ...) \
|
||||
template <field_rc rec, field_ov ov> \
|
||||
void dppc_interpreter::power_##op(uint32_t instr) { \
|
||||
__VA_ARGS__ \
|
||||
} \
|
||||
template void dppc_interpreter::power_##op<RC0, OV0>(uint32_t instr); \
|
||||
template void dppc_interpreter::power_##op<RC1, OV0>(uint32_t instr); \
|
||||
template void dppc_interpreter::power_##op<RC0, OV1>(uint32_t instr); \
|
||||
template void dppc_interpreter::power_##op<RC1, OV1>(uint32_t instr);
|
||||
|
||||
#undef OPCODEREC
|
||||
#define OPCODEREC(op, grabber, number, ...) \
|
||||
template <field_rc rec> \
|
||||
void dppc_interpreter::ppc_##op(uint32_t instr) { \
|
||||
__VA_ARGS__ \
|
||||
} \
|
||||
template void dppc_interpreter::ppc_##op<RC0>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<RC1>(uint32_t instr); \
|
||||
|
||||
#undef OPCODERECF
|
||||
#define OPCODERECF(op, grabber, number, ...) \
|
||||
template <field_rc rec> \
|
||||
void dppc_interpreter::ppc_##op(uint32_t instr) { \
|
||||
__VA_ARGS__ \
|
||||
} \
|
||||
template void dppc_interpreter::ppc_##op<RC0>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<RC1>(uint32_t instr); \
|
||||
|
||||
#undef POWEROPCODEREC
|
||||
#define POWEROPCODEREC(op, grabber, number, ...) \
|
||||
template <field_rc rec> \
|
||||
void dppc_interpreter::power_##op(uint32_t instr) { \
|
||||
__VA_ARGS__ \
|
||||
} \
|
||||
template void dppc_interpreter::power_##op<RC0>(uint32_t instr); \
|
||||
template void dppc_interpreter::power_##op<RC1>(uint32_t instr);
|
||||
|
||||
#undef OPCODELOGIC
|
||||
#define OPCODELOGIC(op, grabber, number, ...) \
|
||||
template <logical_fun logical_op, field_rc rec> \
|
||||
void dppc_interpreter::ppc_##op(uint32_t instr) { \
|
||||
__VA_ARGS__ \
|
||||
} \
|
||||
template void dppc_interpreter::ppc_##op<ppc_and, RC0>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<ppc_andc, RC0>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<ppc_eqv, RC0>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<ppc_nand, RC0>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<ppc_nor, RC0>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<ppc_or, RC0>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<ppc_orc, RC0>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<ppc_xor, RC0>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<ppc_and, RC1>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<ppc_andc, RC1>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<ppc_eqv, RC1>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<ppc_nand, RC1>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<ppc_nor, RC1>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<ppc_or, RC1>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<ppc_orc, RC1>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<ppc_xor, RC1>(uint32_t instr);
|
||||
|
||||
#undef OPCODELKAA
|
||||
#define OPCODELKAA(op, grabber, number, ...) \
|
||||
template <field_lk l, field_aa a> \
|
||||
void dppc_interpreter::ppc_##op(uint32_t instr) { \
|
||||
__VA_ARGS__ \
|
||||
} \
|
||||
template void dppc_interpreter::ppc_##op<LK0, AA0>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<LK0, AA1>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<LK1, AA0>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<LK1, AA1>(uint32_t instr);
|
||||
|
||||
#undef OPCODEMEM
|
||||
#define OPCODEMEM(op, grabber, number, ...) \
|
||||
template <class T> \
|
||||
void dppc_interpreter::ppc_##op(uint32_t instr) { \
|
||||
__VA_ARGS__ \
|
||||
} \
|
||||
template void dppc_interpreter::ppc_##op<uint8_t>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<uint16_t>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<uint32_t>(uint32_t instr);
|
||||
|
||||
#undef OPCODEMEMINDEXED
|
||||
#define OPCODEMEMINDEXED(op, grabber, number, ...) \
|
||||
template <class T> \
|
||||
void dppc_interpreter::ppc_##op(uint32_t instr) { \
|
||||
__VA_ARGS__ \
|
||||
} \
|
||||
template void dppc_interpreter::ppc_##op<uint8_t>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<uint16_t>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<uint32_t>(uint32_t instr);
|
||||
|
||||
#undef OPCODE601REC
|
||||
#define OPCODE601REC(op, grabber, number, ...) \
|
||||
template <field_601 for601, field_rc rec> \
|
||||
void dppc_interpreter::ppc_##op(uint32_t instr) { \
|
||||
__VA_ARGS__ \
|
||||
} \
|
||||
template void dppc_interpreter::ppc_##op<NOT601, RC0>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<IS601, RC0>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<NOT601, RC1>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<IS601, RC1>(uint32_t instr); \
|
||||
|
||||
#undef OPCODE601L
|
||||
#define OPCODE601L(op, grabber, number, ...) \
|
||||
template <field_lk l, field_601 for601> \
|
||||
void dppc_interpreter::ppc_##op(uint32_t instr) { \
|
||||
__VA_ARGS__ \
|
||||
} \
|
||||
template void dppc_interpreter::ppc_##op<LK0, NOT601>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<LK0, IS601>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<LK1, NOT601>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<LK1, IS601>(uint32_t instr); \
|
||||
|
||||
#undef OPCODEL
|
||||
#define OPCODEL(op, grabber, number, ...) \
|
||||
template <field_lk l> \
|
||||
void dppc_interpreter::ppc_##op(uint32_t instr) { \
|
||||
__VA_ARGS__ \
|
||||
} \
|
||||
template void dppc_interpreter::ppc_##op<LK0>(uint32_t instr); \
|
||||
template void dppc_interpreter::ppc_##op<LK1>(uint32_t instr);
|
||||
@@ -1,156 +0,0 @@
|
||||
/*
|
||||
DingusPPC - The Experimental PowerPC Macintosh emulator
|
||||
Copyright (C) 2018-24 divingkatae and maximum
|
||||
(theweirdo) spatium
|
||||
|
||||
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#undef OPCODE
|
||||
#define OPCODE(op, grabber, number, ...) \
|
||||
Opcode##grabber##Grabber[number] = ppc_##op;
|
||||
|
||||
#undef OPCODE31
|
||||
#define OPCODE31(op, grabber, number, ...) \
|
||||
Opcode##grabber##Grabber[number << 1] = ppc_##op;
|
||||
|
||||
#undef POWEROPCODE
|
||||
#define POWEROPCODE(op, grabber, number, ...) \
|
||||
if (is_601) \
|
||||
Opcode##grabber##Grabber[number] = power_##op;
|
||||
|
||||
#undef POWEROPCODE31
|
||||
#define POWEROPCODE31(op, grabber, number, ...) \
|
||||
if (is_601) \
|
||||
Opcode##grabber##Grabber[number << 1] = power_##op;
|
||||
|
||||
#undef OPCODESHIFT
|
||||
#define OPCODESHIFT(op, grabber, number, ...) \
|
||||
Opcode##grabber##Grabber[number ] = ppc_##op<SHFT0>; \
|
||||
Opcode##grabber##Grabber[number + 1] = ppc_##op<SHFT1>;
|
||||
|
||||
#undef OPCODESHIFTREC
|
||||
#define OPCODESHIFTREC(op, grabber, number, ...) \
|
||||
Opcode##grabber##Grabber[number ] = ppc_##op<LEFT1 , RC0>; \
|
||||
Opcode##grabber##Grabber[number + 1] = ppc_##op<LEFT1 , RC1>; \
|
||||
Opcode##grabber##Grabber[number + (1 << 9) ] = ppc_##op<RIGHT0, RC0>; \
|
||||
Opcode##grabber##Grabber[number + (1 << 9) + 1] = ppc_##op<RIGHT0, RC1>; \
|
||||
|
||||
#undef OPCODEOVREC
|
||||
#define OPCODEOVREC(op, grabber, number, ...) \
|
||||
Opcode##grabber##Grabber[number ] = ppc_##op<RC0, OV0>; \
|
||||
Opcode##grabber##Grabber[number + 1] = ppc_##op<RC1, OV0>; \
|
||||
Opcode##grabber##Grabber[number + 2] = ppc_##op<RC0, OV1>; \
|
||||
Opcode##grabber##Grabber[number + 3] = ppc_##op<RC1, OV1>;
|
||||
|
||||
#undef OPCODEEXTSIGN
|
||||
#define OPCODEEXTSIGN(op, grabber, number, ...) \
|
||||
Opcode##grabber##Grabber[ number << 1 ] = ppc_##op<int16_t, RC0>; \
|
||||
Opcode##grabber##Grabber[( number << 1) + 1] = ppc_##op<int16_t, RC1>; \
|
||||
Opcode##grabber##Grabber[ (number + 32) << 1 ] = ppc_##op<int8_t, RC0>; \
|
||||
Opcode##grabber##Grabber[((number + 32) << 1) + 1] = ppc_##op<int8_t, RC1>;
|
||||
|
||||
#undef POWEROPCODEOVREC
|
||||
#define POWEROPCODEOVREC(op, grabber, number, ...) \
|
||||
if (is_601) { \
|
||||
Opcode##grabber##Grabber[ number << 1 ] = power_##op<RC0, OV0>; \
|
||||
Opcode##grabber##Grabber[(number << 1) + 1] = power_##op<RC1, OV0>; \
|
||||
Opcode##grabber##Grabber[(number << 1) + 2] = power_##op<RC0, OV1>; \
|
||||
Opcode##grabber##Grabber[(number << 1) + 3] = power_##op<RC1, OV1>; \
|
||||
}
|
||||
|
||||
#undef OPCODEREC
|
||||
#define OPCODEREC(op, grabber, number, ...) \
|
||||
Opcode##grabber##Grabber[ number << 1 ] = ppc_##op<RC0>; \
|
||||
Opcode##grabber##Grabber[(number << 1) + 1] = ppc_##op<RC1>; \
|
||||
|
||||
#undef OPCODERECF
|
||||
#define OPCODERECF(op, grabber, number, ...) \
|
||||
for (int i = 0; i < 2048; i += 32) { \
|
||||
Opcode##grabber##Grabber[(number + i) << 1 ] = ppc_##op<RC0>; \
|
||||
Opcode##grabber##Grabber[((number + i) << 1) + 1] = ppc_##op<RC1>; \
|
||||
}
|
||||
|
||||
#undef POWEROPCODEREC
|
||||
#define POWEROPCODEREC(op, grabber, number, ...) \
|
||||
if (is_601) { \
|
||||
Opcode##grabber##Grabber[ number << 1 ] = power_##op<RC0>; \
|
||||
Opcode##grabber##Grabber[(number << 1) + 1] = power_##op<RC1>; \
|
||||
}
|
||||
|
||||
#undef OPCODELOGIC
|
||||
#define OPCODELOGIC(op, grabber, number, ...) \
|
||||
Opcode##grabber##Grabber[ number ] = ppc_##op<ppc_and , RC0>; \
|
||||
Opcode##grabber##Grabber[((number + 1) << 1) ] = ppc_##op<ppc_and , RC1>; \
|
||||
Opcode##grabber##Grabber[((number + 32) << 1) ] = ppc_##op<ppc_andc, RC0>; \
|
||||
Opcode##grabber##Grabber[((number + 32) << 1) + 1] = ppc_##op<ppc_andc, RC1>; \
|
||||
Opcode##grabber##Grabber[((number + 96) << 1) ] = ppc_##op<ppc_nor , RC0>; \
|
||||
Opcode##grabber##Grabber[((number + 96) << 1) + 1] = ppc_##op<ppc_nor , RC1>; \
|
||||
Opcode##grabber##Grabber[((number + 256) << 1) ] = ppc_##op<ppc_eqv , RC0>; \
|
||||
Opcode##grabber##Grabber[((number + 256) << 1) + 1] = ppc_##op<ppc_eqv , RC1>; \
|
||||
Opcode##grabber##Grabber[((number + 288) << 1) ] = ppc_##op<ppc_xor , RC0>; \
|
||||
Opcode##grabber##Grabber[((number + 288) << 1) + 1] = ppc_##op<ppc_xor , RC1>; \
|
||||
Opcode##grabber##Grabber[((number + 384) << 1) ] = ppc_##op<ppc_orc , RC0>; \
|
||||
Opcode##grabber##Grabber[((number + 384) << 1) + 1] = ppc_##op<ppc_orc , RC1>; \
|
||||
Opcode##grabber##Grabber[((number + 416) << 1) ] = ppc_##op<ppc_or , RC0>; \
|
||||
Opcode##grabber##Grabber[((number + 416) << 1) + 1] = ppc_##op<ppc_or , RC1>; \
|
||||
Opcode##grabber##Grabber[((number + 448) << 1) ] = ppc_##op<ppc_nand, RC0>; \
|
||||
Opcode##grabber##Grabber[((number + 448) << 1) + 1] = ppc_##op<ppc_nand, RC1>; \
|
||||
|
||||
#undef OPCODELKAA
|
||||
#define OPCODELKAA(op, grabber, number, ...) \
|
||||
Opcode##grabber##Grabber[number ] = ppc_##op<LK0, AA0>; \
|
||||
Opcode##grabber##Grabber[number + 1] = ppc_##op<LK1, AA0>; \
|
||||
Opcode##grabber##Grabber[number + 2] = ppc_##op<LK0, AA1>; \
|
||||
Opcode##grabber##Grabber[number + 3] = ppc_##op<LK1, AA1>;
|
||||
|
||||
#undef OPCODEMEM
|
||||
#define OPCODEMEM(op, grabber, number, ...) \
|
||||
Opcode##grabber##Grabber[number ] = ppc_##op<uint32_t>; \
|
||||
Opcode##grabber##Grabber[number + 2] = ppc_##op<uint8_t>; \
|
||||
Opcode##grabber##Grabber[number + 8] = ppc_##op<uint16_t>;
|
||||
|
||||
#undef OPCODEMEMINDEXED
|
||||
#define OPCODEMEMINDEXED(op, grabber, number, ...) \
|
||||
Opcode##grabber##Grabber[ number << 1 ] = ppc_##op<uint32_t>; \
|
||||
Opcode##grabber##Grabber[(number << 1) + (1 << 6)] = ppc_##op<uint8_t>; \
|
||||
Opcode##grabber##Grabber[(number << 1) + (1 << 8)] = ppc_##op<uint16_t>;
|
||||
|
||||
#undef OPCODE601REC
|
||||
#define OPCODE601REC(op, grabber, number, ...) \
|
||||
if (is_601) { \
|
||||
Opcode##grabber##Grabber[number ] = ppc_##op<IS601, RC0>; \
|
||||
Opcode##grabber##Grabber[number + 1] = ppc_##op<IS601, RC1>; \
|
||||
} else { \
|
||||
Opcode##grabber##Grabber[number ] = ppc_##op<NOT601, RC0>; \
|
||||
Opcode##grabber##Grabber[number + 1] = ppc_##op<NOT601, RC1>; \
|
||||
}
|
||||
|
||||
#undef OPCODE601L
|
||||
#define OPCODE601L(op, grabber, number, ...) \
|
||||
if (is_601) { \
|
||||
Opcode##grabber##Grabber[number ] = ppc_##op<LK0, IS601>; \
|
||||
Opcode##grabber##Grabber[number + 1] = ppc_##op<LK1, IS601>; \
|
||||
} \
|
||||
else { \
|
||||
Opcode##grabber##Grabber[number ] = ppc_##op<LK0, NOT601>; \
|
||||
Opcode##grabber##Grabber[number + 1] = ppc_##op<LK1, NOT601>; \
|
||||
}
|
||||
|
||||
#undef OPCODEL
|
||||
#define OPCODEL(op, grabber, number, ...) \
|
||||
Opcode##grabber##Grabber[number ] = ppc_##op<LK0>; \
|
||||
Opcode##grabber##Grabber[number + 1] = ppc_##op<LK1>;
|
||||
@@ -37,12 +37,12 @@ int ntested; // number of tested instructions
|
||||
int nfailed; // number of failed instructions
|
||||
|
||||
#if defined(PPC_TESTS)
|
||||
void ppc_exception_handler(Except_Type exception_type, uint32_t srr1_bits) {
|
||||
void ppc_exception_handler(Except_Type exception_type, uint32_t srr1_bits, uint32_t exec_flags) {
|
||||
power_on = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void xer_ov_test(string mnem, uint32_t opcode) {
|
||||
void xer_ov_test(string mnem, uint32_t opcode) {
|
||||
ppc_state.gpr[3] = 2;
|
||||
ppc_state.gpr[4] = 2;
|
||||
ppc_state.spr[SPR::XER] = 0xFFFFFFFF;
|
||||
@@ -316,7 +316,8 @@ static void read_test_float_data() {
|
||||
}
|
||||
|
||||
int main() {
|
||||
initialize_ppc_opcode_tables(true); //kludge
|
||||
is_601 = true;
|
||||
initialize_ppc_opcode_table(); //kludge
|
||||
|
||||
cout << "Running DingusPPC emulator tests..." << endl << endl;
|
||||
|
||||
|
||||
+24
-4
@@ -22,6 +22,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#include <cpu/ppc/ppcdisasm.h>
|
||||
#include <cpu/ppc/ppcemu.h>
|
||||
#include <cpu/ppc/ppcmmu.h>
|
||||
#include <debugger/debugger.h>
|
||||
#include <devices/common/hwinterrupt.h>
|
||||
#include <devices/common/ofnvram.h>
|
||||
#include "memaccess.h"
|
||||
@@ -161,7 +162,7 @@ print_bin:
|
||||
#define EMU_68K_TABLE_SIZE 0x80000
|
||||
|
||||
/** Execute one emulated 68k instruction. */
|
||||
void exec_single_68k(uint32_t instr)
|
||||
void exec_single_68k()
|
||||
{
|
||||
uint32_t emu_table_virt, cur_68k_pc, cur_instr_tab_entry, ppc_pc;
|
||||
|
||||
@@ -174,7 +175,7 @@ void exec_single_68k(uint32_t instr)
|
||||
|
||||
/* calculate address of the current opcode table entry as follows:
|
||||
get_word(68k_PC) * entry_size + table_base */
|
||||
cur_instr_tab_entry = mmu_read_vmem<uint16_t>(cur_68k_pc, 0) * 8 + emu_table_virt;
|
||||
cur_instr_tab_entry = mmu_read_vmem<uint16_t>(NO_OPCODE, cur_68k_pc) * 8 + emu_table_virt;
|
||||
|
||||
/* grab the PPC PC too */
|
||||
ppc_pc = get_reg(string("PC"));
|
||||
@@ -438,7 +439,18 @@ static void mysig_handler(int signum)
|
||||
}
|
||||
#endif
|
||||
|
||||
void enter_debugger() {
|
||||
static void delete_prompt() {
|
||||
#ifndef _WIN32
|
||||
// move up, carriage return (move to column 0), erase from cursor to end of line
|
||||
cout << "\e[A\r\e[0K";
|
||||
#endif
|
||||
}
|
||||
|
||||
DppcDebugger::DppcDebugger() {
|
||||
|
||||
}
|
||||
|
||||
void DppcDebugger::enter_debugger() {
|
||||
string inp, cmd, addr_str, expr_str, reg_expr, last_cmd, reg_value_str,
|
||||
inst_string, inst_num_str, profile_name, sub_cmd;
|
||||
uint32_t addr, inst_grab;
|
||||
@@ -620,11 +632,17 @@ void enter_debugger() {
|
||||
|
||||
if (context == 2) {
|
||||
#ifdef ENABLE_68K_DEBUGGER
|
||||
if (cmd_repeat) {
|
||||
delete_prompt();
|
||||
}
|
||||
for (; --count >= 0;) {
|
||||
exec_single_68k(0);
|
||||
exec_single_68k();
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
if (cmd_repeat) {
|
||||
delete_prompt();
|
||||
}
|
||||
for (; --count >= 0;) {
|
||||
ppc_exec_single();
|
||||
}
|
||||
@@ -703,6 +721,7 @@ void enter_debugger() {
|
||||
if (context == 2) {
|
||||
#ifdef ENABLE_68K_DEBUGGER
|
||||
if (cmd_repeat) {
|
||||
delete_prompt();
|
||||
addr = next_addr_68k;
|
||||
}
|
||||
else {
|
||||
@@ -713,6 +732,7 @@ void enter_debugger() {
|
||||
#endif
|
||||
} else {
|
||||
if (cmd_repeat) {
|
||||
delete_prompt();
|
||||
addr = next_addr_ppc;
|
||||
}
|
||||
else {
|
||||
|
||||
+17
-1
@@ -22,6 +22,22 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#ifndef DEBUGGER_H_
|
||||
#define DEBUGGER_H_
|
||||
|
||||
void enter_debugger();
|
||||
#include <memory>
|
||||
|
||||
class DppcDebugger {
|
||||
public:
|
||||
static DppcDebugger* get_instance() {
|
||||
if (!debugger_obj) {
|
||||
debugger_obj = std::unique_ptr<DppcDebugger>(new DppcDebugger());
|
||||
}
|
||||
return debugger_obj.get();
|
||||
};
|
||||
|
||||
void enter_debugger();
|
||||
|
||||
private:
|
||||
inline static std::unique_ptr<DppcDebugger> debugger_obj{nullptr};
|
||||
explicit DppcDebugger(); // private constructor to implement a singleton
|
||||
};
|
||||
|
||||
#endif // DEBUGGER_H_
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
DingusPPC - The Experimental PowerPC Macintosh emulator
|
||||
Copyright (C) 2018-24 divingkatae and maximum
|
||||
(theweirdo) spatium
|
||||
|
||||
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @file Apple Desktop Bus AppleJack controller emulation. */
|
||||
|
||||
#include <devices/common/adb/adbapplejack.h>
|
||||
#include <devices/common/adb/adbbus.h>
|
||||
#include <devices/deviceregistry.h>
|
||||
#include <core/hostevents.h>
|
||||
#include <loguru.hpp>
|
||||
|
||||
AdbAppleJack::AdbAppleJack(std::string name) : AdbMouse(name, AdbMouse::TRACKBALL, 2, 7, 300) {
|
||||
EventManager::get_instance()->add_gamepad_handler(this, &AdbAppleJack::event_handler);
|
||||
}
|
||||
|
||||
void AdbAppleJack::event_handler(const GamepadEvent& event) {
|
||||
uint32_t button_bit = 1 << event.button;
|
||||
|
||||
if (event.flags & GAMEPAD_EVENT_DOWN)
|
||||
this->buttons_state |= button_bit;
|
||||
else if (event.flags & GAMEPAD_EVENT_UP)
|
||||
this->buttons_state &= ~button_bit;
|
||||
|
||||
if (button_bit & ((1 << GamepadButton::LeftTrigger) | (1 << GamepadButton::RightTrigger)))
|
||||
this->triggers_changed = true;
|
||||
else
|
||||
this->buttons_changed = true;
|
||||
}
|
||||
|
||||
void AdbAppleJack::reset() {
|
||||
this->AdbMouse::reset();
|
||||
this->buttons_state = 0;
|
||||
this->triggers_changed = false;
|
||||
this->buttons_changed = false;
|
||||
LOG_F(INFO, "%s: reset; in mouse emulation mode", this->name.c_str());
|
||||
}
|
||||
|
||||
bool AdbAppleJack::get_register_0() {
|
||||
bool changed = this->triggers_changed || this->buttons_changed;
|
||||
|
||||
uint8_t mouse_buttons = this->AdbMouse::get_buttons_state();
|
||||
// AppleJack triggers always affect the mouse button bits.
|
||||
mouse_buttons |= (this->buttons_state >> (GamepadButton::LeftTrigger - 0)) & 1;
|
||||
mouse_buttons |= (this->buttons_state >> (GamepadButton::RightTrigger - 1)) & 2;
|
||||
changed |= this->AdbMouse::get_register_0(mouse_buttons, changed);
|
||||
this->triggers_changed = false;
|
||||
|
||||
if (this->dev_handler_id == APPLEJACK_HANDLER_ID && this->buttons_changed) {
|
||||
uint8_t* out_buf = this->host_obj->get_output_buf();
|
||||
|
||||
out_buf[2] = ~this->buttons_state >> 8;
|
||||
out_buf[3] = ~this->buttons_state & 0xFF;
|
||||
|
||||
this->host_obj->set_output_count(4);
|
||||
this->buttons_changed = false;
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
void AdbAppleJack::set_register_3() {
|
||||
if (this->host_obj->get_input_count() < 2) // ensure we got enough data
|
||||
return;
|
||||
|
||||
const uint8_t* in_data = this->host_obj->get_input_buf();
|
||||
|
||||
switch (in_data[1]) {
|
||||
case APPLEJACK_HANDLER_ID: // switch over to AppleJack protocol
|
||||
this->dev_handler_id = in_data[1];
|
||||
LOG_F(INFO, "%s: switched to AppleJack mode", this->name.c_str());
|
||||
break;
|
||||
default:
|
||||
this->AdbMouse::set_register_3();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static const DeviceDescription AdbAppleJack_Descriptor = {
|
||||
AdbAppleJack::create, {}, {}
|
||||
};
|
||||
|
||||
REGISTER_DEVICE(AdbAppleJack, AdbAppleJack_Descriptor);
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
DingusPPC - The Experimental PowerPC Macintosh emulator
|
||||
Copyright (C) 2018-24 divingkatae and maximum
|
||||
(theweirdo) spatium
|
||||
|
||||
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @file Apple Desktop Bus AppleJack controller definitions. */
|
||||
|
||||
#ifndef ADB_APPLEJACK_H
|
||||
#define ADB_APPLEJACK_H
|
||||
|
||||
#include <devices/common/adb/adbmouse.h>
|
||||
#include <devices/common/hwcomponent.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
enum : uint8_t {
|
||||
APPLEJACK_HANDLER_ID = 0x46,
|
||||
};
|
||||
|
||||
class GamepadEvent;
|
||||
|
||||
class AdbAppleJack : public AdbMouse {
|
||||
public:
|
||||
AdbAppleJack(std::string name);
|
||||
~AdbAppleJack() = default;
|
||||
|
||||
static std::unique_ptr<HWComponent> create() {
|
||||
return std::unique_ptr<AdbAppleJack>(new AdbAppleJack("ADB-APPLEJACK"));
|
||||
}
|
||||
|
||||
void reset() override;
|
||||
void event_handler(const GamepadEvent& event);
|
||||
|
||||
bool get_register_0() override;
|
||||
void set_register_3() override;
|
||||
|
||||
private:
|
||||
uint32_t buttons_state = 0;
|
||||
bool triggers_changed = false;
|
||||
bool buttons_changed = false;
|
||||
};
|
||||
|
||||
#endif // ADB_APPLEJACK_H
|
||||
@@ -25,6 +25,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#include <devices/common/adb/adbdevice.h>
|
||||
#include <devices/deviceregistry.h>
|
||||
#include <loguru.hpp>
|
||||
#include <machines/machinebase.h>
|
||||
#include <sstream>
|
||||
|
||||
AdbBus::AdbBus(std::string name) {
|
||||
this->set_name(name);
|
||||
@@ -32,6 +34,30 @@ AdbBus::AdbBus(std::string name) {
|
||||
this->devices.clear();
|
||||
}
|
||||
|
||||
int AdbBus::device_postinit() {
|
||||
std::string adb_device_list = GET_STR_PROP("adb_devices");
|
||||
if (adb_device_list.empty())
|
||||
return 0;
|
||||
|
||||
std::string adb_device;
|
||||
std::istringstream adb_device_stream(adb_device_list);
|
||||
|
||||
while (getline(adb_device_stream, adb_device, ',')) {
|
||||
std::string dev_name = "Adb" + adb_device;
|
||||
|
||||
if (dev_name == this->name)
|
||||
continue; // don't register a second ADB bus
|
||||
|
||||
if (DeviceRegistry::device_registered(dev_name)) {
|
||||
gMachineObj->add_device(dev_name, DeviceRegistry::get_descriptor(dev_name).m_create_func());
|
||||
} else {
|
||||
LOG_F(WARNING, "Unknown specified ADB device \"%s\"", adb_device.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void AdbBus::register_device(AdbDevice* dev_obj) {
|
||||
this->devices.push_back(dev_obj);
|
||||
}
|
||||
@@ -102,8 +128,12 @@ uint8_t AdbBus::process_command(const uint8_t* in_data, int data_size) {
|
||||
return ADB_STAT_OK;
|
||||
}
|
||||
|
||||
static const PropMap AdbBus_Properties = {
|
||||
{"adb_devices", new StrProperty("Mouse,Keyboard")},
|
||||
};
|
||||
|
||||
static const DeviceDescription AdbBus_Descriptor = {
|
||||
AdbBus::create, {}, {}
|
||||
AdbBus::create, {}, AdbBus_Properties
|
||||
};
|
||||
|
||||
REGISTER_DEVICE(AdbBus, AdbBus_Descriptor);
|
||||
@@ -51,6 +51,8 @@ public:
|
||||
return std::unique_ptr<AdbBus>(new AdbBus("ADB-BUS"));
|
||||
}
|
||||
|
||||
int device_postinit() override;
|
||||
|
||||
void register_device(AdbDevice* dev_obj);
|
||||
uint8_t process_command(const uint8_t* in_data, int data_size);
|
||||
uint8_t get_output_count() { return this->output_count; };
|
||||
|
||||
@@ -28,7 +28,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#include <memaccess.h>
|
||||
#include <loguru.hpp>
|
||||
|
||||
AdbMouse::AdbMouse(std::string name) : AdbDevice(name) {
|
||||
AdbMouse::AdbMouse(
|
||||
std::string name, uint8_t device_class, int num_buttons, int num_bits, uint16_t resolution) : AdbDevice(name), device_class(device_class), num_buttons(num_buttons), num_bits(num_bits), resolution(resolution) {
|
||||
EventManager::get_instance()->add_mouse_handler(this, &AdbMouse::event_handler);
|
||||
|
||||
this->reset();
|
||||
@@ -63,8 +64,10 @@ void AdbMouse::reset() {
|
||||
this->changed = false;
|
||||
}
|
||||
|
||||
bool AdbMouse::get_register_0() {
|
||||
if (this->x_rel || this->y_rel || this->changed) {
|
||||
bool AdbMouse::get_register_0(uint8_t buttons_state, bool force) {
|
||||
bool should_update = this->x_rel || this->y_rel || this->changed || force;
|
||||
|
||||
if (should_update) {
|
||||
uint8_t* p;
|
||||
uint8_t* out_buf = this->host_obj->get_output_buf();
|
||||
|
||||
@@ -86,7 +89,7 @@ bool AdbMouse::get_register_0() {
|
||||
bits = 7;
|
||||
|
||||
while (bits_remaining > 0) {
|
||||
*p = (val & ((1 << bits) - 1)) | (((this->buttons_state >> button) ^ 1) << bits) | (*p << (bits + 1));
|
||||
*p = (val & ((1 << bits) - 1)) | (((buttons_state >> button) ^ 1) << bits) | (*p << (bits + 1));
|
||||
val >>= bits;
|
||||
bits_remaining -= bits;
|
||||
p = bits == 7 ? &out_buf[2] : p + 1;
|
||||
@@ -109,12 +112,16 @@ bool AdbMouse::get_register_0() {
|
||||
if (this->device_class == MOUSE && this->dev_handler_id == 1)
|
||||
count = 2;
|
||||
this->host_obj->set_output_count(count);
|
||||
return true;
|
||||
return should_update;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AdbMouse::get_register_0() {
|
||||
return get_register_0(this->buttons_state, false);
|
||||
}
|
||||
|
||||
bool AdbMouse::get_register_1() {
|
||||
uint8_t* out_buf = this->host_obj->get_output_buf();
|
||||
// Identifier
|
||||
@@ -156,6 +163,10 @@ void AdbMouse::set_register_3() {
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t AdbMouse::get_buttons_state() const {
|
||||
return this->buttons_state;
|
||||
}
|
||||
|
||||
static const DeviceDescription AdbMouse_Descriptor = {
|
||||
AdbMouse::create, {}, {}
|
||||
};
|
||||
|
||||
@@ -35,19 +35,31 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
class MouseEvent;
|
||||
|
||||
class AdbMouse : public AdbDevice {
|
||||
|
||||
public:
|
||||
enum DeviceClass {
|
||||
TABLET = 0,
|
||||
MOUSE = 1,
|
||||
TRACKBALL = 2,
|
||||
};
|
||||
|
||||
public:
|
||||
AdbMouse(std::string name);
|
||||
AdbMouse(
|
||||
std::string name, uint8_t device_class, int num_buttons, int num_bits, uint16_t resolution);
|
||||
~AdbMouse() = default;
|
||||
|
||||
static std::unique_ptr<HWComponent> create() {
|
||||
return std::unique_ptr<AdbMouse>(new AdbMouse("ADB-MOUSE"));
|
||||
#ifdef ABSOLUTE
|
||||
uint8_t device_class = TABLET;
|
||||
int num_buttons = 3;
|
||||
int num_bits = 16;
|
||||
uint16_t resolution = 72;
|
||||
#else
|
||||
uint8_t device_class = MOUSE;
|
||||
int num_buttons = 3;
|
||||
int num_bits = 10;
|
||||
uint16_t resolution = 300;
|
||||
#endif
|
||||
return std::unique_ptr<AdbMouse>(
|
||||
new AdbMouse("ADB-MOUSE", device_class, num_buttons, num_bits, resolution));
|
||||
}
|
||||
|
||||
void reset() override;
|
||||
@@ -57,6 +69,10 @@ public:
|
||||
bool get_register_1() override;
|
||||
void set_register_3() override;
|
||||
|
||||
protected:
|
||||
bool get_register_0(uint8_t buttons_state, bool force);
|
||||
uint8_t get_buttons_state() const;
|
||||
|
||||
private:
|
||||
int32_t x_rel = 0;
|
||||
int32_t y_rel = 0;
|
||||
@@ -64,17 +80,10 @@ private:
|
||||
int32_t y_abs = 0;
|
||||
uint8_t buttons_state = 0;
|
||||
bool changed = false;
|
||||
#ifdef ABSOLUTE
|
||||
uint8_t device_class = TABLET;
|
||||
int num_buttons = 3;
|
||||
int num_bits = 16;
|
||||
uint16_t resolution = 72;
|
||||
#else
|
||||
uint8_t device_class = MOUSE;
|
||||
int num_buttons = 3;
|
||||
int num_bits = 10;
|
||||
uint16_t resolution = 300;
|
||||
#endif
|
||||
uint8_t device_class;
|
||||
int num_buttons;
|
||||
int num_bits;
|
||||
uint16_t resolution;
|
||||
};
|
||||
|
||||
#endif // ADB_MOUSE_H
|
||||
@@ -120,6 +120,7 @@ enum ATA_Cmd : uint8_t {
|
||||
NOP = 0x00,
|
||||
ATAPI_SOFT_RESET = 0x08,
|
||||
RECALIBRATE = 0x10,
|
||||
ATAPI_COMMAND_MODE_SENSE6 = 0x1A,
|
||||
READ_SECTOR = 0x20,
|
||||
READ_SECTOR_NR = 0x21,
|
||||
READ_LONG = 0x22,
|
||||
@@ -128,6 +129,7 @@ enum ATA_Cmd : uint8_t {
|
||||
WRITE_SECTOR_NR = 0x31,
|
||||
WRITE_LONG = 0x32,
|
||||
READ_VERIFY = 0x40,
|
||||
ATAPI_COMMAND_GET_CONFIG = 0x46,
|
||||
FORMAT_TRACKS = 0x50,
|
||||
IDE_SEEK = 0x70,
|
||||
DIAGNOSTICS = 0x90,
|
||||
@@ -135,6 +137,7 @@ enum ATA_Cmd : uint8_t {
|
||||
ATAPI_PACKET = 0xA0,
|
||||
ATAPI_IDFY_DEV = 0xA1,
|
||||
ATAPI_SERVICE = 0xA2,
|
||||
ATAPI_READ_DVD_STRUCTURE = 0xAD,
|
||||
READ_MULTIPLE = 0xC4,
|
||||
WRITE_MULTIPLE = 0xC5,
|
||||
SET_MULTIPLE_MODE = 0xC6,
|
||||
|
||||
@@ -326,11 +326,12 @@ done:
|
||||
heads, sectors);
|
||||
}
|
||||
|
||||
static const PropMap AtaHardDiskProperties = {
|
||||
static const PropMap AtaHardDisk_Properties = {
|
||||
{"hdd_img", new StrProperty("")},
|
||||
};
|
||||
|
||||
static const DeviceDescription AtaHardDiskDescriptor =
|
||||
{AtaHardDisk::create, {}, AtaHardDiskProperties};
|
||||
static const DeviceDescription AtaHardDisk_Descriptor = {
|
||||
AtaHardDisk::create, {}, AtaHardDisk_Properties
|
||||
};
|
||||
|
||||
REGISTER_DEVICE(AtaHardDisk, AtaHardDiskDescriptor);
|
||||
REGISTER_DEVICE(AtaHardDisk, AtaHardDisk_Descriptor);
|
||||
@@ -132,8 +132,19 @@ void AtapiCdrom::perform_packet_command() {
|
||||
this->data_out_phase();
|
||||
}
|
||||
break;
|
||||
case ScsiCommand::MODE_SENSE_6:
|
||||
this->xfer_cnt = this->mode_sense_ex(true, this->cmd_pkt, this->data_buf);
|
||||
if (!this->xfer_cnt) {
|
||||
this->present_status();
|
||||
} else {
|
||||
this->r_byte_count = this->xfer_cnt;
|
||||
this->data_ptr = (uint16_t*)this->data_buf;
|
||||
this->status_good();
|
||||
this->data_out_phase();
|
||||
}
|
||||
break;
|
||||
case ScsiCommand::MODE_SENSE_10:
|
||||
this->xfer_cnt = this->mode_sense_ex(this->cmd_pkt, this->data_buf);
|
||||
this->xfer_cnt = this->mode_sense_ex(false, this->cmd_pkt, this->data_buf);
|
||||
if (!this->xfer_cnt) {
|
||||
this->present_status();
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,238 @@
|
||||
/*
|
||||
DingusPPC - The Experimental PowerPC Macintosh emulator
|
||||
Copyright (C) 2018-24 divingkatae and maximum
|
||||
(theweirdo) spatium
|
||||
|
||||
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @file CMD646U2 PCI Ultra ATA controller emulation. */
|
||||
|
||||
#include <devices/common/ata/cmd646.h>
|
||||
#include <devices/deviceregistry.h>
|
||||
#include <loguru.hpp>
|
||||
#include <machines/machinebase.h>
|
||||
|
||||
CmdIdeCtrl::CmdIdeCtrl() : PCIDevice("cmd-ide") {
|
||||
this->supports_types(HWCompType::PCI_DEV | HWCompType::IDE_HOST);
|
||||
|
||||
// set up PCI configuration space header
|
||||
this->vendor_id = this->subsys_vndr = PCI_VENDOR_SILICON_IMAGE;
|
||||
this->device_id = this->subsys_id = DEV_ID_CMD646;
|
||||
this->class_rev = ((MY_DEV_CLASS | this->prog_if) << 8) | MY_REV_ID;
|
||||
this->max_lat = 4;
|
||||
this->min_gnt = 2;
|
||||
this->irq_pin = 1;
|
||||
|
||||
this->bars_cfg[0] = 0xFFFFFFF9; // Command block I/O space, primary channel
|
||||
this->bars_cfg[1] = 0xFFFFFFFD; // Control block I/O space, primary channel
|
||||
this->bars_cfg[2] = 0xFFFFFFF9; // Command block I/O space, secondary channel
|
||||
this->bars_cfg[3] = 0xFFFFFFFD; // Control block I/O space, secondary channel
|
||||
this->bars_cfg[4] = 0xFFFFFFF1; // Bus master I/O space, both channels
|
||||
|
||||
this->finish_config_bars();
|
||||
|
||||
this->pci_notify_bar_change = [this](int bar_num) {
|
||||
this->notify_bar_change(bar_num);
|
||||
};
|
||||
|
||||
gMachineObj->add_device("CmdAta0", std::unique_ptr<IdeChannel>(new IdeChannel("CmdAta0")));
|
||||
gMachineObj->add_device("CmdAta1", std::unique_ptr<IdeChannel>(new IdeChannel("CmdAta1")));
|
||||
|
||||
this->ch0 = dynamic_cast<IdeChannel*>(gMachineObj->get_comp_by_name("CmdAta0"));
|
||||
this->ch1 = dynamic_cast<IdeChannel*>(gMachineObj->get_comp_by_name("CmdAta1"));
|
||||
|
||||
this->ch0->set_irq_callback([this](const uint8_t intrq_state) {
|
||||
LOG_F(INFO, "CmdAta0 INTRQ updated to %d", intrq_state);
|
||||
this->update_irq(0, intrq_state);
|
||||
});
|
||||
|
||||
this->ch1->set_irq_callback([this](const uint8_t intrq_state) {
|
||||
LOG_F(INFO, "CmdAta1 INTRQ updated to %d", intrq_state);
|
||||
this->update_irq(1, intrq_state);
|
||||
});
|
||||
}
|
||||
|
||||
uint32_t CmdIdeCtrl::pci_cfg_read(uint32_t reg_offs, AccessDetails &details) {
|
||||
if (reg_offs < 64)
|
||||
return PCIDevice::pci_cfg_read(reg_offs, details);
|
||||
|
||||
if (details.size != 1)
|
||||
ABORT_F("%s: non-byte read from PCI config reg 0x%X", this->name.c_str(),
|
||||
reg_offs + details.offset);
|
||||
|
||||
if (reg_offs < 112)
|
||||
return this->read_config_reg(reg_offs + details.offset);
|
||||
|
||||
LOG_F(WARNING, "%s: reading config reg at 0x%X", this->name.c_str(), reg_offs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CmdIdeCtrl::pci_cfg_write(uint32_t reg_offs, uint32_t value, AccessDetails &details) {
|
||||
if (reg_offs < 64) {
|
||||
PCIDevice::pci_cfg_write(reg_offs, value, details);
|
||||
return;
|
||||
}
|
||||
|
||||
if (details.size != 1)
|
||||
ABORT_F("%s: non-byte write to PCI config reg 0x%X", this->name.c_str(),
|
||||
reg_offs + details.offset);
|
||||
|
||||
if (reg_offs < 112)
|
||||
this->write_config_reg(reg_offs + details.offset, value);
|
||||
else
|
||||
LOG_F(WARNING, "%s: writing config reg at 0x%X", this->name.c_str(), reg_offs);
|
||||
}
|
||||
|
||||
void CmdIdeCtrl::notify_bar_change(int bar_num) {
|
||||
if (bar_num >= 0 && bar_num <= 4)
|
||||
this->io_bases[bar_num] = this->bars[bar_num] & ~3;
|
||||
}
|
||||
|
||||
bool CmdIdeCtrl::pci_io_read(uint32_t offset, uint32_t size, uint32_t* res) {
|
||||
*res = 0;
|
||||
|
||||
if ((offset & ~7) == this->io_bases[0]) {
|
||||
*res = this->ch0->read(offset & 7, size);
|
||||
} else if ((offset & ~7) == this->io_bases[2]) {
|
||||
*res = this->ch1->read(offset & 7, size);
|
||||
} else if ((offset & ~3) == this->io_bases[1]) {
|
||||
*res = this->ch0->read((offset & 3) + DEV_CTRL_BLK_OFFSET, size);
|
||||
} else if ((offset & ~3) == this->io_bases[3]) {
|
||||
*res = this->ch1->read((offset & 3) + DEV_CTRL_BLK_OFFSET, size);
|
||||
} else if ((offset & ~0xF) == this->io_bases[4]) {
|
||||
*res = this->read_bus_master_reg(offset & 0xF);
|
||||
} else {
|
||||
*res = 0xFFFFFFFFUL;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CmdIdeCtrl::pci_io_write(uint32_t offset, uint32_t value, uint32_t size) {
|
||||
if ((offset & ~7) == this->io_bases[0]) {
|
||||
this->ch0->write(offset & 7, value, size);
|
||||
} else if ((offset & ~7) == this->io_bases[2]) {
|
||||
this->ch1->write(offset & 7, value, size);
|
||||
} else if ((offset & ~3) == this->io_bases[1]) {
|
||||
this->ch0->write((offset & 3) + DEV_CTRL_BLK_OFFSET, value, size);
|
||||
} else if ((offset & ~3) == this->io_bases[3]) {
|
||||
this->ch1->write((offset & 3) + DEV_CTRL_BLK_OFFSET, value, size);
|
||||
} else if ((offset & ~0xF) == this->io_bases[4]) {
|
||||
this->write_bus_master_reg(offset & 0xF, value & 0xFFU);
|
||||
} else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
uint8_t CmdIdeCtrl::read_config_reg(uint32_t reg_offset) {
|
||||
switch(reg_offset) {
|
||||
case ARTTIM0:
|
||||
return this->addr_setup_time_0;
|
||||
case DRWTIM0:
|
||||
return this->data_rw_time_0;
|
||||
case ARTTIM1:
|
||||
return this->addr_setup_time_1;
|
||||
case DRWTIM1:
|
||||
return this->data_rw_time_1;
|
||||
default:
|
||||
LOG_F(ERROR, "%s: unimplemented config reg at 0x%X", this->name.c_str(),
|
||||
reg_offset);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CmdIdeCtrl::write_config_reg(uint32_t reg_offset, uint8_t val) {
|
||||
switch(reg_offset) {
|
||||
case ARTTIM0:
|
||||
this->addr_setup_time_0 = val;
|
||||
LOG_F(9, "%s: ARTTIM0 set to 0x%X", this->name.c_str(), val);
|
||||
break;
|
||||
case DRWTIM0:
|
||||
this->data_rw_time_0 = val;
|
||||
LOG_F(9, "%s: DRWTIM0 set to 0x%X", this->name.c_str(), val);
|
||||
break;
|
||||
case ARTTIM1:
|
||||
this->addr_setup_time_1 = val;
|
||||
LOG_F(9, "%s: ARTTIM1 set to 0x%X", this->name.c_str(), val);
|
||||
break;
|
||||
case DRWTIM1:
|
||||
this->data_rw_time_1 = val;
|
||||
LOG_F(9, "%s: DRWTIM1 set to 0x%X", this->name.c_str(), val);
|
||||
break;
|
||||
default:
|
||||
LOG_F(ERROR, "%s: unimplemented config reg at 0x%X", this->name.c_str(),
|
||||
reg_offset);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t CmdIdeCtrl::read_bus_master_reg(const uint8_t reg_offset) {
|
||||
switch(reg_offset) {
|
||||
case MRDMODE:
|
||||
return this->mrdmode;
|
||||
default:
|
||||
LOG_F(ERROR, "%s: unimplemented bus master reg at 0x%X", this->name.c_str(),
|
||||
reg_offset);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CmdIdeCtrl::write_bus_master_reg(const uint8_t reg_offset, const uint8_t val) {
|
||||
switch(reg_offset) {
|
||||
case MRDMODE:
|
||||
if (val & BM_CH0_INT)
|
||||
this->mrdmode &= ~BM_CH0_INT;
|
||||
if (val & BM_CH1_INT)
|
||||
this->mrdmode &= ~BM_CH1_INT;
|
||||
this->mrdmode = (this->mrdmode & ~(BM_BLOCK_CH0_INT | BM_BLOCK_CH1_INT)) |
|
||||
(val & (BM_BLOCK_CH0_INT | BM_BLOCK_CH1_INT));
|
||||
LOG_F(INFO, "%s: MRDMODE set to 0x%X", this->name.c_str(), val);
|
||||
if ((this->mrdmode & BM_CH0_INT) && !(this->mrdmode & BM_BLOCK_CH0_INT))
|
||||
this->update_irq(0, 1);
|
||||
if ((this->mrdmode & BM_CH1_INT) && !(this->mrdmode & BM_BLOCK_CH1_INT))
|
||||
this->update_irq(1, 1);
|
||||
break;
|
||||
case UDIDETCR0:
|
||||
this->udma_time_cr = val;
|
||||
break;
|
||||
default:
|
||||
LOG_F(ERROR, "%s: unimplemented bus master reg at 0x%X", this->name.c_str(),
|
||||
reg_offset);
|
||||
}
|
||||
}
|
||||
|
||||
void CmdIdeCtrl::update_irq(const int ch_num, const uint8_t irq_level) {
|
||||
bool forward_irq = !(this->mrdmode & (ch_num ? BM_BLOCK_CH1_INT : BM_BLOCK_CH0_INT));
|
||||
|
||||
if (irq_level)
|
||||
this->mrdmode |= ch_num ? BM_CH1_INT : BM_CH0_INT;
|
||||
else
|
||||
this->mrdmode &= ~(ch_num ? BM_CH1_INT : BM_CH0_INT);
|
||||
|
||||
if (!irq_level || forward_irq)
|
||||
this->pci_interrupt(irq_level);
|
||||
}
|
||||
|
||||
static const DeviceDescription CmdIde_Descriptor = {
|
||||
CmdIdeCtrl::create, {}, {}
|
||||
};
|
||||
|
||||
REGISTER_DEVICE(CmdAta, CmdIde_Descriptor);
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
DingusPPC - The Experimental PowerPC Macintosh emulator
|
||||
Copyright (C) 2018-24 divingkatae and maximum
|
||||
(theweirdo) spatium
|
||||
|
||||
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @file CMD646U2 PCI Ultra ATA controller definitions. */
|
||||
|
||||
#ifndef CMD646_IDE_H
|
||||
#define CMD646_IDE_H
|
||||
|
||||
#include <devices/common/hwcomponent.h>
|
||||
#include <devices/common/hwinterrupt.h>
|
||||
#include <devices/common/ata/idechannel.h>
|
||||
#include <devices/common/pci/pcidevice.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#define DEV_ID_CMD646 0x646
|
||||
#define MY_DEV_CLASS 0x010180 // mass storage | IDE controller | IDE master
|
||||
#define MY_REV_ID 7
|
||||
|
||||
// Offset for converting addresses of the device control block registers
|
||||
// defined in the PCI IDE Controller specification, rev. 1.0 3/4/94
|
||||
// to the addresses used in IdeChannel
|
||||
#define DEV_CTRL_BLK_OFFSET 0x14
|
||||
|
||||
/** CMD646 control/status registers. */
|
||||
enum {
|
||||
ARTTIM0 = 0x53,
|
||||
DRWTIM0 = 0x54,
|
||||
ARTTIM1 = 0x55,
|
||||
DRWTIM1 = 0x56,
|
||||
};
|
||||
|
||||
/** CMD646 bus master registers. */
|
||||
enum {
|
||||
MRDMODE = 1, // misnomer, contains interrupt control/status bits (CMD646U2 specific)
|
||||
UDIDETCR0 = 3, // Ultra DMA timing control register (CMD646U2 specific)
|
||||
};
|
||||
|
||||
/** Bit definitions for the MRDMODE register. */
|
||||
enum {
|
||||
BM_CH0_INT = 1 << 2,
|
||||
BM_CH1_INT = 1 << 3,
|
||||
BM_BLOCK_CH0_INT = 1 << 4,
|
||||
BM_BLOCK_CH1_INT = 1 << 5,
|
||||
};
|
||||
|
||||
class CmdIdeCtrl : public PCIDevice {
|
||||
public:
|
||||
CmdIdeCtrl();
|
||||
~CmdIdeCtrl() = default;
|
||||
|
||||
static std::unique_ptr<HWComponent> create() {
|
||||
return std::unique_ptr<CmdIdeCtrl>(new CmdIdeCtrl());
|
||||
}
|
||||
|
||||
// PCIDevice methods
|
||||
uint32_t pci_cfg_read(uint32_t reg_offs, AccessDetails &details) override;
|
||||
void pci_cfg_write(uint32_t reg_offs, uint32_t value, AccessDetails &details) override;
|
||||
|
||||
bool pci_io_read(uint32_t offset, uint32_t size, uint32_t* res) override;
|
||||
bool pci_io_write(uint32_t offset, uint32_t value, uint32_t size) override;
|
||||
|
||||
private:
|
||||
void notify_bar_change(int bar_num);
|
||||
uint8_t read_config_reg(uint32_t reg_offset);
|
||||
void write_config_reg(uint32_t reg_offset, uint8_t val);
|
||||
uint8_t read_bus_master_reg(const uint8_t reg_offset);
|
||||
void write_bus_master_reg(const uint8_t reg_offset, const uint8_t val);
|
||||
void update_irq(const int ch_num, const uint8_t irq_level);
|
||||
|
||||
// on reset, programming interface defaults to
|
||||
// "both channels operating in native mode"
|
||||
uint8_t prog_if = 0x0F;
|
||||
|
||||
uint32_t io_bases[5] = {};
|
||||
|
||||
IdeChannel *ch0 = nullptr;
|
||||
IdeChannel *ch1 = nullptr;
|
||||
|
||||
// unknown default, set it to 2 clocks (60 ns)
|
||||
uint8_t addr_setup_time_0 = 0x40; // address setup time for drive 0
|
||||
uint8_t addr_setup_time_1 = 0x40; // address setup time for drive 1
|
||||
uint8_t data_rw_time_0 = 0x00; // data read/write time for drive 0
|
||||
uint8_t data_rw_time_1 = 0x00; // data read/write time for drive 1
|
||||
|
||||
uint8_t mrdmode = 0;
|
||||
uint8_t udma_time_cr = 0;
|
||||
};
|
||||
|
||||
#endif // CMD646_IDE_H
|
||||
+57
-18
@@ -97,6 +97,7 @@ uint8_t DMAChannel::interpret_cmd() {
|
||||
switch (this->cur_cmd) {
|
||||
case DBDMA_Cmd::OUTPUT_MORE:
|
||||
case DBDMA_Cmd::OUTPUT_LAST:
|
||||
this->xfer_to_device();
|
||||
if (this->out_cb)
|
||||
this->out_cb();
|
||||
break;
|
||||
@@ -131,6 +132,7 @@ uint8_t DMAChannel::interpret_cmd() {
|
||||
case DBDMA_Cmd::STOP:
|
||||
this->ch_stat &= ~CH_STAT_ACTIVE;
|
||||
this->cmd_in_progress = false;
|
||||
this->finish_cmd();
|
||||
break;
|
||||
default:
|
||||
LOG_F(ERROR, "%s: Unsupported DMA command 0x%X", this->get_name().c_str(),
|
||||
@@ -170,9 +172,7 @@ void DMAChannel::finish_cmd() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (res.is_writable)
|
||||
WRITE_WORD_LE_A(&cmd_desc[14], this->ch_stat | CH_STAT_ACTIVE);
|
||||
this->ch_stat &= ~CH_STAT_FLUSH;
|
||||
this->ch_stat &= ~CH_STAT_BT;
|
||||
|
||||
// react to cmd.b (branch) bits
|
||||
if (cmd_desc[2] & 0xC) {
|
||||
@@ -187,21 +187,29 @@ void DMAChannel::finish_cmd() {
|
||||
if (cond) {
|
||||
this->cmd_ptr = READ_DWORD_LE_A(&cmd_desc[8]);
|
||||
branch_taken = true;
|
||||
this->ch_stat |= CH_STAT_BT;
|
||||
}
|
||||
}
|
||||
|
||||
this->update_irq();
|
||||
if (res.is_writable)
|
||||
WRITE_WORD_LE_A(&cmd_desc[14], this->ch_stat | CH_STAT_ACTIVE);
|
||||
}
|
||||
|
||||
this->ch_stat &= ~(CH_STAT_FLUSH | CH_STAT_BT);
|
||||
|
||||
// all INPUT and OUTPUT commands including LOAD_QUAD and STORE_QUAD update cmd.resCount
|
||||
if (this->cur_cmd < DBDMA_Cmd::NOP && res.is_writable) {
|
||||
WRITE_WORD_LE_A(&cmd_desc[12], this->queue_len);
|
||||
this->res_count = 0;
|
||||
}
|
||||
|
||||
if (!branch_taken)
|
||||
if (this->cur_cmd < DBDMA_Cmd::STOP && !branch_taken)
|
||||
this->cmd_ptr += 16;
|
||||
|
||||
if (this->cur_cmd < DBDMA_Cmd::STOP) {
|
||||
this->update_irq();
|
||||
}
|
||||
|
||||
this->cmd_in_progress = false;
|
||||
}
|
||||
|
||||
@@ -293,24 +301,27 @@ void DMAChannel::update_irq() {
|
||||
}
|
||||
|
||||
uint32_t DMAChannel::reg_read(uint32_t offset, int size) {
|
||||
if (size != 4) {
|
||||
ABORT_F("%s: non-DWORD read from a DMA channel not supported",
|
||||
this->get_name().c_str());
|
||||
}
|
||||
uint32_t result = 0;
|
||||
|
||||
switch (offset) {
|
||||
switch (offset & ~3) {
|
||||
case DMAReg::CH_CTRL:
|
||||
return 0; // ChannelControl reads as 0 (DBDMA spec 5.5.1, table 74)
|
||||
result = 0; // ChannelControl reads as 0 (DBDMA spec 5.5.1, table 74)
|
||||
break;
|
||||
case DMAReg::CH_STAT:
|
||||
return BYTESWAP_32(this->ch_stat);
|
||||
result = this->ch_stat;
|
||||
break;
|
||||
case DMAReg::CMD_PTR_LO:
|
||||
return BYTESWAP_32(this->cmd_ptr);
|
||||
result = this->cmd_ptr;
|
||||
break;
|
||||
default:
|
||||
LOG_F(WARNING, "%s: Unsupported DMA channel register read at 0x%X",
|
||||
this->get_name().c_str(), offset);
|
||||
}
|
||||
|
||||
return 0;
|
||||
if ((offset & 3) || size != 4)
|
||||
return BYTESWAP_SIZED(result >> ((offset & 3) * 8), size);
|
||||
else
|
||||
return BYTESWAP_32(result);
|
||||
}
|
||||
|
||||
void DMAChannel::reg_write(uint32_t offset, uint32_t value, int size) {
|
||||
@@ -327,7 +338,7 @@ void DMAChannel::reg_write(uint32_t offset, uint32_t value, int size) {
|
||||
switch (offset) {
|
||||
case DMAReg::CH_CTRL:
|
||||
mask = value >> 16;
|
||||
new_stat = (value & mask & 0xF0FFU) | (old_stat & ~mask);
|
||||
new_stat = (value & mask & 0xF0FFU) | (old_stat & ~(mask & 0xC0FF));
|
||||
LOG_F(9, "%s: New ChannelStatus value = 0x%X", this->get_name().c_str(), new_stat);
|
||||
|
||||
// update ch_stat.s0...s7 if requested (needed for interrupt generation)
|
||||
@@ -365,9 +376,13 @@ void DMAChannel::reg_write(uint32_t offset, uint32_t value, int size) {
|
||||
this->ch_stat = new_stat;
|
||||
}
|
||||
} else if ((new_stat & CH_STAT_WAKE) != (old_stat & CH_STAT_WAKE)) {
|
||||
new_stat |= CH_STAT_ACTIVE;
|
||||
this->ch_stat = new_stat;
|
||||
this->resume();
|
||||
if (new_stat & CH_STAT_WAKE) {
|
||||
new_stat |= CH_STAT_ACTIVE;
|
||||
this->ch_stat = new_stat;
|
||||
this->resume();
|
||||
} else {
|
||||
LOG_F(ERROR, "%s: Attempt to clear wake status bit 0x%04x", this->get_name().c_str(), CH_STAT_WAKE);
|
||||
}
|
||||
} else if ((new_stat & CH_STAT_PAUSE) != (old_stat & CH_STAT_PAUSE)) {
|
||||
if (new_stat & CH_STAT_PAUSE) {
|
||||
new_stat &= ~CH_STAT_ACTIVE;
|
||||
@@ -420,6 +435,20 @@ void DMAChannel::xfer_from_device() {
|
||||
this->interpret_cmd();
|
||||
}
|
||||
|
||||
void DMAChannel::xfer_to_device() {
|
||||
if (this->dev_obj == nullptr)
|
||||
return;
|
||||
|
||||
this->xfer_dir = DMA_DIR_TO_DEV;
|
||||
|
||||
if (!this->dev_obj->xfer_to(this->queue_data, this->queue_len)) {
|
||||
this->queue_len = 0;
|
||||
this->finish_cmd();
|
||||
}
|
||||
|
||||
this->interpret_cmd();
|
||||
}
|
||||
|
||||
DmaPullResult DMAChannel::pull_data(uint32_t req_len, uint32_t *avail_len, uint8_t **p_data)
|
||||
{
|
||||
*avail_len = 0;
|
||||
@@ -543,6 +572,7 @@ void DMAChannel::start() {
|
||||
if (this->ch_stat & CH_STAT_PAUSE) {
|
||||
LOG_F(WARNING, "%s: Cannot start DMA channel, PAUSE bit is set",
|
||||
this->get_name().c_str());
|
||||
this->ch_stat &= ~CH_STAT_ACTIVE; // TODO: Test this in Open Firmware.
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -571,6 +601,15 @@ void DMAChannel::resume() {
|
||||
}
|
||||
|
||||
LOG_F(INFO, "%s: Resuming DMA channel", this->get_name().c_str());
|
||||
|
||||
// some DBDMA programs contain commands that don't transfer data
|
||||
// between a device and memory (LOAD_QUAD, STORE_QUAD, NOP and STOP).
|
||||
// We thus interprete the DBDMA program until a data transfer between
|
||||
// a device and memory is queued or the channel becomes idle/dead.
|
||||
while (!this->cmd_in_progress && !(this->ch_stat & CH_STAT_DEAD) &&
|
||||
(this->ch_stat & CH_STAT_ACTIVE)) {
|
||||
this->interpret_cmd();
|
||||
}
|
||||
}
|
||||
|
||||
void DMAChannel::abort() {
|
||||
|
||||
@@ -135,6 +135,7 @@ protected:
|
||||
void xfer_quad(const DMACmd *cmd_desc, DMACmd *cmd_host);
|
||||
void update_irq();
|
||||
void xfer_from_device();
|
||||
void xfer_to_device();
|
||||
|
||||
void start(void);
|
||||
void resume(void);
|
||||
|
||||
@@ -99,6 +99,7 @@ public:
|
||||
void connect(DmaChannel *ch_obj) { this->channel_obj = ch_obj; };
|
||||
void notify(DmaMsg msg) {};
|
||||
virtual int xfer_from(uint8_t *buf, int len) { return len; };
|
||||
virtual int xfer_to(uint8_t *buf, int len) { return len; };
|
||||
|
||||
protected:
|
||||
DmaChannel* channel_obj = nullptr;
|
||||
|
||||
@@ -71,6 +71,15 @@ enum IntSrc : uint32_t {
|
||||
DMA_DAVBUS_Rx,
|
||||
DMA_ETHERNET_Tx,
|
||||
DMA_ETHERNET_Rx,
|
||||
FIREWIRE,
|
||||
PCI_J12,
|
||||
PCI_J11,
|
||||
PCI_J10,
|
||||
PCI_J9,
|
||||
ATA,
|
||||
USB,
|
||||
PIPPIN_E,
|
||||
PIPPIN_F,
|
||||
};
|
||||
|
||||
/** Base class for interrupt controllers. */
|
||||
|
||||
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <cpu/ppc/ppcemu.h>
|
||||
#include <devices/common/hwcomponent.h>
|
||||
#include <devices/common/nvram.h>
|
||||
#include <devices/deviceregistry.h>
|
||||
@@ -81,6 +82,10 @@ void NVram::init() {
|
||||
}
|
||||
|
||||
void NVram::save() {
|
||||
if (is_deterministic) {
|
||||
LOG_F(INFO, "Skipping NVRAM write to \"%s\" in deterministic mode", this->file_name.c_str());
|
||||
return;
|
||||
}
|
||||
ofstream f(this->file_name, ios::out | ios::binary);
|
||||
|
||||
/* write file identification */
|
||||
|
||||
@@ -122,7 +122,7 @@ void BanditPciDevice::verbose_address_space()
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_F(INFO, "%s address spaces:", this->pci_name.c_str());
|
||||
LOG_F(INFO, "%s address spaces:", this->get_name().c_str());
|
||||
|
||||
// verbose coarse aka 256MB memory regions
|
||||
for (mask = 0x10000, bit_pos = 0; mask != 0x80000000UL; mask <<= 1, bit_pos++) {
|
||||
@@ -143,8 +143,21 @@ void BanditPciDevice::verbose_address_space()
|
||||
|
||||
uint32_t BanditHost::read(uint32_t rgn_start, uint32_t offset, int size)
|
||||
{
|
||||
switch (offset >> 22) {
|
||||
case 3: // CONFIG_DATA
|
||||
switch (offset >> 21) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
// I/O space
|
||||
return pci_io_read_broadcast(offset & 0x007FFFFF, size);
|
||||
|
||||
case 4:
|
||||
case 5:
|
||||
// CONFIG_ADDR
|
||||
return (this->is_aspen) ? this->config_addr : BYTESWAP_32(this->config_addr);
|
||||
|
||||
case 6:
|
||||
// CONFIG_DATA
|
||||
int bus_num, dev_num, fun_num;
|
||||
uint8_t reg_offs;
|
||||
AccessDetails details;
|
||||
@@ -160,18 +173,46 @@ uint32_t BanditHost::read(uint32_t rgn_start, uint32_t offset, int size)
|
||||
LOG_READ_NON_EXISTENT_PCI_DEVICE();
|
||||
return 0xFFFFFFFFUL; // PCI spec §6.1
|
||||
|
||||
case 2: // CONFIG_ADDR
|
||||
return (this->is_aspen) ? this->config_addr : BYTESWAP_32(this->config_addr);
|
||||
case 7:
|
||||
// Interrupt
|
||||
LOG_F(ERROR, "%s: Interrupt Acknowledge Cycle 0x%08x unsupported", this->name.c_str(), offset & 0x001FFFFF);
|
||||
break;
|
||||
|
||||
default: // I/O space
|
||||
return pci_io_read_broadcast(offset, size);
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
case 13:
|
||||
case 14:
|
||||
// 24-Bit Memory Address
|
||||
case 15:
|
||||
// 24-Bit Memory Address or VGA Device Access
|
||||
LOG_F(ERROR, "%s: Pass-Through read 0x%08x unsupported", this->name.c_str(), offset & 0x00FFFFFF);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void BanditHost::write(uint32_t rgn_start, uint32_t offset, uint32_t value, int size)
|
||||
{
|
||||
switch (offset >> 22) {
|
||||
case 3: // CONFIG_DATA
|
||||
switch (offset >> 21) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
// I/O space
|
||||
pci_io_write_broadcast(offset & 0x007FFFFF, size, value);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
case 5:
|
||||
// CONFIG_ADDR
|
||||
this->config_addr = (this->is_aspen) ? value : BYTESWAP_32(value);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
// CONFIG_DATA
|
||||
int bus_num, dev_num, fun_num;
|
||||
uint8_t reg_offs;
|
||||
AccessDetails details;
|
||||
@@ -192,12 +233,23 @@ void BanditHost::write(uint32_t rgn_start, uint32_t offset, uint32_t value, int
|
||||
LOG_WRITE_NON_EXISTENT_PCI_DEVICE();
|
||||
break;
|
||||
|
||||
case 2: // CONFIG_ADDR
|
||||
this->config_addr = (this->is_aspen) ? value : BYTESWAP_32(value);
|
||||
case 7:
|
||||
// Special
|
||||
LOG_F(ERROR, "%s: Special Cycle 0x%08x unsupported", this->name.c_str(), offset & 0x001FFFFF);
|
||||
break;
|
||||
|
||||
default: // I/O space
|
||||
pci_io_write_broadcast(offset, size, value);
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
case 13:
|
||||
case 14:
|
||||
// 24-Bit Memory Address
|
||||
case 15:
|
||||
// 24-Bit Memory Address or VGA Device Access
|
||||
LOG_F(ERROR, "%s: Pass-Through read 0x%08x unsupported", this->name.c_str(), offset & 0x00FFFFFF);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,32 +287,7 @@ inline void BanditHost::cfg_setup(uint32_t offset, int size, int &bus_num,
|
||||
}
|
||||
|
||||
int BanditHost::device_postinit() {
|
||||
std::string pci_dev_name;
|
||||
|
||||
static const std::map<std::string, int> pci_slots1 = {
|
||||
{"pci_A1", DEV_FUN(0xD,0)}, {"pci_B1", DEV_FUN(0xE,0)}, {"pci_C1", DEV_FUN(0xF,0)}
|
||||
};
|
||||
|
||||
static const std::map<std::string, int> pci_slots2 = {
|
||||
{"pci_D2", DEV_FUN(0xD,0)}, {"pci_E2", DEV_FUN(0xE,0)}, {"pci_F2", DEV_FUN(0xF,0)}
|
||||
};
|
||||
|
||||
static const std::map<std::string, int> vci_slots = {
|
||||
{"vci_D", DEV_FUN(0xD,0)}, {"vci_E", DEV_FUN(0xE,0)}, {"vci_F", DEV_FUN(0xF,0)}
|
||||
};
|
||||
|
||||
for (auto& slot :
|
||||
this->bridge_num == 0 ? vci_slots :
|
||||
this->bridge_num == 1 ? pci_slots1 :
|
||||
this->bridge_num == 2 ? pci_slots2 :
|
||||
pci_slots1
|
||||
) {
|
||||
pci_dev_name = GET_STR_PROP(slot.first);
|
||||
if (!pci_dev_name.empty()) {
|
||||
this->attach_pci_device(pci_dev_name, slot.second);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return this->pcihost_device_postinit();
|
||||
}
|
||||
|
||||
Bandit::Bandit(int bridge_num, std::string name, int dev_id, int rev)
|
||||
@@ -277,14 +304,15 @@ Bandit::Bandit(int bridge_num, std::string name, int dev_id, int rev)
|
||||
|
||||
// add memory mapped I/O region for Bandit control registers
|
||||
// This region has the following layout:
|
||||
// base_addr + 0x000000 --> I/O space
|
||||
// base_addr + 0x800000 --> CONFIG_ADDR
|
||||
// base_addr + 0xC00000 --> CONFIG_DATA
|
||||
// base_addr + 0x1000000 --> pass-through memory space (not included below)
|
||||
mem_ctrl->add_mmio_region(base_addr, 0x01000000, this);
|
||||
// base_addr + 0x00000000 --> I/O space
|
||||
// base_addr + 0x00800000 --> CONFIG_ADDR
|
||||
// base_addr + 0x00C00000 --> CONFIG_DATA
|
||||
// base_addr + 0x00E00000 --> Special(W)/Interrupt(R)
|
||||
// base_addr + 0x01000000 --> pass-through memory space ; grandcentral exists here for pci1
|
||||
mem_ctrl->add_mmio_region(base_addr, bridge_num == 1 ? 0x01000000 : 0x02000000, this);
|
||||
|
||||
// connnect Bandit PCI device
|
||||
this->my_pci_device = unique_ptr<BanditPciDevice>(
|
||||
this->my_pci_device = std::unique_ptr<BanditPciDevice>(
|
||||
new BanditPciDevice(bridge_num, name, dev_id, rev)
|
||||
);
|
||||
this->pci_register_device(DEV_FUN(BANDIT_DEV,0), this->my_pci_device.get());
|
||||
@@ -346,7 +374,18 @@ static const PropMap Chaos_Properties = {
|
||||
new StrProperty("")},
|
||||
{"vci_E",
|
||||
new StrProperty("")},
|
||||
{"vci_F",
|
||||
};
|
||||
|
||||
static const PropMap PsxPci1_Properties = {
|
||||
{"pci_A1",
|
||||
new StrProperty("")},
|
||||
{"pci_B1",
|
||||
new StrProperty("")},
|
||||
{"pci_C1",
|
||||
new StrProperty("")},
|
||||
{"pci_E1",
|
||||
new StrProperty("")},
|
||||
{"pci_F1",
|
||||
new StrProperty("")},
|
||||
};
|
||||
|
||||
@@ -359,7 +398,7 @@ static const DeviceDescription Bandit2_Descriptor = {
|
||||
};
|
||||
|
||||
static const DeviceDescription PsxPci1_Descriptor = {
|
||||
Bandit::create_psx_first, {}, Bandit1_Properties
|
||||
Bandit::create_psx_first, {}, PsxPci1_Properties
|
||||
};
|
||||
|
||||
static const DeviceDescription Chaos_Descriptor = {
|
||||
|
||||
@@ -73,14 +73,11 @@ class BanditHost : public PCIHost, public MMIODevice {
|
||||
public:
|
||||
BanditHost(int bridge_num) { this->bridge_num = bridge_num; };
|
||||
|
||||
// PCIHost methods
|
||||
virtual void pci_interrupt(uint8_t irq_line_state, PCIBase *dev) {}
|
||||
|
||||
// MMIODevice methods
|
||||
uint32_t read(uint32_t rgn_start, uint32_t offset, int size);
|
||||
void write(uint32_t rgn_start, uint32_t offset, uint32_t value, int size);
|
||||
uint32_t read(uint32_t rgn_start, uint32_t offset, int size) override;
|
||||
void write(uint32_t rgn_start, uint32_t offset, uint32_t value, int size) override;
|
||||
|
||||
int device_postinit();
|
||||
int device_postinit() override;
|
||||
|
||||
protected:
|
||||
uint32_t config_addr;
|
||||
|
||||
@@ -86,8 +86,28 @@ void DecPciBridge::pci_cfg_write(uint32_t reg_offs, uint32_t value, AccessDetail
|
||||
}
|
||||
}
|
||||
|
||||
static const PropMap Dec21154Yosemite_Properties = {
|
||||
{"pci_FireWire",
|
||||
new StrProperty("")},
|
||||
{"pci_UltraATA",
|
||||
new StrProperty("")},
|
||||
{"pci_J11",
|
||||
new StrProperty("")},
|
||||
{"pci_J10",
|
||||
new StrProperty("")},
|
||||
{"pci_J9",
|
||||
new StrProperty("")},
|
||||
{"pci_USB",
|
||||
new StrProperty("")},
|
||||
};
|
||||
|
||||
static const DeviceDescription Dec21154_Descriptor = {
|
||||
DecPciBridge::create, {}, {}
|
||||
};
|
||||
|
||||
static const DeviceDescription Dec21154Yosemite_Descriptor = {
|
||||
DecPciBridge::create_yosemite, {}, Dec21154Yosemite_Properties
|
||||
};
|
||||
|
||||
REGISTER_DEVICE(Dec21154, Dec21154_Descriptor);
|
||||
REGISTER_DEVICE(Dec21154Yosemite, Dec21154Yosemite_Descriptor);
|
||||
@@ -44,6 +44,10 @@ public:
|
||||
return std::unique_ptr<DecPciBridge>(new DecPciBridge("DEC21154"));
|
||||
}
|
||||
|
||||
static std::unique_ptr<HWComponent> create_yosemite() {
|
||||
return std::unique_ptr<DecPciBridge>(new DecPciBridge("DEC21154Yosemite"));
|
||||
}
|
||||
|
||||
// PCIDevice methods
|
||||
uint32_t pci_cfg_read(uint32_t reg_offs, AccessDetails &details);
|
||||
void pci_cfg_write(uint32_t reg_offs, uint32_t value, AccessDetails &details);
|
||||
|
||||
@@ -32,7 +32,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
PCIBase::PCIBase(std::string name, PCIHeaderType hdr_type, int num_bars)
|
||||
{
|
||||
this->name = name;
|
||||
this->pci_name = name;
|
||||
this->hdr_type = hdr_type;
|
||||
this->num_bars = num_bars;
|
||||
|
||||
@@ -162,17 +161,17 @@ int PCIBase::attach_exp_rom_image(const std::string img_path)
|
||||
|
||||
if (exp_rom_image_size == this->exp_rom_size) {
|
||||
LOG_F(INFO, "%s: loaded expansion rom (%d bytes).",
|
||||
this->pci_name.c_str(), this->exp_rom_size);
|
||||
this->get_name().c_str(), this->exp_rom_size);
|
||||
}
|
||||
else {
|
||||
LOG_F(WARNING, "%s: loaded expansion rom (%d bytes adjusted to %d bytes).",
|
||||
this->pci_name.c_str(), (int)exp_rom_image_size, this->exp_rom_size);
|
||||
this->get_name().c_str(), (int)exp_rom_image_size, this->exp_rom_size);
|
||||
}
|
||||
|
||||
this->exp_bar_cfg = ~(this->exp_rom_size - 1);
|
||||
}
|
||||
catch (const std::exception& exc) {
|
||||
LOG_F(ERROR, "%s: %s", this->pci_name.c_str(), exc.what());
|
||||
LOG_F(ERROR, "%s: %s", this->get_name().c_str(), exc.what());
|
||||
result = -1;
|
||||
}
|
||||
|
||||
@@ -192,7 +191,7 @@ void PCIBase::set_bar_value(int bar_num, uint32_t value)
|
||||
case PCIBarType::Io_32_Bit:
|
||||
this->bars[bar_num] = (value & bar_cfg & ~3) | (bar_cfg & 3);
|
||||
if (value != 0xFFFFFFFFUL && (value & ~3) != (value & bar_cfg & ~3)) {
|
||||
LOG_F(ERROR, "%s: BAR %d cannot be 0x%08x (set to 0x%08x)", this->pci_name.c_str(), bar_num, (value & ~3), (value & bar_cfg & ~3));
|
||||
LOG_F(ERROR, "%s: BAR %d cannot be 0x%08x (set to 0x%08x)", this->get_name().c_str(), bar_num, (value & ~3), (value & bar_cfg & ~3));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -201,7 +200,7 @@ void PCIBase::set_bar_value(int bar_num, uint32_t value)
|
||||
case PCIBarType::Mem_64_Bit_Lo:
|
||||
this->bars[bar_num] = (value & bar_cfg & ~0xF) | (bar_cfg & 0xF);
|
||||
if (value != 0xFFFFFFFFUL && (value & ~0xF) != (value & bar_cfg & ~0xF)) {
|
||||
LOG_F(ERROR, "%s: BAR %d cannot be 0x%08x (set to 0x%08x)", this->pci_name.c_str(), bar_num, (value & ~0xF), (value & bar_cfg & ~0xF));
|
||||
LOG_F(ERROR, "%s: BAR %d cannot be 0x%08x (set to 0x%08x)", this->get_name().c_str(), bar_num, (value & ~0xF), (value & bar_cfg & ~0xF));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -239,11 +238,11 @@ void PCIBase::finish_config_bars()
|
||||
case 2:
|
||||
if (bar_num >= num_bars - 1) {
|
||||
ABORT_F("%s: BAR %d cannot be 64-bit",
|
||||
this->pci_name.c_str(), bar_num);
|
||||
this->get_name().c_str(), bar_num);
|
||||
}
|
||||
else if (this->bars_cfg[bar_num+1] == 0) {
|
||||
ABORT_F("%s: 64-bit BAR %d has zero for upper 32 bits",
|
||||
this->pci_name.c_str(), bar_num);
|
||||
this->get_name().c_str(), bar_num);
|
||||
}
|
||||
else {
|
||||
bars_typ[bar_num++] = PCIBarType::Mem_64_Bit_Lo;
|
||||
@@ -252,7 +251,7 @@ void PCIBase::finish_config_bars()
|
||||
break;
|
||||
default:
|
||||
ABORT_F("%s: invalid or unsupported PCI space type %d for BAR %d",
|
||||
this->pci_name.c_str(), pci_space_type, bar_num);
|
||||
this->get_name().c_str(), pci_space_type, bar_num);
|
||||
} // switch pci_space_type
|
||||
}
|
||||
} // for bar_num
|
||||
@@ -302,3 +301,21 @@ void PCIBase::pci_wr_exp_rom_bar(uint32_t data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PCIBase::pci_interrupt(uint8_t irq_line_state) {
|
||||
if (!(this->command & 0x0400)) {
|
||||
if (!this->int_details.int_ctrl_obj)
|
||||
this->host_instance->register_pci_int(this);
|
||||
if (this->int_details.int_ctrl_obj && this->int_details.irq_id)
|
||||
this->int_details.int_ctrl_obj->ack_int(this->int_details.irq_id, irq_line_state);
|
||||
else
|
||||
LOG_F(ERROR, "Unhandled interrupt from device %s", this->get_name().c_str());
|
||||
/* A pci device should set the interrupt status bit when an interrupt occurs
|
||||
* and it should clear the interrupt status bit when its interrupt bits are cleared.
|
||||
* The interrupt status bit is new to PCI Local Bus Specification Revision 2.3
|
||||
* and Power Macs use PCI Local Bus Specification Revision 2.0. Some PCI cards
|
||||
* might not implement this bit.
|
||||
*/
|
||||
//this->status |= 0x0008;
|
||||
}
|
||||
}
|
||||
@@ -52,11 +52,12 @@ enum {
|
||||
|
||||
/** PCI Vendor IDs for devices used in Power Macintosh computers. */
|
||||
enum {
|
||||
PCI_VENDOR_ATI = 0x1002,
|
||||
PCI_VENDOR_DEC = 0x1011,
|
||||
PCI_VENDOR_MOTOROLA = 0x1057,
|
||||
PCI_VENDOR_APPLE = 0x106B,
|
||||
PCI_VENDOR_NVIDIA = 0x10DE,
|
||||
PCI_VENDOR_ATI = 0x1002,
|
||||
PCI_VENDOR_DEC = 0x1011,
|
||||
PCI_VENDOR_MOTOROLA = 0x1057,
|
||||
PCI_VENDOR_APPLE = 0x106B,
|
||||
PCI_VENDOR_SILICON_IMAGE = 0x1095,
|
||||
PCI_VENDOR_NVIDIA = 0x10DE,
|
||||
};
|
||||
|
||||
/** PCI BAR types */
|
||||
@@ -76,6 +77,7 @@ typedef struct {
|
||||
} BarConfig;
|
||||
|
||||
class PCIBase : public MMIODevice {
|
||||
friend class PCIHost;
|
||||
public:
|
||||
PCIBase(std::string name, PCIHeaderType hdr_type, int num_bars);
|
||||
virtual ~PCIBase() = default;
|
||||
@@ -125,10 +127,12 @@ public:
|
||||
this->irq_pin = irq_pin;
|
||||
}
|
||||
|
||||
virtual void pci_interrupt(uint8_t irq_line_state) {
|
||||
this->host_instance->pci_interrupt(irq_line_state, this);
|
||||
virtual void set_int_details(IntDetails &int_details) {
|
||||
this->int_details = int_details;
|
||||
}
|
||||
|
||||
virtual void pci_interrupt(uint8_t irq_line_state);
|
||||
|
||||
// MMIODevice methods
|
||||
virtual uint32_t read(uint32_t rgn_start, uint32_t offset, int size) { return 0; }
|
||||
virtual void write(uint32_t rgn_start, uint32_t offset, uint32_t value, int size) { }
|
||||
@@ -141,7 +145,6 @@ protected:
|
||||
void map_exp_rom_mem();
|
||||
void unmap_exp_rom_mem();
|
||||
|
||||
std::string pci_name; // human-readable device name
|
||||
PCIHost* host_instance; // host bridge instance to call back
|
||||
|
||||
// PCI configuration space state (type 0, 1, and 2)
|
||||
@@ -174,6 +177,8 @@ protected:
|
||||
|
||||
// 0 = not writable; 1 = bit is enabled in command register
|
||||
uint16_t command_cfg = 0xffff - (1<<3) - (1<<7); // disable: special cycles and stepping
|
||||
|
||||
IntDetails int_details = { 0 };
|
||||
};
|
||||
|
||||
inline uint32_t pci_cfg_log(uint32_t value, AccessDetails &details) {
|
||||
|
||||
@@ -85,3 +85,7 @@ void PCIBridgeBase::pci_cfg_write(uint32_t reg_offs, uint32_t value, AccessDetai
|
||||
return PCIBase::pci_cfg_write(reg_offs, value, details);
|
||||
}
|
||||
}
|
||||
|
||||
int PCIBridgeBase::device_postinit() {
|
||||
return this->pcihost_device_postinit();
|
||||
}
|
||||
@@ -68,6 +68,9 @@ public:
|
||||
std::function<uint16_t()> pci_rd_bridge_control;
|
||||
std::function<void(uint16_t)> pci_wr_bridge_control;
|
||||
|
||||
// HWComponent methods
|
||||
virtual int device_postinit();
|
||||
|
||||
protected:
|
||||
// PCI configuration space state
|
||||
uint8_t primary_bus = 0;
|
||||
|
||||
@@ -30,6 +30,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#include <loguru.hpp>
|
||||
|
||||
#include <cinttypes>
|
||||
#include <cpu/ppc/ppcemu.h>
|
||||
|
||||
bool PCIHost::pci_register_device(int dev_fun_num, PCIBase* dev_instance)
|
||||
{
|
||||
@@ -75,15 +76,17 @@ void PCIHost::pci_unregister_device(int dev_fun_num)
|
||||
if (!this->dev_map.count(dev_fun_num)) {
|
||||
return;
|
||||
}
|
||||
PCIBase* dev_instance = this->dev_map[dev_fun_num];
|
||||
auto dev_instance = this->dev_map[dev_fun_num];
|
||||
|
||||
HWComponent *hwc = dynamic_cast<HWComponent*>(this);
|
||||
LOG_F(
|
||||
ERROR, "%s: pci_unregister_device(%s) not supported yet (every PCI device needs a working destructor)",
|
||||
// FIXME: need destructors to remove memory regions and downstream devices.
|
||||
ERROR, "%s: pci_unregister_device(%s) not supported yet (every PCI device needs a working destructor to unregister memory and downstream devices etc.)",
|
||||
hwc ? hwc->get_name().c_str() : "PCIHost", dev_instance->get_name().c_str()
|
||||
);
|
||||
|
||||
delete dev_instance;
|
||||
this->dev_map.erase(dev_fun_num);
|
||||
gMachineObj->remove_device(dev_instance); // calls destructor of dev_instance since it is a unique_ptr in the device_map.
|
||||
}
|
||||
|
||||
bool PCIHost::pci_register_mmio_region(uint32_t start_addr, uint32_t size, PCIBase* obj)
|
||||
@@ -119,9 +122,8 @@ PCIBase *PCIHost::attach_pci_device(const std::string& dev_name, int slot_id, co
|
||||
}
|
||||
|
||||
// attempt to create device object
|
||||
MachineFactory::register_device_settings(dev_name);
|
||||
auto desc = DeviceRegistry::get_descriptor(dev_name);
|
||||
map<string, string> settings;
|
||||
MachineFactory::get_device_settings(desc, settings);
|
||||
auto dev_obj = desc.m_create_func();
|
||||
|
||||
if (!dev_obj->supports_type(HWCompType::PCI_DEV)) {
|
||||
@@ -138,6 +140,7 @@ PCIBase *PCIHost::attach_pci_device(const std::string& dev_name, int slot_id, co
|
||||
gMachineObj->add_device(dev_name + dev_suffix, std::move(dev_obj));
|
||||
|
||||
PCIBase *dev = dynamic_cast<PCIBase*>(gMachineObj->get_comp_by_name(dev_name + dev_suffix));
|
||||
dev->set_name(dev->get_name() + dev_suffix);
|
||||
|
||||
// register device with the PCI host
|
||||
this->pci_register_device(slot_id, dev);
|
||||
@@ -145,7 +148,16 @@ PCIBase *PCIHost::attach_pci_device(const std::string& dev_name, int slot_id, co
|
||||
return dev;
|
||||
}
|
||||
|
||||
IntDetails PCIHost::register_pci_int(PCIBase* dev_instance) {
|
||||
InterruptCtrl *PCIHost::get_interrupt_controller() {
|
||||
if (!this->int_ctrl) {
|
||||
InterruptCtrl *int_ctrl_obj =
|
||||
dynamic_cast<InterruptCtrl*>(gMachineObj->get_comp_by_type(HWCompType::INT_CTRL));
|
||||
this->int_ctrl = int_ctrl_obj;
|
||||
}
|
||||
return this->int_ctrl;
|
||||
}
|
||||
|
||||
bool PCIHost::register_pci_int(PCIBase* dev_instance) {
|
||||
bool dev_found = false;
|
||||
int dev_fun_num = 0;
|
||||
|
||||
@@ -160,10 +172,24 @@ IntDetails PCIHost::register_pci_int(PCIBase* dev_instance) {
|
||||
ABORT_F("register_pci_int: requested device not found");
|
||||
|
||||
for (auto& irq : this->my_irq_map) {
|
||||
if (irq.dev_fun_num == dev_fun_num)
|
||||
return {this->int_ctrl, irq.irq_id};
|
||||
if (irq.dev_fun_num == dev_fun_num) {
|
||||
IntDetails new_int_detail;
|
||||
new_int_detail.int_ctrl_obj = this->get_interrupt_controller();
|
||||
if (new_int_detail.int_ctrl_obj && irq.int_src)
|
||||
new_int_detail.irq_id = new_int_detail.int_ctrl_obj->register_dev_int(irq.int_src);
|
||||
dev_instance->set_int_details(new_int_detail);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
ABORT_F("register_pci_int: no IRQ map for device 0x%X", dev_fun_num);
|
||||
|
||||
PCIBridgeBase *self = dynamic_cast<PCIBridgeBase*>(this);
|
||||
if (self) {
|
||||
if (!self->int_details.int_ctrl_obj)
|
||||
self->host_instance->register_pci_int(self);
|
||||
dev_instance->set_int_details(self->int_details);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PCIHost::pci_io_read_loop(uint32_t offset, int size, uint32_t &res)
|
||||
@@ -202,7 +228,8 @@ uint32_t PCIHost::pci_io_read_broadcast(uint32_t offset, int size)
|
||||
hwc ? hwc->get_name().c_str() : "PCIHost", offset,
|
||||
SIZE_ARG(size)
|
||||
);
|
||||
// FIXME: add machine check exception (DEFAULT CATCH!, code=FFF00200)
|
||||
// machine check exception (DEFAULT CATCH!, code=FFF00200)
|
||||
ppc_exception_handler(Except_Type::EXC_MACHINE_CHECK, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -245,3 +272,19 @@ PCIBase *PCIHost::pci_find_device(uint8_t dev_num, uint8_t fun_num)
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int PCIHost::pcihost_device_postinit()
|
||||
{
|
||||
std::string pci_dev_name;
|
||||
|
||||
for (auto& slot : this->my_irq_map) {
|
||||
if (slot.slot_name) {
|
||||
pci_dev_name = GET_STR_PROP(slot.slot_name);
|
||||
if (!pci_dev_name.empty()) {
|
||||
this->attach_pci_device(pci_dev_name, slot.dev_fun_num, std::string("@") + slot.slot_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -53,7 +53,7 @@ typedef struct AccessDetails {
|
||||
typedef struct {
|
||||
const char * slot_name;
|
||||
int dev_fun_num;
|
||||
uint32_t irq_id;
|
||||
IntSrc int_src;
|
||||
} PciIrqMap;
|
||||
|
||||
class PCIBase;
|
||||
@@ -86,16 +86,16 @@ public:
|
||||
virtual PCIBase *pci_find_device(uint8_t bus_num, uint8_t dev_num, uint8_t fun_num);
|
||||
virtual PCIBase *pci_find_device(uint8_t dev_num, uint8_t fun_num);
|
||||
|
||||
virtual void pci_interrupt(uint8_t irq_line_state, PCIBase *dev) {}
|
||||
|
||||
virtual void set_irq_map(const std::vector<PciIrqMap> &irq_map) {
|
||||
this->my_irq_map = irq_map;
|
||||
};
|
||||
virtual int pcihost_device_postinit();
|
||||
|
||||
virtual IntDetails register_pci_int(PCIBase* dev_instance);
|
||||
virtual bool register_pci_int(PCIBase* dev_instance);
|
||||
virtual void set_interrupt_controller(InterruptCtrl * int_ctrl_obj) {
|
||||
this->int_ctrl = int_ctrl_obj;
|
||||
};
|
||||
virtual InterruptCtrl *get_interrupt_controller();
|
||||
|
||||
protected:
|
||||
std::unordered_map<int, PCIBase*> dev_map;
|
||||
|
||||
@@ -33,7 +33,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#include <cinttypes>
|
||||
#include <cstring>
|
||||
|
||||
Sc53C94::Sc53C94(uint8_t chip_id, uint8_t my_id) : ScsiDevice("SC53C94", my_id)
|
||||
Sc53C94::Sc53C94(uint8_t chip_id, uint8_t my_id) : ScsiDevice("SC53C94", my_id), DmaDevice()
|
||||
{
|
||||
this->chip_id = chip_id;
|
||||
this->my_bus_id = my_id;
|
||||
@@ -751,6 +751,73 @@ void Sc53C94::dma_stop()
|
||||
}
|
||||
}
|
||||
|
||||
int Sc53C94::xfer_from(uint8_t *buf, int len) {
|
||||
if (len > this->xfer_count + this->data_fifo_pos)
|
||||
LOG_F(WARNING, "%s: DMA xfer len > command xfer len", this->name.c_str());
|
||||
|
||||
if (this->data_fifo_pos) {
|
||||
int fifo_bytes = std::min(this->data_fifo_pos, len);
|
||||
std::memcpy(buf, this->data_fifo, fifo_bytes);
|
||||
this->data_fifo_pos -= fifo_bytes;
|
||||
this->xfer_count -= fifo_bytes;
|
||||
len -= fifo_bytes;
|
||||
buf += fifo_bytes;
|
||||
if (!this->xfer_count) {
|
||||
this->status |= STAT_TC; // signal zero transfer count
|
||||
this->cur_state = SeqState::XFER_END;
|
||||
this->sequencer();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (this->bus_obj->pull_data(this->target_id, buf, this->xfer_count)) {
|
||||
this->xfer_count = 0;
|
||||
this->status |= STAT_TC; // signal zero transfer count
|
||||
this->cur_state = SeqState::XFER_END;
|
||||
this->sequencer();
|
||||
return 0;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
int Sc53C94::xfer_to(uint8_t *buf, int len) {
|
||||
if (!this->xfer_count)
|
||||
return len;
|
||||
|
||||
// Being in the DATA_OUT phase means that we're about to move
|
||||
// a big chunk of data. The real device uses its FIFO as buffer.
|
||||
// For simplicity, the code below transfers the whole chunk at once.
|
||||
// This can be broken into smaller chunks later if desired.
|
||||
if (this->cur_bus_phase == ScsiPhase::DATA_OUT) {
|
||||
if (this->bus_obj->push_data(this->target_id, buf, len)) {
|
||||
this->xfer_count -= len;
|
||||
if (!this->xfer_count) {
|
||||
this->status |= STAT_TC; // signal zero transfer count
|
||||
this->cur_state = SeqState::XFER_END;
|
||||
this->sequencer();
|
||||
}
|
||||
len = 0;
|
||||
} else
|
||||
LOG_F(WARNING, "%s: xfer_to failed to transfer data", this->name.c_str());
|
||||
}
|
||||
|
||||
if (this->xfer_count) {
|
||||
// fill in the data FIFO first
|
||||
uint32_t fifo_bytes = std::min(len, DATA_FIFO_MAX - this->data_fifo_pos);
|
||||
std::memcpy(&this->data_fifo[this->data_fifo_pos], buf, fifo_bytes);
|
||||
len -= fifo_bytes;
|
||||
this->data_fifo_pos += fifo_bytes;
|
||||
this->xfer_count -= fifo_bytes;
|
||||
if (!this->xfer_count) {
|
||||
this->status |= STAT_TC; // signal zero transfer count
|
||||
this->sequencer();
|
||||
}
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static const PropMap Sc53C94_properties = {
|
||||
{"hdd_img", new StrProperty("")},
|
||||
{"cdr_img", new StrProperty("")},
|
||||
|
||||
@@ -187,7 +187,7 @@ typedef struct {
|
||||
|
||||
typedef std::function<void(const uint8_t drq_state)> DrqCb;
|
||||
|
||||
class Sc53C94 : public ScsiDevice {
|
||||
class Sc53C94 : public ScsiDevice, public DmaDevice {
|
||||
public:
|
||||
Sc53C94(uint8_t chip_id=12, uint8_t my_id=7);
|
||||
~Sc53C94() = default;
|
||||
@@ -235,6 +235,10 @@ public:
|
||||
int send_data(uint8_t* dst_ptr, int count);
|
||||
void process_command() {};
|
||||
|
||||
// DmaChannel methods
|
||||
int xfer_from(uint8_t *buf, int len); // Must be marked override!
|
||||
int xfer_to(uint8_t *buf, int len); // Must be marked override!
|
||||
|
||||
protected:
|
||||
void reset_device();
|
||||
void update_command_reg(uint8_t cmd);
|
||||
|
||||
@@ -106,7 +106,6 @@ void ScsiHardDisk::process_command() {
|
||||
case ScsiCommand::WRITE_10:
|
||||
lba = READ_DWORD_BE_U(&cmd[2]);
|
||||
this->write(lba, READ_WORD_BE_U(&cmd[7]), 10);
|
||||
this->switch_phase(ScsiPhase::DATA_OUT);
|
||||
break;
|
||||
case ScsiCommand::READ_BUFFER:
|
||||
read_buffer();
|
||||
@@ -488,6 +487,8 @@ void ScsiHardDisk::write(uint32_t lba, uint16_t transfer_len, uint8_t cmd_len) {
|
||||
this->post_xfer_action = [this, device_offset]() {
|
||||
this->disk_img.write(this->data_buf, device_offset, this->incoming_size);
|
||||
};
|
||||
|
||||
this->switch_phase(ScsiPhase::DATA_OUT);
|
||||
}
|
||||
|
||||
void ScsiHardDisk::read_buffer() {
|
||||
|
||||
@@ -72,7 +72,7 @@ private:
|
||||
uint8_t msg_code = 0;
|
||||
|
||||
//inquiry info
|
||||
char vendor_info[8] = {'D', 'i', 'n', 'g', 'u', 's', 'D', '\0'};
|
||||
char vendor_info[8] = {'Q', 'U', 'A', 'N', 'T', 'U', 'M', '\0'};
|
||||
char prod_info[16] = {'E', 'm', 'u', 'l', 'a', 't', 'e', 'd', ' ', 'D', 'i', 's', 'k', '\0'};
|
||||
char rev_info[4] = {'d', 'i', '0', '1'};
|
||||
};
|
||||
|
||||
@@ -751,7 +751,22 @@ void ViaCuda::pseudo_command() {
|
||||
}
|
||||
|
||||
uint32_t ViaCuda::calc_real_time() {
|
||||
auto end = std::chrono::system_clock::now();
|
||||
std::chrono::time_point<std::chrono::system_clock> end;
|
||||
if (is_deterministic) {
|
||||
// March 24, 2001 was the public release date of Mac OS X.
|
||||
std::tm tm = {
|
||||
.tm_sec = 0,
|
||||
.tm_min = 0,
|
||||
.tm_hour = 12,
|
||||
.tm_mday = 24,
|
||||
.tm_mon = 3 - 1,
|
||||
.tm_year = 2001 - 1900,
|
||||
.tm_isdst = 0
|
||||
};
|
||||
end = std::chrono::system_clock::from_time_t(std::mktime(&tm));
|
||||
} else {
|
||||
end = std::chrono::system_clock::now();
|
||||
}
|
||||
auto elapsed_systemclock = end - this->mac_epoch;
|
||||
auto elapsed_seconds = std::chrono::duration_cast<std::chrono::seconds>(elapsed_systemclock);
|
||||
return uint32_t(elapsed_seconds.count());
|
||||
@@ -836,7 +851,7 @@ void ViaCuda::i2c_comb_transaction(
|
||||
}
|
||||
|
||||
static const vector<string> Cuda_Subdevices = {
|
||||
"AdbBus", "AdbMouse", "AdbKeyboard"
|
||||
"AdbBus"
|
||||
};
|
||||
|
||||
static const DeviceDescription ViaCuda_Descriptor = {
|
||||
|
||||
@@ -36,7 +36,7 @@ bool DeviceRegistry::add(const std::string name, DeviceDescription desc)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DeviceRegistry::device_registered(const string dev_name)
|
||||
bool DeviceRegistry::device_registered(const std::string dev_name)
|
||||
{
|
||||
if (get_registry().find(dev_name) != get_registry().end()) {
|
||||
return true;
|
||||
@@ -45,7 +45,7 @@ bool DeviceRegistry::device_registered(const string dev_name)
|
||||
return false;
|
||||
}
|
||||
|
||||
unique_ptr<HWComponent> DeviceRegistry::create(const std::string& name)
|
||||
std::unique_ptr<HWComponent> DeviceRegistry::create(const std::string& name)
|
||||
{
|
||||
auto it = get_registry().find(name);
|
||||
if (it != get_registry().end()) {
|
||||
|
||||
@@ -34,12 +34,12 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
class HWComponent;
|
||||
|
||||
typedef std::function<unique_ptr<HWComponent> ()> CreateFunc;
|
||||
typedef std::function<std::unique_ptr<HWComponent> ()> CreateFunc;
|
||||
|
||||
struct DeviceDescription {
|
||||
CreateFunc m_create_func;
|
||||
vector<string> subdev_list;
|
||||
PropMap properties;
|
||||
CreateFunc m_create_func;
|
||||
std::vector<std::string> subdev_list;
|
||||
PropMap properties;
|
||||
};
|
||||
|
||||
class DeviceRegistry
|
||||
@@ -47,17 +47,17 @@ class DeviceRegistry
|
||||
public:
|
||||
DeviceRegistry() = delete;
|
||||
|
||||
static bool add(const string name, DeviceDescription desc);
|
||||
static bool add(const std::string name, DeviceDescription desc);
|
||||
|
||||
static bool device_registered(const string dev_name);
|
||||
static bool device_registered(const std::string dev_name);
|
||||
|
||||
static unique_ptr<HWComponent> create(const string& name);
|
||||
static std::unique_ptr<HWComponent> create(const std::string& name);
|
||||
|
||||
static DeviceDescription& get_descriptor(const std::string& name);
|
||||
|
||||
private:
|
||||
static map<string, DeviceDescription> & get_registry() {
|
||||
static map<string, DeviceDescription> device_registry;
|
||||
static std::map<std::string, DeviceDescription> & get_registry() {
|
||||
static std::map<std::string, DeviceDescription> device_registry;
|
||||
return device_registry;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -55,8 +55,6 @@ void MacSuperDrive::reset_params()
|
||||
|
||||
void MacSuperDrive::command(uint8_t addr, uint8_t value)
|
||||
{
|
||||
uint8_t new_motor_stat;
|
||||
|
||||
LOG_F(9, "%s: command addr=0x%X, value=%d", this->get_name().c_str(), addr, value);
|
||||
|
||||
switch(addr) {
|
||||
@@ -68,26 +66,15 @@ void MacSuperDrive::command(uint8_t addr, uint8_t value)
|
||||
this->cur_track += this->step_dir;
|
||||
if (this->cur_track < 0)
|
||||
this->cur_track = 0;
|
||||
else if (this->cur_track >= this->num_tracks) {
|
||||
LOG_F(ERROR, "%s: track:%d is greater than max track:%d", this->get_name().c_str(), this->cur_track, this->num_tracks - 1);
|
||||
this->cur_track = this->num_tracks - 1;
|
||||
}
|
||||
this->track_zero = this->cur_track == 0;
|
||||
}
|
||||
break;
|
||||
case CommandAddr::Motor_On_Off:
|
||||
new_motor_stat = value ^ 1;
|
||||
if (this->motor_stat != new_motor_stat) {
|
||||
this->motor_stat = new_motor_stat;
|
||||
if (new_motor_stat) {
|
||||
this->motor_on_time = TimerManager::get_instance()->current_time_ns();
|
||||
this->track_start_time = 0;
|
||||
this->sector_start_time = 0;
|
||||
this->init_track_search(-1);
|
||||
this->is_ready = 1;
|
||||
LOG_F(INFO, "%s: turn spindle motor on", this->get_name().c_str());
|
||||
} else {
|
||||
this->motor_on_time = 0;
|
||||
this->is_ready = 0;
|
||||
LOG_F(INFO, "%s: turn spindle motor off", this->get_name().c_str());
|
||||
}
|
||||
}
|
||||
this->set_motor_stat(value ^ 1);
|
||||
break;
|
||||
case CommandAddr::Eject_Disk:
|
||||
if (value) {
|
||||
@@ -95,6 +82,7 @@ void MacSuperDrive::command(uint8_t addr, uint8_t value)
|
||||
this->eject_latch = 1;
|
||||
this->reset_params();
|
||||
}
|
||||
break;
|
||||
case CommandAddr::Reset_Eject_Latch:
|
||||
if (value) {
|
||||
this->eject_latch = 0;
|
||||
@@ -111,43 +99,78 @@ void MacSuperDrive::command(uint8_t addr, uint8_t value)
|
||||
}
|
||||
}
|
||||
|
||||
void MacSuperDrive::set_motor_stat(uint8_t new_motor_stat)
|
||||
{
|
||||
if (this->motor_stat != new_motor_stat) {
|
||||
this->motor_stat = new_motor_stat;
|
||||
if (new_motor_stat) {
|
||||
this->motor_on_time = TimerManager::get_instance()->current_time_ns();
|
||||
this->track_start_time = 0;
|
||||
this->sector_start_time = 0;
|
||||
this->init_track_search(-1);
|
||||
this->is_ready = 1;
|
||||
LOG_F(INFO, "%s: turn spindle motor on", this->get_name().c_str());
|
||||
} else {
|
||||
this->motor_on_time = 0;
|
||||
this->is_ready = 0;
|
||||
LOG_F(INFO, "%s: turn spindle motor off", this->get_name().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t MacSuperDrive::status(uint8_t addr)
|
||||
{
|
||||
LOG_F(9, "%s: status request, addr = 0x%X", this->get_name().c_str(), addr);
|
||||
uint8_t value;
|
||||
|
||||
switch(addr) {
|
||||
case StatusAddr::Step_Status:
|
||||
return 1; // not sure what should be returned here
|
||||
value = 1; // not sure what should be returned here
|
||||
break;
|
||||
case StatusAddr::Motor_Status:
|
||||
return this->motor_stat ^ 1; // reverse logic
|
||||
value = this->motor_stat ^ 1; // reverse logic
|
||||
break;
|
||||
case StatusAddr::Eject_Latch:
|
||||
return this->eject_latch;
|
||||
value = this->eject_latch;
|
||||
break;
|
||||
case StatusAddr::Select_Head_0:
|
||||
return this->cur_head = 0;
|
||||
value = this->cur_head = 0;
|
||||
break;
|
||||
case StatusAddr::MFM_Support:
|
||||
return 1; // Superdrive does support MFM encoding scheme
|
||||
value = 1; // Superdrive does support MFM encoding scheme
|
||||
break;
|
||||
case StatusAddr::Double_Sided:
|
||||
return 1; // yes, Superdrive is double sided
|
||||
value = 1; // yes, Superdrive is double sided
|
||||
break;
|
||||
case StatusAddr::Drive_Exists:
|
||||
return 0; // tell the world I'm here
|
||||
value = 0; // tell the world I'm here
|
||||
break;
|
||||
case StatusAddr::Disk_In_Drive:
|
||||
return this->has_disk ^ 1; // reverse logic (active low)!
|
||||
value = this->has_disk ^ 1; // reverse logic (active low)!
|
||||
break;
|
||||
case StatusAddr::Write_Protect:
|
||||
return this->wr_protect ^ 1; // reverse logic
|
||||
value = this->wr_protect ^ 1; // reverse logic
|
||||
break;
|
||||
case StatusAddr::Track_Zero:
|
||||
return this->track_zero ^ 1; // reverse logic
|
||||
value = this->track_zero ^ 1; // reverse logic
|
||||
break;
|
||||
case StatusAddr::Select_Head_1:
|
||||
return this->cur_head = 1;
|
||||
value = this->cur_head = 1;
|
||||
break;
|
||||
case StatusAddr::Drive_Mode:
|
||||
return this->drive_mode;
|
||||
value = this->drive_mode;
|
||||
break;
|
||||
case StatusAddr::Drive_Ready:
|
||||
return this->is_ready ^ 1; // reverse logic
|
||||
value = this->is_ready ^ 1; // reverse logic
|
||||
break;
|
||||
case StatusAddr::Media_Kind:
|
||||
return this->media_kind ^ 1; // reverse logic!
|
||||
value = this->media_kind ^ 1; // reverse logic!
|
||||
break;
|
||||
default:
|
||||
LOG_F(WARNING, "%s: unimplemented status request, addr=0x%X", this->get_name().c_str(), addr);
|
||||
return 0;
|
||||
value = 0;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
int MacSuperDrive::insert_disk(std::string& img_path, int write_flag = 0)
|
||||
|
||||
@@ -102,6 +102,7 @@ public:
|
||||
void command(uint8_t addr, uint8_t value);
|
||||
uint8_t status(uint8_t addr);
|
||||
int insert_disk(std::string& img_path, int write_flag);
|
||||
void set_motor_stat(uint8_t new_motor_stat);
|
||||
void init_track_search(int pos);
|
||||
uint64_t sync_to_disk();
|
||||
uint64_t next_addr_mark_delay(uint8_t *next_sect_num);
|
||||
|
||||
+35
-11
@@ -42,6 +42,16 @@ Swim3Ctrl::Swim3Ctrl()
|
||||
this->name = "SWIM3";
|
||||
this->supported_types = HWCompType::FLOPPY_CTRL;
|
||||
|
||||
this->reset();
|
||||
|
||||
// Attach virtual Superdrive to the internal drive connector
|
||||
// TODO: make SWIM3/drive wiring user selectable
|
||||
this->int_drive = std::unique_ptr<MacSuperdrive::MacSuperDrive>
|
||||
(new MacSuperdrive::MacSuperDrive("Superdrive1"));
|
||||
}
|
||||
|
||||
void Swim3Ctrl::reset()
|
||||
{
|
||||
this->setup_reg = 0;
|
||||
this->mode_reg = 0;
|
||||
this->int_reg = 0;
|
||||
@@ -54,10 +64,24 @@ Swim3Ctrl::Swim3Ctrl()
|
||||
|
||||
this->cur_state = SWIM3_IDLE;
|
||||
|
||||
// Attach virtual Superdrive to the internal drive connector
|
||||
// TODO: make SWIM3/drive wiring user selectable
|
||||
this->int_drive = std::unique_ptr<MacSuperdrive::MacSuperDrive>
|
||||
(new MacSuperdrive::MacSuperDrive("Superdrive1"));
|
||||
this->cur_track = 0xFF;
|
||||
this->cur_sector = 0x7F;
|
||||
|
||||
this->timer_val = 0;
|
||||
this->phase_lines = 0;
|
||||
|
||||
if (this->one_us_timer_id) {
|
||||
TimerManager::get_instance()->cancel_timer(this->one_us_timer_id);
|
||||
this->one_us_timer_id = 0;
|
||||
}
|
||||
if (this->step_timer_id) {
|
||||
TimerManager::get_instance()->cancel_timer(this->step_timer_id);
|
||||
this->step_timer_id = 0;
|
||||
}
|
||||
if (this->access_timer_id) {
|
||||
TimerManager::get_instance()->cancel_timer(this->access_timer_id);
|
||||
this->access_timer_id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int Swim3Ctrl::device_postinit()
|
||||
@@ -92,8 +116,8 @@ uint8_t Swim3Ctrl::read(uint8_t reg_offset)
|
||||
case Swim3Reg::Setup:
|
||||
return this->setup_reg;
|
||||
case Swim3Reg::Handshake_Mode1:
|
||||
if (this->mode_reg & 2) { // internal drive?
|
||||
status_addr = ((this->mode_reg & 0x20) >> 2) | (this->phase_lines & 7);
|
||||
if (this->mode_reg & SWIM3_DRIVE_1) { // internal drive?
|
||||
status_addr = ((this->mode_reg & SWIM3_HEAD_SELECT) >> 2) | (this->phase_lines & 7);
|
||||
rddata_val = this->int_drive->status(status_addr) & 1;
|
||||
|
||||
// transfer rddata_val to both bit 2 (RDDATA) and bit 3 (SENSE)
|
||||
@@ -140,14 +164,14 @@ void Swim3Ctrl::write(uint8_t reg_offset, uint8_t value)
|
||||
case Swim3Reg::Phase:
|
||||
this->phase_lines = value & 0xF;
|
||||
if (this->phase_lines & 8) { // CA3 aka LSTRB high -> sending a command to the drive
|
||||
if (this->mode_reg & 2) { // if internal drive is selected
|
||||
if (this->mode_reg & SWIM3_DRIVE_1) { // if internal drive is selected
|
||||
this->int_drive->command(
|
||||
((this->mode_reg & 0x20) >> 3) | (this->phase_lines & 3),
|
||||
((this->mode_reg & SWIM3_HEAD_SELECT) >> 3) | (this->phase_lines & 3),
|
||||
(value >> 2) & 1
|
||||
);
|
||||
}
|
||||
} else if (this->phase_lines == 4 && (this->mode_reg & 2)) {
|
||||
status_addr = ((this->mode_reg & 0x20) >> 2) | (this->phase_lines & 7);
|
||||
} else if (this->phase_lines == 4 && (this->mode_reg & SWIM3_DRIVE_1)) {
|
||||
status_addr = ((this->mode_reg & SWIM3_HEAD_SELECT) >> 2) | (this->phase_lines & 7);
|
||||
this->rd_line = this->int_drive->status(status_addr) & 1;
|
||||
}
|
||||
break;
|
||||
@@ -239,7 +263,7 @@ void Swim3Ctrl::start_stepping()
|
||||
return;
|
||||
}
|
||||
|
||||
if ((((this->mode_reg & 0x20) >> 3) | (this->phase_lines & 3))
|
||||
if ((((this->mode_reg & SWIM3_HEAD_SELECT) >> 3) | (this->phase_lines & 3))
|
||||
!= MacSuperdrive::CommandAddr::Do_Step) {
|
||||
LOG_F(WARNING, "SWIM3: invalid command address on the phase lines!");
|
||||
return;
|
||||
|
||||
+11
-5
@@ -57,10 +57,14 @@ enum Swim3Reg : uint8_t {
|
||||
|
||||
/** Mode register bits. */
|
||||
enum {
|
||||
SWIM3_INT_ENA = 0x01,
|
||||
SWIM3_GO = 0x08,
|
||||
SWIM3_WR_MODE = 0x10,
|
||||
SWIM3_GO_STEP = 0x80,
|
||||
SWIM3_INT_ENA = 0x01,
|
||||
SWIM3_DRIVE_1 = 0x02,
|
||||
SWIM3_DRIVE_2 = 0x04,
|
||||
SWIM3_GO = 0x08,
|
||||
SWIM3_WR_MODE = 0x10,
|
||||
SWIM3_HEAD_SELECT = 0x20,
|
||||
SWIM3_FORMAT_MODE = 0x40,
|
||||
SWIM3_GO_STEP = 0x80,
|
||||
};
|
||||
|
||||
/** Interrupt flags. */
|
||||
@@ -69,6 +73,7 @@ enum {
|
||||
INT_STEP_DONE = 0x02,
|
||||
INT_ID_READ = 0x04,
|
||||
INT_SECT_DONE = 0x08,
|
||||
INT_SENSE = 0x10, // unused by SWIM3 driver
|
||||
};
|
||||
|
||||
// SWIM3 internal states.
|
||||
@@ -98,6 +103,7 @@ public:
|
||||
};
|
||||
|
||||
protected:
|
||||
void reset();
|
||||
void update_irq();
|
||||
void start_stepping();
|
||||
void do_step();
|
||||
@@ -113,7 +119,7 @@ private:
|
||||
|
||||
DmaBidirChannel* dma_ch;
|
||||
|
||||
uint8_t timer_val = 0; // internal timer that decrements at a 1 us rate
|
||||
uint8_t timer_val; // internal timer that decrements at a 1 us rate
|
||||
uint8_t setup_reg;
|
||||
uint8_t mode_reg;
|
||||
uint8_t error;
|
||||
|
||||
+18
-4
@@ -132,7 +132,15 @@ uint32_t AMIC::read(uint32_t rgn_start, uint32_t offset, int size)
|
||||
case 1:
|
||||
return this->viacuda->read(offset >> 9);
|
||||
case 4: // SCC registers
|
||||
return this->escc->read(compat_to_macrisc[(offset >> 1) & 0xF]);
|
||||
if ((offset & 0xF) < 0x0C)
|
||||
return this->escc->read(compat_to_macrisc[(offset >> 1) & 0xF]);
|
||||
else
|
||||
LOG_F(ERROR, "AMIC SCC read @%x.%c", offset, SIZE_ARG(size));
|
||||
return 0;
|
||||
case 0x8:
|
||||
case 0x9:
|
||||
LOG_F(WARNING, "AMIC Ethernet ID Rom read @%x.%c", offset, SIZE_ARG(size));
|
||||
return 0;
|
||||
case 0xA: // MACE registers
|
||||
return this->mace->read((offset >> 4) & 0x1F);
|
||||
case 0x10: // SCSI registers
|
||||
@@ -207,6 +215,8 @@ uint32_t AMIC::read(uint32_t rgn_start, uint32_t offset, int size)
|
||||
return (this->floppy_addr_ptr >> (3 - (offset & 3)) * 8) & 0xFF;
|
||||
case AMICReg::Floppy_DMA_Ctrl:
|
||||
return this->floppy_dma->read_stat();
|
||||
case SCC_DMA_Xmt_A_Ctrl:
|
||||
return this->escc_xmit_a_dma->read_stat();
|
||||
case SCC_DMA_Xmt_B_Ctrl:
|
||||
return this->escc_xmit_b_dma->read_stat();
|
||||
default:
|
||||
@@ -225,8 +235,12 @@ void AMIC::write(uint32_t rgn_start, uint32_t offset, uint32_t value, int size)
|
||||
case 1:
|
||||
this->viacuda->write(offset >> 9, value);
|
||||
return;
|
||||
case 4:
|
||||
this->escc->write(compat_to_macrisc[(offset >> 1) & 0xF], value);
|
||||
case 4: // SCC registers
|
||||
if ((offset & 0xF) < 0x0C)
|
||||
this->escc->write(compat_to_macrisc[(offset >> 1) & 0xF], value);
|
||||
else
|
||||
LOG_F(ERROR, "AMIC SCC write @%x.%c = %0*x",
|
||||
offset, SIZE_ARG(size), size * 2, value);
|
||||
return;
|
||||
case 0xA: // MACE registers
|
||||
this->mace->write((offset >> 4) & 0x1F, value);
|
||||
@@ -754,7 +768,7 @@ DmaPullResult AmicSerialXmitDma::pull_data(uint32_t req_len, uint32_t *avail_len
|
||||
return DmaPullResult::NoMoreData;
|
||||
};
|
||||
|
||||
static vector<string> Amic_Subdevices = {
|
||||
static std::vector<std::string> Amic_Subdevices = {
|
||||
"ScsiCurio", "Sc53C94", "Escc", "Mace", "ViaCuda", "Swim3"
|
||||
};
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ void NvramDev::iodev_write(uint32_t address, uint16_t value) {
|
||||
this->nvram->write_byte((addr_hi->iodev_read(0) << 5) + address, value);
|
||||
}
|
||||
|
||||
GrandCentral::GrandCentral() : PCIDevice("mac-io/grandcentral"), InterruptCtrl()
|
||||
GrandCentral::GrandCentral() : PCIDevice("mac-io_grandcentral"), InterruptCtrl()
|
||||
{
|
||||
supports_types(HWCompType::MMIO_DEV | HWCompType::PCI_DEV | HWCompType::INT_CTRL);
|
||||
|
||||
@@ -125,7 +125,12 @@ GrandCentral::GrandCentral() : PCIDevice("mac-io/grandcentral"), InterruptCtrl()
|
||||
this->curio = dynamic_cast<Sc53C94*>(gMachineObj->get_comp_by_name("Sc53C94"));
|
||||
this->curio_dma = std::unique_ptr<DMAChannel> (new DMAChannel("curio_scsi"));
|
||||
this->curio_dma->register_dma_int(this, this->register_dma_int(IntSrc::DMA_SCSI_CURIO));
|
||||
this->curio->set_dma_channel(this->curio_dma.get());
|
||||
this->curio_dma->connect(this->curio);
|
||||
this->curio->connect(this->curio_dma.get());
|
||||
//this->curio->set_dma_channel(this->curio_dma.get());
|
||||
this->curio->set_drq_callback([this](const uint8_t drq_state) {
|
||||
this->curio_dma->set_stat((drq_state & 1) << 5);
|
||||
});
|
||||
|
||||
// connect Ethernet HW
|
||||
this->mace = dynamic_cast<MaceController*>(gMachineObj->get_comp_by_name("Mace"));
|
||||
@@ -163,7 +168,7 @@ void GrandCentral::notify_bar_change(int bar_num)
|
||||
}
|
||||
this->base_addr = this->bars[0] & 0xFFFFFFF0UL;
|
||||
this->host_instance->pci_register_mmio_region(this->base_addr, 0x20000, this);
|
||||
LOG_F(INFO, "%s: base address set to 0x%X", this->pci_name.c_str(), this->base_addr);
|
||||
LOG_F(INFO, "%s: base address set to 0x%X", this->get_name().c_str(), this->base_addr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,9 +186,13 @@ uint32_t GrandCentral::read(uint32_t rgn_start, uint32_t offset, int size)
|
||||
case 1: // MACE
|
||||
return this->mace->read((offset >> 4) & 0x1F);
|
||||
case 2: // ESCC compatible addressing
|
||||
if ((offset & 0xFF) < 16) {
|
||||
if ((offset & 0xFF) < 0x0C) {
|
||||
return this->escc->read(compat_to_macrisc[(offset >> 1) & 0xF]);
|
||||
}
|
||||
if ((offset & 0xFF) < 0x60) {
|
||||
LOG_F(ERROR, "%s: ESCC compatible read @%x.%c", this->name.c_str(), offset, SIZE_ARG(size));
|
||||
return 0;
|
||||
}
|
||||
// fallthrough
|
||||
case 3: // ESCC MacRISC addressing
|
||||
return this->escc->read((offset >> 4) & 0xF);
|
||||
@@ -288,10 +297,15 @@ void GrandCentral::write(uint32_t rgn_start, uint32_t offset, uint32_t value, in
|
||||
this->mace->write((offset >> 4) & 0x1F, value);
|
||||
break;
|
||||
case 2: // ESCC compatible addressing
|
||||
if ((offset & 0xFF) < 16) {
|
||||
if ((offset & 0xFF) < 0x0C) {
|
||||
this->escc->write(compat_to_macrisc[(offset >> 1) & 0xF], value);
|
||||
break;
|
||||
}
|
||||
if ((offset & 0xFF) < 0x60) {
|
||||
LOG_F(ERROR, "%s: SCC write @%x.%c = %0*x", this->name.c_str(),
|
||||
offset, SIZE_ARG(size), size * 2, value);
|
||||
break;
|
||||
}
|
||||
// fallthrough
|
||||
case 3: // ESCC MacRISC addressing
|
||||
this->escc->write((offset >> 4) & 0xF, value);
|
||||
@@ -388,6 +402,7 @@ void GrandCentral::write(uint32_t rgn_start, uint32_t offset, uint32_t value, in
|
||||
switch (offset) {
|
||||
case MIO_INT_MASK1:
|
||||
this->int_mask = BYTESWAP_32(value);
|
||||
this->signal_cpu_int(this->int_events & this->int_mask);
|
||||
break;
|
||||
case MIO_INT_CLEAR1:
|
||||
if ((this->int_mask & MACIO_INT_MODE) && (value & MACIO_INT_CLR))
|
||||
@@ -446,6 +461,9 @@ uint32_t GrandCentral::register_dev_int(IntSrc src_id) {
|
||||
|
||||
case IntSrc::PLATINUM : return INT_TO_IRQ_ID(0x1E); // EXT10
|
||||
|
||||
case IntSrc::PIPPIN_F : return INT_TO_IRQ_ID(0x1D); // EXT9
|
||||
case IntSrc::PIPPIN_E : return INT_TO_IRQ_ID(0x1E); // EXT10
|
||||
|
||||
default:
|
||||
ABORT_F("%s: unknown interrupt source %d", this->name.c_str(), src_id);
|
||||
}
|
||||
@@ -474,14 +492,8 @@ uint32_t GrandCentral::register_dma_int(IntSrc src_id) {
|
||||
}
|
||||
|
||||
void GrandCentral::ack_int_common(uint32_t irq_id, uint8_t irq_line_state) {
|
||||
// native mode: set IRQ bits in int_events1 on a 0-to-1 transition
|
||||
// emulated mode: set IRQ bits in int_events1 on all transitions
|
||||
//#if 1
|
||||
// if (irq_id & ~(INT_TO_IRQ_ID(0x12) | INT_TO_IRQ_ID(0x1A)))
|
||||
// LOG_F(INTERRUPT, "%s: native interrupt mask:%08x events:%08x levels:%08x change:%08x state:%d",
|
||||
// this->name.c_str(), this->int_mask, this->int_events + 0, this->int_levels + 0, irq_id, irq_line_state
|
||||
// );
|
||||
//#endif
|
||||
// native mode: set IRQ bits in int_events on a 0-to-1 transition
|
||||
// emulated mode: set IRQ bits in int_events on all transitions
|
||||
if ((this->int_mask & MACIO_INT_MODE) ||
|
||||
(irq_line_state && !(this->int_levels & irq_id))) {
|
||||
this->int_events |= irq_id;
|
||||
@@ -489,8 +501,6 @@ void GrandCentral::ack_int_common(uint32_t irq_id, uint8_t irq_line_state) {
|
||||
this->int_events &= ~irq_id;
|
||||
}
|
||||
|
||||
this->int_events &= this->int_mask;
|
||||
|
||||
// update IRQ line state
|
||||
if (irq_line_state) {
|
||||
this->int_levels |= irq_id;
|
||||
@@ -510,7 +520,7 @@ void GrandCentral::ack_dma_int(uint32_t irq_id, uint8_t irq_line_state) {
|
||||
}
|
||||
|
||||
void GrandCentral::signal_cpu_int(uint32_t irq_id) {
|
||||
if (this->int_events) {
|
||||
if (this->int_events & this->int_mask) {
|
||||
if (!this->cpu_int_latch) {
|
||||
this->cpu_int_latch = true;
|
||||
ppc_assert_int();
|
||||
@@ -522,14 +532,14 @@ void GrandCentral::signal_cpu_int(uint32_t irq_id) {
|
||||
}
|
||||
|
||||
void GrandCentral::clear_cpu_int() {
|
||||
if (!this->int_events) {
|
||||
if (!(this->int_events & this->int_mask) && this->cpu_int_latch) {
|
||||
this->cpu_int_latch = false;
|
||||
ppc_release_int();
|
||||
LOG_F(5, "%s: CPU INT latch cleared", this->name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
static const vector<string> GCSubdevices = {
|
||||
static const std::vector<std::string> GCSubdevices = {
|
||||
"NVRAM", "ViaCuda", "Escc", "ScsiCurio", "Sc53C94", "Mace", "Swim3"
|
||||
};
|
||||
|
||||
|
||||
+75
-41
@@ -44,7 +44,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
using namespace std;
|
||||
|
||||
HeathrowIC::HeathrowIC() : PCIDevice("mac-io/heathrow"), InterruptCtrl()
|
||||
HeathrowIC::HeathrowIC() : PCIDevice("mac-io_heathrow"), InterruptCtrl()
|
||||
{
|
||||
supports_types(HWCompType::MMIO_DEV | HWCompType::PCI_DEV | HWCompType::INT_CTRL);
|
||||
|
||||
@@ -88,6 +88,9 @@ HeathrowIC::HeathrowIC() : PCIDevice("mac-io/heathrow"), InterruptCtrl()
|
||||
// connect serial HW
|
||||
this->escc = dynamic_cast<EsccController*>(gMachineObj->get_comp_by_name("Escc"));
|
||||
|
||||
// connect DBDMA
|
||||
this->escc_b_rcv_dma = std::unique_ptr<DMAChannel>(new DMAChannel("DBDMABRx"));
|
||||
|
||||
// connect floppy disk HW and initialize its DMA channel
|
||||
this->swim3 = dynamic_cast<Swim3::Swim3Ctrl*>(gMachineObj->get_comp_by_name("Swim3"));
|
||||
this->floppy_dma = std::unique_ptr<DMAChannel> (new DMAChannel("floppy"));
|
||||
@@ -114,7 +117,7 @@ void HeathrowIC::notify_bar_change(int bar_num)
|
||||
}
|
||||
this->base_addr = this->bars[0] & 0xFFFFFFF0UL;
|
||||
this->host_instance->pci_register_mmio_region(this->base_addr, 0x80000, this);
|
||||
LOG_F(INFO, "%s: base address set to 0x%X", this->pci_name.c_str(), this->base_addr);
|
||||
LOG_F(INFO, "%s: base address set to 0x%X", this->get_name().c_str(), this->base_addr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,6 +134,8 @@ uint32_t HeathrowIC::dma_read(uint32_t offset, int size) {
|
||||
return this->enet_xmit_dma->reg_read(offset & 0xFF, size);
|
||||
case MIO_OHARE_DMA_ETH_RCV:
|
||||
return this->enet_rcv_dma->reg_read(offset & 0xFF, size);
|
||||
case MIO_OHARE_DMA_ESCC_B_RCV:
|
||||
return this->escc_b_rcv_dma->reg_read(offset & 0xFF, size);
|
||||
case MIO_OHARE_DMA_AUDIO_OUT:
|
||||
return this->snd_out_dma->reg_read(offset & 0xFF, size);
|
||||
default:
|
||||
@@ -154,6 +159,9 @@ void HeathrowIC::dma_write(uint32_t offset, uint32_t value, int size) {
|
||||
case MIO_OHARE_DMA_ETH_RCV:
|
||||
this->enet_rcv_dma->reg_write(offset & 0xFF, value, size);
|
||||
break;
|
||||
case MIO_OHARE_DMA_ESCC_B_RCV:
|
||||
this->escc_b_rcv_dma->reg_write(offset & 0xFF, value, size);
|
||||
break;
|
||||
case MIO_OHARE_DMA_AUDIO_OUT:
|
||||
this->snd_out_dma->reg_write(offset & 0xFF, value, size);
|
||||
break;
|
||||
@@ -164,7 +172,7 @@ void HeathrowIC::dma_write(uint32_t offset, uint32_t value, int size) {
|
||||
|
||||
|
||||
uint32_t HeathrowIC::read(uint32_t rgn_start, uint32_t offset, int size) {
|
||||
uint32_t res = 0;
|
||||
uint32_t value;
|
||||
|
||||
LOG_F(9, "%s: reading from offset %x", this->name.c_str(), offset);
|
||||
|
||||
@@ -172,48 +180,57 @@ uint32_t HeathrowIC::read(uint32_t rgn_start, uint32_t offset, int size) {
|
||||
|
||||
switch (sub_addr) {
|
||||
case 0:
|
||||
res = mio_ctrl_read(offset, size);
|
||||
value = mio_ctrl_read(offset, size);
|
||||
break;
|
||||
case 8:
|
||||
res = dma_read(offset - 0x8000, size);
|
||||
value = dma_read(offset & 0x7FFF, size);
|
||||
break;
|
||||
case 0x10: // SCSI
|
||||
res = this->mesh->read((offset >> 4) & 0xF);
|
||||
value = this->mesh->read((offset >> 4) & 0xF);
|
||||
break;
|
||||
case 0x11: // Ethernet
|
||||
res = BYTESWAP_SIZED(this->bmac->read(offset & 0xFFFU), size);
|
||||
value = BYTESWAP_SIZED(this->bmac->read(offset & 0xFFFU), size);
|
||||
break;
|
||||
case 0x12: // ESCC compatible addressing
|
||||
if ((offset & 0xFF) < 16) {
|
||||
return this->escc->read(compat_to_macrisc[(offset >> 1) & 0xF]);
|
||||
if ((offset & 0xFF) < 0x0C) {
|
||||
value = this->escc->read(compat_to_macrisc[(offset >> 1) & 0xF]);
|
||||
break;
|
||||
}
|
||||
if ((offset & 0xFF) < 0x60) {
|
||||
value = 0;
|
||||
LOG_F(ERROR, "%s: ESCC compatible read @%x.%c", this->name.c_str(), offset, SIZE_ARG(size));
|
||||
break;
|
||||
}
|
||||
// fallthrough
|
||||
case 0x13: // ESCC MacRISC addressing
|
||||
return this->escc->read((offset >> 4) & 0xF);
|
||||
value = this->escc->read((offset >> 4) & 0xF);
|
||||
break;
|
||||
case 0x14:
|
||||
res = this->snd_codec->snd_ctrl_read(offset - 0x14000, size);
|
||||
value = this->snd_codec->snd_ctrl_read(offset & 0xFF, size);
|
||||
break;
|
||||
case 0x15: // SWIM3
|
||||
return this->swim3->read((offset >> 4 )& 0xF);
|
||||
value = this->swim3->read((offset >> 4) & 0xF);
|
||||
break;
|
||||
case 0x16: // VIA-CUDA
|
||||
case 0x17:
|
||||
res = this->viacuda->read((offset - 0x16000) >> 9);
|
||||
value = this->viacuda->read((offset >> 9) & 0xF);
|
||||
break;
|
||||
case 0x20: // IDE 0
|
||||
res = this->ide_0->read((offset >> 4) & 0x1F, size);
|
||||
value = this->ide_0->read((offset >> 4) & 0x1F, size);
|
||||
break;
|
||||
case 0x21: // IDE 1
|
||||
res = this->ide_1->read((offset >> 4) & 0x1F, size);
|
||||
value = this->ide_1->read((offset >> 4) & 0x1F, size);
|
||||
break;
|
||||
default:
|
||||
if (sub_addr >= 0x60) {
|
||||
res = this->nvram->read_byte((offset - 0x60000) >> 4);
|
||||
value = this->nvram->read_byte((offset >> 4) & 0x1FFF);
|
||||
} else {
|
||||
value = 0;
|
||||
LOG_F(WARNING, "Attempting to read from unmapped I/O space: %x", offset);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
return value;
|
||||
}
|
||||
|
||||
void HeathrowIC::write(uint32_t rgn_start, uint32_t offset, uint32_t value, int size) {
|
||||
@@ -223,10 +240,10 @@ void HeathrowIC::write(uint32_t rgn_start, uint32_t offset, uint32_t value, int
|
||||
|
||||
switch (sub_addr) {
|
||||
case 0:
|
||||
mio_ctrl_write(offset, value, size);
|
||||
this->mio_ctrl_write(offset, value, size);
|
||||
break;
|
||||
case 8:
|
||||
dma_write(offset - 0x8000, value, size);
|
||||
this->dma_write(offset & 0x7FFF, value, size);
|
||||
break;
|
||||
case 0x10: // SCSI
|
||||
this->mesh->write((offset >> 4) & 0xF, value);
|
||||
@@ -235,23 +252,28 @@ void HeathrowIC::write(uint32_t rgn_start, uint32_t offset, uint32_t value, int
|
||||
this->bmac->write(offset & 0xFFFU, BYTESWAP_SIZED(value, size));
|
||||
break;
|
||||
case 0x12: // ESCC compatible addressing
|
||||
if ((offset & 0xFF) < 16) {
|
||||
if ((offset & 0xFF) < 0x0C) {
|
||||
this->escc->write(compat_to_macrisc[(offset >> 1) & 0xF], value);
|
||||
break;
|
||||
}
|
||||
if ((offset & 0xFF) < 0x60) {
|
||||
LOG_F(ERROR, "%s: SCC write @%x.%c = %0*x", this->name.c_str(),
|
||||
offset, SIZE_ARG(size), size * 2, value);
|
||||
break;
|
||||
}
|
||||
// fallthrough
|
||||
case 0x13: // ESCC MacRISC addressing
|
||||
this->escc->write((offset >> 4) & 0xF, value);
|
||||
break;
|
||||
case 0x14:
|
||||
this->snd_codec->snd_ctrl_write(offset - 0x14000, value, size);
|
||||
this->snd_codec->snd_ctrl_write(offset & 0xFF, value, size);
|
||||
break;
|
||||
case 0x15: // SWIM3
|
||||
this->swim3->write((offset >> 4) & 0xF, value);
|
||||
break;
|
||||
case 0x16: // VIA-CUDA
|
||||
case 0x17:
|
||||
this->viacuda->write((offset - 0x16000) >> 9, value);
|
||||
this->viacuda->write((offset >> 9) & 0xF, value);
|
||||
break;
|
||||
case 0x20: // IDE O
|
||||
this->ide_0->write((offset >> 4) & 0x1F, value, size);
|
||||
@@ -269,53 +291,56 @@ void HeathrowIC::write(uint32_t rgn_start, uint32_t offset, uint32_t value, int
|
||||
}
|
||||
|
||||
uint32_t HeathrowIC::mio_ctrl_read(uint32_t offset, int size) {
|
||||
uint32_t res = 0;
|
||||
uint32_t value;
|
||||
|
||||
switch (offset & 0xFC) {
|
||||
case MIO_INT_EVENTS2:
|
||||
res = this->int_events2;
|
||||
value = this->int_events2;
|
||||
break;
|
||||
case MIO_INT_MASK2:
|
||||
res = this->int_mask2;
|
||||
value = this->int_mask2;
|
||||
break;
|
||||
case MIO_INT_LEVELS2:
|
||||
res = this->int_levels2;
|
||||
value = this->int_levels2;
|
||||
break;
|
||||
case MIO_INT_EVENTS1:
|
||||
res = this->int_events1;
|
||||
value = this->int_events1;
|
||||
break;
|
||||
case MIO_INT_MASK1:
|
||||
res = this->int_mask1;
|
||||
value = this->int_mask1;
|
||||
break;
|
||||
case MIO_INT_LEVELS1:
|
||||
res = this->int_levels1;
|
||||
value = this->int_levels1;
|
||||
break;
|
||||
case MIO_INT_CLEAR1:
|
||||
case MIO_INT_CLEAR2:
|
||||
// some Mac OS drivers reads from those write-only registers
|
||||
// so we return zero here as real HW does
|
||||
value = 0;
|
||||
break;
|
||||
case MIO_OHARE_ID:
|
||||
LOG_F(9, "read from MIO:ID register at Address %x", ppc_state.pc);
|
||||
res = (this->fp_id << 24) | (this->mon_id << 16) | (this->mb_id << 8) |
|
||||
(this->cpu_id | (this->emmo_pin << 4));
|
||||
value = (this->fp_id << 24) | (this->mon_id << 16) | (this->mb_id << 8) |
|
||||
(this->cpu_id | (this->emmo_pin << 4));
|
||||
break;
|
||||
case MIO_OHARE_FEAT_CTRL:
|
||||
LOG_F(9, "read from MIO:Feat_Ctrl register");
|
||||
res = this->feat_ctrl;
|
||||
value = this->feat_ctrl;
|
||||
break;
|
||||
default:
|
||||
value = 0;
|
||||
LOG_F(WARNING, "read from unknown MIO register at %x", offset);
|
||||
break;
|
||||
}
|
||||
|
||||
return BYTESWAP_32(res);
|
||||
return BYTESWAP_32(value);
|
||||
}
|
||||
|
||||
void HeathrowIC::mio_ctrl_write(uint32_t offset, uint32_t value, int size) {
|
||||
switch (offset & 0xFC) {
|
||||
case MIO_INT_MASK2:
|
||||
this->int_mask2 |= BYTESWAP_32(value) & ~MACIO_INT_MODE;
|
||||
this->signal_cpu_int();
|
||||
break;
|
||||
case MIO_INT_CLEAR2:
|
||||
this->int_events2 &= ~(BYTESWAP_32(value) & 0x7FFFFFFFUL);
|
||||
@@ -325,6 +350,7 @@ void HeathrowIC::mio_ctrl_write(uint32_t offset, uint32_t value, int size) {
|
||||
this->int_mask1 = BYTESWAP_32(value);
|
||||
// copy IntMode bit to InterruptMask2 register
|
||||
this->int_mask2 = (this->int_mask2 & ~MACIO_INT_MODE) | (this->int_mask1 & MACIO_INT_MODE);
|
||||
this->signal_cpu_int();
|
||||
break;
|
||||
case MIO_INT_CLEAR1:
|
||||
if ((this->int_mask1 & MACIO_INT_MODE) && (value & MACIO_INT_CLR)) {
|
||||
@@ -381,14 +407,15 @@ uint32_t HeathrowIC::register_dev_int(IntSrc src_id)
|
||||
{
|
||||
switch (src_id) {
|
||||
case IntSrc::SCSI_MESH : return INT_TO_IRQ_ID(0x0C);
|
||||
case IntSrc::IDE0 : return INT_TO_IRQ_ID(0x0D);
|
||||
case IntSrc::IDE0 : return INT_TO_IRQ_ID(0x0D); // Beige G3 first IDE controller, or Yosemite ata-3
|
||||
case IntSrc::IDE1 : return INT_TO_IRQ_ID(0x0E);
|
||||
case IntSrc::SCCA : return INT_TO_IRQ_ID(0x0F);
|
||||
case IntSrc::SCCB : return INT_TO_IRQ_ID(0x10);
|
||||
case IntSrc::DAVBUS : return INT_TO_IRQ_ID(0x11);
|
||||
case IntSrc::VIA_CUDA : return INT_TO_IRQ_ID(0x12);
|
||||
case IntSrc::SWIM3 : return INT_TO_IRQ_ID(0x13);
|
||||
case IntSrc::NMI : return INT_TO_IRQ_ID(0x14); // nmiSource in AppleHeathrow/Heathrow.cpp
|
||||
case IntSrc::NMI : return INT_TO_IRQ_ID(0x14); // nmiSource in AppleHeathrow/Heathrow.cpp; programmer-switch in B&W G3
|
||||
|
||||
case IntSrc::PERCH2 : return INT_TO_IRQ_ID(0x15);
|
||||
case IntSrc::PCI_GPU : return INT_TO_IRQ_ID(0x16);
|
||||
case IntSrc::PCI_A : return INT_TO_IRQ_ID(0x17);
|
||||
@@ -396,7 +423,17 @@ uint32_t HeathrowIC::register_dev_int(IntSrc src_id)
|
||||
case IntSrc::PCI_C : return INT_TO_IRQ_ID(0x19);
|
||||
case IntSrc::PERCH1 : return INT_TO_IRQ_ID(0x1A);
|
||||
case IntSrc::PCI_PERCH : return INT_TO_IRQ_ID(0x1C);
|
||||
|
||||
case IntSrc::FIREWIRE : return INT_TO_IRQ_ID(0x15); // Yosemite built-in PCI FireWire
|
||||
case IntSrc::PCI_J12 : return INT_TO_IRQ_ID(0x16); // Yosemite 32-bit 66MHz slot for GPU
|
||||
case IntSrc::PCI_J11 : return INT_TO_IRQ_ID(0x17); // Yosemite 64-bit 33MHz slot
|
||||
case IntSrc::PCI_J10 : return INT_TO_IRQ_ID(0x18); // Yosemite 64-bit 33MHz slot
|
||||
case IntSrc::PCI_J9 : return INT_TO_IRQ_ID(0x19); // Yosemite 64-bit 33MHz slot
|
||||
case IntSrc::ATA : return INT_TO_IRQ_ID(0x1A); // Yosemite PCI pci-ata
|
||||
case IntSrc::USB : return INT_TO_IRQ_ID(0x1C); // Yosemite PCI usb
|
||||
|
||||
case IntSrc::ETHERNET : return INT_TO_IRQ_ID(0x2A);
|
||||
|
||||
default:
|
||||
ABORT_F("Heathrow: unknown interrupt source %d", src_id);
|
||||
}
|
||||
@@ -455,7 +492,6 @@ void HeathrowIC::ack_int(uint32_t irq_id, uint8_t irq_line_state)
|
||||
} else {
|
||||
this->int_events2 &= ~irq_id;
|
||||
}
|
||||
this->int_events2 &= this->int_mask2;
|
||||
// update IRQ line state
|
||||
if (irq_line_state) {
|
||||
this->int_levels2 |= irq_id;
|
||||
@@ -476,7 +512,6 @@ void HeathrowIC::ack_int(uint32_t irq_id, uint8_t irq_line_state)
|
||||
} else {
|
||||
this->int_events1 &= ~irq_id;
|
||||
}
|
||||
this->int_events1 &= this->int_mask1;
|
||||
// update IRQ line state
|
||||
if (irq_line_state) {
|
||||
this->int_levels1 |= irq_id;
|
||||
@@ -531,7 +566,6 @@ void HeathrowIC::ack_dma_int(uint32_t irq_id, uint8_t irq_line_state)
|
||||
} else {
|
||||
this->int_events2 &= ~irq_id;
|
||||
}
|
||||
this->int_events2 &= this->int_mask2;
|
||||
// update IRQ line state
|
||||
if (irq_line_state) {
|
||||
this->int_levels2 |= irq_id;
|
||||
@@ -548,7 +582,6 @@ void HeathrowIC::ack_dma_int(uint32_t irq_id, uint8_t irq_line_state)
|
||||
} else {
|
||||
this->int_events1 &= ~irq_id;
|
||||
}
|
||||
this->int_events1 &= this->int_mask1;
|
||||
// update IRQ line state
|
||||
if (irq_line_state) {
|
||||
this->int_levels1 |= irq_id;
|
||||
@@ -591,7 +624,7 @@ void HeathrowIC::ack_dma_int(uint32_t irq_id, uint8_t irq_line_state)
|
||||
}
|
||||
|
||||
void HeathrowIC::signal_cpu_int() {
|
||||
if (this->int_events1 || this->int_events2) {
|
||||
if ((this->int_events1 & this->int_mask1) || (this->int_events2 & this->int_mask2)) {
|
||||
if (!this->cpu_int_latch) {
|
||||
this->cpu_int_latch = true;
|
||||
ppc_assert_int();
|
||||
@@ -603,7 +636,8 @@ void HeathrowIC::signal_cpu_int() {
|
||||
|
||||
void HeathrowIC::clear_cpu_int()
|
||||
{
|
||||
if (!this->int_events1 && !this->int_events2) {
|
||||
if (!(this->int_events1 & this->int_mask1) && !(this->int_events2 & this->int_mask2) &&
|
||||
this->cpu_int_latch) {
|
||||
this->cpu_int_latch = false;
|
||||
ppc_release_int();
|
||||
LOG_F(5, "Heathrow: CPU INT latch cleared");
|
||||
|
||||
@@ -406,6 +406,7 @@ private:
|
||||
std::unique_ptr<DMAChannel> floppy_dma;
|
||||
std::unique_ptr<DMAChannel> enet_xmit_dma;
|
||||
std::unique_ptr<DMAChannel> enet_rcv_dma;
|
||||
std::unique_ptr<DMAChannel> escc_b_rcv_dma;
|
||||
std::unique_ptr<DMAChannel> snd_out_dma;
|
||||
};
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace loguru {
|
||||
};
|
||||
}
|
||||
|
||||
OHare::OHare() : PCIDevice("mac-io/ohare"), InterruptCtrl()
|
||||
OHare::OHare() : PCIDevice("mac-io_ohare"), InterruptCtrl()
|
||||
{
|
||||
supports_types(HWCompType::MMIO_DEV | HWCompType::PCI_DEV | HWCompType::INT_CTRL);
|
||||
|
||||
@@ -77,11 +77,11 @@ void OHare::notify_bar_change(int bar_num)
|
||||
if (this->base_addr != (this->bars[bar_num] & 0xFFFFFFF0UL)) {
|
||||
if (this->base_addr) {
|
||||
LOG_F(WARNING, "%s: deallocating I/O memory not implemented",
|
||||
this->pci_name.c_str());
|
||||
this->get_name().c_str());
|
||||
}
|
||||
this->base_addr = this->bars[0] & 0xFFFFFFF0UL;
|
||||
this->host_instance->pci_register_mmio_region(this->base_addr, 0x80000, this);
|
||||
LOG_F(INFO, "%s: base address set to 0x%X", this->pci_name.c_str(), this->base_addr);
|
||||
LOG_F(INFO, "%s: base address set to 0x%X", this->get_name().c_str(), this->base_addr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,7 +296,7 @@ void OHare::clear_cpu_int()
|
||||
}
|
||||
}
|
||||
|
||||
static const vector<string> OHare_Subdevices = {
|
||||
static const std::vector<std::string> OHare_Subdevices = {
|
||||
"NVRAM", "ViaCuda", "ScsiMesh", "MeshHeathrow", "Escc", "Swim3"
|
||||
};
|
||||
|
||||
|
||||
@@ -128,11 +128,13 @@ void HammerheadCtrl::write(uint32_t rgn_start, uint32_t offset, uint32_t value,
|
||||
|
||||
void HammerheadCtrl::insert_ram_dimm(int slot_num, uint32_t capacity)
|
||||
{
|
||||
if (slot_num < 0 || slot_num >= 26) {
|
||||
if (slot_num < 0 || slot_num >= 13) {
|
||||
ABORT_F("%s: invalid DIMM slot number %d", this->name.c_str(), slot_num);
|
||||
}
|
||||
|
||||
switch (capacity) {
|
||||
case 0:
|
||||
break;
|
||||
case DRAM_CAP_2MB:
|
||||
case DRAM_CAP_4MB:
|
||||
case DRAM_CAP_8MB:
|
||||
|
||||
@@ -45,9 +45,6 @@ MPC106::MPC106() : MemCtrlBase(), PCIDevice("Grackle"), PCIHost()
|
||||
this->command = 6;
|
||||
this->status = 0x80;
|
||||
|
||||
// assign PCI device number zero to myself
|
||||
this->pci_register_device(DEV_FUN(0,0), this);
|
||||
|
||||
// add PCI/ISA I/O space, 64K for now
|
||||
add_mmio_region(0xFE000000, 0x10000, this);
|
||||
|
||||
@@ -57,59 +54,9 @@ MPC106::MPC106() : MemCtrlBase(), PCIDevice("Grackle"), PCIHost()
|
||||
|
||||
int MPC106::device_postinit()
|
||||
{
|
||||
std::string pci_dev_name;
|
||||
|
||||
static const std::map<std::string, int> pci_slots = {
|
||||
{"pci_PERCH", DEV_FUN(0xC,0)}, {"pci_A1", DEV_FUN(0xD,0)},
|
||||
{"pci_B1", DEV_FUN(0xE,0)}, {"pci_C1", DEV_FUN(0xF,0)},
|
||||
{"pci_GPU", DEV_FUN(0x12,0)}
|
||||
};
|
||||
|
||||
for (auto& slot : pci_slots) {
|
||||
pci_dev_name = GET_STR_PROP(slot.first);
|
||||
if (!pci_dev_name.empty()) {
|
||||
this->attach_pci_device(pci_dev_name, slot.second, std::string("@") + slot.first);
|
||||
}
|
||||
}
|
||||
|
||||
this->int_ctrl = dynamic_cast<InterruptCtrl*>(
|
||||
gMachineObj->get_comp_by_type(HWCompType::INT_CTRL));
|
||||
|
||||
this->irq_id_PCI_A = this->int_ctrl->register_dev_int(IntSrc::PCI_A );
|
||||
this->irq_id_PCI_B = this->int_ctrl->register_dev_int(IntSrc::PCI_B );
|
||||
this->irq_id_PCI_C = this->int_ctrl->register_dev_int(IntSrc::PCI_C );
|
||||
this->irq_id_PCI_GPU = this->int_ctrl->register_dev_int(IntSrc::PCI_GPU );
|
||||
this->irq_id_PCI_PERCH = this->int_ctrl->register_dev_int(IntSrc::PCI_PERCH);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MPC106::pci_interrupt(uint8_t irq_line_state, PCIBase *dev) {
|
||||
auto it = std::find_if(dev_map.begin(), dev_map.end(),
|
||||
[&dev](const std::pair<int, PCIBase*> &p) {
|
||||
return p.second == dev;
|
||||
}
|
||||
);
|
||||
|
||||
if (it == dev_map.end()) {
|
||||
LOG_F(ERROR, "Interrupt from unknown device %s", dev->get_name().c_str());
|
||||
}
|
||||
else {
|
||||
uint32_t irq_id;
|
||||
switch (it->first) {
|
||||
case DEV_FUN(0x0C,0): irq_id = this->irq_id_PCI_PERCH; break;
|
||||
case DEV_FUN(0x0D,0): irq_id = this->irq_id_PCI_A ; break;
|
||||
case DEV_FUN(0x0E,0): irq_id = this->irq_id_PCI_B ; break;
|
||||
case DEV_FUN(0x0F,0): irq_id = this->irq_id_PCI_C ; break;
|
||||
case DEV_FUN(0x12,0): irq_id = this->irq_id_PCI_GPU ; break;
|
||||
default:
|
||||
LOG_F(ERROR, "Interrupt from device %s at unexpected device/function %02x.%x",
|
||||
dev->get_name().c_str(), it->first >> 3, it->first & 7);
|
||||
return;
|
||||
}
|
||||
if (this->int_ctrl)
|
||||
this->int_ctrl->ack_int(irq_id, irq_line_state);
|
||||
}
|
||||
// assign PCI device number zero to myself
|
||||
this->pci_register_device(DEV_FUN(0,0), this);
|
||||
return this->pcihost_device_postinit();
|
||||
}
|
||||
|
||||
uint32_t MPC106::read(uint32_t rgn_start, uint32_t offset, int size) {
|
||||
@@ -357,6 +304,8 @@ static const PropMap Grackle_Properties = {
|
||||
new StrProperty("")},
|
||||
{"pci_GPU",
|
||||
new StrProperty("")},
|
||||
{"pci_J12",
|
||||
new StrProperty("")},
|
||||
};
|
||||
|
||||
static const DeviceDescription Grackle_Descriptor = {
|
||||
|
||||
@@ -79,17 +79,15 @@ public:
|
||||
return std::unique_ptr<MPC106>(new MPC106());
|
||||
}
|
||||
|
||||
uint32_t read(uint32_t rgn_start, uint32_t offset, int size);
|
||||
void write(uint32_t rgn_start, uint32_t offset, uint32_t value, int size);
|
||||
uint32_t read(uint32_t rgn_start, uint32_t offset, int size) override;
|
||||
void write(uint32_t rgn_start, uint32_t offset, uint32_t value, int size) override;
|
||||
|
||||
virtual void pci_interrupt(uint8_t irq_line_state, PCIBase *dev);
|
||||
|
||||
int device_postinit();
|
||||
int device_postinit() override;
|
||||
|
||||
protected:
|
||||
/* my own PCI configuration registers access */
|
||||
uint32_t pci_cfg_read(uint32_t reg_offs, AccessDetails &details);
|
||||
void pci_cfg_write(uint32_t reg_offs, uint32_t value, AccessDetails &details);
|
||||
uint32_t pci_cfg_read(uint32_t reg_offs, AccessDetails &details) override;
|
||||
void pci_cfg_write(uint32_t reg_offs, uint32_t value, AccessDetails &details) override;
|
||||
|
||||
void setup_ram(void);
|
||||
|
||||
@@ -115,14 +113,6 @@ private:
|
||||
uint32_t mem_end[2] = {};
|
||||
uint32_t ext_mem_end[2] = {};
|
||||
uint8_t mem_bank_en = 0;
|
||||
|
||||
// interrupt related stuff
|
||||
InterruptCtrl* int_ctrl = nullptr;
|
||||
uint32_t irq_id_PCI_A = 0;
|
||||
uint32_t irq_id_PCI_B = 0;
|
||||
uint32_t irq_id_PCI_C = 0;
|
||||
uint32_t irq_id_PCI_GPU = 0;
|
||||
uint32_t irq_id_PCI_PERCH = 0;
|
||||
};
|
||||
|
||||
#endif // MPC106_H
|
||||
@@ -143,7 +143,13 @@ uint32_t PlatinumCtrl::read(uint32_t rgn_start, uint32_t offset, int size) {
|
||||
value = this->fb_addr;
|
||||
break;
|
||||
case PlatinumReg::MON_ID_SENSE:
|
||||
value = (this->mon_sense ^ 7);
|
||||
value = this->mon_sense;
|
||||
break;
|
||||
case PlatinumReg::FB_TEST:
|
||||
value = this->fb_test;
|
||||
break;
|
||||
case PlatinumReg::VRAM_REFRESH:
|
||||
value = this->vram_refresh;
|
||||
break;
|
||||
case PlatinumReg::SWATCH_CONFIG:
|
||||
value = this->swatch_config;
|
||||
@@ -195,7 +201,7 @@ uint32_t PlatinumCtrl::read(uint32_t rgn_start, uint32_t offset, int size) {
|
||||
value = 0;
|
||||
}
|
||||
|
||||
if (size == 4)
|
||||
if (size == 4 && !(offset & 3))
|
||||
return value;
|
||||
else
|
||||
return extract_with_wrap_around(value, offset, size);
|
||||
@@ -205,6 +211,9 @@ void PlatinumCtrl::write(uint32_t rgn_start, uint32_t offset, uint32_t value, in
|
||||
{
|
||||
static uint8_t vid_enable_seq[] = {3, 2, 0};
|
||||
|
||||
uint8_t mon_dirs = 0;
|
||||
uint8_t mon_levels = 0;
|
||||
|
||||
if (rgn_start == VRAM_REGION_BASE) {
|
||||
if (offset < this->vram_size)
|
||||
write_mem(&this->vram_ptr[offset], value, size);
|
||||
@@ -237,15 +246,21 @@ void PlatinumCtrl::write(uint32_t rgn_start, uint32_t offset, uint32_t value, in
|
||||
case PlatinumReg::FB_BASE_ADDR:
|
||||
this->fb_addr = value;
|
||||
this->fb_offset = value & 0x3FFFFF;
|
||||
this->change_display();
|
||||
break;
|
||||
case PlatinumReg::ROW_WORDS:
|
||||
this->row_words = value & ~7;
|
||||
this->change_display();
|
||||
break;
|
||||
case PlatinumReg::CLOCK_DIVISOR:
|
||||
this->clock_divisor = value;
|
||||
this->change_display();
|
||||
break;
|
||||
case PlatinumReg::FB_CONFIG_1:
|
||||
this->fb_config_1 = value;
|
||||
LOG_F(INFO, "%s: write FB_CONFIG_1 %03x.%c = %0*x", this->name.c_str(), offset, SIZE_ARG(size), size * 2, value);
|
||||
this->fb_config_1 =
|
||||
(this->fb_config_1 & ~(CFG1_FULL_BANKS | CFG1_VID_ENABLE | CFG1_INTERLACE | CFG1_SAM_512BIT | CFG1_VRAMS_2MBIT)) |
|
||||
(value & (CFG1_FULL_BANKS | CFG1_VID_ENABLE | CFG1_INTERLACE | CFG1_SAM_512BIT | CFG1_VRAMS_2MBIT));
|
||||
this->half_bank = !!(this->vram_megs == 1 && (value & CFG1_FULL_BANKS));
|
||||
break;
|
||||
case PlatinumReg::FB_CONFIG_2:
|
||||
@@ -256,11 +271,13 @@ void PlatinumCtrl::write(uint32_t rgn_start, uint32_t offset, uint32_t value, in
|
||||
break;
|
||||
case PlatinumReg::MON_ID_SENSE:
|
||||
value &= 7;
|
||||
this->mon_sense = this->display_id->read_monitor_sense(value, value ^ 7)
|
||||
<< (value ^ 7);
|
||||
mon_dirs = value ^ 7;
|
||||
mon_levels = (this->fb_test >> SENSE_LINE_OUTPUT_DATA_pos) & 7;
|
||||
mon_levels = (mon_levels & mon_dirs) | (mon_dirs ^ 7);
|
||||
this->mon_sense = (mon_dirs << 3) |
|
||||
(this->display_id->read_monitor_sense(mon_levels, mon_dirs) ^ 7);
|
||||
break;
|
||||
case PlatinumReg::FB_RESET:
|
||||
|
||||
if (value == 7 && this->crtc_on) {
|
||||
LOG_F(INFO, "%s: video disabled", this->name.c_str());
|
||||
this->reset_step = 0;
|
||||
@@ -270,7 +287,7 @@ void PlatinumCtrl::write(uint32_t rgn_start, uint32_t offset, uint32_t value, in
|
||||
LOG_F(INFO, "%s: video enabled", this->name.c_str());
|
||||
this->enable_display();
|
||||
} else {
|
||||
this->blank_display();
|
||||
this->disable_display();
|
||||
}
|
||||
this->reset_step = 0;
|
||||
}
|
||||
@@ -278,6 +295,22 @@ void PlatinumCtrl::write(uint32_t rgn_start, uint32_t offset, uint32_t value, in
|
||||
this->reset_step = 0;
|
||||
this->fb_reset = value;
|
||||
this->half_access = !!(this->half_bank && value == 6);
|
||||
|
||||
if (this->fb_reset == 7) {
|
||||
this->disable_display();
|
||||
}
|
||||
else if (this->fb_reset == 0) {
|
||||
this->change_display();
|
||||
}
|
||||
else {
|
||||
LOG_F(ERROR, "%s: display reset written with 0x%X", this->name.c_str(), value);
|
||||
}
|
||||
|
||||
break;
|
||||
case PlatinumReg::FB_TEST:
|
||||
this->fb_test =
|
||||
(this->fb_test & ~(SENSE_LINE_OUTPUT_DATA | SYNCS_OUTPUT_ENABLE | FORCED_SYNC_LEVELS)) |
|
||||
(value & (SENSE_LINE_OUTPUT_DATA | SYNCS_OUTPUT_ENABLE | FORCED_SYNC_LEVELS));
|
||||
break;
|
||||
case PlatinumReg::VRAM_REFRESH:
|
||||
this->vram_refresh = value;
|
||||
@@ -320,6 +353,7 @@ void PlatinumCtrl::write(uint32_t rgn_start, uint32_t offset, uint32_t value, in
|
||||
case PlatinumReg::SWATCH_VFP:
|
||||
case PlatinumReg::SWATCH_VFPEQ:
|
||||
this->swatch_params[REG_TO_INDEX(offset >> 4)] = value;
|
||||
this->change_display();
|
||||
break;
|
||||
case PlatinumReg::TIMING_ADJUST:
|
||||
this->timing_adjust = value;
|
||||
@@ -346,6 +380,8 @@ void PlatinumCtrl::insert_ram_dimm(int slot_num, uint32_t capacity) {
|
||||
}
|
||||
|
||||
switch (capacity) {
|
||||
case 0:
|
||||
break;
|
||||
case DRAM_CAP_2MB:
|
||||
case DRAM_CAP_4MB:
|
||||
case DRAM_CAP_8MB:
|
||||
@@ -381,6 +417,10 @@ void PlatinumCtrl::map_phys_ram() {
|
||||
|
||||
// ====================== Framebuffer controller stuff =======================
|
||||
void PlatinumCtrl::enable_display() {
|
||||
bool did_size_change = false;
|
||||
bool did_refresh_rate_change = false;
|
||||
bool did_depth_change = false;
|
||||
|
||||
int clock_divisor = this->dacula->get_clock_div();
|
||||
|
||||
this->pixel_clock = this->dacula->get_dot_freq();
|
||||
@@ -407,6 +447,8 @@ void PlatinumCtrl::enable_display() {
|
||||
this->vert_blank >>= 1;
|
||||
}
|
||||
|
||||
if (new_width != this->active_width || new_height != this->active_height)
|
||||
did_size_change = true;
|
||||
this->active_width = new_width;
|
||||
this->active_height = new_height;
|
||||
|
||||
@@ -417,7 +459,10 @@ void PlatinumCtrl::enable_display() {
|
||||
this->fb_ptr = &this->vram_ptr[this->fb_offset] + 16;
|
||||
this->fb_pitch = this->row_words;
|
||||
|
||||
this->pixel_depth = this->dacula->get_pix_width();
|
||||
int new_pixel_depth = this->dacula->get_pix_width();
|
||||
if (new_pixel_depth != this->pixel_depth)
|
||||
did_depth_change = true;
|
||||
this->pixel_depth = new_pixel_depth;
|
||||
|
||||
// attach framebuffer conversion routine
|
||||
switch (this->pixel_depth) {
|
||||
@@ -451,16 +496,37 @@ void PlatinumCtrl::enable_display() {
|
||||
return;
|
||||
}
|
||||
|
||||
this->refresh_rate = (double)(this->pixel_clock) / (this->hori_total * this->vert_total);
|
||||
float new_refresh_rate = (double)(this->pixel_clock) / (this->hori_total * this->vert_total);
|
||||
if (new_refresh_rate != this->refresh_rate)
|
||||
did_refresh_rate_change = true;
|
||||
this->refresh_rate = new_refresh_rate;
|
||||
|
||||
this->start_refresh_task();
|
||||
|
||||
LOG_F(INFO, "%s: video width=%d, height=%d", this->name.c_str(), new_width, new_height);
|
||||
LOG_F(INFO, "%s: refresh rate set to %f Hz", this->name.c_str(), this->refresh_rate);
|
||||
if (did_size_change)
|
||||
LOG_F(INFO, "%s: video width=%d, height=%d", this->name.c_str(), new_width, new_height);
|
||||
if (did_depth_change)
|
||||
LOG_F(INFO, "%s: video depth=%d", this->name.c_str(), new_pixel_depth);
|
||||
if (did_refresh_rate_change)
|
||||
LOG_F(INFO, "%s: refresh rate set to %f Hz", this->name.c_str(), this->refresh_rate);
|
||||
if (this->blank_on == true || this->crtc_on == false)
|
||||
LOG_F(INFO, "%s: display enabled", this->name.c_str());
|
||||
|
||||
this->blank_on = false;
|
||||
this->crtc_on = true;
|
||||
}
|
||||
|
||||
void PlatinumCtrl::disable_display() {
|
||||
this->crtc_on = false;
|
||||
this->blank_display();
|
||||
}
|
||||
|
||||
void PlatinumCtrl::change_display() {
|
||||
if (this->fb_reset == 0) {
|
||||
this->enable_display();
|
||||
}
|
||||
}
|
||||
|
||||
void PlatinumCtrl::enable_cursor_int() {
|
||||
if (!(this->swatch_int_mask & SWATCH_INT_CURSOR))
|
||||
return;
|
||||
@@ -496,7 +562,7 @@ void PlatinumCtrl::update_irq(uint8_t irq_line_state, uint8_t irq_mask) {
|
||||
// ========================== Device registry stuff ==========================
|
||||
static const PropMap Platinum_Properties = {
|
||||
{"gfxmem_size",
|
||||
new IntProperty(1, vector<uint32_t>({1, 2, 4}))},
|
||||
new IntProperty(1, std::vector<uint32_t>({1, 2, 4}))},
|
||||
{"mon_id",
|
||||
new StrProperty("HiRes12-14in")},
|
||||
};
|
||||
|
||||
+167
-69
@@ -105,78 +105,147 @@ enum CpuSpeed3 {
|
||||
|
||||
/** Configuration and status register offsets. */
|
||||
enum PlatinumReg : uint32_t {
|
||||
CPU_ID = 0x00, // read 0x30018140 ; read byte happens
|
||||
ASIC_REVISION = 0x01,
|
||||
ROM_TIMING = 0x02,
|
||||
CACHE_CONFIG = 0x03,
|
||||
DRAM_TIMING = 0x04,
|
||||
DRAM_REFRESH = 0x05,
|
||||
BANK_0_BASE = 0x06,
|
||||
BANK_1_BASE = 0x07,
|
||||
BANK_2_BASE = 0x08,
|
||||
BANK_3_BASE = 0x09, // read byte happens
|
||||
BANK_4_BASE = 0x0A,
|
||||
BANK_5_BASE = 0x0B,
|
||||
BANK_6_BASE = 0x0C,
|
||||
BANK_7_BASE = 0x0D,
|
||||
GP_SW_SCRATCH = 0x0E,
|
||||
PCI_ADDR_MASK = 0x0F,
|
||||
FB_BASE_ADDR = 0x10,
|
||||
CPU_ID = 0x00, // Catalyst CPU ID Register ; read 0x30018140 ; read byte happens
|
||||
ASIC_REVISION = 0x01, // Platinum Revision/Test Register
|
||||
ROM_TIMING = 0x02, // ROM Timing Configuration Register
|
||||
CACHE_CONFIG = 0x03, // Cache Configuration Register
|
||||
DRAM_TIMING = 0x04, // DRAM Timing Configuration Register
|
||||
DRAM_REFRESH = 0x05, // DRAM Refresh Timing
|
||||
BANK_0_BASE = 0x06, // DRAM Bank 0 Base Address Register
|
||||
BANK_1_BASE = 0x07, // DRAM Bank 1 Base Address Register
|
||||
BANK_2_BASE = 0x08, // DRAM Bank 2 Base Address Register
|
||||
BANK_3_BASE = 0x09, // DRAM Bank 3 Base Address Register ; read byte happens
|
||||
BANK_4_BASE = 0x0A, // DRAM Bank 4 Base Address Register
|
||||
BANK_5_BASE = 0x0B, // DRAM Bank 5 Base Address Register
|
||||
BANK_6_BASE = 0x0C, // DRAM Bank 6 Base Address Register
|
||||
BANK_7_BASE = 0x0D, // DRAM Bank 7 Base Address Register
|
||||
GP_SW_SCRATCH = 0x0E, // General Purpose Software Register
|
||||
PCI_ADDR_MASK = 0x0F, // PCI Address Mask Register
|
||||
FB_BASE_ADDR = 0x10, // Frame Buffer/Display Base Addresses
|
||||
// = 0x11,
|
||||
ROW_WORDS = 0x12,
|
||||
CLOCK_DIVISOR = 0x13, // write 0xff, 0x02
|
||||
FB_CONFIG_1 = 0x14,
|
||||
FB_CONFIG_2 = 0x15,
|
||||
VMEM_PAGE_MODE = 0x16,
|
||||
MON_ID_SENSE = 0x17,
|
||||
FB_RESET = 0x18, // write 6, 3, 7, 2
|
||||
DBL_BUF_CNTL = 0x19,
|
||||
V_TEST_REG = 0x1A,
|
||||
VRAM_REFRESH = 0x1B,
|
||||
ROW_WORDS = 0x12, // Row Words
|
||||
CLOCK_DIVISOR = 0x13, // Video Clock Configuration ; write 0xff, 0x02
|
||||
FB_CONFIG_1 = 0x14, // Frame Buffer Configuration 1
|
||||
FB_CONFIG_2 = 0x15, // Frame Buffer Configuration 2
|
||||
VMEM_PAGE_MODE = 0x16, // Page Mode Enable
|
||||
MON_ID_SENSE = 0x17, // Monitor ID Sense Lines ; Sense Line Enable
|
||||
FB_RESET = 0x18, // Frame Buffer Reset ; Reset ; write 6, 3, 7, 2
|
||||
DBL_BUF_CNTL = 0x19, // Double Buffer Control
|
||||
FB_TEST = 0x1A, // Frame Buffer Test
|
||||
VRAM_REFRESH = 0x1B, // VRAM Refresh Timing
|
||||
|
||||
// Swatch timing generator registers
|
||||
SWATCH_CONFIG = 0x20, // 0xff0 ; pxffc for 1280 modes
|
||||
SWATCH_INT_MASK = 0x21, // 4
|
||||
SWATCH_INT_STAT = 0x22, // 0
|
||||
CLR_CURSOR_INT = 0x23, // 0
|
||||
CLR_ANIM_INT = 0x24, // 0
|
||||
CLR_VBL_INT = 0x25, // 0
|
||||
CURSOR_LINE = 0x26, // write 0x320, 0x209, 0x299, 0x38f, 0x428
|
||||
ANIMATE_LINE = 0x27, // 0
|
||||
COUNTER_TEST = 0x28, // 0
|
||||
SWATCH_CONFIG = 0x20, // Swatch Mode ; 0xff0 ; pxffc for 1280 modes
|
||||
SWATCH_INT_MASK = 0x21, // Interrupt Mask ; 4
|
||||
SWATCH_INT_STAT = 0x22, // Interrupt Status ; 0
|
||||
CLR_CURSOR_INT = 0x23, // Clear Cursor Interrupt ; 0
|
||||
CLR_ANIM_INT = 0x24, // Clear Animation Line Interrupt ; 0
|
||||
CLR_VBL_INT = 0x25, // Clear VBL Interrupt ; 0
|
||||
CURSOR_LINE = 0x26, // Cursor Line ; write 0x320, 0x209, 0x299, 0x38f, 0x428
|
||||
ANIMATE_LINE = 0x27, // Animation Line ; 0
|
||||
COUNTER_TEST = 0x28, // Counter Test ; 0
|
||||
FIRST_SWATCH = 0x29,
|
||||
SWATCH_HSERR = 0x29,
|
||||
SWATCH_HLFLN = 0x2A,
|
||||
SWATCH_HEQ = 0x2B,
|
||||
SWATCH_HSP = 0x2C,
|
||||
SWATCH_HBWAY = 0x2D,
|
||||
SWATCH_HBRST = 0x2E,
|
||||
SWATCH_HBP = 0x2F,
|
||||
SWATCH_HAL = 0x30,
|
||||
SWATCH_HFP = 0x31,
|
||||
SWATCH_HPIX = 0x32,
|
||||
SWATCH_VHLINE = 0x33,
|
||||
SWATCH_VSYNC = 0x34,
|
||||
SWATCH_VBPEQ = 0x35,
|
||||
SWATCH_VBP = 0x36,
|
||||
SWATCH_VAL = 0x37,
|
||||
SWATCH_VFP = 0x38,
|
||||
SWATCH_VFPEQ = 0x39,
|
||||
TIMING_ADJUST = 0x3A,
|
||||
SWATCH_HSERR = 0x29, // Horizontal Serration Pulse
|
||||
SWATCH_HLFLN = 0x2A, // Horizontal Half Line
|
||||
SWATCH_HEQ = 0x2B, // Horizontal Equalization Pulse
|
||||
SWATCH_HSP = 0x2C, // Horizontal Sync Pulse
|
||||
SWATCH_HBWAY = 0x2D, // Horizontal Beezeway
|
||||
SWATCH_HBRST = 0x2E, // Horizontal Burst Gate
|
||||
SWATCH_HBP = 0x2F, // Horizontal Back Porch
|
||||
SWATCH_HAL = 0x30, // Horizontal Active Line
|
||||
SWATCH_HFP = 0x31, // Horizontal Front Porch
|
||||
SWATCH_HPIX = 0x32, // Horizontal Pixels
|
||||
SWATCH_VHLINE = 0x33, // Vertical Half Lines
|
||||
SWATCH_VSYNC = 0x34, // Vertical Sync Pulse
|
||||
SWATCH_VBPEQ = 0x35, // Vertical Back Porch Equalization
|
||||
SWATCH_VBP = 0x36, // Vertical Back Porch
|
||||
SWATCH_VAL = 0x37, // Vertical Active Line
|
||||
SWATCH_VFP = 0x38, // Vertical Front Porch
|
||||
SWATCH_VFPEQ = 0x39, // Vertical Front Porch Equalization
|
||||
TIMING_ADJUST = 0x3A, // Timing Adjust
|
||||
CURRENT_LINE = 0x3B, // Current Scan Line
|
||||
|
||||
// Iridium datapath registers
|
||||
IRIDIUM_CONFIG = 0x4A, // write 4
|
||||
POWER_DOWN_CTRL = 0x4B, // 1-bit register, writing "1" enables power down mode
|
||||
FG_COLOR = 0x40, // Foreground Color
|
||||
BG_COLOR = 0x41, // Background Color
|
||||
SRC_BASE = 0x42, // Source Image Base Address
|
||||
DST_BASE = 0x43, // Destination Image Base Address
|
||||
ROW_BYTES = 0x44, // Source/Destination RowBytes
|
||||
DST_SIZE = 0x45, // Destination Size (H, V pixels)
|
||||
QDA_CNTL = 0x46, // Control 1
|
||||
QDA_CMD = 0x47, // Control 2
|
||||
QDA_STATUS = 0x48, // Command/Status
|
||||
QDA_PTR = 0x49, // Command List Pointer
|
||||
IRIDIUM_CONFIG = 0x4A, // System Configuration Register ; write 4
|
||||
POWER_DOWN_CTRL = 0x4B, // Sleep (power down) Mode Enable ; 1-bit register, writing "1" enables power down mode
|
||||
};
|
||||
|
||||
#define REG_TO_INDEX(reg) ((reg) - FIRST_SWATCH)
|
||||
|
||||
// DRAM_TIMING register bits.
|
||||
enum {
|
||||
DT_SLOW_ADDRESS_ONLY_CYCLE = 1 << 12,
|
||||
DT_QDA_READ_RAS_DELAY = 1 << 11,
|
||||
DT_QDA_READ_CAS_DELAY_1 = 1 << 10,
|
||||
DT_QDA_READ_CAS_DELAY_2 = 1 << 9,
|
||||
DT_PAGE_MODE = 1 << 8,
|
||||
DT_READ_RAS_DELAY = 1 << 7,
|
||||
DT_READ_CAS_DELAY_1 = 1 << 6,
|
||||
DT_READ_CAS_DELAY_2 = 1 << 5,
|
||||
DT_WRITE_RAS_DELAY = 1 << 4,
|
||||
DT_WRITE_CAS_DELAY = 1 << 3,
|
||||
DT_RAS_PRECHARGE = 1 << 2,
|
||||
DT_CBR_DELAY_1 = 1 << 1,
|
||||
DT_CBR_DELAY_2 = 1 << 0,
|
||||
DT_DEFAULT = 0xEFF,
|
||||
};
|
||||
|
||||
// DRAM_REFRESH register bits.
|
||||
enum {
|
||||
DRAM_REFRESH_INTERVAL = 0x7FF,
|
||||
DRAM_REFRESH_INTERVAL_DEFAULT = 500, // (Bus clock speed (in MHz) x DRAM refresh period (in μs)) - 20
|
||||
};
|
||||
|
||||
// FB_CONFIG_1 register bits.
|
||||
enum {
|
||||
CFG1_INTERLACE = (1 << 2), // 1 - interlaced video enabled
|
||||
CFG1_VID_ENABLE = (1 << 4), // 1 - display refresh enabled
|
||||
CFG1_FULL_BANKS = (1 << 12), // full VRAM banks (64-bit) access enable
|
||||
CFG1_VRAMS_2MBIT = 1 << 0, // 2 MB VRAMs
|
||||
CFG1_SAM_512BIT = 1 << 1, // 512 Bit SAM
|
||||
CFG1_INTERLACE = 1 << 2, // 1 - interlaced video enabled
|
||||
CFG1_WORD_INTERLEAVE = 1 << 3, // unused in Platinum
|
||||
CFG1_VID_ENABLE = 1 << 4, // 1 - display refresh enabled
|
||||
CFG1_VRAM_REFRESH_COUNT = 7 << 5, // unused in Platinum
|
||||
CFG1_ROM_SPEED = 15 << 8, // unused in Platinum = 0xF
|
||||
CFG1_FULL_BANKS = 1 << 12, // full VRAM banks (64-bit) access enable
|
||||
};
|
||||
|
||||
// FB_CONFIG_2 register bits.
|
||||
enum {
|
||||
CFG2_QDA_READ_RAS_DELAY = 1 << 12,
|
||||
CFG2_QDA_READ_CAS_DELAY_1 = 1 << 11,
|
||||
CFG2_QDA_READ_CAS_DELAY_2 = 1 << 10,
|
||||
CFG2_READ_RAS_DELAY = 1 << 9,
|
||||
CFG2_READ_CAS_DELAY_1 = 1 << 8,
|
||||
CFG2_READ_CAS_DELAY_2 = 1 << 7,
|
||||
CFG2_WRITE_RAS_DELAY = 1 << 6,
|
||||
CFG2_WRITE_CAS_DELAY = 1 << 5,
|
||||
CFG2_RAS_PRECHARGE = 1 << 4,
|
||||
CFG2_CBR_DELAY_1 = 1 << 3,
|
||||
CFG2_CBR_DELAY_2 = 1 << 2,
|
||||
CFG2_XFER_DELAY_1 = 1 << 1,
|
||||
CFG2_XFER_DELAY_2 = 1 << 0,
|
||||
CFG2_ALL_BITS = 0x1FFF,
|
||||
};
|
||||
|
||||
// VMEM_PAGE_MODE register bits
|
||||
enum {
|
||||
PAGE_MODE_ENABLE = 1 << 0,
|
||||
};
|
||||
|
||||
// MON_ID_SENSE register bits.
|
||||
enum {
|
||||
SENSE_BITS = 7 << 0,
|
||||
INVERSE_SENSE_PINS = 7 << 0, INVERSE_SENSE_PINS_pos = 0,
|
||||
INVERSE_SENSE_BITS = 7 << 3, INVERSE_SENSE_BITS_pos = 3,
|
||||
};
|
||||
|
||||
// FB_RESET register bits.
|
||||
@@ -184,6 +253,7 @@ enum {
|
||||
VRAM_SM_RESET = (1 << 0), // VRAM state machine reset
|
||||
VREFRESH_SM_RESET = (1 << 1), // Video refresh state machine reset
|
||||
SWATCH_RESET = (1 << 2), // Swatch reset
|
||||
FB_RESET_DEFAULT = 7,
|
||||
};
|
||||
|
||||
// SWATCH_INT_MASK register bits.
|
||||
@@ -193,8 +263,34 @@ enum {
|
||||
SWATCH_INT_CURSOR = (1 << 2)
|
||||
};
|
||||
|
||||
#define DAMFB_VERSION_PLATINUM 6 // DAMFB cell version in the Platinum ASIC
|
||||
#define IRIDIUM_VENDOR_VLSI 0 // Vendor ID for the Iridium ASIC => VLSI
|
||||
// FB_TEST register bits.
|
||||
enum {
|
||||
SENSE_LINE_OUTPUT_DATA_pos = 16, SENSE_LINE_OUTPUT_DATA_size = 3,
|
||||
SENSE_LINE_OUTPUT_DATA = 7 << SENSE_LINE_OUTPUT_DATA_pos,
|
||||
SYNCS_OUTPUT_ENABLE = 1 << 15,
|
||||
DAFB_VERSION_NUMBER_pos = 9, DAFB_VERSION_NUMBER_size = 3,
|
||||
DAFB_VERSION_PLATINUM = 6, // DAFB cell version in the Platinum ASIC
|
||||
FORCED_VSYNC_LEVEL = 1 << 3,
|
||||
FORCED_HSYNC_LEVEL = 1 << 2,
|
||||
FORCED_CSYNC_LEVEL = 1 << 1,
|
||||
FORCED_SYNC_LEVELS = 7 << 1,
|
||||
};
|
||||
|
||||
// VRAM_REFRESH register bits.
|
||||
enum {
|
||||
VRAM_REFRESH_INTERVAL = 0x7FF,
|
||||
VRAM_REFRESH_INTERVAL_DEFAULT = 500, // (Bus clock speed (in MHz) x VRAM refresh period (in μs)) - 20
|
||||
};
|
||||
|
||||
// IRIDIUM_CONFIG register bits.
|
||||
enum {
|
||||
IRIDIUM_REVISION_pos = 28, IRIDIUM_REVISION_size = 4,
|
||||
IRIDIUM_VENDOR_pos = 24, IRIDIUM_VENDOR_size = 4,
|
||||
IRIDIUM_VENDOR_VLSI = 0, // Vendor ID for the Iridium ASIC => VLSI
|
||||
IRIDIUM_VENDOR_TI = 1,
|
||||
DISPLAY_PIXEL_DEPTH_pos = 1, DISPLAY_PIXEL_DEPTH_size = 2,
|
||||
BIG_ENDIAN_BUS = 1,
|
||||
};
|
||||
|
||||
constexpr auto VRAM_REGION_BASE = 0xF1000000UL;
|
||||
constexpr auto PLATINUM_IOREG_BASE = 0xF8000000UL;
|
||||
@@ -222,6 +318,8 @@ public:
|
||||
|
||||
protected:
|
||||
void enable_display();
|
||||
void change_display();
|
||||
void disable_display();
|
||||
void enable_cursor_int();
|
||||
void update_irq(uint8_t irq_line_state, uint8_t irq_mask);
|
||||
|
||||
@@ -231,24 +329,24 @@ private:
|
||||
|
||||
// memory controller state
|
||||
uint32_t rom_timing = 0;
|
||||
uint32_t dram_timing = 0xEFF;
|
||||
uint32_t dram_refresh = 0x1F4;
|
||||
uint32_t dram_timing = Platinum::DT_DEFAULT;
|
||||
uint32_t dram_refresh = Platinum::DRAM_REFRESH_INTERVAL_DEFAULT;
|
||||
uint32_t bank_base[8] = {};
|
||||
uint32_t bank_size[8] = {};
|
||||
|
||||
// frame buffer controller state
|
||||
uint32_t fb_addr = Platinum::VRAM_REGION_BASE;
|
||||
uint32_t fb_offset = 0;
|
||||
uint32_t fb_config_1 = 0x1F00;
|
||||
uint32_t fb_config_2 = 0x1FFF;
|
||||
uint32_t fb_config_1 = Platinum::CFG1_FULL_BANKS + Platinum::CFG1_ROM_SPEED;
|
||||
uint32_t fb_config_2 = Platinum::CFG2_ALL_BITS;
|
||||
uint32_t clock_divisor = 0;
|
||||
uint32_t row_words = 0;
|
||||
uint32_t fb_reset = 7;
|
||||
uint32_t fb_reset = Platinum::FB_RESET_DEFAULT;
|
||||
int reset_step = 0;
|
||||
uint32_t fb_test = DAMFB_VERSION_PLATINUM << 9;
|
||||
uint32_t vram_refresh = 0x1F4;
|
||||
uint32_t fb_test = Platinum::DAFB_VERSION_PLATINUM << Platinum::DAFB_VERSION_NUMBER_pos;
|
||||
uint32_t vram_refresh = Platinum::VRAM_REFRESH_INTERVAL_DEFAULT;
|
||||
uint32_t vram_size = 0;
|
||||
uint32_t iridium_cfg = (IRIDIUM_VENDOR_VLSI << 24) | 1; // big-endian bus
|
||||
uint32_t iridium_cfg = (Platinum::IRIDIUM_VENDOR_VLSI << Platinum::IRIDIUM_VENDOR_pos) | Platinum::BIG_ENDIAN_BUS;
|
||||
uint8_t vram_megs = 0;
|
||||
uint8_t half_bank = 0;
|
||||
uint8_t half_access = 0;
|
||||
|
||||
@@ -94,6 +94,8 @@ void PsxCtrl::insert_ram_dimm(int slot_num, uint32_t capacity)
|
||||
}
|
||||
|
||||
switch (capacity) {
|
||||
case 0:
|
||||
break;
|
||||
case DRAM_CAP_2MB:
|
||||
case DRAM_CAP_4MB:
|
||||
case DRAM_CAP_8MB:
|
||||
@@ -114,10 +116,6 @@ void PsxCtrl::map_phys_ram()
|
||||
total_ram += this->bank_sizes[i];
|
||||
}
|
||||
|
||||
if (total_ram > DRAM_CAP_32MB) {
|
||||
ABORT_F("PSX: RAM bigger than 32MB not supported yet");
|
||||
}
|
||||
|
||||
if (!add_ram_region(0x00000000, total_ram)) {
|
||||
ABORT_F("PSX: could not allocate RAM storage");
|
||||
}
|
||||
|
||||
+37
-35
@@ -288,25 +288,25 @@ CharIoSocket::CharIoSocket()
|
||||
address.sun_family = AF_UNIX;
|
||||
strcpy(address.sun_path, path);
|
||||
|
||||
sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (sockfd == -1) {
|
||||
this->sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (this->sockfd == -1) {
|
||||
LOG_F(INFO, "socket create err: %s", strerror(errno));
|
||||
break;
|
||||
}
|
||||
|
||||
rc = bind(sockfd, (sockaddr*)(&address), sizeof(address));
|
||||
rc = bind(this->sockfd, (sockaddr*)(&address), sizeof(address));
|
||||
if (rc == -1) {
|
||||
LOG_F(INFO, "socket bind err: %s", strerror(errno));
|
||||
close(sockfd);
|
||||
sockfd = -1;
|
||||
close(this->sockfd);
|
||||
this->sockfd = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
rc = listen(sockfd, 100);
|
||||
rc = listen(this->sockfd, 100);
|
||||
if (rc == -1) {
|
||||
LOG_F(INFO, "socket listen err: %s", strerror(errno));
|
||||
close(sockfd);
|
||||
sockfd = -1;
|
||||
close(this->sockfd);
|
||||
this->sockfd = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -366,13 +366,13 @@ bool CharIoSocket::rcv_char_available_now()
|
||||
fd_set errorfds;
|
||||
|
||||
int sockmax = 0;
|
||||
if (sockfd != -1) {
|
||||
if (this->sockfd != -1) {
|
||||
FD_ZERO(&readfds);
|
||||
FD_SET(sockfd, &readfds);
|
||||
if (sockfd > sockmax) sockmax = sockfd;
|
||||
if (acceptfd != -1) {
|
||||
FD_SET(acceptfd, &readfds);
|
||||
if (acceptfd > sockmax) sockmax = acceptfd;
|
||||
FD_SET(this->sockfd, &readfds);
|
||||
if (this->sockfd > sockmax) sockmax = this->sockfd;
|
||||
if (this->acceptfd != -1) {
|
||||
FD_SET(this->acceptfd, &readfds);
|
||||
if (this->acceptfd > sockmax) sockmax = this->acceptfd;
|
||||
}
|
||||
writefds = readfds;
|
||||
errorfds = readfds;
|
||||
@@ -388,12 +388,12 @@ bool CharIoSocket::rcv_char_available_now()
|
||||
}
|
||||
|
||||
if (sel_rv > 0) {
|
||||
if (sockfd != -1) {
|
||||
if (FD_ISSET(sockfd, &readfds)) {
|
||||
if (this->sockfd != -1) {
|
||||
if (FD_ISSET(this->sockfd, &readfds)) {
|
||||
uint8_t c;
|
||||
int received = (int)recv(sockfd, &c, 1, 0);
|
||||
int received = (int)recv(this->sockfd, &c, 1, 0);
|
||||
if (received == -1) {
|
||||
if (acceptfd == -1) {
|
||||
if (this->acceptfd == -1) {
|
||||
//LOG_F(INFO, "socket sock read (not accepted yet) err: %s", strerror(errno)); // this happens once before accept
|
||||
}
|
||||
else {
|
||||
@@ -407,12 +407,12 @@ bool CharIoSocket::rcv_char_available_now()
|
||||
LOG_F(INFO, "socket sock read %d", received); // should never happen
|
||||
}
|
||||
|
||||
if (acceptfd == -1) {
|
||||
if (this->acceptfd == -1) {
|
||||
sockaddr_un acceptfdaddr;
|
||||
memset(&acceptfdaddr, 0, sizeof(acceptfdaddr));
|
||||
socklen_t len = sizeof(acceptfdaddr);
|
||||
acceptfd = accept(sockfd, (struct sockaddr *) &acceptfdaddr, &len);
|
||||
if (acceptfd == -1) {
|
||||
this->acceptfd = accept(this->sockfd, (struct sockaddr *) &acceptfdaddr, &len);
|
||||
if (this->acceptfd == -1) {
|
||||
LOG_F(INFO, "socket accept err: %s", strerror(errno));
|
||||
}
|
||||
else {
|
||||
@@ -421,30 +421,30 @@ bool CharIoSocket::rcv_char_available_now()
|
||||
}
|
||||
} // if read
|
||||
|
||||
if (FD_ISSET(sockfd, &writefds)) {
|
||||
if (FD_ISSET(this->sockfd, &writefds)) {
|
||||
LOG_F(INFO, "socket sock write");
|
||||
}
|
||||
|
||||
if (FD_ISSET(sockfd, &errorfds)) {
|
||||
if (FD_ISSET(this->sockfd, &errorfds)) {
|
||||
LOG_F(INFO, "socket sock error");
|
||||
}
|
||||
} // if sockfd
|
||||
} // if this->sockfd
|
||||
|
||||
if (acceptfd != -1) {
|
||||
if (FD_ISSET(acceptfd, &readfds)) {
|
||||
if (this->acceptfd != -1) {
|
||||
if (FD_ISSET(this->acceptfd, &readfds)) {
|
||||
// LOG_F(INFO, "socket accept read havechars");
|
||||
havechars = true;
|
||||
consecutivechars++;
|
||||
} // if read
|
||||
|
||||
if (FD_ISSET(acceptfd, &writefds)) {
|
||||
if (FD_ISSET(this->acceptfd, &writefds)) {
|
||||
// LOG_F(INFO, "socket accept write"); // this is usually always true
|
||||
}
|
||||
|
||||
if (FD_ISSET(acceptfd, &errorfds)) {
|
||||
if (FD_ISSET(this->acceptfd, &errorfds)) {
|
||||
LOG_F(INFO, "socket accept error");
|
||||
}
|
||||
} // if acceptfd
|
||||
} // if this->acceptfd
|
||||
}
|
||||
else
|
||||
consecutivechars = 0;
|
||||
@@ -453,11 +453,13 @@ bool CharIoSocket::rcv_char_available_now()
|
||||
|
||||
int CharIoSocket::xmit_char(uint8_t c)
|
||||
{
|
||||
if (acceptfd == -1)
|
||||
write(STDOUT_FILENO, &c, 1);
|
||||
|
||||
if (this->acceptfd == -1)
|
||||
this->rcv_char_available_now();
|
||||
|
||||
if (acceptfd != -1) {
|
||||
int sent = (int)send(acceptfd, &c, 1, 0);
|
||||
if (this->acceptfd != -1) {
|
||||
int sent = (int)send(this->acceptfd, &c, 1, 0);
|
||||
if (sent == -1) {
|
||||
LOG_F(INFO, "socket accept write err: %s", strerror(errno));
|
||||
}
|
||||
@@ -479,11 +481,11 @@ int CharIoSocket::xmit_char(uint8_t c)
|
||||
|
||||
int CharIoSocket::rcv_char(uint8_t *c)
|
||||
{
|
||||
if (acceptfd == -1)
|
||||
if (this->acceptfd == -1)
|
||||
this->rcv_char_available_now();
|
||||
|
||||
if (acceptfd != -1) {
|
||||
int received = (int)recv(acceptfd, c, 1, 0);
|
||||
if (this->acceptfd != -1) {
|
||||
int received = (int)recv(this->acceptfd, c, 1, 0);
|
||||
if (received == -1) {
|
||||
LOG_F(INFO, "socket accept read err: %s", strerror(errno));
|
||||
}
|
||||
|
||||
@@ -425,7 +425,7 @@ void EsccChannel::dma_in_rx()
|
||||
[this]() {
|
||||
this->timer_id_rx = 0;
|
||||
char c = receive_byte();
|
||||
int xx = dma_ch[1]->push_data(&c, 1);
|
||||
dma_ch[1]->push_data(&c, 1);
|
||||
this->dma_in_rx();
|
||||
});
|
||||
}
|
||||
@@ -477,7 +477,7 @@ void EsccChannel::dma_flush_rx()
|
||||
});
|
||||
}
|
||||
|
||||
static const vector<string> CharIoBackends = {"null", "stdio", "socket"};
|
||||
static const std::vector<std::string> CharIoBackends = {"null", "stdio", "socket"};
|
||||
|
||||
static const PropMap Escc_Properties = {
|
||||
{"serial_backend", new StrProperty("null", CharIoBackends)},
|
||||
|
||||
@@ -69,8 +69,7 @@ void AwacsBase::dma_out_start() {
|
||||
}
|
||||
|
||||
if (!this->out_stream_ready) {
|
||||
if ((err = this->snd_server->open_out_stream(this->cur_sample_rate,
|
||||
(void *)this->dma_out_ch))) {
|
||||
if ((err = this->snd_server->open_out_stream(this->cur_sample_rate, this->dma_out_ch))) {
|
||||
LOG_F(ERROR, "%s: unable to open sound output stream: %d",
|
||||
this->name.c_str(), err);
|
||||
return;
|
||||
|
||||
@@ -38,6 +38,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include <memory>
|
||||
|
||||
class DmaOutChannel;
|
||||
|
||||
class SoundServer : public HWComponent {
|
||||
public:
|
||||
SoundServer();
|
||||
@@ -45,7 +47,7 @@ public:
|
||||
|
||||
int start();
|
||||
void shutdown();
|
||||
int open_out_stream(uint32_t sample_rate, void *user_data);
|
||||
int open_out_stream(uint32_t sample_rate, DmaOutChannel *dma_ch);
|
||||
int start_out_stream();
|
||||
void close_out_stream();
|
||||
|
||||
|
||||
@@ -19,30 +19,40 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX
|
||||
#endif // NOMINMAX
|
||||
|
||||
#include <core/timermanager.h>
|
||||
#include <cpu/ppc/ppcemu.h>
|
||||
#include <devices/common/dmacore.h>
|
||||
#include <devices/sound/soundserver.h>
|
||||
#include <endianswap.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <loguru.hpp>
|
||||
#include <cubeb/cubeb.h>
|
||||
#ifdef _WIN32
|
||||
#include <objbase.h>
|
||||
#endif
|
||||
|
||||
enum {
|
||||
typedef enum {
|
||||
SND_SERVER_DOWN = 0,
|
||||
SND_API_READY,
|
||||
SND_SERVER_UP,
|
||||
SND_STREAM_OPENED,
|
||||
SND_STREAM_CLOSED
|
||||
};
|
||||
} Status;
|
||||
|
||||
class SoundServer::Impl {
|
||||
public:
|
||||
int status; /* server status */
|
||||
Status status = SND_SERVER_DOWN;
|
||||
cubeb *cubeb_ctx;
|
||||
|
||||
cubeb_stream *out_stream;
|
||||
|
||||
uint32_t deterministic_poll_timer = 0;
|
||||
std::function<void()> deterministic_poll_cb;
|
||||
};
|
||||
|
||||
SoundServer::SoundServer(): impl(std::make_unique<Impl>())
|
||||
@@ -91,6 +101,10 @@ void SoundServer::shutdown()
|
||||
/* fall through */
|
||||
case SND_API_READY:
|
||||
cubeb_destroy(impl->cubeb_ctx);
|
||||
break;
|
||||
case SND_SERVER_DOWN:
|
||||
// Nothing to do.
|
||||
break;
|
||||
}
|
||||
|
||||
impl->status = SND_SERVER_DOWN;
|
||||
@@ -148,8 +162,30 @@ static void status_callback(cubeb_stream *stream, void *user_data, cubeb_state s
|
||||
LOG_F(9, "Cubeb status callback fired, status = %d", state);
|
||||
}
|
||||
|
||||
int SoundServer::open_out_stream(uint32_t sample_rate, void *user_data)
|
||||
int SoundServer::open_out_stream(uint32_t sample_rate, DmaOutChannel *dma_ch)
|
||||
{
|
||||
if (is_deterministic) {
|
||||
impl->deterministic_poll_cb = [dma_ch] {
|
||||
if (!dma_ch->is_out_active()) {
|
||||
return;
|
||||
}
|
||||
// Drain the DMA buffer, but don't do anything else.
|
||||
int req_size = std::max(dma_ch->get_pull_data_remaining(), 1024);
|
||||
int out_size = 0;
|
||||
while (req_size > 0) {
|
||||
uint8_t *chunk;
|
||||
uint32_t chunk_size;
|
||||
if (!dma_ch->pull_data(req_size, &chunk_size, &chunk)) {
|
||||
req_size -= chunk_size;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
impl->status = SND_STREAM_OPENED;
|
||||
LOG_F(9, "Deterministic sound output callback set up.");
|
||||
return 0;
|
||||
}
|
||||
int res;
|
||||
uint32_t latency_frames;
|
||||
cubeb_stream_params params;
|
||||
@@ -170,7 +206,7 @@ int SoundServer::open_out_stream(uint32_t sample_rate, void *user_data)
|
||||
|
||||
res = cubeb_stream_init(impl->cubeb_ctx, &impl->out_stream, "SndOut stream",
|
||||
NULL, NULL, NULL, ¶ms, latency_frames,
|
||||
sound_out_callback, status_callback, user_data);
|
||||
sound_out_callback, status_callback, dma_ch);
|
||||
if (res != CUBEB_OK) {
|
||||
LOG_F(ERROR, "Could not open sound output stream, error: %d", res);
|
||||
return -1;
|
||||
@@ -185,11 +221,22 @@ int SoundServer::open_out_stream(uint32_t sample_rate, void *user_data)
|
||||
|
||||
int SoundServer::start_out_stream()
|
||||
{
|
||||
if (is_deterministic) {
|
||||
LOG_F(9, "Starting sound output deterministic polling.");
|
||||
impl->deterministic_poll_timer = TimerManager::get_instance()->add_cyclic_timer(MSECS_TO_NSECS(10), impl->deterministic_poll_cb);
|
||||
return 0;
|
||||
}
|
||||
return cubeb_stream_start(impl->out_stream);
|
||||
}
|
||||
|
||||
void SoundServer::close_out_stream()
|
||||
{
|
||||
if (is_deterministic) {
|
||||
LOG_F(9, "Stopping sound output deterministic polling.");
|
||||
TimerManager::get_instance()->cancel_timer(impl->deterministic_poll_timer);
|
||||
impl->status = SND_STREAM_CLOSED;
|
||||
return;
|
||||
}
|
||||
cubeb_stream_stop(impl->out_stream);
|
||||
cubeb_stream_destroy(impl->out_stream);
|
||||
impl->status = SND_STREAM_CLOSED;
|
||||
|
||||
@@ -98,11 +98,11 @@ uint32_t CdromDrive::inquiry(uint8_t *cmd_ptr, uint8_t *data_ptr) {
|
||||
return 36;
|
||||
}
|
||||
|
||||
uint32_t CdromDrive::mode_sense_ex(uint8_t *cmd_ptr, uint8_t *data_ptr) {
|
||||
uint32_t CdromDrive::mode_sense_ex(bool is_sense_6, uint8_t* cmd_ptr, uint8_t* data_ptr) {
|
||||
uint8_t *resp_ptr;
|
||||
|
||||
uint8_t page_code = cmd_ptr[2] & 0x3F;
|
||||
uint8_t alloc_len = READ_WORD_BE_U(&cmd_ptr[7]);
|
||||
uint8_t alloc_len = is_sense_6 ? READ_WORD_BE_U(&cmd_ptr[4]) : READ_WORD_BE_U(&cmd_ptr[7]);
|
||||
|
||||
std::memset(data_ptr, 0, alloc_len);
|
||||
|
||||
@@ -137,7 +137,19 @@ uint32_t CdromDrive::mode_sense_ex(uint8_t *cmd_ptr, uint8_t *data_ptr) {
|
||||
WRITE_WORD_BE_A(&resp_ptr[14], 706); // report current speed (4x)
|
||||
data_ptr[1] += 20; // adjust overall length
|
||||
break;
|
||||
case 0x31:
|
||||
resp_ptr[1] = 14; // page data length
|
||||
std::memset(&resp_ptr[2], 0, 14);
|
||||
resp_ptr[8] = 0x31;
|
||||
resp_ptr[9] = 6;
|
||||
resp_ptr[10] = '.';
|
||||
resp_ptr[11] = 'A';
|
||||
resp_ptr[12] = 'p';
|
||||
resp_ptr[13] = 'p';
|
||||
data_ptr[1] += 2; // adjust overall length
|
||||
break;
|
||||
default:
|
||||
LOG_F(ERROR, "ATAPI CD-ROM: Invalid Page Code 0x%x", page_code);
|
||||
this->set_error(ScsiSense::ILLEGAL_REQ, ScsiError::INVALID_CDB);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
void insert_image(std::string filename);
|
||||
|
||||
virtual uint32_t inquiry(uint8_t *cmd_ptr, uint8_t *data_ptr);
|
||||
virtual uint32_t mode_sense_ex(uint8_t *cmd_ptr, uint8_t *data_ptr);
|
||||
virtual uint32_t mode_sense_ex(bool is_sense_6, uint8_t *cmd_ptr, uint8_t *data_ptr);
|
||||
virtual uint32_t request_sense(uint8_t *data_ptr, uint8_t sense_key, uint8_t asc,
|
||||
uint8_t ascq);
|
||||
virtual uint32_t report_capacity(uint8_t *data_ptr);
|
||||
|
||||
@@ -168,7 +168,7 @@ void AppleRamdac::iodev_write(uint32_t address, uint16_t value) {
|
||||
}
|
||||
|
||||
int AppleRamdac::get_clock_div() {
|
||||
return 1 << ((dac_cr >> 6) + 1);
|
||||
return 1 << (((dac_cr >> 6) + 1) & 3);
|
||||
}
|
||||
|
||||
int AppleRamdac::get_pix_width() {
|
||||
|
||||
@@ -203,6 +203,36 @@ enum {
|
||||
ATI_CUR_VERT_OFF = 16, ATI_CUR_VERT_OFF_size = 6,
|
||||
|
||||
ATI_GP_IO = 0x01E, // 0x0078
|
||||
ATI_GP_IO_0 = 0, // 0x0078
|
||||
ATI_GP_IO_1 = 1,
|
||||
ATI_GP_IO_2 = 2,
|
||||
ATI_GP_IO_3 = 3,
|
||||
ATI_GP_IO_4 = 4,
|
||||
ATI_GP_IO_5 = 5,
|
||||
ATI_GP_IO_6 = 6,
|
||||
ATI_GP_IO_7 = 7,
|
||||
ATI_GP_IO_8 = 8, // sense 0 level // 0x0079
|
||||
ATI_GP_IO_9 = 9,
|
||||
ATI_GP_IO_A = 10,
|
||||
ATI_GP_IO_B = 11,
|
||||
ATI_GP_IO_C = 12, // sense 1 level
|
||||
ATI_GP_IO_D = 13, // sense 2 level
|
||||
ATI_GP_IO_DIR_0 = 16, // 0x007A
|
||||
ATI_GP_IO_DIR_1 = 17,
|
||||
ATI_GP_IO_DIR_2 = 18,
|
||||
ATI_GP_IO_DIR_3 = 19,
|
||||
ATI_GP_IO_DIR_4 = 20,
|
||||
ATI_GP_IO_DIR_5 = 21,
|
||||
ATI_GP_IO_DIR_6 = 22,
|
||||
ATI_GP_IO_DIR_7 = 23,
|
||||
ATI_GP_IO_DIR_8 = 24, // sense 0 dir // 0x007B
|
||||
ATI_GP_IO_DIR_9 = 25,
|
||||
ATI_GP_IO_DIR_A = 26,
|
||||
ATI_GP_IO_DIR_B = 27,
|
||||
ATI_GP_IO_DIR_C = 28, // sense 1 dir
|
||||
ATI_GP_IO_DIR_D = 29, // sense 2 dir
|
||||
ATI_MPP_IO_DRIVE = 30,
|
||||
ATI_I2C_IO_DRIVE = 31,
|
||||
|
||||
ATI_HW_DEBUG = 0x01F, // 0x007C
|
||||
ATI_SCRATCH_REG0 = 0x020, // 0x0080
|
||||
@@ -573,11 +603,11 @@ enum {
|
||||
ATI_INVALID = 0xFFFF
|
||||
};
|
||||
|
||||
constexpr auto APERTURE_SIZE = 0x01000000UL; // Mach64 aperture size
|
||||
constexpr auto BE_FB_OFFSET = 0x00800000UL; // Offset to the big-endian frame buffer
|
||||
constexpr auto MM_REGS_0_OFF = 0x007FFC00UL; // offset to memory mapped registers, block 0
|
||||
constexpr auto MM_REGS_1_OFF = 0x007FF800UL; // offset to memory mapped registers, block 1
|
||||
constexpr auto MM_REGS_2_OFF = 0x003FFC00UL; // offset to memory mapped registers, 4MB aperture
|
||||
constexpr auto APERTURE_SIZE = 0x01000000U; // Mach64 aperture size
|
||||
constexpr auto BE_FB_OFFSET = 0x00800000U; // Offset to the big-endian frame buffer
|
||||
constexpr auto MM_REGS_0_OFF = 0x007FFC00U; // offset to memory mapped registers, block 0
|
||||
constexpr auto MM_REGS_1_OFF = 0x007FF800U; // offset to memory mapped registers, block 1
|
||||
constexpr auto MM_REGS_2_OFF = 0x003FFC00U; // offset to memory mapped registers, 4MB aperture
|
||||
|
||||
constexpr auto ATI_XTAL = 14318180.0f; // external crystal oscillator frequency
|
||||
|
||||
|
||||
@@ -510,6 +510,7 @@ void AtiMach64Gx::write_reg(uint32_t reg_offset, uint32_t value, uint32_t size)
|
||||
}
|
||||
|
||||
if (bit_changed(old_value, new_value, ATI_CRTC_ENABLE)) {
|
||||
draw_fb = true;
|
||||
this->crtc_update();
|
||||
}
|
||||
break;
|
||||
@@ -922,7 +923,7 @@ void AtiMach64Gx::rgb514_write_ind_reg(uint8_t reg_addr, uint8_t value)
|
||||
|
||||
static const PropMap AtiMach64gx_Properties = {
|
||||
{"gfxmem_size",
|
||||
new IntProperty( 2, vector<uint32_t>({2, 4, 6}))},
|
||||
new IntProperty( 2, std::vector<uint32_t>({2, 4, 6}))},
|
||||
{"mon_id",
|
||||
new StrProperty("")},
|
||||
};
|
||||
|
||||
@@ -169,7 +169,7 @@ void ATIRage::notify_bar_change(int bar_num)
|
||||
switch (bar_num) {
|
||||
case 0:
|
||||
change_one_bar(this->aperture_base[bar_num],
|
||||
this->aperture_size[bar_num] - this->vram_size,
|
||||
std::min(this->aperture_size[bar_num] - 4096, BE_FB_OFFSET + this->vram_size),
|
||||
this->bars[bar_num] & ~15, bar_num);
|
||||
break;
|
||||
case 2:
|
||||
@@ -396,8 +396,11 @@ void ATIRage::write_reg(uint32_t reg_offset, uint32_t value, uint32_t size) {
|
||||
}
|
||||
}
|
||||
|
||||
this->regs[reg_num] = new_value;
|
||||
if (bit_changed(old_value, new_value, ATI_CRTC_ENABLE)) {
|
||||
|
||||
if (bit_changed(old_value, new_value, ATI_CRTC_ENABLE)
|
||||
|| extract_bits(old_value, ATI_CRTC_PIX_WIDTH, ATI_CRTC_PIX_WIDTH_size) != extract_bits(new_value, ATI_CRTC_PIX_WIDTH, ATI_CRTC_PIX_WIDTH_size)
|
||||
) {
|
||||
draw_fb = true;
|
||||
if (bit_set(new_value, ATI_CRTC_ENABLE) &&
|
||||
!bit_set(new_value, ATI_CRTC_DISPLAY_DIS)) {
|
||||
this->crtc_update();
|
||||
@@ -437,8 +440,10 @@ void ATIRage::write_reg(uint32_t reg_offset, uint32_t value, uint32_t size) {
|
||||
if (offset <= 1 && offset + size > 1) {
|
||||
uint8_t gpio_levels = (new_value >> 8) & 0xFFU;
|
||||
gpio_levels = ((gpio_levels & 0x30) >> 3) | (gpio_levels & 1);
|
||||
gpio_levels ^= 7;
|
||||
uint8_t gpio_dirs = (new_value >> 24) & 0xFFU;
|
||||
gpio_dirs = ((gpio_dirs & 0x30) >> 3) | (gpio_dirs & 1);
|
||||
gpio_levels &= ~gpio_dirs;
|
||||
gpio_levels = this->disp_id->read_monitor_sense(gpio_levels, gpio_dirs);
|
||||
insert_bits<uint32_t>(new_value,
|
||||
((gpio_levels & 6) << 3) | (gpio_levels & 1), 8, 8);
|
||||
@@ -925,7 +930,7 @@ int ATIRage::device_postinit()
|
||||
|
||||
static const PropMap AtiRage_Properties = {
|
||||
{"gfxmem_size",
|
||||
new IntProperty( 2, vector<uint32_t>({2, 4, 6}))},
|
||||
new IntProperty( 2, std::vector<uint32_t>({2, 4, 6}))},
|
||||
{"mon_id",
|
||||
new StrProperty("")},
|
||||
};
|
||||
|
||||
@@ -685,9 +685,9 @@ void ControlVideo::disable_display()
|
||||
|
||||
static const PropMap Control_Properties = {
|
||||
{"gfxmem_banks",
|
||||
new IntProperty(3, vector<uint32_t>({0, 1, 2, 3}))},
|
||||
new IntProperty(3, std::vector<uint32_t>({0, 1, 2, 3}))},
|
||||
{"gfxmem_size",
|
||||
new IntProperty(4, vector<uint32_t>({0, 2, 4}))},
|
||||
new IntProperty(4, std::vector<uint32_t>({0, 2, 4}))},
|
||||
{"mon_id",
|
||||
new StrProperty("AppleVision1710")},
|
||||
};
|
||||
|
||||
@@ -29,12 +29,15 @@ public:
|
||||
uint32_t disp_wnd_id = 0;
|
||||
SDL_Window* display_wnd = 0;
|
||||
SDL_Renderer* renderer = 0;
|
||||
double renderer_scale_x; // scaling factor from guest OS to host OS
|
||||
double renderer_scale_y;
|
||||
SDL_Texture* disp_texture = 0;
|
||||
SDL_Texture* cursor_texture = 0;
|
||||
SDL_Rect cursor_rect; // destination rectangle for cursor drawing
|
||||
};
|
||||
|
||||
Display::Display(): impl(std::make_unique<Impl>()) {
|
||||
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest");
|
||||
}
|
||||
|
||||
Display::~Display() {
|
||||
@@ -61,7 +64,7 @@ bool Display::configure(int width, int height) {
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
width, height,
|
||||
SDL_WINDOW_OPENGL
|
||||
SDL_WINDOW_OPENGL | SDL_WINDOW_ALLOW_HIGHDPI
|
||||
);
|
||||
|
||||
impl->disp_wnd_id = SDL_GetWindowID(impl->display_wnd);
|
||||
@@ -72,6 +75,11 @@ bool Display::configure(int width, int height) {
|
||||
if (impl->renderer == NULL)
|
||||
ABORT_F("Display: SDL_CreateRenderer failed with %s", SDL_GetError());
|
||||
|
||||
int drawable_width, drawable_height;
|
||||
SDL_GetRendererOutputSize(impl->renderer, &drawable_width, &drawable_height);
|
||||
impl->renderer_scale_x = static_cast<double>(drawable_width) / width;
|
||||
impl->renderer_scale_y = static_cast<float>(drawable_height) / height;
|
||||
|
||||
is_initialization = true;
|
||||
} else { // resize display window
|
||||
SDL_SetWindowSize(impl->display_wnd, width, height);
|
||||
@@ -100,6 +108,16 @@ void Display::handle_events(const WindowEvent& wnd_event) {
|
||||
if (wnd_event.sub_type == SDL_WINDOWEVENT_EXPOSED &&
|
||||
wnd_event.window_id == impl->disp_wnd_id)
|
||||
SDL_RenderPresent(impl->renderer);
|
||||
if (wnd_event.sub_type == WINDOW_SCALE_QUALITY_TOGGLE &&
|
||||
wnd_event.window_id == impl->disp_wnd_id) {
|
||||
auto current_quality = SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY);
|
||||
auto new_quality = current_quality == NULL || strcmp(current_quality, "nearest") == 0 ? "best" : "nearest";
|
||||
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, new_quality);
|
||||
// We need the window/texture to be recreated to pick up the hint change.
|
||||
int width, height;
|
||||
SDL_GetWindowSize(impl->display_wnd, &width, &height);
|
||||
this->configure(width, height);
|
||||
}
|
||||
}
|
||||
|
||||
void Display::blank() {
|
||||
@@ -133,8 +151,8 @@ void Display::update(std::function<void(uint8_t *dst_buf, int dst_pitch)> conver
|
||||
|
||||
// draw HW cursor if enabled
|
||||
if (draw_hw_cursor) {
|
||||
impl->cursor_rect.x = cursor_x;
|
||||
impl->cursor_rect.y = cursor_y;
|
||||
impl->cursor_rect.x = cursor_x * impl->renderer_scale_x;
|
||||
impl->cursor_rect.y = cursor_y * impl->renderer_scale_y;
|
||||
SDL_RenderCopy(impl->renderer, impl->cursor_texture, NULL, &impl->cursor_rect);
|
||||
}
|
||||
|
||||
@@ -170,6 +188,6 @@ void Display::setup_hw_cursor(std::function<void(uint8_t *dst_buf, int dst_pitch
|
||||
|
||||
impl->cursor_rect.x = 0;
|
||||
impl->cursor_rect.y = 0;
|
||||
impl->cursor_rect.w = cursor_width;
|
||||
impl->cursor_rect.h = cursor_height;
|
||||
impl->cursor_rect.w = cursor_width * impl->renderer_scale_x;
|
||||
impl->cursor_rect.h = cursor_height * impl->renderer_scale_y;
|
||||
}
|
||||
@@ -63,11 +63,9 @@ void PdmOnboardVideo::set_video_mode(uint8_t new_mode)
|
||||
case PdmVideoMode::VGA:
|
||||
if (this->video_mode != (new_mode & 0x1F)) {
|
||||
this->video_mode = new_mode & 0x1F;
|
||||
LOG_F(INFO, "PDM-Video: video mode set to 0x%X", this->video_mode);
|
||||
}
|
||||
if (!this->blanking) {
|
||||
this->enable_video_internal();
|
||||
LOG_F(INFO, "PDM-Video: video mode changed to 0x%X", this->video_mode);
|
||||
}
|
||||
this->enable_video_internal();
|
||||
break;
|
||||
default:
|
||||
LOG_F(9, "PDM-Video: video disabled, new mode = 0x%X", new_mode & 0x1F);
|
||||
@@ -165,7 +163,8 @@ void PdmOnboardVideo::enable_video_internal()
|
||||
case PdmVideoMode::Rgb16in:
|
||||
case PdmVideoMode::VGA:
|
||||
if (this->pixel_depth > 8) {
|
||||
ABORT_F("PDM-Video: no 16bpp support in mode %d!", this->video_mode);
|
||||
LOG_F(ERROR, "PDM-Video: no 16bpp support in mode %d!", this->video_mode);
|
||||
this->pixel_depth = 8;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
@@ -212,10 +211,6 @@ void PdmOnboardVideo::enable_video_internal()
|
||||
ABORT_F("PDM-Video: invalid video mode %d", this->video_mode);
|
||||
}
|
||||
|
||||
if (new_width != this->active_width || new_height != this->active_height) {
|
||||
LOG_F(WARNING, "Display window resizing not implemented yet!");
|
||||
}
|
||||
|
||||
// figure out where our framebuffer is located
|
||||
uint64_t hmc_control = this->hmc_obj->get_control_reg();
|
||||
uint32_t fb_base_phys = ((hmc_control >> HMC_VBASE_BIT) & 1) ? 0 : 0x100000;
|
||||
|
||||
@@ -72,9 +72,9 @@ protected:
|
||||
void set_depth_internal(int width);
|
||||
void enable_video_internal();
|
||||
void disable_video_internal();
|
||||
void convert_frame_1bpp_indexed(uint8_t *dst_buf, int dst_pitch);
|
||||
void convert_frame_2bpp_indexed(uint8_t *dst_buf, int dst_pitch);
|
||||
void convert_frame_4bpp_indexed(uint8_t *dst_buf, int dst_pitch);
|
||||
void convert_frame_1bpp_indexed(uint8_t *dst_buf, int dst_pitch) override;
|
||||
void convert_frame_2bpp_indexed(uint8_t *dst_buf, int dst_pitch) override;
|
||||
void convert_frame_4bpp_indexed(uint8_t *dst_buf, int dst_pitch) override;
|
||||
|
||||
private:
|
||||
uint8_t video_mode;
|
||||
|
||||
@@ -49,6 +49,14 @@ void MachineBase::add_device(std::string name, std::unique_ptr<HWComponent> dev_
|
||||
this->device_map[name] = std::move(dev_obj);
|
||||
}
|
||||
|
||||
void MachineBase::remove_device(HWComponent* dev_obj) {
|
||||
for (auto it = this->device_map.begin(); it != this->device_map.end(); ++it)
|
||||
if (it->second.get() == dev_obj) {
|
||||
this->device_map.erase(it->first);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
HWComponent* MachineBase::get_comp_by_name(std::string name) {
|
||||
if (this->device_map.count(name)) {
|
||||
return this->device_map[name].get();
|
||||
|
||||
@@ -40,6 +40,7 @@ public:
|
||||
~MachineBase();
|
||||
|
||||
void add_device(std::string name, std::unique_ptr<HWComponent> dev_obj);
|
||||
void remove_device(HWComponent* dev_obj);
|
||||
HWComponent* get_comp_by_name(std::string name);
|
||||
HWComponent* get_comp_by_name_optional(std::string name);
|
||||
HWComponent* get_comp_by_type(HWCompType type);
|
||||
|
||||
@@ -36,6 +36,14 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include <string>
|
||||
|
||||
static std::vector<PciIrqMap> bandit1_irq_map = {
|
||||
{nullptr , DEV_FUN(0x0B,0), IntSrc::BANDIT1},
|
||||
{"pci_A1", DEV_FUN(0x0D,0), IntSrc::PCI_A},
|
||||
{"pci_B1", DEV_FUN(0x0E,0), IntSrc::PCI_B},
|
||||
{"pci_C1", DEV_FUN(0x0F,0), IntSrc::PCI_C},
|
||||
{nullptr , DEV_FUN(0x10,0), }, // GrandCentral
|
||||
};
|
||||
|
||||
int initialize_catalyst(std::string& id)
|
||||
{
|
||||
LOG_F(INFO, "Building machine Catalyst...");
|
||||
@@ -43,6 +51,7 @@ int initialize_catalyst(std::string& id)
|
||||
PlatinumCtrl* platinum_obj;
|
||||
|
||||
PCIHost *pci_host = dynamic_cast<PCIHost*>(gMachineObj->get_comp_by_name("Bandit1"));
|
||||
pci_host->set_irq_map(bandit1_irq_map);
|
||||
|
||||
// get (raw) pointer to the I/O controller
|
||||
GrandCentral* gc_obj = dynamic_cast<GrandCentral*>(gMachineObj->get_comp_by_name("GrandCentral"));
|
||||
@@ -70,8 +79,11 @@ int initialize_catalyst(std::string& id)
|
||||
return -1;
|
||||
}
|
||||
|
||||
// plug 8MB RAM DIMM into slot #0
|
||||
platinum_obj->insert_ram_dimm(0, DRAM_CAP_8MB);
|
||||
// insert RAM DIMMs
|
||||
platinum_obj->insert_ram_dimm(0, GET_INT_PROP("rambank1_size") * DRAM_CAP_1MB);
|
||||
platinum_obj->insert_ram_dimm(1, GET_INT_PROP("rambank2_size") * DRAM_CAP_1MB);
|
||||
platinum_obj->insert_ram_dimm(2, GET_INT_PROP("rambank3_size") * DRAM_CAP_1MB);
|
||||
platinum_obj->insert_ram_dimm(3, GET_INT_PROP("rambank4_size") * DRAM_CAP_1MB);
|
||||
|
||||
// allocate and map physical RAM
|
||||
platinum_obj->map_phys_ram();
|
||||
@@ -98,20 +110,20 @@ int initialize_catalyst(std::string& id)
|
||||
|
||||
static const PropMap pm7200_settings = {
|
||||
{"rambank1_size",
|
||||
new IntProperty(16, vector<uint32_t>({4, 8, 16, 32, 64, 128}))},
|
||||
new IntProperty( 8, std::vector<uint32_t>({ 4, 8, 16, 32, 64, 128}))},
|
||||
{"rambank2_size",
|
||||
new IntProperty( 0, vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))},
|
||||
new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))},
|
||||
{"rambank3_size",
|
||||
new IntProperty( 0, vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))},
|
||||
new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))},
|
||||
{"rambank4_size",
|
||||
new IntProperty( 0, vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))},
|
||||
new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))},
|
||||
{"emmo",
|
||||
new BinProperty(0)},
|
||||
{"cpu",
|
||||
new StrProperty("601", vector<std::string>({"601", "750"}))},
|
||||
new StrProperty("601", std::vector<std::string>({"601", "750"}))},
|
||||
};
|
||||
|
||||
static vector<string> pm7200_devices = {
|
||||
static std::vector<std::string> pm7200_devices = {
|
||||
"Platinum", "Bandit1", "GrandCentral"
|
||||
};
|
||||
|
||||
|
||||
+671
-110
@@ -51,23 +51,343 @@ map<string, unique_ptr<BasicProperty>> gMachineSettings;
|
||||
/**
|
||||
Power Macintosh ROM identification map.
|
||||
|
||||
Maps Bootstrap string located at offset 0x30D064 (PCI Macs)
|
||||
or 0x30C064 (Nubus Macs) to machine name and description.
|
||||
Maps rom info to machine name and description.
|
||||
*/
|
||||
static const map<uint32_t, std::tuple<string, const char*>> rom_identity = {
|
||||
{0x416C6368, {"pm6400", "Performa 6400"}}, // Alchemy
|
||||
//{"Come", "PowerBook 2400"}, // Comet
|
||||
{0x436F7264, {"pm5200", "Power Mac 5200/6200 series"}}, // Cordyceps
|
||||
{0x47617A65, {"pm6500", "Power Mac 6500"}}, // Gazelle
|
||||
{0x476F7373, {"pmg3dt", "Power Mac G3 Beige"}}, // Gossamer
|
||||
{0x47525820, {"pbg3", "PowerBook G3 Wallstreet"}},
|
||||
//{"Hoop", "PowerBook 3400"}, // Hooper
|
||||
{0x50425820, {"pb-preg3", "PowerBook Pre-G3"}},
|
||||
{0x50444D20, {"pm6100", "Nubus Power Mac"}}, // Piltdown Man (6100/7100/8100)
|
||||
{0x50697020, {"pippin", "Bandai Pippin"}}, // Pippin
|
||||
//{"Powe", "Generic Power Mac"}, // Power Mac?
|
||||
{0x544E5420, {"pm7200", "Power Mac 7xxxx/8xxx series"}}, // Trinitrotoluene :-)
|
||||
{0x5A616E7A, {"pm4400", "Power Mac 4400/7220"}}, // Zanzibar
|
||||
|
||||
typedef struct {
|
||||
uint32_t firmware_version;
|
||||
uint32_t firmware_size_k;
|
||||
uint32_t ow_expected_checksum;
|
||||
uint32_t nw_product_id;
|
||||
uint32_t nw_subconfig_expected_checksum; // checksum of the system config section but without the firmware version and date
|
||||
const char *id_str; // Bootstrap string located at offset 0x30D064 (PCI Macs) or 0x30C064 (Nubus Macs) to machine name and description.
|
||||
const char *nw_firmware_updater_name;
|
||||
const char *nw_openfirmware_name;
|
||||
const char *dppc_machine;
|
||||
const char *dppc_description;
|
||||
const char *rom_description;
|
||||
} rom_info;
|
||||
|
||||
static rom_info rom_identity[] = {
|
||||
{ 0x00696000, 64, 0x28ba61ce, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Macintosh 128K" },
|
||||
{ 0x00696000, 64, 0x28ba4e50, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Macintosh 512K" },
|
||||
{ 0x00756000, 128, 0x4d1eeee1, 0, 0, nullptr , 0, 0, nullptr , nullptr , "MacPlus v1" },
|
||||
{ 0x00756000, 128, 0x4d1eeae1, 0, 0, nullptr , 0, 0, nullptr , nullptr , "MacPlus v2" },
|
||||
{ 0x00756000, 128, 0x4d1f8172, 0, 0, nullptr , 0, 0, nullptr , nullptr , "MacPlus v3" },
|
||||
{ 0x01780000, 256, 0x97221136, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Mac II FDHD & IIx & IIcx" },
|
||||
{ 0x01780000, 256, 0x9779d2c4, 0, 0, nullptr , 0, 0, nullptr , nullptr , "MacII (800k v2)" },
|
||||
{ 0x01780000, 256, 0x97851db6, 0, 0, nullptr , 0, 0, nullptr , nullptr , "MacII (800k v1)" },
|
||||
{ 0x02760000, 256, 0xb2e362a8, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Mac SE" },
|
||||
{ 0x02760000, 256, 0xb306e171, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Mac SE FDHD" },
|
||||
{ 0x02760000, 512, 0xa49f9914, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Classic (with XO ROMDisk)" },
|
||||
{ 0x037a0000, 256, 0x96ca3846, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Mac Portable" },
|
||||
{ 0x037a11f1, 256, 0x96645f9c, 0, 0, nullptr , 0, 0, nullptr , nullptr , "PowerBook 100" },
|
||||
{ 0x067c10f1, 512, 0x368cadfe, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Mac IIci" },
|
||||
{ 0x067c11f2, 512, 0x4147dd77, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Mac IIfx" },
|
||||
{ 0x067c12f1, 512, 0x36b7fb6c, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Mac IIsi" },
|
||||
{ 0x067c13f1, 512, 0x350eacf0, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Mac LC" },
|
||||
{ 0x067c15f1, 1024, 0x420dbff3, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Quadra 700&900 & PB140&170" },
|
||||
{ 0x067c16f1, 512, 0x3193670e, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Classic II" },
|
||||
{ 0x067c17f2, 1024, 0x3dc27823, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Quadra 950" },
|
||||
{ 0x067c18f1, 1024, 0xe33b2724, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Powerbook 160 & 165c & 180 & 180c" },
|
||||
{ 0x067c19f2, 512, 0x35c28f5f, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Mac LCII" },
|
||||
{ 0x067c20f2, 1024, 0x4957eb49, 0, 0, nullptr , 0, 0, nullptr , nullptr , "MacIIvx & IIvi" },
|
||||
{ 0x067c21f5, 1024, 0xecfa989b, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Powerbook 210,230,250" },
|
||||
{ 0x067c22f2, 1024, 0xec904829, 0, 0, nullptr , 0, 0, nullptr , nullptr , "LCIII (older)" },
|
||||
{ 0x067c22f3, 1024, 0xecbbc41c, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Mac LCIII" },
|
||||
{ 0x067c23f1, 1024, 0xf1a6f343, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Centris 610,650, Quadra 800" },
|
||||
{ 0x067c23f2, 1024, 0xf1acad13, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Quadra 610,650,maybe 800" },
|
||||
{ 0x067c24f2, 1024, 0xecd99dc0, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Color Classic" },
|
||||
{ 0x067c25f1, 1024, 0xede66cbd, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Color Classic II & LC 550 & Performa 275,550,560 & Macintosh TV"},
|
||||
{ 0x067c26f1, 1024, 0xff7439ee, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Quadra 605" },
|
||||
{ 0x067c27f2, 1024, 0x0024d346, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Powerbook Duo 270" },
|
||||
{ 0x067c29f2, 1024, 0x015621d7, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Powerbook 280&280c" },
|
||||
{ 0x067c30f1, 2048, 0xb6909089, 0, 0, nullptr , 0, 0, nullptr , nullptr , "PowerBook 520&520c&540&540c" },
|
||||
{ 0x067c30f2, 2048, 0xb57687a5, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Pb550c" },
|
||||
{ 0x067c31f1, 1024, 0xfda22562, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Powerbook 150" },
|
||||
{ 0x067c32f1, 1024, 0x06684214, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Quadra 630" },
|
||||
{ 0x067c32f2, 1024, 0x064dc91d, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Performa 580 & 588" },
|
||||
{ 0x077d10f3, 2048, 0x5bf10fd1, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Quadra 660av & 840av" },
|
||||
|
||||
{ 0x077d20f2, 4096, 0x9feb69b3, 0, 0, "Boot PDM 601 1.0", 0, 0, "pm6100" , "Nubus Power Mac" , "Power Mac 6100 & 7100 & 8100" }, // Piltdown Man
|
||||
{ 0x077d22f1, 4096, 0x9c7c98f7, 0, 0, "Boot PDM 601 1.0", 0, 0, "pm9150" , "Nubus Power Mac" , "Workgroup Server 9150-80" }, // Piltdown Man
|
||||
{ 0x077d23f1, 4096, 0x9b7a3aad, 0, 0, "Boot PDM 601 1.1", 0, 0, "pm7100" , "Nubus Power Mac" , "Power Mac 7100 (newer)" }, // Piltdown Man
|
||||
{ 0x077d25f1, 4096, 0x9b037f6f, 0, 0, "Boot PDM 601 1.1", 0, 0, "pm9150" , "Nubus Power Mac" , "Workgroup Server 9150-120" }, // Piltdown Man
|
||||
{ 0x077d26f1, 4096, 0x63abfd3f, 0, 0, "Boot Cordyceps 6", 0, 0, "pm5200" , "Power Mac 5200/6200 series" , "Power Mac & Performa 5200,5300,6200,6300" }, // Cordyceps
|
||||
{ 0x077d28a5, 4096, 0x67a1aa96, 0, 0, "..0.....Boot TNT", 0, 0, nullptr , nullptr , "TNT A5c1" },
|
||||
{ 0x077d28f1, 4096, 0x96cd923d, 0, 0, "Boot TNT 0.1p..]", 0, 0, "pm7200" , "Power Mac 7xxxx/8xxx series", "Power Mac 7200&7500&8500&9500 v1" }, // TNT Trinitrotoluene
|
||||
{ 0x077d28f2, 4096, 0x9630c68b, 0, 0, "Boot TNT 0.1p..]", 0, 0, "pm7200" , "Power Mac 7xxxx/8xxx series", "Power Mac 7200&7500&8500&9500 v2, SuperMac S900" }, // TNT Trinitrotoluene
|
||||
{ 0x077d28f2, 4096, 0x962f6c13, 0, 0, "Boot TNT 0.1p..]", 0, 0, nullptr , "Apple Network Server series", "Apple Network Server 500" }, // TNT Trinitrotoluene // Shiner
|
||||
{ 0x077d29f1, 4096, 0x6f5724c0, 0, 0, "Boot Alchemy 0.1", 0, 0, "pm6400" , "Performa 6400" , "PM 5400, Performa 6400" }, // Alchemy
|
||||
{ 0x077d2af2, 4096, 0x83c54f75, 0, 0, "Boot PBX 603 0.0", 0, 0, "pb-preg3", "PowerBook Pre-G3" , "Powerbook 2300 & PB5x0 PPC Upgrade" },
|
||||
{ 0x077d2bf1, 2048, 0x4d27039c, 0, 0, nullptr , 0, 0, nullptr , nullptr , "Powerbook 190cs" },
|
||||
{ 0x077d2cc6, 4096, 0x2bf65931, 0, 0, "Boot Pip 0.1p..]", 0, 0, "pippin" , "Bandai Pippin" , "Bandai Pippin (Kinka Dev)" },
|
||||
{ 0x077d2cf2, 4096, 0x2bef21b7, 0, 0, "Boot Pip 0.1p..]", 0, 0, "pippin" , "Bandai Pippin" , "Bandai Pippin (Kinka 1.0)" },
|
||||
{ 0x077d2cf5, 4096, 0x3e10e14c, 0, 0, "Boot Pip 0.1p..]", 0, 0, "pippin" , "Bandai Pippin" , "Bandai Pippin (Kinka 1.2)" },
|
||||
{ 0x077d2cf8, 4096, 0x3e6b3ee4, 0, 0, "Boot Pip 0.1p..]", 0, 0, "pippin" , "Bandai Pippin" , "Bandai Pippin (Kinka 1.3)" },
|
||||
{ 0x077d32f3, 4096, 0x838c0831, 0, 0, "Boot PBX 603 0.0", 0, 0, "pb-preg3", "PowerBook Pre-G3" , "PowerBook 1400" },
|
||||
{ 0x077d32f3, 4096, 0x83a21950, 0, 0, "Boot PBX 603 0.0", 0, 0, "pb-preg3", "PowerBook Pre-G3" , "PowerBook 1400cs" },
|
||||
{ 0x077d34f2, 4096, 0x960e4be9, 0, 0, "Boot TNT 0.1p..]", 0, 0, "pm7300" , "Power Mac 7xxxx/8xxx series", "Power Mac 7300 & 7600 & 8600 & 9600 (v1)" }, // TNT Trinitrotoluene
|
||||
{ 0x077d34f5, 4096, 0x960fc647, 0, 0, "Boot TNT 0.1p..]", 0, 0, "pm8600" , "Power Mac 7xxxx/8xxx series", "Power Mac 8600 & 9600 (v2)" }, // TNT Trinitrotoluene
|
||||
{ 0x077d35f2, 4096, 0x6e92fe08, 0, 0, "Boot Gazelle 0.1", 0, 0, "pm6500" , "Power Mac 6500" , "Power Mac 6500, Twentieth Anniversary Macintosh" }, // Gazelle
|
||||
{ 0x077d36f1, 4096, 0x276ec1f1, 0, 0, "Boot PSX 0.1p..]", 0, 0, nullptr , nullptr , "PowerBook 2400, 2400c, 3400, 3400c" }, // Comet, Hooper
|
||||
{ 0x077d36f5, 4096, 0x2560f229, 0, 0, "Boot PSX 0.1p..]", 0, 0, nullptr , nullptr , "PowerBook G3 Kanga" },
|
||||
{ 0x077d39b7, 4096, 0x4604518f, 0, 0, "Boot PEX 0.1p..]", 0, 0, nullptr , nullptr , "PowerExpress TriPEx" },
|
||||
{ 0x077d39f1, 4096, 0x46001f1b, 0, 0, "Boot PEX 0.1p..]", 0, 0, nullptr , nullptr , "Power Express (9700 Prototype)" },
|
||||
{ 0x077d3af2, 4096, 0x58f03416, 0, 0, "Boot Zanzibar 0.", 0, 0, "pm4400" , "Power Mac 4400/7220" , "Motorola 4400, 7220" }, // Zanzibar
|
||||
{ 0x077d40f2, 4096, 0x79d68d63, 0, 0, "Boot Gossamer 0.", 0, 0, "pmg3dt" , "Power Mac G3 Beige" , "Power Mac G3 desktop" }, // Gossamer
|
||||
{ 0x077d41f5, 4096, 0xcbb01212, 0, 0, "Boot GRX 0.1p..]", 0, 0, "pbg3" , "PowerBook G3 Wallstreet" , "PowerBook G3 Wallstreet" },
|
||||
{ 0x077d41f6, 4096, 0xb46ffb63, 0, 0, "Boot GRX 0.1p..]", 0, 0, "pbg3" , "PowerBook G3 Wallstreet" , "PowerBook G3 Wallstreet PDQ" },
|
||||
{ 0x077d45f1, 4096, 0x78fdb784, 0, 0, "Boot Gossamer 0.", 0, 0, "pmg3dt" , "Power Mac G3 Beige" , "PowerMac G3 Minitower (beige 266MHz), Beige G3 233"}, // Gossamer
|
||||
{ 0x077d45f2, 4096, 0x78f57389, 0, 0, "Boot Gossamer 0.", 0, 0, "pmg3dt" , "Power Mac G3 Beige" , "Power Mac G3 (v3)" }, // Gossamer
|
||||
{ 0x077d45f3, 4096, 0x78e842a8, 0, 0, "Boot Gossamer 0.", 0, 0, "pmg3dt" , "Power Mac G3 Beige" , "Power Mac G3 (v4)" }, // Gossamer ?
|
||||
{ 0x077d45f3, 4096, 0x78eb4234, 0, 0, "Boot Gossamer 0.", 0, 0, "pmg3dt" , "Power Mac G3 Beige" , "Power Mac G3 (v4)" }, // Gossamer Speedbump 9cc0e3e01bb02691b497d792ea3e9403
|
||||
|
||||
{ 0x077d44f1, 4096, 0xfd86d120, 0, 0, "NewWorld v1.0.p.", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 1.1" }, // 1998-07-21 - Mac OS 8.1 (iMac, Rev A Bundle)
|
||||
{ 0x077d44f3, 4096, 0xfd12b69e, 0, 0, "NewWorld v1.0.p.", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 1.1.2" }, // 1998-08-27 - Mac OS 8.5 (Retail CD), iMac Update 1.0
|
||||
{ 0x077d44f4, 4096, 0xfcaad843, 0, 0, "NewWorld v1.0.p.", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 1.1.5" }, // 1998-09-19 - Mac OS 8.5 (iMac, Rev B Bundle)
|
||||
{ 0x077d44f1, 4096, 0xd36ba902, 0, 0, "NewWorld v1.0.p.", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 1.2" }, // 1998-12-03 - Power Macintosh G3 (Blue and White) Mac OS 8.5.1 Bundle, Macintosh Server G3 (Blue and White) Mac OS 8.5.1 Bundle
|
||||
{ 0x077d44f1, 4096, 0xd377adb7, 0, 0, "NewWorld v1.0.p.", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 1.2.1" }, // 1999-01-22 - Mac OS 8.5.1 (Colors iMac 266 MHz Bundle), iMac Update 1.1
|
||||
{ 0x077d44b5, 4096, 0xc804f7f4, 0, 0, "NewWorld v1.0.p.", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 1.4" }, // 1999-04-05 - Mac OS 8.6 (Retail CD), Mac OS 8.6 (Colors iMac 333 MHz Bundle), Power Macintosh G3 (Blue and White) Mac OS 8.6 Bundle
|
||||
{ 0x077d44b5, 4096, 0xc7cb0323, 0, 0, "NewWorld v1.0.p.", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 1.6" }, // 1999-05-14 - Macintosh PowerBook G3 Series 8.6 Bundle, Mac OS ROM Update 1.0
|
||||
{ 0x077d44f1, 4096, 0xc75c6aab, 0, 0, "NewWorld v1.0.p.", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 1.7.1" }, // 1999-08-23 - Mac OS 8.6 bundled on Power Mac G4 (PCI)
|
||||
{ 0x077d44f1, 4096, 0xc753c667, 0, 0, "NewWorld v1.0.p.", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 1.8.1" }, // 1999-08-28 - Mac OS 8.6 Power Mac G4 ROM 1.8.1 Update
|
||||
{ 0x077d45f3, 4096, 0xcde9cda4, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 2.3.1" }, // 1999-09-13 - Mac OS 8.6 bundled on iMac (Slot Loading), iBook
|
||||
{ 0x077d45f3, 4096, 0xce8a3b5c, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 2.5.1" }, // 1999-09-17 - Mac OS 8.6 bundled on Power Mac G4 (AGP)
|
||||
{ 0x077d45f4, 4096, 0xce1fd217, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 3.0" }, // 1999-09-27 - Retail Mac OS 9.0 installed on Power Macintosh G3 (Blue and White), Retail Mac OS 9.0 installed on iMac, Mac OS 9.0 bundled on PowerBook G3 Bronze
|
||||
{ 0x077d45f5, 4096, 0xce1cf7f7, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 3.1.1" }, // 1999-10-28 - Mac OS 9.0 bundled on iBook, Mac OS 9.0 bundled on Power Mac G4 (AGP Graphics):iMac (Slot-Loading)
|
||||
{ 0x077d45f6, 4096, 0xb9eb8c3d, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 3.5" }, // 2000-01-29 - Mac OS 9.0.2 bundled on Power Mac G4 (AGP) and iBook, Mac OS 9.0.2 installed on PowerBook (FireWire)
|
||||
{ 0x077d45f6, 4096, 0xb8c832f3, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 3.6" }, // 2000-02-17 - Mac OS 9.0.3 bundled with iMac (Slot Loading)
|
||||
{ 0x077d45f6, 4096, 0xb8b2c971, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 3.7" }, // 2000-03-15 - 9.0.4 Retail CD
|
||||
{ 0x077d45f6, 4096, 0xb8bea8b3, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 3.8" }, // 2000-05-22 - 9.0.4 Ethernet Update
|
||||
{ 0x077d45f6, 4096, 0xc90b6289, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 4.6.1" }, // 2000-06-18 - Mac OS 9.04 Mac OS 9.0.4 bundled on iMac (Summer 2000), Power Mac G4 (Summer 2000)
|
||||
{ 0x077d45f6, 4096, 0xc92f71d3, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 4.9.1" }, // 2000-06-28 - Mac OS 9.0.4 bundled on Power Mac G4 MP (Summer 2000) (CPU software 2.3), Power Mac G4 (Gigabit Ethernet)
|
||||
{ 0x077d45f6, 4096, 0xc8e1be97, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 5.2.1" }, // 2000-07-12 - Mac OS 9.0.4 installed on Power Mac G4 Cube (CPU software 2.4)
|
||||
{ 0x077d45f6, 4096, 0xce2a2a5b, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 5.3.1" }, // 2000-08-14 - Mac OS 9.0.4 bundled on iBook (Summer 2000) (CPU software 2.5)
|
||||
{ 0x077d45f6, 4096, 0xce1b9fd2, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 5.5.1" }, // 2000-08-25 - Mac OS 9.0.4 from International G4 Cube Install CD
|
||||
{ 0x077d45f6, 4096, 0xe20aa0d0, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 6.1" }, // 2000-11-03 - 9.1 Universal Update
|
||||
{ 0x077d45f6, 4096, 0xeacb3ca4, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 6.7.1" }, // 2000-12-01 - Mac OS 9.1 installed on Power Mac G4 (Digital Audio)
|
||||
{ 0x077d45f6, 4096, 0xea00f1b7, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 7.5.1" }, // 2001-02-07 - 9.1 iMac 2001
|
||||
{ 0x077d45f6, 4096, 0xeece7cd0, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 7.8.1" }, // 2001-04-10 - bundled on iBook (Dual USB) (CPU Software 3.5)
|
||||
{ 0x077d45f6, 4096, 0xeed28047, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 7.9.1" }, // 2001-04-24 - Mac OS 9.1 bundled on PowerBook G4
|
||||
{ 0x077d45f6, 4096, 0xee6bc7d9, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 8.0" }, // - Mac OS 9.2 Power Mac G4 Install CD
|
||||
{ 0x077d45f6, 4096, 0xed7f9fc2, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 8.3.1" }, // 2001-07-18 - Mac OS 9.2 installed on iMac (Summer 2001), Mac OS 9.2 installed on Power Mac G4 (QuickSilver)
|
||||
{ 0x077d45f6, 4096, 0xed26a1ef, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 8.4" }, // 2001-07-30 - Mac OS 9.2.1 Update CD
|
||||
{ 0x077d45f6, 4096, 0xec849611, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 8.6.1" }, // 2001-09-25 - Mac OS 9.2.1 bundled on iBook G3 (Late 2001)
|
||||
{ 0x077d45f6, 4096, 0xecc44a65, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 8.7" }, // 2001-11-07 - Mac OS 9.2.2 Update SMI
|
||||
{ 0x077d45f6, 4096, 0xec96aeb6, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 8.8" }, // 2001-11-26 - Mac OS 9.2.2 Update CD
|
||||
{ 0x077d45f6, 4096, 0xec93ab73, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 8.9.1" }, // 2001-12-11 - Mac OS 9.2.2 bundled on iBook (CPU Software 4.4)
|
||||
{ 0x077d45f6, 4096, 0xec86128e, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 9.0.1" }, // 2001-12-19 - Mac OS 9.2.2 bundled on iMac (2001)
|
||||
{ 0x077d45f6, 4096, 0xecef6af1, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 9.1.1" }, // 2002-04-08 - Mac OS 9.2.2 bundled on iMac G4
|
||||
{ 0x077d45f6, 4096, 0xecc6f29a, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 9.2.1" }, // 2002-04-17 - Mac OS 9.2.2 bundled on eMac (CPU Software 4.9)
|
||||
{ 0x077d45f6, 4096, 0xecd3453f, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 9.3.1" }, // 2002-04-18 - Mac OS 9.2.2 bundled on PowerBook G4 (CPU Software 5.0)
|
||||
{ 0x077d45f6, 4096, 0xecaf0460, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 9.5.1" }, // 2002-07-18 - Mac OS 9.2.2 bundled on iMac (17" Flat Panel) (CPU Software 5.3)
|
||||
{ 0x077d45f6, 4096, 0xecbd9bd2, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 9.6.1" }, // 2002-09-03 - Mac OS 9.2.2 (CPU Software 5.4)
|
||||
{ 0x077d45f6, 4096, 0xecb7c4f9, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 9.7.1" }, // 2002-10-11 - Mac OS 9.2.2 bundled on PowerBook (Titanium, 1GHz)
|
||||
{ 0x077d45f6, 4096, 0xecb96443, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 9.8.1" }, // 2003-01-10 - Mac OS 9.2.2
|
||||
{ 0x077d45f6, 4096, 0xecb8e951, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 10.1.1" }, // 2003-03-17 - Mac OS 9.2.2 bundled on eMac 800MHz (CPU Software 5.7)
|
||||
{ 0x077d45f6, 4096, 0xecb73ad5, 0, 0, "NewWorld v1.0...", 0, 0, nullptr , "NewWorld Mac" , "Mac OS ROM file 10.2.1" }, // 2003-04-03 - Mac OS 9.2.2 Retail International CD
|
||||
|
||||
{ 0x10f1, 1024, 0, 0, 0, 0, nullptr , nullptr , nullptr , nullptr , "PowerBook G3 Lombard" }, // PowerBook1,1
|
||||
{ 0x11f4, 1024, 0, 0, 0, 0, nullptr , nullptr , "pmg3nw" , "Power Mac Yosemite" , "Power Mac B&W G3" }, // PowerMac1,1
|
||||
{ 0x13f2, 1024, 0, 0, 0, 0, nullptr , nullptr , nullptr , nullptr , "iMac (233 MHz) (Bondi Blue)" }, // iMac,1
|
||||
{ 0x13f3, 1024, 0, 0, 0, 0, nullptr , nullptr , nullptr , nullptr , "iMac (266,333 MHz) (Tray Loading)" }, // iMac,1
|
||||
|
||||
{ 0, 1024, 0, 0x008100, 0x266f2e55, 0, "Kihei" , "P7" , nullptr , nullptr , "iMac G3 (Slot Loading)" }, // PowerMac2,1 // 2001-09-14 419f1
|
||||
{ 0, 1024, 0, 0x008100, 0x55402f54, 0, "Kihei" , "P7" , nullptr , nullptr , "iMac G3 (Slot Loading)" }, // PowerMac2,1
|
||||
{ 0, 1024, 0, 0x008100, 0xf88e2d56, 0, "P7" , "P7" , nullptr , nullptr , "iMac G3 (Slot Loading)" }, // PowerMac2,1
|
||||
{ 0, 1024, 0, 0x008200, 0x141d2d96, 0, "P51" , "P51" , nullptr , nullptr , "iMac G3 (Summer 2000)" }, // PowerMac2,2
|
||||
{ 0, 1024, 0, 0x008200, 0x41ef2e95, 0, "Perigee" , "P51" , nullptr , nullptr , "iMac G3 (Summer 2000)" }, // PowerMac2,2
|
||||
{ 0, 1024, 0, 0x008201, 0x4a862e17, 0, "P51_15" , "P51" , nullptr , nullptr , "iMac G3 (Summer 2000)" }, // PowerMac2,2
|
||||
{ 0, 1024, 0, 0x008201, 0x78582f16, 0, "Perigee_15" , "P51" , nullptr , nullptr , "iMac G3 (Summer 2000)" }, // PowerMac2,2
|
||||
{ 0, 1024, 0, 0x010100, 0, 0, nullptr , "P52" , nullptr , nullptr , "iMac G3 (2001)" }, // PowerMac4,1
|
||||
{ 0, 1024, 0, 0x010101, 0x9a7a2c2c, 0, "P52" , nullptr , nullptr , nullptr , "iMac G3 (2001)" }, // PowerMac4,1
|
||||
{ 0, 1024, 0, 0x010101, 0xc84c2d2b, 0, "Apogee" , nullptr , nullptr , nullptr , "iMac G3 (2001)" }, // PowerMac4,1
|
||||
{ 0, 1024, 0, 0x010200, 0xe27f2d68, 0, "Tessera" , "P80" , nullptr , nullptr , "iMac G4 (Flat Panel)" }, // PowerMac4,2
|
||||
{ 0, 1024, 0, 0x010202, 0xc32928ab, 0, "P80" , nullptr , nullptr , nullptr , "iMac G4 (Flat Panel)" }, // PowerMac4,2
|
||||
{ 0, 1024, 0, 0x010202, 0xe3512d6a, 0, "Insp" , nullptr , nullptr , nullptr , "iMac G4 (Flat Panel)" }, // PowerMac4,2
|
||||
{ 0, 1024, 0, 0x010202, 0xfaf12da6, 0, "P80|Insp" , nullptr , nullptr , nullptr , "iMac G4 (Flat Panel)" }, // PowerMac4,2 // 2002-04-08 440f1
|
||||
{ 0, 1024, 0, 0x010203, 0, 0, nullptr , "P80" , nullptr , nullptr , "iMac G4 (Flat Panel)" }, // PowerMac4,2
|
||||
{ 0, 1024, 0, 0x010300, 0xe27f2d68, 0, "Infinity" , nullptr , nullptr , nullptr , nullptr }, // PowerMac4,3
|
||||
{ 0, 1024, 0, 0x010400, 0xa0972cec, 0, "Beyond" , "P62" , nullptr , nullptr , "eMac G4" }, // PowerMac4,4
|
||||
{ 0, 1024, 0, 0x010400, 0xa7cd2b85, 0, "P62" , "P62" , nullptr , nullptr , "eMac G4" }, // PowerMac4,4
|
||||
{ 0, 1024, 0, 0x010400, 0xe72d2d73, 0, "NorthnLites" , "P62" , nullptr , nullptr , "eMac G4" }, // PowerMac4,4
|
||||
{ 0, 1024, 0, 0x010401, 0, 0, nullptr , "P86" , nullptr , nullptr , "eMac G4" }, // PowerMac4,4
|
||||
{ 0, 1024, 0, 0x010402, 0, 0, nullptr , "P86" , nullptr , nullptr , "eMac G4" }, // PowerMac4,4
|
||||
{ 0, 1024, 0, 0x010500, 0xa90624c6, 0, "P79" , "P79" , nullptr , nullptr , "iMac G4 17 inch (Flat Panel)" }, // PowerMac4,5
|
||||
{ 0, 1024, 0, 0x010500, 0xf1332daa, 0, "Taliesin" , "P79" , nullptr , nullptr , "iMac G4 17 inch (Flat Panel)" }, // PowerMac4,5
|
||||
{ 0, 1024, 0, 0x010500, 0xd6d825c5, 0, "P79|Taliesin", "P79" , nullptr , nullptr , "iMac G4 17 inch (Flat Panel)" }, // PowerMac4,5 // 2002-07-23 445f3
|
||||
{ 0, 1024, 0, 0x018101, 0, 0, nullptr , "Q26" , nullptr , nullptr , "iMac G4/1.0 17 inch (Flat Panel)" }, // PowerMac6,1
|
||||
{ 0, 1024, 0, 0x018102, 0xcd1f2ca7, 0, "P87" , "Q26" , nullptr , nullptr , "iMac G4/1.0 17 inch (Flat Panel)" }, // PowerMac6,1
|
||||
{ 0, 1024, 0, 0x018301, 0, 0, nullptr , "Q59" , nullptr , nullptr , "iMac G4/1.0 (Flat Panel - USB 2.0)" }, // PowerMac6,3
|
||||
{ 0, 1024, 0, 0x018401, 0, 0, nullptr , "Q86" , nullptr , nullptr , "eMac G4 (2005)" }, // PowerMac6,4
|
||||
{ 0, 1024, 0, 0x018402, 0, 0, nullptr , "Q86" , nullptr , nullptr , "eMac G4 (2005)" }, // PowerMac6,4
|
||||
{ 0, 1024, 0, 0x018403, 0, 0, nullptr , "Q86" , nullptr , nullptr , "eMac G4 (2005)" }, // PowerMac6,4
|
||||
{ 0, 1024, 0, 0x020101, 0xfcaf4eb7, 0, "Q45" , "Q45" , nullptr , nullptr , "iMac G5" }, // PowerMac8,1
|
||||
{ 0, 1024, 0, 0x020101, 0xfd1f4eb8, 0, "Q45" , "Q45" , nullptr , nullptr , "iMac G5" }, // PowerMac8,1
|
||||
{ 0, 1024, 0, 0x020102, 0, 0, nullptr , "Q45" , nullptr , nullptr , "iMac G5" }, // PowerMac8,1
|
||||
{ 0, 1024, 0, 0x020109, 0x00064ebf, 0, "Q45p" , nullptr , nullptr , nullptr , "iMac G5" }, // PowerMac8,1
|
||||
{ 0, 1024, 0, 0x020109, 0x00764ec0, 0, "Q45p" , nullptr , nullptr , nullptr , "iMac G5" }, // PowerMac8,1
|
||||
{ 0, 1024, 0, 0x020109, 0x24372c87, 0, "Q45p" , nullptr , nullptr , nullptr , "iMac G5" }, // PowerMac8,1
|
||||
{ 0, 1024, 0, 0x020109, 0x24932c8b, 0, "Q45p" , nullptr , nullptr , nullptr , "iMac G5" }, // PowerMac8,1
|
||||
{ 0, 1024, 0, 0x020201, 0, 0, nullptr , "Q45C" , nullptr , nullptr , "iMac G5 (Ambient Light Sensor)" }, // PowerMac8,2
|
||||
{ 0, 1024, 0, 0x020f01, 0x20ef2c7f, 0, "Q45xa" , nullptr , nullptr , nullptr , nullptr }, // PowerMac8,15
|
||||
{ 0, 1024, 0, 0x020f01, 0x214b2c83, 0, "Q45xa" , nullptr , nullptr , nullptr , nullptr }, // PowerMac8,15
|
||||
{ 0, 1024, 0, 0x020f01, 0xeace56ae, 0, "Neoa" , nullptr , nullptr , nullptr , nullptr }, // PowerMac8,15
|
||||
{ 0, 1024, 0, 0x020f02, 0x21582c80, 0, "Q45xb" , nullptr , nullptr , nullptr , nullptr }, // PowerMac8,15
|
||||
{ 0, 1024, 0, 0x020f02, 0x21b42c84, 0, "Q45xb" , nullptr , nullptr , nullptr , nullptr }, // PowerMac8,15
|
||||
{ 0, 1024, 0, 0x020f02, 0xf92756d2, 0, "Neob" , nullptr , nullptr , nullptr , nullptr }, // PowerMac8,15
|
||||
{ 0, 1024, 0, 0x020f03, 0x21c12c81, 0, "Q45xc" , nullptr , nullptr , nullptr , nullptr }, // PowerMac8,15
|
||||
{ 0, 1024, 0, 0x020f03, 0x221d2c85, 0, "Q45xc" , nullptr , nullptr , nullptr , nullptr }, // PowerMac8,15
|
||||
{ 0, 1024, 0, 0x020f03, 0x9e7f55ef, 0, "Neoc" , nullptr , nullptr , nullptr , nullptr }, // PowerMac8,15
|
||||
{ 0, 1024, 0, 0x028101, 0xf4dc2533, 0, nullptr , "Q88" , nullptr , nullptr , "Mac mini G4" }, // PowerMac10,1 // 2005-03-23 489f4
|
||||
{ 0, 1024, 0, 0x028201, 0xf4dc2533, 0, nullptr , "Q88" , nullptr , nullptr , "Mac mini G4 1.5GHz Radeon 9200" }, // PowerMac10,2 // 2005-07-12 494f1
|
||||
{ 0, 1024, 0, 0x030101, 0, 0, nullptr , "M23" , nullptr , nullptr , "iMac G5 (iSight)" }, // PowerMac12,1
|
||||
{ 0, 1024, 0, 0x108100, 0x71fd2fc9, 0, "P1" , "P1" , nullptr , nullptr , "iBook G3 (Original/Clamshell)" }, // PowerBook2,1
|
||||
{ 0, 1024, 0, 0x108100, 0x9fcf30c8, 0, "P1" , "P1" , nullptr , nullptr , "iBook G3 (Original/Clamshell)" }, // PowerBook2,1
|
||||
{ 0, 1024, 0, 0x108100, 0xcea031c7, 0, "P1" , "P1" , nullptr , nullptr , "iBook G3 (Original/Clamshell)" }, // PowerBook2,1
|
||||
{ 0, 1024, 0, 0x108101, 0x72902fcb, 0, "P1_05" , "P1" , nullptr , nullptr , "iBook G3 (Original/Clamshell)" }, // PowerBook2,1
|
||||
{ 0, 1024, 0, 0x108101, 0xa06230ca, 0, "P1_05" , "P1" , nullptr , nullptr , "iBook G3 (Original/Clamshell)" }, // PowerBook2,1 // 2001-03-20 417f4
|
||||
{ 0, 1024, 0, 0x108101, 0xcf3331c9, 0, "P1_05" , "P1" , nullptr , nullptr , "iBook G3 (Original/Clamshell)" }, // PowerBook2,1
|
||||
{ 0, 1024, 0, 0x108102, 0x7de22ffd, 0, "P1_1" , "P1" , nullptr , nullptr , "iBook G3 (Original/Clamshell)" }, // PowerBook2,1
|
||||
{ 0, 1024, 0, 0x108102, 0xabb430fc, 0, "P1_1" , "P1" , nullptr , nullptr , "iBook G3 (Original/Clamshell)" }, // PowerBook2,1
|
||||
{ 0, 1024, 0, 0x108102, 0xda8531fb, 0, "P1_1" , "P1" , nullptr , nullptr , "iBook G3 (Original/Clamshell)" }, // PowerBook2,1
|
||||
{ 0, 1024, 0, 0x108200, 0x7bdc2fd9, 0, "P1_5" , "P1_5" , nullptr , nullptr , "iBook G3 366 MHz CD (Firewire/Clamshell)" }, // PowerBook2,2
|
||||
{ 0, 1024, 0, 0x108200, 0xa9ae30d8, 0, "Midway" , "P1_5" , nullptr , nullptr , "iBook G3 366 MHz CD (Firewire/Clamshell)" }, // PowerBook2,2
|
||||
{ 0, 1024, 0, 0x108201, 0x9745301a, 0, "P1_5DVD" , "P1_5" , nullptr , nullptr , "iBook G3 466 MHz DVD (Firewire/Clamshell)" }, // PowerBook2,2
|
||||
{ 0, 1024, 0, 0x108201, 0xc5173119, 0, "MidwayDVD" , "P1_5" , nullptr , nullptr , "iBook G3 466 MHz DVD (Firewire/Clamshell)" }, // PowerBook2,2
|
||||
{ 0, 1024, 0, 0x110100, 0x5f1c2fe5, 0, "Marble" , "P29" , nullptr , nullptr , "iBook G3 (Dual USB Snow)" }, // PowerBook4,1
|
||||
{ 0, 1024, 0, 0x110100, 0x69e42f6e, 0, "P29" , "P29" , nullptr , nullptr , "iBook G3 (Dual USB Snow)" }, // PowerBook4,1
|
||||
{ 0, 1024, 0, 0x110100, 0x97b6306d, 0, "Marble" , "P29" , nullptr , nullptr , "iBook G3 (Dual USB Snow)" }, // PowerBook4,1
|
||||
{ 0, 1024, 0, 0x110101, 0x44852fa6, 0, "MarbleLite" , nullptr , nullptr , nullptr , "iBook G3 (Dual USB Snow)" }, // PowerBook4,1
|
||||
{ 0, 1024, 0, 0x110102, 0x60192fe8, 0, "MarbleFat" , "P29" , nullptr , nullptr , "iBook G3 (Dual USB Snow)" }, // PowerBook4,1
|
||||
{ 0, 1024, 0, 0x110102, 0x6b1d2f73, 0, "P29Fat" , "P29" , nullptr , nullptr , "iBook G3 (Dual USB Snow)" }, // PowerBook4,1
|
||||
{ 0, 1024, 0, 0x110102, 0x98ef3072, 0, "MarbleFat" , "P29" , nullptr , nullptr , "iBook G3 (Dual USB Snow)" }, // PowerBook4,1
|
||||
{ 0, 1024, 0, 0x110103, 0x58762f44, 0, "P29fat100" , "P29" , nullptr , nullptr , "iBook G3 (Dual USB Snow)" }, // PowerBook4,1
|
||||
{ 0, 1024, 0, 0x110103, 0x86483043, 0, "Mrblfat100" , "P29" , nullptr , nullptr , "iBook G3 (Dual USB Snow)" }, // PowerBook4,1
|
||||
{ 0, 1024, 0, 0x110200, 0x4c372fb6, 0, "Diesel" , "P54" , nullptr , nullptr , "iBook G3/600 14-Inch (Early 2002 Snow)" }, // PowerBook4,2
|
||||
{ 0, 1024, 0, 0x110200, 0x573b2f41, 0, "P54" , "P54" , nullptr , nullptr , "iBook G3/600 14-Inch (Early 2002 Snow)" }, // PowerBook4,2
|
||||
{ 0, 1024, 0, 0x110300, 0x58e12d5c, 0, "P72" , "P72" , nullptr , nullptr , "iBook G3 (Snow)" }, // PowerBook4,3 // 2002-11-11 454f1
|
||||
{ 0, 1024, 0, 0x110300, 0xb98a30be, 0, "Nectr" , "P72" , nullptr , nullptr , "iBook G3 (Snow)" }, // PowerBook4,3
|
||||
{ 0, 1024, 0, 0x110301, 0x594a2d5d, 0, "P73" , "P73" , nullptr , nullptr , "iBook G3 (Snow)" }, // PowerBook4,3
|
||||
{ 0, 1024, 0, 0x110302, 0x59b32d5e, 0, "P72x" , "P73" , nullptr , nullptr , "iBook G3 (Snow)" }, // PowerBook4,3 // 2003-03-15 464f1
|
||||
{ 0, 1024, 0, 0x110302, 0x3eb82d1d, 0, "P72x" , "P73" , nullptr , nullptr , "iBook G3 (Snow)" }, // PowerBook4,3
|
||||
{ 0, 1024, 0, 0x110303, 0x3f212d1e, 0, "P73x" , "P73" , nullptr , nullptr , "iBook G3 (Snow)" }, // PowerBook4,3
|
||||
{ 0, 1024, 0, 0x118101, 0, 0, nullptr , "P99" , nullptr , nullptr , "PowerBook G4 (Aluminum)" }, // PowerBook6,1
|
||||
{ 0, 1024, 0, 0x118202, 0, 0, nullptr , "Q54" , nullptr , nullptr , "PowerBook G4 1.0 12 inch (DVI - Aluminum)" }, // PowerBook6,2
|
||||
{ 0, 1024, 0, 0x118302, 0, 0, nullptr , "P72D" , nullptr , nullptr , "iBook G4 (Original - Opaque)" }, // PowerBook6,3
|
||||
{ 0, 1024, 0, 0x11830c, 0, 0, nullptr , "P73D" , nullptr , nullptr , "iBook G4 (Original - Opaque)" }, // PowerBook6,3
|
||||
{ 0, 1024, 0, 0x118402, 0, 0, nullptr , "Q54A" , nullptr , nullptr , "PowerBook G4 1.33 12 inch (Aluminum)" }, // PowerBook6,4
|
||||
{ 0, 1024, 0, 0x118502, 0x033929a6, 0, nullptr , "Q72" , nullptr , nullptr , "iBook G4 (Early 2004)" }, // PowerBook6,5 // 2004-04-06 485f0
|
||||
{ 0, 1024, 0, 0x118504, 0, 0, nullptr , "Q72A" , nullptr , nullptr , "iBook G4" }, // PowerBook6,5
|
||||
{ 0, 1024, 0, 0x118509, 0, 0, nullptr , "Q73" , nullptr , nullptr , "iBook G4" }, // PowerBook6,5
|
||||
{ 0, 1024, 0, 0x11850b, 0x067f29b0, 0, nullptr , "Q73A" , nullptr , nullptr , "iBook G4" }, // PowerBook6,5 // 2004-09-23 487f1
|
||||
{ 0, 1024, 0, 0x118603, 0, 0, nullptr , "U210" , nullptr , nullptr , nullptr }, // PowerBook6,6
|
||||
{ 0, 1024, 0, 0x118701, 0, 0, nullptr , "Q72B" , nullptr , nullptr , "iBook G4 12-Inch (Mid-2005 - Opaque)" }, // PowerBook6,7
|
||||
{ 0, 1024, 0, 0x118709, 0, 0, nullptr , "Q73B" , nullptr , nullptr , "iBook G4 12-Inch (Mid-2005 - Opaque)" }, // PowerBook6,7
|
||||
{ 0, 1024, 0, 0x11870c, 0, 0, nullptr , "Q73B-Best", nullptr , nullptr , "iBook G4 12-Inch (Mid-2005 - Opaque)" }, // PowerBook6,7
|
||||
{ 0, 1024, 0, 0x118801, 0, 0, nullptr , "Q54B" , nullptr , nullptr , "PowerBook G4 1.5 12 inch (Aluminum)" }, // PowerBook6,8
|
||||
{ 0, 1024, 0, 0x20c100, 0x85e72bd1, 0, "P5" , "P5" , nullptr , nullptr , "Power Mac G4 (AGP Graphics) Sawtooth" }, // PowerMac3,1
|
||||
{ 0, 1024, 0, 0x20c100, 0xb3b92cd0, 0, "Sawtooth" , "P5" , nullptr , nullptr , "Power Mac G4 (AGP Graphics) Sawtooth" }, // PowerMac3,1
|
||||
{ 0, 1024, 0, 0x20c100, 0xe28a2dcf, 0, "Sawtooth" , "P5" , nullptr , nullptr , "Power Mac G4 (AGP Graphics) Sawtooth" }, // PowerMac3,1
|
||||
{ 0, 1024, 0, 0x20c101, 0x8d142cda, 0, "Mystic" , "P5" , nullptr , nullptr , "Power Mac G4 (AGP Graphics) Sawtooth" }, // PowerMac3,1 // 2000-02-17 324f1
|
||||
{ 0, 1024, 0, 0x20c101, 0x5e432bdb, 0, "Mystic" , "P5" , nullptr , nullptr , "Power Mac G4 (AGP Graphics) Sawtooth" }, // PowerMac3,1 // 2001-10-11 428f1
|
||||
{ 0, 1024, 0, 0x20c101, 0x30712adc, 0, "P10" , "P5" , nullptr , nullptr , "Power Mac G4 (AGP Graphics) Sawtooth" }, // PowerMac3,1
|
||||
{ 0, 1024, 0, 0x20c300, 0x66752b5c, 0, "P15" , "P5" , nullptr , nullptr , "Power Macintosh Mac G4 (Gigabit)" }, // PowerMac3,3
|
||||
{ 0, 1024, 0, 0x20c300, 0x94472c5b, 0, "Clockwork" , "P5" , nullptr , nullptr , "Power Macintosh Mac G4 (Gigabit)" }, // PowerMac3,3
|
||||
{ 0, 1024, 0, 0x20c400, 0x47fe2da3, 0, "P21" , "P21" , nullptr , nullptr , "Power Mac G4 (Digital Audio)" }, // PowerMac3,4
|
||||
{ 0, 1024, 0, 0x20c400, 0x75d02ea2, 0, "Tangent" , "P21" , nullptr , nullptr , "Power Mac G4 (Digital Audio)" }, // PowerMac3,4 // 2001-10-11 428f1
|
||||
{ 0, 1024, 0, 0x20c400, 0x6ea22e91, 0, "P21|Tangent" , "P21" , nullptr , nullptr , "Power Mac G4 (Digital Audio)" }, // PowerMac3,4 // 2000-12-04 410f1
|
||||
{ 0, 1024, 0, 0x20c500, 0x4b5e2dab, 0, "P57" , "P57" , nullptr , nullptr , "Power Mac G4 Quicksilver" }, // PowerMac3,5
|
||||
{ 0, 1024, 0, 0x20c500, 0x75d02ea2, 0, "NiChrome" , "P57" , nullptr , nullptr , "Power Mac G4 Quicksilver" }, // PowerMac3,5
|
||||
{ 0, 1024, 0, 0x20c500, 0x79302eaa, 0, "NiChrome" , "P57" , nullptr , nullptr , "Power Mac G4 Quicksilver" }, // PowerMac3,5 // 2001-08-16 425f1
|
||||
{ 0, 1024, 0, 0x20c600, 0x6e5a2d67, 0, "P58_133" , "P58" , nullptr , nullptr , "Power Mac G4 (Mirrored Drive Doors)" }, // PowerMac3,6 // 2002-09-30 448f2
|
||||
{ 0, 1024, 0, 0x20c600, 0x79302eaa, 0, "Moj" , "P58" , nullptr , nullptr , "Power Mac G4 (Mirrored Drive Doors)" }, // PowerMac3,6
|
||||
{ 0, 1024, 0, 0x20c601, 0x20df2ca4, 0, "P58_167" , "P58" , nullptr , nullptr , "Power Mac G4 (Mirrored Drive Doors)" }, // PowerMac3,6
|
||||
{ 0, 1024, 0, 0x20c602, 0x6f2c2d69, 0, nullptr , "P58" , nullptr , nullptr , "Power Mac G4 (FW 800)" }, // PowerMac3,6 // 2003-01-15 457f1
|
||||
{ 0, 1024, 0, 0x20c603, 0x21b12ca6, 0, nullptr , "P58" , nullptr , nullptr , "Power Mac G4 (FW 800)" }, // PowerMac3,6 // 2003-02-20 460f1
|
||||
{ 0, 1024, 0, 0x214100, 0x4af52b1c, 0, "P9" , "P9" , nullptr , nullptr , "Power Mac G4 Cube" }, // PowerMac5,1
|
||||
{ 0, 1024, 0, 0x214100, 0x78c72c1b, 0, "Trinity" , "P9" , nullptr , nullptr , "Power Mac G4 Cube" }, // PowerMac5,1 // 2000-07-10 332f1 // 2001-09-14 419f1
|
||||
{ 0, 1024, 0, 0x214100, 0x78c72c1b, 0, "Kubrick" , "P9" , nullptr , nullptr , "Power Mac G4 Cube" }, // PowerMac5,1 // 2000-07-10 332f1 // 2001-09-14 419f1
|
||||
{ 0, 1024, 0, 0x214100, 0x8cab2cd9, 0, "Kubrick" , "P9" , nullptr , nullptr , "Power Mac G4 Cube" }, // PowerMac5,1
|
||||
{ 0, 1024, 0, 0x21c200, 0x25142c89, 0, "Q37high" , "Q37" , nullptr , nullptr , "Power Mac G5 1.6 (PCI)" }, // PowerMac7,2
|
||||
{ 0, 1024, 0, 0x21c200, 0x25702c8d, 0, "Q37high" , "Q37" , nullptr , nullptr , "Power Mac G5 1.6 (PCI)" }, // PowerMac7,2
|
||||
{ 0, 1024, 0, 0x21c200, 0xa5b7555f, 0, "Q37high" , "Q37" , nullptr , nullptr , "Power Mac G5 1.6 (PCI)" }, // PowerMac7,2
|
||||
{ 0, 1024, 0, 0x21c201, 0x336d2cad, 0, "Q37med" , "Q37" , nullptr , nullptr , "Power Mac G5 1.6 (PCI)" }, // PowerMac7,2
|
||||
{ 0, 1024, 0, 0x21c201, 0x33c92cb1, 0, "Q37med" , "Q37" , nullptr , nullptr , "Power Mac G5 1.6 (PCI)" }, // PowerMac7,2
|
||||
{ 0, 1024, 0, 0x21c201, 0x514d2dbb, 0, "P76" , "Q37" , nullptr , nullptr , "Power Mac G5 1.6 (PCI)" }, // PowerMac7,2
|
||||
{ 0, 1024, 0, 0x21c201, 0xb4105583, 0, "Q37med" , "Q37" , nullptr , nullptr , "Power Mac G5 1.6 (PCI)" }, // PowerMac7,2
|
||||
{ 0, 1024, 0, 0x21c202, 0x596854a0, 0, "Q37low" , "Q37low" , nullptr , nullptr , "Power Mac G5 1.6 (PCI)" }, // PowerMac7,2
|
||||
{ 0, 1024, 0, 0x21c202, 0xd8c62bca, 0, "Q37low" , "Q37low" , nullptr , nullptr , "Power Mac G5 1.6 (PCI)" }, // PowerMac7,2 // 2004-09-21 515f2
|
||||
{ 0, 1024, 0, 0x21c203, 0x343f2caf, 0, "Q37A" , "Q37low" , nullptr , nullptr , "Power Mac G5 1.6 (PCI)" }, // PowerMac7,2
|
||||
{ 0, 1024, 0, 0x21c203, 0x349b2cb3, 0, "Q37A" , "Q37low" , nullptr , nullptr , "Power Mac G5 1.6 (PCI)" }, // PowerMac7,2
|
||||
{ 0, 1024, 0, 0x21c203, 0xb4e25585, 0, "Q37A" , "Q37low" , nullptr , nullptr , "Power Mac G5 1.6 (PCI)" }, // PowerMac7,2
|
||||
{ 0, 1024, 0, 0x21c204, 0xa8955568, 0, "Q37C" , "Q77hi" , nullptr , nullptr , "Power Mac G5 1.6 (PCI)" }, // PowerMac7,2
|
||||
{ 0, 1024, 0, 0x21c204, 0xa930556d, 0, "Q37C" , "Q77hi" , nullptr , nullptr , "Power Mac G5 1.6 (PCI)" }, // PowerMac7,2
|
||||
{ 0, 1024, 0, 0x21c301, 0xb6cf558d, 0, "Q77best" , "Q77hi" , nullptr , nullptr , "Power Macintosh G5 Dual Processor" }, // PowerMac7,3
|
||||
{ 0, 1024, 0, 0x21c301, 0xb76a5592, 0, "Q77best" , "Q77hi" , nullptr , nullptr , "Power Macintosh G5 Dual Processor" }, // PowerMac7,3
|
||||
{ 0, 1024, 0, 0x21c302, 0xa7635563, 0, "Q77mid" , "Q77" , nullptr , nullptr , "Power Macintosh G5 Dual Processor" }, // PowerMac7,3
|
||||
{ 0, 1024, 0, 0x21c303, 0xb5bc5587, 0, "Q77good" , "Q77good" , nullptr , nullptr , "Power Macintosh G5 Dual Processor" }, // PowerMac7,3
|
||||
{ 0, 1024, 0, 0x21c304, 0xb80a5590, 0, "Q77better" , "Q77better", nullptr , nullptr , "Power Macintosh G5 Dual Processor" }, // PowerMac7,3
|
||||
{ 0, 1024, 0, 0x21c304, 0xb8a55595, 0, "Q77better" , "Q77better", nullptr , nullptr , "Power Macintosh G5 Dual Processor" }, // PowerMac7,3
|
||||
{ 0, 1024, 0, 0x21c305, 0, 0, nullptr , "M18wl" , nullptr , nullptr , "Power Macintosh G5 Dual Processor" }, // PowerMac7,3
|
||||
{ 0, 1024, 0, 0x21c306, 0, 0, nullptr , "Q87good" , nullptr , nullptr , "Power Macintosh G5 Dual Processor" }, // PowerMac7,3
|
||||
{ 0, 1024, 0, 0x21c307, 0, 0, nullptr , "Q77better", nullptr , nullptr , "Power Macintosh G5 Dual Processor" }, // PowerMac7,3
|
||||
{ 0, 1024, 0, 0x21c308, 0, 0, nullptr , "Q77hi" , nullptr , nullptr , "Power Macintosh G5 Dual Processor" }, // PowerMac7,3
|
||||
{ 0, 1024, 0, 0x224102, 0, 0, nullptr , "Q78" , nullptr , nullptr , "Power Macintosh G5 1.8 (PCI)" }, // PowerMac9,1
|
||||
{ 0, 1024, 0, 0x224108, 0x84d94d6f, 0, "Q78EVT" , nullptr , nullptr , nullptr , "Power Macintosh G5 1.8 (PCI)" }, // PowerMac9,1
|
||||
{ 0, 1024, 0, 0x224109, 0x82b74d9f, 0, "Q78p" , nullptr , nullptr , nullptr , "Power Macintosh G5 1.8 (PCI)" }, // PowerMac9,1
|
||||
{ 0, 1024, 0, 0x224109, 0x86774da9, 0, "Q78p" , nullptr , nullptr , nullptr , "Power Macintosh G5 1.8 (PCI)" }, // PowerMac9,1
|
||||
{ 0, 1024, 0, 0x22c101, 0, 0, nullptr , "M18" , nullptr , nullptr , nullptr }, // PowerMac11,1
|
||||
{ 0, 1024, 0, 0x22c102, 0, 0, nullptr , "M20wl" , nullptr , nullptr , nullptr }, // PowerMac11,1
|
||||
{ 0, 1024, 0, 0x22c201, 0, 0, nullptr , "Q63Proto" , nullptr , nullptr , "Power Mac G5 Quad Core Proto" }, // PowerMac11,2
|
||||
{ 0, 1024, 0, 0x22c202, 0xb7fe51fc, 0, nullptr , "Q63" , nullptr , nullptr , "Power Mac G5 Quad Core" }, // PowerMac11,2 // 2005-09-30 527f1
|
||||
{ 0, 1024, 0, 0x30c100, 0x0c653168, 0, "P8" , "P8" , nullptr , nullptr , "PowerBook G3 (FireWire) Pismo" }, // PowerBook3,1
|
||||
{ 0, 1024, 0, 0x30c100, 0x3a373267, 0, "Pismo" , "P8" , nullptr , nullptr , "PowerBook G3 (FireWire) Pismo" }, // PowerBook3,1 // 2001-03-21 418f5
|
||||
{ 0, 1024, 0, 0x30c100, 0x69083366, 0, "Pismo" , "P8" , nullptr , nullptr , "PowerBook G3 (FireWire) Pismo" }, // PowerBook3,1
|
||||
{ 0, 1024, 0, 0x30c1ff, 0xcb8e3457, 0, "Pismo66" , nullptr , nullptr , nullptr , "PowerBook G3 (FireWire) Pismo" }, // PowerBook3,1
|
||||
{ 0, 1024, 0, 0x30c200, 0, 0, nullptr , "P12" , nullptr , nullptr , "PowerBook G4 (Original - Titanium)" }, // PowerBook3,2
|
||||
{ 0, 1024, 0, 0x30c201, 0x33b22dc6, 0, "P12" , "P12" , nullptr , nullptr , "PowerBook G4 (Original - Titanium)" }, // PowerBook3,2
|
||||
{ 0, 1024, 0, 0x30c201, 0x61842ec5, 0, "Mercury" , "P12" , nullptr , nullptr , "PowerBook G4 (Original - Titanium)" }, // PowerBook3,2
|
||||
{ 0, 1024, 0, 0x30c300, 0x3e4f2dd5, 0, "P25_100" , "P25" , nullptr , nullptr , "PowerBook G4 (Gigabit - Titanium)" }, // PowerBook3,3
|
||||
{ 0, 1024, 0, 0x30c300, 0x63762eca, 0, "Onyx" , "P25" , nullptr , nullptr , "PowerBook G4 (Gigabit - Titanium)" }, // PowerBook3,3
|
||||
{ 0, 1024, 0, 0x30c300, 0x6c212ed4, 0, "Onix100" , "P25" , nullptr , nullptr , "PowerBook G4 (Gigabit - Titanium)" }, // PowerBook3,3
|
||||
{ 0, 1024, 0, 0x30c301, 0x4c2b2df8, 0, "P25" , "P25" , nullptr , nullptr , "PowerBook G4 (Gigabit - Titanium)" }, // PowerBook3,3
|
||||
{ 0, 1024, 0, 0x30c301, 0x79fd2ef7, 0, "Onix" , "P25" , nullptr , nullptr , "PowerBook G4 (Gigabit - Titanium)" }, // PowerBook3,3
|
||||
{ 0, 1024, 0, 0x30c302, 0x7e6c2f0a, 0, "OnixStar" , nullptr , nullptr , nullptr , "PowerBook G4 (Gigabit - Titanium)" }, // PowerBook3,3
|
||||
{ 0, 1024, 0, 0x30c400, 0x7a002ef7, 0, "Ivry" , "P59" , nullptr , nullptr , "PowerBook G4 (DVI - Titanium)" }, // PowerBook3,4
|
||||
{ 0, 1024, 0, 0x30c400, 0x91952f11, 0, "P59_667" , "P59" , nullptr , nullptr , "PowerBook G4 (DVI - Titanium)" }, // PowerBook3,4
|
||||
{ 0, 1024, 0, 0x30c402, 0x92672f13, 0, "P59_800" , nullptr , nullptr , nullptr , "PowerBook G4 (DVI - Titanium)" }, // PowerBook3,4
|
||||
{ 0, 1024, 0, 0x30c403, 0x92d02f14, 0, "P59_DVT" , nullptr , nullptr , nullptr , "PowerBook G4 (DVI - Titanium)" }, // PowerBook3,4
|
||||
{ 0, 1024, 0, 0x30c404, 0x93392f15, 0, "P59_DualFan" , "P59DF" , nullptr , nullptr , "PowerBook G4 (DVI - Titanium)" }, // PowerBook3,4
|
||||
{ 0, 1024, 0, 0x30c500, 0, 0, nullptr , "P88" , nullptr , nullptr , "PowerBook G4 (Titanum)" }, // PowerBook3,5
|
||||
{ 0, 1024, 0, 0x30c501, 0, 0, nullptr , "P881G" , nullptr , nullptr , "PowerBook G4 (Titanum)" }, // PowerBook3,5
|
||||
{ 0, 1024, 0, 0x314100, 0x6ece5388, 0, "P84i" , nullptr , nullptr , nullptr , "PowerBook G4 1.0 17 inch (Aluminum)" }, // PowerBook5,1
|
||||
{ 0, 1024, 0, 0x314103, 0x5c13264b, 0, nullptr , "P84" , nullptr , nullptr , "PowerBook G4 1.0 17 inch (Aluminum)" }, // PowerBook5,1 // 2003-02-18 462f1
|
||||
{ 0, 1024, 0, 0x314202, 0, 0, nullptr , "Q16-EVT" , nullptr , nullptr , "PowerBook G4 15 inch (FW 800 - Aluminum)" }, // PowerBook5,2
|
||||
{ 0, 1024, 0, 0x314301, 0, 0, nullptr , "Q41" , nullptr , nullptr , "PowerBook G4 1.33 17 inch (Aluminum)" }, // PowerBook5,3
|
||||
{ 0, 1024, 0, 0x314401, 0, 0, nullptr , "Q16A" , nullptr , nullptr , "PowerBook G4 15 inch (Aluminum)" }, // PowerBook5,4
|
||||
{ 0, 1024, 0, 0x314501, 0, 0, nullptr , "Q41A" , nullptr , nullptr , "PowerBook G4 1.5 17 inch (Aluminum)" }, // PowerBook5,5
|
||||
{ 0, 1024, 0, 0x314601, 0, 0, nullptr , "Q16B" , nullptr , nullptr , "PowerBook G4 15 inch (Aluminum)" }, // PowerBook5,6
|
||||
{ 0, 1024, 0, 0x314701, 0, 0, nullptr , "Q41B" , nullptr , nullptr , "PowerBook G4 1.67 17 inch (Aluminum)" }, // PowerBook5,7
|
||||
{ 0, 1024, 0, 0x314801, 0x35c72568, 0, nullptr , "Q16C" , nullptr , nullptr , "PowerBook G4 DLSD" }, // PowerBook5,8 // 2005-09-22 495f3
|
||||
{ 0, 1024, 0, 0x314801, 0, 0, nullptr , "Q41C" , nullptr , nullptr , "PowerBook G4 DLSD" }, // PowerBook5,8
|
||||
{ 0, 1024, 0, 0x314802, 0, 0, nullptr , "Q16CBest" , nullptr , nullptr , "PowerBook G4 DLSD" }, // PowerBook5,8
|
||||
{ 0, 1024, 0, 0x314901, 0x35c72568, 0, nullptr , "Q41C" , nullptr , nullptr , "PowerBook G4 1.67 17 inch (DLSD/HiRes - Aluminum)" }, // PowerBook5,9 // 2005-10-05 496f0
|
||||
{ 0, 1024, 0, 0x318100, 0x6ca8272f, 0, "P99" , nullptr , nullptr , nullptr , "PowerBook G4 867 12 inch (Aluminum)" }, // PowerBook6,1
|
||||
{ 0, 1024, 0, 0x31c101, 0xbb11558a, 0, "Q51p" , "Q51" , nullptr , nullptr , nullptr }, // PowerBook7,1
|
||||
{ 0, 1024, 0, 0x31c101, 0xbc5d558d, 0, "Q51p" , "Q51" , nullptr , nullptr , nullptr }, // PowerBook7,1
|
||||
{ 0, 1024, 0, 0x31c201, 0xbb11558a, 0, "Q43p" , "Q43" , nullptr , nullptr , nullptr }, // PowerBook7,2
|
||||
{ 0, 1024, 0, 0x31c201, 0xbc5d558d, 0, "Q43p" , "Q43" , nullptr , nullptr , nullptr }, // PowerBook7,2
|
||||
{ 0, 1024, 0, 0x380101, 0, 0, nullptr , "T3" , nullptr , nullptr , nullptr }, // PowerBook32,1
|
||||
{ 0, 1024, 0, 0x380201, 0, 0, nullptr , "M22" , nullptr , nullptr , nullptr }, // PowerBook32,2
|
||||
{ 0, 1024, 0, 0x404100, 0x268f2cab, 0, "P69" , "P69" , nullptr , nullptr , "Xserve G4 1.0 GHz" }, // RackMac1,1
|
||||
{ 0, 1024, 0, 0x404200, 0, 0, nullptr , "Q28" , nullptr , nullptr , "Xserve G4 1.33 GHz (Slot Load)" }, // RackMac1,2 // 465f3
|
||||
{ 0, 1024, 0, 0x40c100, 0xc2f855a9, 0, "Q42" , "Q42" , nullptr , nullptr , "Xserve G5 (PCI-X)" }, // RackMac3,1
|
||||
{ 0, 1024, 0, 0x40c101, 0xc28755a8, 0, "Q42B" , "Q42" , nullptr , nullptr , "Xserve G5 (PCI-X)" }, // RackMac3,1
|
||||
{ 0, 1024, 0, 0x414101, 0, 0, nullptr , "Q42C" , nullptr , nullptr , nullptr }, // RackMac5,1
|
||||
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
static const map<string, string> PropHelp = {
|
||||
@@ -75,6 +395,15 @@ static const map<string, string> PropHelp = {
|
||||
{"rambank2_size", "specifies RAM bank 2 size in MB"},
|
||||
{"rambank3_size", "specifies RAM bank 3 size in MB"},
|
||||
{"rambank4_size", "specifies RAM bank 4 size in MB"},
|
||||
{"rambank5_size", "specifies RAM bank 5 size in MB"},
|
||||
{"rambank6_size", "specifies RAM bank 6 size in MB"},
|
||||
{"rambank7_size", "specifies RAM bank 7 size in MB"},
|
||||
{"rambank8_size", "specifies RAM bank 8 size in MB"},
|
||||
{"rambank9_size", "specifies RAM bank 9 size in MB"},
|
||||
{"rambank10_size", "specifies RAM bank 10 size in MB"},
|
||||
{"rambank11_size", "specifies RAM bank 11 size in MB"},
|
||||
{"rambank12_size", "specifies RAM bank 12 size in MB"},
|
||||
{"rambank0_size", "specifies onboard RAM bank size in MB"},
|
||||
{"gfxmem_size", "specifies video memory size in MB"},
|
||||
{"fdd_img", "specifies path to floppy disk image"},
|
||||
{"fdd_fmt", "specifies floppy disk format"},
|
||||
@@ -85,21 +414,51 @@ static const map<string, string> PropHelp = {
|
||||
{"cdr_img", "specifies path(s) to CD-ROM image(s)"},
|
||||
{"cdr_img2", "specifies path(s) to secondary CD-ROM image(s)"},
|
||||
{"mon_id", "specifies which monitor to emulate"},
|
||||
{"pci_GPU", "specifies PCI device for Beige G3 grackle device @12"},
|
||||
{"pci_J12", "insert a PCI device into 32-bit 66MHz slot J12"},
|
||||
{"pci_J11", "insert a PCI device into 64-bit 33MHz slot J11"},
|
||||
{"pci_J10", "insert a PCI device into 64-bit 33MHz slot J10"},
|
||||
{"pci_J9", "insert a PCI device into 64-bit 33MHz slot J9"},
|
||||
{"pci_FireWire", "insert a PCI device into PCI slot reserved for Yosemite FireWire"},
|
||||
{"pci_UltraATA", "insert a PCI device into PCI slot reserved for Yosemite Ultra ATA"},
|
||||
{"pci_USB", "insert a PCI device into PCI slot reserved for Yosemite USB"},
|
||||
{"pci_PERCH", "insert a PCI device into PERCH slot"},
|
||||
{"pci_A1", "insert a PCI device into A1 slot"},
|
||||
{"pci_B1", "insert a PCI device into B1 slot"},
|
||||
{"pci_C1", "insert a PCI device into C1 slot"},
|
||||
{"pci_E1", "insert a PCI device into E1 slot"},
|
||||
{"pci_F1", "insert a PCI device into F1 slot"},
|
||||
{"pci_D2", "insert a PCI device into D2 slot"},
|
||||
{"pci_E2", "insert a PCI device into E2 slot"},
|
||||
{"pci_F2", "insert a PCI device into F2 slot"},
|
||||
{"vci_D", "insert a VCI device 0x0D"},
|
||||
{"vci_E", "insert a VCI device 0x0E"},
|
||||
{"vci_F", "insert a VCI device 0x0F"},
|
||||
{"serial_backend", "specifies the backend for the serial port"},
|
||||
{"emmo", "enables/disables factory HW tests during startup"},
|
||||
{"cpu", "specifies CPU"},
|
||||
{"adb_devices", "specifies which ADB device(s) to attach"},
|
||||
};
|
||||
|
||||
static uint32_t adler32(char *buf, size_t len) {
|
||||
uint32_t sum1 = 1;
|
||||
uint32_t sum2 = 0;
|
||||
while (len--) {
|
||||
sum1 = (sum1 + *(uint8_t*)buf++) % 65521;
|
||||
sum2 = (sum2 + sum1) % 65521;
|
||||
}
|
||||
return sum1 + 65536 * sum2;
|
||||
}
|
||||
|
||||
static uint32_t oldworldchecksum(char *buf, size_t len) {
|
||||
uint32_t ck = 0;
|
||||
while (len) {
|
||||
ck += READ_WORD_BE_A(buf);
|
||||
buf += 2;
|
||||
len -= 2;
|
||||
}
|
||||
return ck;
|
||||
}
|
||||
|
||||
bool MachineFactory::add(const string& machine_id, MachineDescription desc)
|
||||
{
|
||||
if (get_registry().find(machine_id) != get_registry().end()) {
|
||||
@@ -193,7 +552,7 @@ void MachineFactory::list_device_settings(DeviceDescription& dev)
|
||||
print_settings(dev.properties);
|
||||
}
|
||||
|
||||
void MachineFactory::print_settings(PropMap& prop_map)
|
||||
void MachineFactory::print_settings(const PropMap& prop_map)
|
||||
{
|
||||
string help;
|
||||
|
||||
@@ -227,27 +586,25 @@ void MachineFactory::print_settings(PropMap& prop_map)
|
||||
}
|
||||
}
|
||||
|
||||
void MachineFactory::get_device_settings(DeviceDescription& dev, map<string, string> &settings)
|
||||
void MachineFactory::register_device_settings(const std::string& name)
|
||||
{
|
||||
auto dev = DeviceRegistry::get_descriptor(name);
|
||||
for (auto& d : dev.subdev_list) {
|
||||
get_device_settings(DeviceRegistry::get_descriptor(d), settings);
|
||||
register_device_settings(d);
|
||||
}
|
||||
|
||||
for (auto& p : dev.properties) {
|
||||
if (settings.count(p.first)) {
|
||||
// This is a hack. Need to implement hierarchical paths and per device properties.
|
||||
LOG_F(ERROR, "Duplicate setting \"%s\".", p.first.c_str());
|
||||
}
|
||||
else {
|
||||
settings[p.first] = p.second->get_string();
|
||||
|
||||
// populate dynamic machine settings from presets
|
||||
gMachineSettings[p.first] = unique_ptr<BasicProperty>(p.second->clone());
|
||||
register_settings(dev.properties);
|
||||
if (!dev.properties.empty()) {
|
||||
std::cout << "Device " << name << " Settings" << endl
|
||||
<< std::string(36, '-') << endl;
|
||||
for (auto& p : dev.properties) {
|
||||
std::cout << std::setw(24) << std::right << p.first << " : "
|
||||
<< gMachineSettings[p.first]->get_string() << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int MachineFactory::get_machine_settings(const string& id, map<string, string> &settings)
|
||||
int MachineFactory::register_machine_settings(const std::string& id)
|
||||
{
|
||||
auto it = get_registry().find(id);
|
||||
if (it != get_registry().end()) {
|
||||
@@ -255,15 +612,17 @@ int MachineFactory::get_machine_settings(const string& id, map<string, string> &
|
||||
|
||||
gMachineSettings.clear();
|
||||
|
||||
for (auto& p : props) {
|
||||
settings[p.first] = p.second->get_string();
|
||||
register_settings(props);
|
||||
|
||||
// populate dynamic machine settings from presets
|
||||
gMachineSettings[p.first] = unique_ptr<BasicProperty>(p.second->clone());
|
||||
std::cout << endl << "Machine " << id << " Settings" << endl
|
||||
<< std::string(36, '-') << endl;
|
||||
for (auto& p : props) {
|
||||
std::cout << std::setw(24) << std::right << p.first << " : "
|
||||
<< gMachineSettings[p.first]->get_string() << endl;
|
||||
}
|
||||
|
||||
for (auto& dev : it->second.devices) {
|
||||
get_device_settings(DeviceRegistry::get_descriptor(dev), settings);
|
||||
register_device_settings(dev);
|
||||
}
|
||||
} else {
|
||||
LOG_F(ERROR, "Unknown machine id %s", id.c_str());
|
||||
@@ -273,132 +632,334 @@ int MachineFactory::get_machine_settings(const string& id, map<string, string> &
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MachineFactory::set_machine_settings(map<string, string> &settings) {
|
||||
for (auto& s : settings) {
|
||||
gMachineSettings.at(s.first)->set_string(s.second);
|
||||
void MachineFactory::register_settings(const PropMap& props) {
|
||||
for (auto& p : props) {
|
||||
if (gMachineSettings.count(p.first)) {
|
||||
// This is a hack. Need to implement hierarchical paths and per device properties.
|
||||
LOG_F(ERROR, "Duplicate setting \"%s\".", p.first.c_str());
|
||||
}
|
||||
else {
|
||||
auto clone = p.second->clone();
|
||||
auto override_value = get_setting_value(p.first);
|
||||
if (override_value) {
|
||||
clone->set_string(*override_value);
|
||||
}
|
||||
gMachineSettings[p.first] = std::unique_ptr<BasicProperty>(clone);
|
||||
}
|
||||
}
|
||||
|
||||
// print machine settings summary
|
||||
cout << endl << "Machine settings summary: " << endl;
|
||||
|
||||
for (auto& p : gMachineSettings) {
|
||||
cout << p.first << " : " << p.second->get_string() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
string MachineFactory::machine_name_from_rom(string& rom_filepath) {
|
||||
size_t MachineFactory::read_boot_rom(string& rom_filepath, char *rom_data)
|
||||
{
|
||||
ifstream rom_file;
|
||||
size_t file_size;
|
||||
uint32_t config_info_offset, rom_id;
|
||||
char rom_id_str[17];
|
||||
|
||||
string machine_name = "";
|
||||
|
||||
rom_file.open(rom_filepath, ios::in | ios::binary);
|
||||
if (rom_file.fail()) {
|
||||
LOG_F(ERROR, "Could not open the specified ROM file.");
|
||||
file_size = 0;
|
||||
goto bail_out;
|
||||
}
|
||||
|
||||
rom_file.seekg(0, rom_file.end);
|
||||
file_size = rom_file.tellg();
|
||||
rom_file.seekg(0, rom_file.beg);
|
||||
|
||||
if (file_size != 0x400000UL) {
|
||||
LOG_F(ERROR, "Unxpected ROM File size. Expected size is 4 megabytes.");
|
||||
if (file_size < 64 * 1024 || file_size > 4 * 1024 * 1024) {
|
||||
LOG_F(ERROR, "Unexpected ROM file size: %zu bytes. Expected size is 1 or 4 megabytes.", file_size);
|
||||
file_size = 0;
|
||||
goto bail_out;
|
||||
}
|
||||
|
||||
/* read config info offset from file */
|
||||
config_info_offset = 0;
|
||||
rom_file.seekg(0x300080, ios::beg);
|
||||
rom_file.read((char*)&config_info_offset, 4);
|
||||
config_info_offset = READ_DWORD_BE_A(&config_info_offset);
|
||||
|
||||
/* rewind to ConfigInfo.BootstrapVersion field */
|
||||
rom_file.seekg(0x300064 + config_info_offset, ios::beg);
|
||||
|
||||
/* read BootstrapVersion as C string */
|
||||
rom_file.read(rom_id_str, 16);
|
||||
rom_id_str[16] = 0;
|
||||
LOG_F(INFO, "ROM BootstrapVersion: %s", rom_id_str);
|
||||
|
||||
if (strncmp(rom_id_str, "Boot", 4) != 0) {
|
||||
LOG_F(ERROR, "Invalid BootstrapVersion string.");
|
||||
goto bail_out;
|
||||
if (rom_data) {
|
||||
rom_file.seekg(0, ios::beg);
|
||||
rom_file.read(rom_data, file_size);
|
||||
}
|
||||
|
||||
/* convert BootstrapVersion string to ROM ID */
|
||||
rom_id = (rom_id_str[5] << 24) | (rom_id_str[6] << 16) |
|
||||
(rom_id_str[7] << 8) | rom_id_str[8];
|
||||
|
||||
LOG_F(INFO, "The machine is identified as... %s",
|
||||
std::get<1>(rom_identity.at(rom_id)));
|
||||
|
||||
machine_name = std::get<0>(rom_identity.at(rom_id));
|
||||
|
||||
bail_out:
|
||||
rom_file.close();
|
||||
|
||||
return file_size;
|
||||
}
|
||||
|
||||
string MachineFactory::machine_name_from_rom(char *rom_data, size_t rom_size) {
|
||||
uint32_t date = 0;
|
||||
uint16_t major_version = 0;
|
||||
uint16_t minor_version = 0;
|
||||
uint32_t firmware_version = 0;
|
||||
uint32_t nw_product_id = 0;
|
||||
uint32_t ow_checksum_stored = 0; uint32_t ow_checksum_calculated = 0;
|
||||
uint32_t nw_start_checksum_stored = 0; uint32_t nw_start_checksum_calculated = 0;
|
||||
uint32_t nw_config_checksum_stored = 0; uint32_t nw_config_checksum_calculated = 0;
|
||||
uint32_t nw_recovery_checksum_stored = 0; uint32_t nw_recovery_checksum_calculated = 0;
|
||||
uint32_t nw_romimage_checksum_stored = 0; uint32_t nw_romimage_checksum_calculated = 0;
|
||||
uint16_t nw_config_signature = 0;
|
||||
bool has_nw_config = false;
|
||||
bool is_nw = false;
|
||||
uint32_t nw_subconfig_checksum_calculated = 0;
|
||||
|
||||
char expected_ow[24];
|
||||
char expected_start[24];
|
||||
char expected_config[24];
|
||||
char expected_recovery[24];
|
||||
char expected_romimage[24];
|
||||
auto checksum_verbosity = loguru::Verbosity_INFO;
|
||||
expected_ow[0] = expected_start[0] = expected_config[0] = expected_recovery[0] = expected_romimage[0] = 0;
|
||||
|
||||
uint32_t config_info_offset;
|
||||
char rom_id_str[17];
|
||||
rom_id_str[0] = '\0';
|
||||
|
||||
int match_pass;
|
||||
int num_matches = 0;
|
||||
int best_match_count = 0;
|
||||
string machine_name = "";
|
||||
|
||||
bool print_all_info = false;
|
||||
|
||||
/* read firmware version from file */
|
||||
date = READ_DWORD_BE_A(&rom_data[8]);
|
||||
nw_config_signature = READ_WORD_BE_A(&rom_data[0x3f00]);
|
||||
has_nw_config = nw_config_signature == 0xc99c || nw_config_signature == 0xc03c;
|
||||
if (has_nw_config || (date > 0x19990000 && date < 0x20060000)) {
|
||||
is_nw = true;
|
||||
firmware_version = READ_DWORD_BE_A(&rom_data[4]);
|
||||
{
|
||||
nw_recovery_checksum_calculated = adler32(&rom_data[0x8000], 0x77ffc);
|
||||
nw_recovery_checksum_stored = READ_DWORD_BE_A(&rom_data[0x7fffc]);
|
||||
nw_romimage_checksum_calculated = adler32(&rom_data[0x80000], 0x7fffc);
|
||||
nw_romimage_checksum_stored = READ_DWORD_BE_A(&rom_data[0xffffc]);
|
||||
}
|
||||
|
||||
if (has_nw_config) {
|
||||
nw_start_checksum_calculated = adler32(&rom_data[0], 0x3efc);
|
||||
nw_start_checksum_stored = READ_DWORD_BE_A(&rom_data[0x3efc]);
|
||||
nw_config_checksum_calculated = adler32(&rom_data[0x3f00], 0x7c);
|
||||
nw_config_checksum_stored = READ_DWORD_BE_A(&rom_data[0x3f7c]);
|
||||
nw_subconfig_checksum_calculated = adler32(&rom_data[0x3f0c], 0x70);
|
||||
nw_product_id = (READ_WORD_BE_A(&rom_data[0x3f02]) << 8) | rom_data[0x3f13];
|
||||
}
|
||||
else {
|
||||
firmware_version &= 0xffff; // the upper 2 bytes might be a machine type: 0=iMac, 1=PowerMac, 2=PowerBook
|
||||
nw_start_checksum_calculated = adler32(&rom_data[0], 0x3ffc);
|
||||
nw_start_checksum_stored = READ_DWORD_BE_A(&rom_data[0x3ffc]);
|
||||
nw_config_checksum_calculated = 0;
|
||||
nw_config_checksum_stored = 0;
|
||||
nw_subconfig_checksum_calculated = 0;
|
||||
nw_product_id = 0;
|
||||
}
|
||||
if (nw_start_checksum_calculated != nw_start_checksum_stored)
|
||||
snprintf(expected_start, sizeof(expected_start), " (expected 0x%04x)", nw_start_checksum_stored);
|
||||
if (nw_config_checksum_calculated != nw_config_checksum_stored)
|
||||
snprintf(expected_config, sizeof(expected_config), " (expected 0x%04x)", nw_config_checksum_stored);
|
||||
if (nw_recovery_checksum_calculated != nw_recovery_checksum_stored)
|
||||
snprintf(expected_recovery, sizeof(expected_recovery), " (expected 0x%04x)", nw_recovery_checksum_stored);
|
||||
if (nw_romimage_checksum_calculated != nw_romimage_checksum_stored)
|
||||
snprintf(expected_romimage, sizeof(expected_romimage), " (expected 0x%04x)", nw_romimage_checksum_stored);
|
||||
}
|
||||
else {
|
||||
date = 0;
|
||||
major_version = READ_WORD_BE_A(&rom_data[8]);
|
||||
minor_version = READ_WORD_BE_A(&rom_data[0x12]);
|
||||
firmware_version = (major_version << 16) | minor_version;
|
||||
ow_checksum_calculated = oldworldchecksum(&rom_data[4], std::min(rom_size - 4, (size_t)0x2ffffc));
|
||||
ow_checksum_stored = READ_DWORD_BE_A(&rom_data[0]);
|
||||
if (ow_checksum_calculated != ow_checksum_stored)
|
||||
snprintf(expected_ow, sizeof(expected_ow), " (expected 0x%04x)", ow_checksum_stored);
|
||||
|
||||
if (firmware_version > 0x077d10f3) {
|
||||
/* read ConfigInfo offset from file */
|
||||
config_info_offset = READ_DWORD_BE_A(&rom_data[0x300080]);
|
||||
|
||||
/* read ConfigInfo.BootstrapVersion field as C string */
|
||||
memcpy(rom_id_str, &rom_data[0x300064 + config_info_offset], 16);
|
||||
rom_id_str[16] = 0;
|
||||
for (int i = 0; i < 16; i++)
|
||||
if (rom_id_str[i] < ' ' || rom_id_str[i] > '~')
|
||||
rom_id_str[i] = '.';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (match_pass = 0; match_pass < 2; match_pass++) {
|
||||
int match_index = 0;
|
||||
for (rom_info *info = &rom_identity[0]; info->firmware_size_k; info++) {
|
||||
if (
|
||||
(info->firmware_version && info->firmware_version == firmware_version) ||
|
||||
(info->nw_product_id && info->nw_product_id == nw_product_id )
|
||||
) {
|
||||
int match_count = 1
|
||||
+ (info->ow_expected_checksum && info->ow_expected_checksum == ow_checksum_stored )
|
||||
+ (info->ow_expected_checksum && info->ow_expected_checksum == ow_checksum_calculated )
|
||||
+ (info->nw_subconfig_expected_checksum && info->nw_subconfig_expected_checksum == nw_subconfig_checksum_calculated )
|
||||
+ (info->id_str && strcmp(rom_id_str, info->id_str) == 0)
|
||||
;
|
||||
|
||||
if (!match_pass) {
|
||||
if (match_count >= best_match_count) {
|
||||
if (match_count > best_match_count) {
|
||||
best_match_count = match_count;
|
||||
num_matches = 0;
|
||||
}
|
||||
num_matches++;
|
||||
}
|
||||
} else {
|
||||
if (num_matches == 0) {
|
||||
LOG_F(ERROR, "Unknown ROM");
|
||||
print_all_info = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (match_count == best_match_count) {
|
||||
match_index++;
|
||||
LOG_F(INFO, "Found match (%d/%d):", match_index, num_matches);
|
||||
if (info->rom_description)
|
||||
LOG_F(INFO, " ROM description: %s", info->rom_description);
|
||||
if (info->dppc_description)
|
||||
LOG_F(INFO, " Machine identified from ROM: %s", info->dppc_description);
|
||||
if (
|
||||
info->nw_firmware_updater_name && info->nw_openfirmware_name &&
|
||||
strcmp(info->nw_firmware_updater_name, info->nw_openfirmware_name) == 0
|
||||
) {
|
||||
LOG_F(INFO, " Code Name: %s", info->nw_firmware_updater_name);
|
||||
} else {
|
||||
if (info->nw_firmware_updater_name)
|
||||
LOG_F(INFO, " Code Name (from Firmware Updater): %s", info->nw_firmware_updater_name);
|
||||
if (info->nw_openfirmware_name)
|
||||
LOG_F(INFO, " Code Name (from Open Firmware): %s", info->nw_openfirmware_name);
|
||||
}
|
||||
if (info->nw_product_id) {
|
||||
LOG_F(INFO, " Product ID: 0x%04x.%02x = %s%d,%d",
|
||||
nw_product_id >> 8, nw_product_id & 0xff,
|
||||
(nw_product_id >> 20) == 0 ? "PowerMac" :
|
||||
(nw_product_id >> 20) == 1 ? "PowerBook" :
|
||||
(nw_product_id >> 20) == 2 ? "PowerMac" :
|
||||
(nw_product_id >> 20) == 3 ? "PowerBook" :
|
||||
(nw_product_id >> 20) == 4 ? "RackMac" : "???",
|
||||
(nw_product_id >> 14) & 31,
|
||||
(nw_product_id >> 8) & 31
|
||||
);
|
||||
}
|
||||
if (info->nw_subconfig_expected_checksum) {
|
||||
LOG_F(INFO, " Config Checksum: 0x%08x", nw_subconfig_checksum_calculated);
|
||||
}
|
||||
if (rom_size != info->firmware_size_k * 1024) {
|
||||
LOG_F(ERROR, " Unexpected ROM file size: %zu bytes. Expected size is %d %s.",
|
||||
rom_size,
|
||||
info->firmware_size_k & 0x3ff ?
|
||||
info->firmware_size_k :
|
||||
info->firmware_size_k / 1024,
|
||||
info->firmware_size_k & 0x3ff ? "kiB" : "MiB"
|
||||
);
|
||||
}
|
||||
if (info->dppc_machine) {
|
||||
if (machine_name.empty()) {
|
||||
machine_name = info->dppc_machine;
|
||||
}
|
||||
} else
|
||||
LOG_F(ERROR, " This ROM is not supported.");
|
||||
}
|
||||
} // if match_pass
|
||||
} // if match
|
||||
} // for rom_info
|
||||
} // for match_pass
|
||||
|
||||
if (1 || print_all_info) {
|
||||
if (is_nw) {
|
||||
LOG_F(INFO, "Info from ROM:");
|
||||
LOG_F(INFO, " ROM Date: %04x-%02x-%02x", date >> 16, (date >> 8) & 0xff, date & 0xff);
|
||||
if (firmware_version < 0xffff)
|
||||
LOG_F(INFO, " ROM Version: %x.%03x", (firmware_version >> 12) & 15, firmware_version & 0xfff);
|
||||
else
|
||||
LOG_F(INFO, " ROM Version: %x.%x.%03x", firmware_version >> 16, (firmware_version >> 12) & 15, firmware_version & 0xfff);
|
||||
if (has_nw_config) {
|
||||
LOG_F(INFO, " Product ID: 0x%04x.%02x 0x%08x = %s%d,%d",
|
||||
nw_product_id >> 8, nw_product_id & 0xff,
|
||||
nw_subconfig_checksum_calculated,
|
||||
(nw_product_id >> 20) == 0 ? "PowerMac" :
|
||||
(nw_product_id >> 20) == 1 ? "PowerBook" :
|
||||
(nw_product_id >> 20) == 2 ? "PowerMac" :
|
||||
(nw_product_id >> 20) == 3 ? "PowerBook" :
|
||||
(nw_product_id >> 20) == 4 ? "RackMac" : "???",
|
||||
(nw_product_id >> 14) & 31,
|
||||
(nw_product_id >> 8) & 31
|
||||
);
|
||||
}
|
||||
} else {
|
||||
LOG_F(INFO, " ROM Version: %04x.%04x", major_version, minor_version);
|
||||
if (rom_id_str[0])
|
||||
LOG_F(INFO, " ConfigInfo.BootstrapVersion: \"%s\"", rom_id_str);
|
||||
}
|
||||
}
|
||||
|
||||
if (expected_ow[0] || expected_start[0] || expected_config[0] || expected_recovery[0] || expected_romimage[0])
|
||||
checksum_verbosity = loguru::Verbosity_ERROR;
|
||||
|
||||
if (1 || print_all_info || checksum_verbosity != loguru::Verbosity_INFO) {
|
||||
if (is_nw) {
|
||||
if (has_nw_config) {
|
||||
VLOG_F(checksum_verbosity, " ROM Checksums: 0x%08x%s, 0x%08x%s, 0x%08x%s, 0x%08x%s",
|
||||
nw_start_checksum_calculated, expected_start,
|
||||
nw_config_checksum_calculated, expected_config,
|
||||
nw_recovery_checksum_calculated, expected_recovery,
|
||||
nw_romimage_checksum_calculated, expected_romimage
|
||||
);
|
||||
}
|
||||
else {
|
||||
VLOG_F(checksum_verbosity, " ROM Checksums: 0x%08x%s, 0x%08x%s, 0x%08x%s",
|
||||
nw_start_checksum_calculated, expected_start,
|
||||
nw_recovery_checksum_calculated, expected_recovery,
|
||||
nw_romimage_checksum_calculated, expected_romimage
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
VLOG_F(checksum_verbosity, " ROM Checksum: 0x%08x%s",
|
||||
ow_checksum_calculated, expected_ow
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return machine_name;
|
||||
}
|
||||
|
||||
/* Read ROM file content and transfer it to the dedicated ROM region */
|
||||
int MachineFactory::load_boot_rom(string& rom_filepath) {
|
||||
ifstream rom_file;
|
||||
size_t file_size;
|
||||
int MachineFactory::load_boot_rom(char *rom_data, size_t rom_size) {
|
||||
int result = 0;
|
||||
uint32_t rom_load_addr;
|
||||
//AddressMapEntry *rom_reg;
|
||||
|
||||
rom_file.open(rom_filepath, ios::in | ios::binary);
|
||||
if (rom_file.fail()) {
|
||||
LOG_F(ERROR, "Could not open the specified ROM file.");
|
||||
rom_file.close();
|
||||
return -1;
|
||||
}
|
||||
|
||||
rom_file.seekg(0, rom_file.end);
|
||||
file_size = rom_file.tellg();
|
||||
rom_file.seekg(0, rom_file.beg);
|
||||
|
||||
if (file_size == 0x400000UL) { // Old World ROMs
|
||||
if (rom_size == 0x400000UL) { // Old World ROMs
|
||||
rom_load_addr = 0xFFC00000UL;
|
||||
} else if (file_size == 0x100000UL) { // New World ROMs
|
||||
} else if (rom_size == 0x100000UL) { // New World ROMs
|
||||
rom_load_addr = 0xFFF00000UL;
|
||||
} else {
|
||||
LOG_F(ERROR, "Unxpected ROM File size: %zu bytes.", file_size);
|
||||
LOG_F(ERROR, "Unexpected ROM File size: %zu bytes.", rom_size);
|
||||
result = -1;
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
unsigned char* sysrom_mem = new unsigned char[file_size];
|
||||
|
||||
rom_file.seekg(0, ios::beg);
|
||||
rom_file.read((char*)sysrom_mem, file_size);
|
||||
|
||||
MemCtrlBase* mem_ctrl = dynamic_cast<MemCtrlBase*>(
|
||||
gMachineObj->get_comp_by_type(HWCompType::MEM_CTRL));
|
||||
|
||||
if ((/*rom_reg = */mem_ctrl->find_rom_region())) {
|
||||
mem_ctrl->set_data(rom_load_addr, sysrom_mem, (uint32_t)file_size);
|
||||
mem_ctrl->set_data(rom_load_addr, (uint8_t*)rom_data, (uint32_t)rom_size);
|
||||
} else {
|
||||
LOG_F(ERROR, "Could not locate physical ROM region!");
|
||||
result = -1;
|
||||
}
|
||||
|
||||
delete[] sysrom_mem;
|
||||
}
|
||||
|
||||
rom_file.close();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int MachineFactory::create_machine_for_id(string& id, string& rom_filepath) {
|
||||
if (MachineFactory::create(id) < 0 || load_boot_rom(rom_filepath) < 0) {
|
||||
int MachineFactory::create_machine_for_id(string& id, char *rom_data, size_t rom_size) {
|
||||
if (MachineFactory::create(id) < 0) {
|
||||
return -1;
|
||||
}
|
||||
if (load_boot_rom(rom_data, rom_size) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GetSettingValueFunc MachineFactory::get_setting_value;
|
||||
+26
-21
@@ -29,49 +29,54 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include <machines/machineproperties.h>
|
||||
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct DeviceDescription;
|
||||
|
||||
struct MachineDescription {
|
||||
string name;
|
||||
string description;
|
||||
vector<string> devices;
|
||||
PropMap settings;
|
||||
function<int(string&)> init_func;
|
||||
std::string name;
|
||||
std::string description;
|
||||
std::vector<std::string> devices;
|
||||
PropMap settings;
|
||||
std::function<int(std::string&)> init_func;
|
||||
};
|
||||
|
||||
typedef std::function<std::optional<std::string>(const std::string&)> GetSettingValueFunc;
|
||||
|
||||
class MachineFactory
|
||||
{
|
||||
public:
|
||||
MachineFactory() = delete;
|
||||
|
||||
static bool add(const string& machine_id, MachineDescription desc);
|
||||
static bool add(const std::string& machine_id, MachineDescription desc);
|
||||
|
||||
static string machine_name_from_rom(string& rom_filepath);
|
||||
static size_t read_boot_rom(std::string& rom_filepath, char *rom_data);
|
||||
static std::string machine_name_from_rom(char *rom_data, size_t rom_size);
|
||||
|
||||
static int create(string& mach_id);
|
||||
static int create_machine_for_id(string& id, string& rom_filepath);
|
||||
static int create(std::string& mach_id);
|
||||
static int create_machine_for_id(std::string& id, char *rom_data, size_t rom_size);
|
||||
|
||||
static void get_device_settings(DeviceDescription& dev, map<string, string> &settings);
|
||||
static int get_machine_settings(const string& id, map<string, string> &settings);
|
||||
static void set_machine_settings(map<string, string> &settings);
|
||||
static void register_device_settings(const std::string &name);
|
||||
static int register_machine_settings(const std::string& id);
|
||||
|
||||
static void list_machines();
|
||||
static void list_properties();
|
||||
|
||||
private:
|
||||
static void create_device(string& dev_name, DeviceDescription& dev);
|
||||
static void print_settings(PropMap& p);
|
||||
static void list_device_settings(DeviceDescription& dev);
|
||||
static int load_boot_rom(string& rom_filepath);
|
||||
static GetSettingValueFunc get_setting_value;
|
||||
|
||||
static map<string, MachineDescription> & get_registry() {
|
||||
static map<string, MachineDescription> machine_registry;
|
||||
private:
|
||||
static void create_device(std::string& dev_name, DeviceDescription& dev);
|
||||
static void print_settings(const PropMap& p);
|
||||
static void list_device_settings(DeviceDescription& dev);
|
||||
static int load_boot_rom(char *rom_data, size_t rom_size);
|
||||
static void register_settings(const PropMap& p);
|
||||
|
||||
static std::map<std::string, MachineDescription> & get_registry() {
|
||||
static std::map<std::string, MachineDescription> machine_registry;
|
||||
return machine_registry;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -34,6 +34,16 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#include <memctrl/memctrlbase.h>
|
||||
#include <loguru.hpp>
|
||||
|
||||
static std::vector<PciIrqMap> psx_irq_map = {
|
||||
{nullptr , DEV_FUN(0x0B,0), IntSrc::BANDIT1},
|
||||
{"pci_A1", DEV_FUN(0x0D,0), IntSrc::PCI_A},
|
||||
{"pci_B1", DEV_FUN(0x0E,0), IntSrc::PCI_B},
|
||||
{"pci_C1", DEV_FUN(0x0F,0), IntSrc::PCI_C},
|
||||
{nullptr , DEV_FUN(0x10,0), }, // OHare
|
||||
{"pci_E1", DEV_FUN(0x11,0), IntSrc::PCI_E},
|
||||
{"pci_F1", DEV_FUN(0x12,0), IntSrc::PCI_F},
|
||||
};
|
||||
|
||||
// TODO: move it to /cpu/ppc
|
||||
int get_cpu_pll_value(const uint64_t cpu_freq_hz) {
|
||||
switch (cpu_freq_hz / 1000000) {
|
||||
@@ -53,6 +63,7 @@ int initialize_gazelle(std::string& id)
|
||||
LOG_F(INFO, "Building machine Gazelle...");
|
||||
|
||||
PCIHost *pci_host = dynamic_cast<PCIHost*>(gMachineObj->get_comp_by_name("PsxPci1"));
|
||||
pci_host->set_irq_map(psx_irq_map);
|
||||
|
||||
// register O'Hare I/O controller with the main PCI bus
|
||||
pci_host->pci_register_device(
|
||||
@@ -66,8 +77,12 @@ int initialize_gazelle(std::string& id)
|
||||
return -1;
|
||||
}
|
||||
|
||||
// plug 32MB RAM DIMM into slot #0
|
||||
psx_obj->insert_ram_dimm(0, DRAM_CAP_32MB);
|
||||
// insert RAM DIMMs
|
||||
psx_obj->insert_ram_dimm(0, GET_INT_PROP("rambank1_size") * DRAM_CAP_1MB);
|
||||
psx_obj->insert_ram_dimm(1, GET_INT_PROP("rambank2_size") * DRAM_CAP_1MB);
|
||||
psx_obj->insert_ram_dimm(2, GET_INT_PROP("rambank3_size") * DRAM_CAP_1MB);
|
||||
psx_obj->insert_ram_dimm(3, GET_INT_PROP("rambank4_size") * DRAM_CAP_1MB);
|
||||
psx_obj->insert_ram_dimm(4, GET_INT_PROP("rambank5_size") * DRAM_CAP_1MB);
|
||||
|
||||
// allocate and map physical RAM
|
||||
psx_obj->map_phys_ram();
|
||||
@@ -87,18 +102,20 @@ int initialize_gazelle(std::string& id)
|
||||
|
||||
static const PropMap pm6500_settings = {
|
||||
{"rambank1_size",
|
||||
new IntProperty(16, vector<uint32_t>({4, 8, 16, 32, 64, 128}))},
|
||||
new IntProperty(32, std::vector<uint32_t>({ 4, 8, 16, 32}))},
|
||||
{"rambank2_size",
|
||||
new IntProperty( 0, vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))},
|
||||
new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32}))},
|
||||
{"rambank3_size",
|
||||
new IntProperty( 0, vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))},
|
||||
new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32}))},
|
||||
{"rambank4_size",
|
||||
new IntProperty( 0, vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))},
|
||||
new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32}))},
|
||||
{"rambank5_size",
|
||||
new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32}))},
|
||||
{"emmo",
|
||||
new BinProperty(0)},
|
||||
};
|
||||
|
||||
static vector<string> pm6500_devices = {
|
||||
static std::vector<std::string> pm6500_devices = {
|
||||
"Psx", "PsxPci1", "OHare"
|
||||
};
|
||||
|
||||
|
||||
@@ -41,6 +41,16 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#include <cinttypes>
|
||||
#include <string>
|
||||
|
||||
static const std::vector<PciIrqMap> grackle_irq_map = {
|
||||
{nullptr , DEV_FUN(0x00,0), }, // Grackle
|
||||
{"pci_PERCH", DEV_FUN(0x0C,0), IntSrc::PCI_PERCH },
|
||||
{"pci_A1" , DEV_FUN(0x0D,0), IntSrc::PCI_A },
|
||||
{"pci_B1" , DEV_FUN(0x0E,0), IntSrc::PCI_B },
|
||||
{"pci_C1" , DEV_FUN(0x0F,0), IntSrc::PCI_C },
|
||||
{nullptr , DEV_FUN(0x10,0), }, // Heathrow
|
||||
{"pci_GPU" , DEV_FUN(0x12,0), IntSrc::PCI_GPU },
|
||||
};
|
||||
|
||||
// Bit definitions for the Gossamer system register at 0xFF000004
|
||||
enum : uint16_t {
|
||||
FDC_TYPE_SWIM3 = (1 << 15), // Macintosh style floppy disk controller
|
||||
@@ -96,6 +106,7 @@ int initialize_gossamer(std::string& id)
|
||||
|
||||
// get pointer to the memory controller/PCI host bridge object
|
||||
MPC106* grackle_obj = dynamic_cast<MPC106*>(gMachineObj->get_comp_by_name("Grackle"));
|
||||
grackle_obj->set_irq_map(grackle_irq_map);
|
||||
|
||||
// configure the Gossamer system register
|
||||
uint16_t sys_reg = FDC_TYPE_SWIM3 | BURST_ROM_TRUE
|
||||
@@ -156,11 +167,11 @@ int initialize_gossamer(std::string& id)
|
||||
|
||||
static const PropMap gossamer_settings = {
|
||||
{"rambank1_size",
|
||||
new IntProperty(256, vector<uint32_t>({8, 16, 32, 64, 128, 256}))},
|
||||
new IntProperty(256, std::vector<uint32_t>({8, 16, 32, 64, 128, 256}))},
|
||||
{"rambank2_size",
|
||||
new IntProperty( 0, vector<uint32_t>({0, 8, 16, 32, 64, 128, 256}))},
|
||||
new IntProperty( 0, std::vector<uint32_t>({0, 8, 16, 32, 64, 128, 256}))},
|
||||
{"rambank3_size",
|
||||
new IntProperty( 0, vector<uint32_t>({0, 8, 16, 32, 64, 128, 256}))},
|
||||
new IntProperty( 0, std::vector<uint32_t>({0, 8, 16, 32, 64, 128, 256}))},
|
||||
{"emmo",
|
||||
new BinProperty(0)},
|
||||
{"hdd_config",
|
||||
@@ -169,11 +180,11 @@ static const PropMap gossamer_settings = {
|
||||
new StrProperty("Ide1:0")},
|
||||
};
|
||||
|
||||
static vector<string> pmg3_devices = {
|
||||
static std::vector<std::string> pmg3_devices = {
|
||||
"Grackle", "ScreamerSnd", "Heathrow", "AtaHardDisk", "AtapiCdrom"
|
||||
};
|
||||
|
||||
static vector<string> pmg3twr_devices = {
|
||||
static std::vector<std::string> pmg3twr_devices = {
|
||||
"Grackle", "ScreamerSnd", "Heathrow", "AtaHardDisk", "AtapiCdrom"
|
||||
};
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ int initialize_pdm(std::string& id)
|
||||
|
||||
// Monitors supported by the PDM on-board video.
|
||||
// see displayid.cpp for the full list of supported monitor IDs.
|
||||
static const vector<string> PDMBuiltinMonitorIDs = {
|
||||
static const std::vector<std::string> PDMBuiltinMonitorIDs = {
|
||||
"PortraitGS", "MacRGB12in", "MacRGB15in", "HiRes12-14in", "VGA-SVGA",
|
||||
"MacRGB16in", "Multiscan15in", "Multiscan17in", "Multiscan20in",
|
||||
"NotConnected"
|
||||
@@ -105,16 +105,16 @@ static const vector<string> PDMBuiltinMonitorIDs = {
|
||||
|
||||
static const PropMap pm6100_settings = {
|
||||
{"rambank1_size",
|
||||
new IntProperty(0, vector<uint32_t>({0, 2, 4, 8, 16, 32, 64, 128}))},
|
||||
new IntProperty(0, std::vector<uint32_t>({0, 2, 4, 8, 16, 32, 64, 128}))},
|
||||
{"rambank2_size",
|
||||
new IntProperty(0, vector<uint32_t>({0, 2, 4, 8, 16, 32, 64, 128}))},
|
||||
new IntProperty(0, std::vector<uint32_t>({0, 2, 4, 8, 16, 32, 64, 128}))},
|
||||
{"mon_id",
|
||||
new StrProperty("HiRes12-14in", PDMBuiltinMonitorIDs)},
|
||||
{"emmo",
|
||||
new BinProperty(0)},
|
||||
};
|
||||
|
||||
static vector<string> pm6100_devices = {
|
||||
static std::vector<std::string> pm6100_devices = {
|
||||
"HMC", "Amic"
|
||||
};
|
||||
|
||||
|
||||
@@ -33,10 +33,19 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#include <machines/machinefactory.h>
|
||||
#include <loguru.hpp>
|
||||
|
||||
static std::vector<PciIrqMap> aspen_irq_map = {
|
||||
// {nullptr , DEV_FUN(0x0B,0), IntSrc::BANDIT1 },
|
||||
// {"pci_A1", DEV_FUN(0x0D,0), IntSrc::PCI_A },
|
||||
{"pci_B1", DEV_FUN(0x0E,0), IntSrc::PIPPIN_E},
|
||||
{"pci_C1", DEV_FUN(0x0F,0), IntSrc::PIPPIN_F},
|
||||
{nullptr , DEV_FUN(0x10,0), }, // GrandCentral
|
||||
};
|
||||
|
||||
int initialize_pippin(std::string& id) {
|
||||
LOG_F(INFO, "Building machine Pippin...");
|
||||
|
||||
PCIHost *pci_host = dynamic_cast<PCIHost*>(gMachineObj->get_comp_by_name("AspenPci1"));
|
||||
pci_host->set_irq_map(aspen_irq_map);
|
||||
|
||||
// connect GrandCentral I/O controller to the PCI1 bus
|
||||
pci_host->pci_register_device(DEV_FUN(0x10,0),
|
||||
@@ -65,18 +74,20 @@ int initialize_pippin(std::string& id) {
|
||||
|
||||
static const PropMap Pippin_Settings = {
|
||||
{"rambank1_size",
|
||||
new IntProperty(4, vector<uint32_t>({4}))}, // fixed size
|
||||
new IntProperty(4, std::vector<uint32_t>({4}))}, // fixed size
|
||||
{"rambank2_size",
|
||||
new IntProperty(1, vector<uint32_t>({1}))}, // fixed size
|
||||
new IntProperty(1, std::vector<uint32_t>({1}))}, // fixed size
|
||||
{"rambank3_size",
|
||||
new IntProperty(0, vector<uint32_t>({0, 1, 4, 8, 16}))},
|
||||
new IntProperty(0, std::vector<uint32_t>({0, 1, 4, 8, 16}))},
|
||||
{"rambank4_size",
|
||||
new IntProperty(0, vector<uint32_t>({0, 1, 4, 8, 16}))},
|
||||
new IntProperty(0, std::vector<uint32_t>({0, 1, 4, 8, 16}))},
|
||||
{"emmo",
|
||||
new BinProperty(0)},
|
||||
{"adb_devices",
|
||||
new StrProperty("AppleJack,Keyboard")},
|
||||
};
|
||||
|
||||
static vector<string> Pippin_Devices = {
|
||||
static std::vector<std::string> Pippin_Devices = {
|
||||
"Aspen", "AspenPci1", "ScsiMesh", "MeshTnt", "GrandCentral", "TaosVideo"
|
||||
};
|
||||
|
||||
|
||||
Loaded 100 of 110 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user