mirror of
https://github.com/dingusdev/dingusppc.git
synced 2026-12-01 06:23:18 -10:00
Compare commits
35
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee838f0519 | ||
|
|
5c646e8270 | ||
|
|
65c5d2425e | ||
|
|
f2676e0324 | ||
|
|
48adf99690 | ||
|
|
3c0432053b | ||
|
|
ebc2fcf216 | ||
|
|
25c74f76d2 | ||
|
|
e3839bdea6 | ||
|
|
742a810624 | ||
|
|
dbc10ab027 | ||
|
|
383f6dd9a1 | ||
|
|
be04300846 | ||
|
|
80c1ebe57d | ||
|
|
5996358308 | ||
|
|
380827e09b | ||
|
|
c4be881d52 | ||
|
|
ae56bb3743 | ||
|
|
fd5bcddcb7 | ||
|
|
af8124a525 | ||
|
|
8105defb0b | ||
|
|
7429a4111e | ||
|
|
a537d09c63 | ||
|
|
7fdb11d64f | ||
|
|
5567041c2b | ||
|
|
c94cfe0d40 | ||
|
|
73d5a2374b | ||
|
|
017f559e90 | ||
|
|
29f9ab14ee | ||
|
|
17b2a1a6e4 | ||
|
|
77f1f72122 | ||
|
|
03ec9d9589 | ||
|
|
b813a080da | ||
|
|
2b0b926f52 | ||
|
|
0ac0a5b77e |
No files matched your search
@@ -8,17 +8,19 @@ Be warned the program is highly unfinished and could use a lot of testing. Any f
|
||||
|
||||
While many other PowerPC emus exist (PearPC, Sheepshaver), none of them currently attempt emulation of PowerPC Macs accurately (except for QEMU).
|
||||
|
||||
This program aims to not only improve upon what Sheepshaver, PearPC, and other PowerPC Mac emulators have done, but also to provide a better debugging environment. This currently is designed to work best with PowerPC Old World ROMs, including those of the Power Mac 6100, 7200, and G3 Beige.
|
||||
This program aims to not only improve upon what Sheepshaver, PearPC, and other PowerPC Mac emulators have done, but also to provide a better debugging environment. This currently is designed to work best with PowerPC NuBus and Old World ROMs, including those of the Power Mac 6100, 7200, and G3 Beige.
|
||||
|
||||
## Implemented Features
|
||||
|
||||
This emulator has a debugging environment, complete with a disassembler. We also have implemented enough to allow Open Firmware to boot, going so far as to allow audio playback of the boot-up jingles.
|
||||
Several machines have been implemented to varying degrees, like many Old World PowerPC Macs, early New World PowerPC Macs, and the Pippin.
|
||||
|
||||
This emulator has a debugging environment, complete with a disassembler.
|
||||
|
||||
## How to Use
|
||||
|
||||
This program currently uses the command prompt to work.
|
||||
|
||||
There are a few command line arguments one must enter when starting the program.
|
||||
There are a few command line arguments one can enter when starting the program.
|
||||
|
||||
```
|
||||
-r, --realtime
|
||||
@@ -36,21 +38,31 @@ Enter the interactive debugger.
|
||||
-b, --bootrom TEXT:FILE
|
||||
```
|
||||
|
||||
Specifies the Boot ROM path (optional; looks for bootrom.bin by default)
|
||||
Specifies the Boot ROM path. It otherwise looks for bootrom.bin.
|
||||
|
||||
```
|
||||
-m, --machine TEXT
|
||||
```
|
||||
|
||||
Specify machine ID (optional; will attempt to determine machine ID from the boot rom otherwise)
|
||||
Specify machine ID. Otherwise, the emulator will attempt to determine machine ID from the boot rom otherwise.
|
||||
|
||||
As of now, the most complete machines are the Power Mac 6100 (SCSI emulation in progress) and the Power Mac G3 Beige (SCSI + ATA emulation in progress, No ATI Rage acceleration).
|
||||
As of now, the most complete machines are the Power Mac 6100, the Power Mac 7500, and the Power Mac G3 Beige.
|
||||
|
||||
To go into to the debugger regardless of how you started the emulator, press Control and C on the terminal window.
|
||||
|
||||
## How to Compile
|
||||
|
||||
You need to install development tools first.
|
||||
|
||||
At least, a C++20 compliant compiler and [CMake](https://cmake.org) are required.
|
||||
At minimum, a C++20 compliant compiler and [CMake](https://cmake.org) are required.
|
||||
|
||||
Clone the repository using the appropriate command:
|
||||
|
||||
```
|
||||
git clone https://github.com/dingusdev/dingusppc
|
||||
```
|
||||
|
||||
If this is from a mirror, replace the argument with the source you want to use instead.
|
||||
|
||||
You will also have to recursive clone or run
|
||||
```
|
||||
@@ -100,7 +112,3 @@ make testppc
|
||||
- 2 GB of RAM
|
||||
- 2 GB of Hard Disk Space
|
||||
- Graphics Card with a minimum resolution of 800*600
|
||||
|
||||
## Compiler Requirements
|
||||
|
||||
- Any C++20 compatible compiler
|
||||
@@ -114,6 +114,8 @@ enum SPR : int {
|
||||
PMC2 = 954,
|
||||
SIA = 955,
|
||||
MMCR1 = 956,
|
||||
PMC3 = 957,
|
||||
PMC4 = 958,
|
||||
SDA = 959,
|
||||
HID0 = 1008,
|
||||
HID1 = 1009,
|
||||
|
||||
+2
-1
@@ -899,7 +899,8 @@ static map<string, int> SPRName2Num = {
|
||||
{"SDR1", SPR::SDR1}, {"MQ", SPR::MQ}, {"RTCU", SPR::RTCU_S},
|
||||
{"RTCL", SPR::RTCL_S}, {"DSISR", SPR::DSISR}, {"DAR", SPR::DAR},
|
||||
{"MMCR0", SPR::MMCR0}, {"PMC1", SPR::PMC1}, {"PMC2", SPR::PMC2},
|
||||
{"SDA", SPR::SDA}, {"SIA", SPR::SIA}, {"MMCR1", SPR::MMCR1}
|
||||
{"SDA", SPR::SDA}, {"SIA", SPR::SIA}, {"MMCR1", SPR::MMCR1},
|
||||
{"PMC3", SPR::PMC3}, {"PMC4", SPR::PMC4},
|
||||
};
|
||||
|
||||
static uint64_t reg_op(string& reg_name, uint64_t val, bool is_write) {
|
||||
|
||||
@@ -321,7 +321,8 @@ int main() {
|
||||
initialize_ppc_opcode_table(); //kludge
|
||||
// MPC601 sets MSR[ME] bit during hard reset / Power-On.
|
||||
// Also set MSR[FP] bit so we can test FPU instructions.
|
||||
ppc_state.msr = (MSR::ME | MSR::IP | MSR::FP);
|
||||
int new_msr = (MSR::ME | MSR::IP | MSR::FP);
|
||||
ppc_msr_did_change(ppc_state.msr, new_msr, false);
|
||||
|
||||
cout << "Running DingusPPC emulator tests..." << endl << endl;
|
||||
|
||||
|
||||
@@ -67,7 +67,8 @@ protected:
|
||||
virtual void set_register_3() {}
|
||||
|
||||
uint8_t exc_event_flag = 0;
|
||||
uint8_t srq_flag = 0;
|
||||
uint8_t srq_flag = 0;
|
||||
uint8_t led_state = 0;
|
||||
uint8_t my_addr = 0;
|
||||
uint8_t dev_handler_id = 0;
|
||||
bool got_collision = false;
|
||||
|
||||
@@ -35,13 +35,18 @@ AdbKeyboard::AdbKeyboard(std::string name) : AdbDevice(name) {
|
||||
|
||||
void AdbKeyboard::event_handler(const KeyboardEvent& event) {
|
||||
this->pending_events.push_back(std::make_unique<KeyboardEvent>(event));
|
||||
|
||||
if (this->pending_events.size() == 1) {
|
||||
this->srq_flag = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void AdbKeyboard::reset() {
|
||||
this->my_addr = ADB_ADDR_KBD;
|
||||
this->dev_handler_id = 2; // Extended ADB keyboard
|
||||
this->exc_event_flag = 1;
|
||||
this->srq_flag = 1; // enable service requests
|
||||
this->srq_flag = 0; // don't process keyboard service requests yet
|
||||
this->led_state = 0; // LEDs off
|
||||
this->pending_events.clear();
|
||||
}
|
||||
|
||||
@@ -53,6 +58,11 @@ bool AdbKeyboard::get_register_0() {
|
||||
out_buf[0] = this->consume_pending_event();
|
||||
out_buf[1] = this->consume_pending_event();
|
||||
this->host_obj->set_output_count(2);
|
||||
|
||||
if (this->pending_events.empty()) {
|
||||
this->srq_flag = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -68,14 +78,7 @@ uint8_t AdbKeyboard::consume_pending_event() {
|
||||
std::unique_ptr<KeyboardEvent> event = std::move(this->pending_events.front());
|
||||
this->pending_events.pop_front();
|
||||
|
||||
uint8_t key_state = 0;
|
||||
if (event->flags & KEYBOARD_EVENT_DOWN) {
|
||||
key_state = 0;
|
||||
} else if (event->flags & KEYBOARD_EVENT_UP) {
|
||||
key_state = 1;
|
||||
} else {
|
||||
LOG_F(WARNING, "%s: unknown keyboard event flags %x", this->name.c_str(), event->flags);
|
||||
}
|
||||
uint8_t key_state = (event->flags & KEYBOARD_EVENT_UP) ? 1 : 0;
|
||||
|
||||
if (this->dev_handler_id != 3) {
|
||||
switch (event->key) {
|
||||
@@ -88,7 +91,31 @@ uint8_t AdbKeyboard::consume_pending_event() {
|
||||
return (key_state << 7) | (event->key & 0x7F);
|
||||
}
|
||||
|
||||
bool AdbKeyboard::get_register_2() {
|
||||
uint8_t* out_buf = this->host_obj->get_output_buf();
|
||||
out_buf[0] = 0;
|
||||
out_buf[1] = this->led_state & 0x07;
|
||||
this->host_obj->set_output_count(2);
|
||||
return true;
|
||||
}
|
||||
|
||||
void AdbKeyboard::set_register_2() {
|
||||
if (this->host_obj->get_input_count() < 2)
|
||||
return;
|
||||
|
||||
const uint8_t* in_data = this->host_obj->get_input_buf();
|
||||
|
||||
this->led_state = in_data[1] & 0x07;
|
||||
}
|
||||
|
||||
bool AdbKeyboard::get_register_3() {
|
||||
uint8_t* out_buf = this->host_obj->get_output_buf();
|
||||
|
||||
out_buf[0] = (this->my_addr << 4) | (1 << 1) | 1; // Address + SRQ Enable + Exc Event
|
||||
out_buf[1] = this->dev_handler_id;
|
||||
|
||||
this->host_obj->set_output_count(2);
|
||||
return true;
|
||||
}
|
||||
|
||||
void AdbKeyboard::set_register_3() {
|
||||
|
||||
@@ -46,6 +46,8 @@ public:
|
||||
void event_handler(const KeyboardEvent& event);
|
||||
|
||||
bool get_register_0() override;
|
||||
bool get_register_2() override;
|
||||
bool get_register_3() override;
|
||||
void set_register_2() override;
|
||||
void set_register_3() override;
|
||||
|
||||
|
||||
@@ -21,13 +21,14 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
/** @file Basic ATA device emulation. */
|
||||
|
||||
#include <core/timermanager.h>
|
||||
#include <devices/common/ata/atabasedevice.h>
|
||||
#include <devices/common/ata/atadefs.h>
|
||||
#include <devices/common/ata/idechannel.h>
|
||||
#include <loguru.hpp>
|
||||
|
||||
#include <cstring>
|
||||
#include <cinttypes>
|
||||
#include <core/timermanager.h>
|
||||
|
||||
using namespace ata_interface;
|
||||
|
||||
@@ -110,7 +111,7 @@ uint16_t AtaBaseDevice::read(const uint8_t reg_addr) {
|
||||
void AtaBaseDevice::write(const uint8_t reg_addr, const uint16_t value) {
|
||||
switch (reg_addr) {
|
||||
case ATA_Reg::DATA:
|
||||
if (is_selected() && this->has_data()) {
|
||||
if (this->is_selected() && this->has_data()) {
|
||||
*this->cur_data_ptr++ = BYTESWAP_16(value);
|
||||
this->chunk_cnt -= 2;
|
||||
if (this->chunk_cnt <= 0) {
|
||||
@@ -159,7 +160,7 @@ void AtaBaseDevice::write(const uint8_t reg_addr, const uint16_t value) {
|
||||
break;
|
||||
}
|
||||
this->r_command = value;
|
||||
if (is_selected() || this->r_command == DIAGNOSTICS) {
|
||||
if (this->is_selected() || this->r_command == DIAGNOSTICS) {
|
||||
perform_command();
|
||||
}
|
||||
break;
|
||||
@@ -191,6 +192,38 @@ void AtaBaseDevice::device_control(const uint8_t new_ctrl) {
|
||||
this->r_dev_ctrl = new_ctrl;
|
||||
}
|
||||
|
||||
int AtaBaseDevice::pull_data(uint8_t *buf, int len) {
|
||||
if (!this->xfer_cnt || !this->is_dma_xfer)
|
||||
return 0;
|
||||
|
||||
int xfer_size = std::min(this->xfer_cnt, len);
|
||||
|
||||
if (this->xfer_cnt != len)
|
||||
LOG_F(WARNING, "%s: xfer_cnt != len", this->name.c_str());
|
||||
|
||||
//for (int i = 0; i < xfer_size >> 1; i++)
|
||||
// this->data_ptr[i] = BYTESWAP_16(this->data_ptr[i]);
|
||||
|
||||
std::memcpy(buf, this->data_ptr, xfer_size);
|
||||
|
||||
this->xfer_cnt -= xfer_size;
|
||||
if (!this->xfer_cnt) {
|
||||
TimerManager::get_instance()->add_oneshot_timer(500, [this]() {
|
||||
this->r_status &= ~(BSY | DRQ);
|
||||
this->update_intrq(1);
|
||||
});
|
||||
} else {
|
||||
this->r_status &= ~BSY;
|
||||
this->r_status |= DRQ;
|
||||
}
|
||||
|
||||
return xfer_size;
|
||||
}
|
||||
|
||||
int AtaBaseDevice::push_data(uint8_t *buf, int len) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void AtaBaseDevice::update_intrq(uint8_t new_intrq_state) {
|
||||
if (!this->is_selected() || (this->r_dev_ctrl & IEN))
|
||||
return;
|
||||
|
||||
@@ -47,6 +47,8 @@ public:
|
||||
|
||||
uint16_t read(const uint8_t reg_addr) override;
|
||||
void write(const uint8_t reg_addr, const uint16_t value) override;
|
||||
int pull_data(uint8_t *buf, int len) override;
|
||||
int push_data(uint8_t *buf, int len) override;
|
||||
|
||||
virtual int perform_command() = 0;
|
||||
|
||||
@@ -103,6 +105,7 @@ protected:
|
||||
int xfer_cnt = 0;
|
||||
int chunk_cnt = 0;
|
||||
int chunk_size = 0;
|
||||
bool is_dma_xfer = false;
|
||||
|
||||
std::function<void()> post_xfer_action = nullptr;
|
||||
};
|
||||
|
||||
@@ -56,7 +56,8 @@ enum ATA_Reg : int {
|
||||
COMMAND = 0x07, // command (write)
|
||||
ALT_STATUS = 0x16, // alt status (read)
|
||||
DEV_CTRL = 0x16, // device control (write)
|
||||
TIME_CONFIG = 0x20 // Apple ASIC specific timing configuration
|
||||
TIME_CONFIG = 0x20, // Apple ASIC specific timing configuration
|
||||
INT_REG = 0x30, // Interrupt Register (read) 0x40 = int request (KeyLargo only)
|
||||
};
|
||||
|
||||
/** ATAPI specific register offsets. */
|
||||
@@ -146,6 +147,7 @@ enum ATA_Cmd : uint8_t {
|
||||
WRITE_DMA = 0xCA,
|
||||
WRITE_DMA_NR = 0xCB,
|
||||
STANDBY_IMMEDIATE = 0xE0,
|
||||
SLEEP = 0xE6,
|
||||
FLUSH_CACHE = 0xE7, // ATA-5
|
||||
WRITE_BUFFER_DMA = 0xE9,
|
||||
READ_BUFFER_DMA = 0xEB,
|
||||
@@ -162,6 +164,8 @@ public:
|
||||
virtual ~AtaInterface() = default;
|
||||
virtual uint16_t read(const uint8_t reg_addr) = 0;
|
||||
virtual void write(const uint8_t reg_addr, const uint16_t val) = 0;
|
||||
virtual int pull_data(uint8_t *buf, int len) { return 0; };
|
||||
virtual int push_data(uint8_t *buf, int len) { return 0; };
|
||||
|
||||
virtual int get_device_id() = 0;
|
||||
virtual void pdiag_callback() {}
|
||||
|
||||
@@ -245,29 +245,32 @@ void AtaHardDisk::prepare_identify_info() {
|
||||
|
||||
std::memset(this->data_buf, 0, sizeof(this->data_buf));
|
||||
|
||||
buf_ptr[ 0] = 0x0040; // ATA device, non-removable media, non-removable drive
|
||||
buf_ptr[49] = 0x0200; // report LBA support
|
||||
WRITE_WORD_LE_A(&buf_ptr[ 0], 0x0040); // ATA device, non-removable media, non-removable drive
|
||||
WRITE_WORD_LE_A(&buf_ptr[49], 0x0200); // report LBA support
|
||||
|
||||
// Maximum number of logical sectors per data block that the device supports
|
||||
// for READ_MULTIPLE/WRITE_MULTIPLE commands.
|
||||
buf_ptr[47] = 0x8000 | SECTORS_PER_INT;
|
||||
WRITE_WORD_LE_A(&buf_ptr[47], 0x8000 | SECTORS_PER_INT);
|
||||
|
||||
// If bit 8 of word 59 is set to one, then bits 7:0 indicate the number of
|
||||
// logical sectors that shall be transferred per data block for
|
||||
// READ_MULTIPLE/WRITE_MULTIPLE commands.
|
||||
if (this->sectors_per_int)
|
||||
buf_ptr[59] = 0x100 | this->sectors_per_int;
|
||||
WRITE_WORD_LE_A(&buf_ptr[59], 0x100 | this->sectors_per_int);
|
||||
|
||||
buf_ptr[ 1] = this->cylinders;
|
||||
buf_ptr[ 3] = this->heads;
|
||||
buf_ptr[ 6] = this->sectors;
|
||||
WRITE_WORD_LE_A(&buf_ptr[ 1], this->cylinders);
|
||||
WRITE_WORD_LE_A(&buf_ptr[ 3], this->heads);
|
||||
WRITE_WORD_LE_A(&buf_ptr[ 6], this->sectors);
|
||||
|
||||
buf_ptr[57] = this->total_sectors & 0xFFFFU;
|
||||
buf_ptr[58] = (this->total_sectors >> 16) & 0xFFFFU;
|
||||
WRITE_WORD_LE_A(&buf_ptr[51], 0x0200); // max. PIO mode for a basic device
|
||||
|
||||
// report validity for the advanced PIO and MWDMA fields
|
||||
//WRITE_WORD_LE_A(&buf_ptr[53], 0x0003);
|
||||
|
||||
WRITE_DWORD_LE_A(&buf_ptr[57], this->total_sectors);
|
||||
|
||||
// report LBA capacity
|
||||
WRITE_WORD_LE_A(&buf_ptr[60], (this->total_sectors & 0xFFFFU));
|
||||
WRITE_WORD_LE_A(&buf_ptr[61], (this->total_sectors >> 16) & 0xFFFFU);
|
||||
WRITE_DWORD_LE_A(&buf_ptr[60], this->total_sectors);
|
||||
|
||||
WRITE_WORD_LE_A(&buf_ptr[63], ((1 << this->cur_dma_mode) << 8) | 7);
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ public:
|
||||
// methods to be implemented in the particular device
|
||||
int perform_command() override;
|
||||
virtual void perform_packet_command() = 0;
|
||||
virtual int get_config(uint8_t* pkt, uint8_t* buf) = 0;
|
||||
virtual int request_data() = 0;
|
||||
virtual bool data_available() = 0;
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#include <machines/machineproperties.h>
|
||||
#include <memaccess.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <core/timermanager.h>
|
||||
|
||||
@@ -315,6 +316,18 @@ void AtapiCdrom::perform_packet_command() {
|
||||
this->data_out_phase();
|
||||
break;
|
||||
}
|
||||
case ScsiCommand::GET_CONFIG: {
|
||||
this->xfer_cnt = this->get_config(this->cmd_pkt, this->data_buf);
|
||||
if (this->xfer_cnt == 0) {
|
||||
this->present_status();
|
||||
} else {
|
||||
this->xfer_cnt = std::min((int)this->r_byte_count, this->xfer_cnt);
|
||||
this->data_ptr = (uint16_t*)this->data_buf;
|
||||
this->status_good();
|
||||
this->data_out_phase();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_F(ERROR, "%s: unsupported ATAPI command 0x%X", this->name.c_str(),
|
||||
this->cmd_pkt[0]);
|
||||
@@ -323,6 +336,29 @@ void AtapiCdrom::perform_packet_command() {
|
||||
}
|
||||
}
|
||||
|
||||
int AtapiCdrom::get_config(uint8_t* pkt, uint8_t* buf) {
|
||||
std::memset(buf, 0, 16);
|
||||
|
||||
// Data length (4 bytes header + 8 bytes for one feature descriptor - 4 bytes for length field)
|
||||
uint32_t data_len = 8;
|
||||
buf[0] = (data_len >> 24) & 0xFF;
|
||||
buf[1] = (data_len >> 16) & 0xFF;
|
||||
buf[2] = (data_len >> 8) & 0xFF;
|
||||
buf[3] = data_len & 0xFF;
|
||||
|
||||
// Feature Descriptor 1 - Set profile to CD-ROM
|
||||
buf[6] = 0;
|
||||
buf[7] = 0x08;
|
||||
|
||||
// Feature Descriptor 2 - Feature Code, Version 0
|
||||
buf[8] = 0x00;
|
||||
buf[9] = 0x01; // Core Feature Code
|
||||
buf[10] = 0x03; // Persist and Current bits set
|
||||
buf[11] = 0x04; // Additional Length
|
||||
|
||||
return 12;
|
||||
}
|
||||
|
||||
int AtapiCdrom::request_data() {
|
||||
// continuation of READ_CD above
|
||||
|
||||
|
||||
@@ -42,6 +42,8 @@ public:
|
||||
|
||||
void perform_packet_command() override;
|
||||
|
||||
int get_config(uint8_t* pkt, uint8_t* buf) override;
|
||||
|
||||
int request_data() override;
|
||||
|
||||
bool data_available() override {
|
||||
|
||||
@@ -30,6 +30,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
and interrupt handling.
|
||||
*/
|
||||
|
||||
#include <core/timermanager.h>
|
||||
#include <devices/common/ata/atabasedevice.h>
|
||||
#include <devices/common/ata/atadefs.h>
|
||||
#include <devices/common/ata/idechannel.h>
|
||||
@@ -81,6 +82,21 @@ void IdeChannel::write(const uint8_t reg_addr, const uint32_t val, const int siz
|
||||
}
|
||||
}
|
||||
|
||||
int IdeChannel::xfer_from(uint8_t *buf, int len) {
|
||||
return this->devices[this->cur_dev]->pull_data(buf, len);
|
||||
}
|
||||
|
||||
int IdeChannel::xfer_to(uint8_t *buf, int len) {
|
||||
return this->devices[this->cur_dev]->push_data(buf, len);
|
||||
}
|
||||
|
||||
void IdeChannel::assert_dmareq(uint64_t delay) {
|
||||
TimerManager::get_instance()->add_oneshot_timer(delay, [this]() {
|
||||
//LOG_F(INFO, "%s: DMAREQ asserted", this->name.c_str());
|
||||
this->channel_obj->xfer_retry();
|
||||
});
|
||||
}
|
||||
|
||||
int MacioIdeChannel::device_postinit() {
|
||||
this->int_ctrl = dynamic_cast<InterruptCtrl*>(
|
||||
gMachineObj->get_comp_by_type(HWCompType::INT_CTRL));
|
||||
|
||||
@@ -25,6 +25,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#define IDE_CHANNEL_H
|
||||
|
||||
#include <devices/common/ata/atadefs.h>
|
||||
#include <devices/common/dmacore.h>
|
||||
#include <devices/common/hwcomponent.h>
|
||||
#include <devices/common/hwinterrupt.h>
|
||||
|
||||
@@ -33,7 +34,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
class IdeChannel : public HWComponent
|
||||
class IdeChannel : public HWComponent, public DmaDevice
|
||||
{
|
||||
public:
|
||||
IdeChannel(const std::string name);
|
||||
@@ -41,8 +42,11 @@ public:
|
||||
|
||||
void register_device(int id, AtaInterface* dev_obj);
|
||||
|
||||
uint32_t read(const uint8_t reg_addr, const int size);
|
||||
void write(const uint8_t reg_addr, const uint32_t val, const int size);
|
||||
virtual uint32_t read(const uint8_t reg_addr, const int size);
|
||||
virtual void write(const uint8_t reg_addr, const uint32_t val, const int size);
|
||||
|
||||
int xfer_from(uint8_t *buf, int len) override;
|
||||
int xfer_to(uint8_t *buf, int len) override;
|
||||
|
||||
void assert_pdiag() {
|
||||
this->devices[0]->pdiag_callback();
|
||||
@@ -60,6 +64,8 @@ public:
|
||||
this->irq_callback(intrq_state);
|
||||
}
|
||||
|
||||
void assert_dmareq(uint64_t delay);
|
||||
|
||||
protected:
|
||||
std::function<void(const uint8_t intrq_state)> irq_callback = nullptr;
|
||||
|
||||
@@ -87,8 +93,8 @@ public:
|
||||
|
||||
int device_postinit() override;
|
||||
|
||||
uint32_t read(const uint8_t reg_addr, const int size);
|
||||
void write(const uint8_t reg_addr, const uint32_t val, const int size);
|
||||
virtual uint32_t read(const uint8_t reg_addr, const int size) override;
|
||||
virtual void write(const uint8_t reg_addr, const uint32_t val, const int size) override;
|
||||
|
||||
private:
|
||||
uint32_t ch_config = 0; // timing configuration for this channel
|
||||
|
||||
@@ -313,6 +313,15 @@ uint32_t DMAChannel::reg_read(uint32_t offset, int size) {
|
||||
case DMAReg::CMD_PTR_LO:
|
||||
result = this->cmd_ptr;
|
||||
break;
|
||||
case DMAReg::INT_SELECT:
|
||||
result = this->int_select;
|
||||
break;
|
||||
case DMAReg::BRANCH_SELECT:
|
||||
result = this->branch_select;
|
||||
break;
|
||||
case DMAReg::WAIT_SELECT:
|
||||
result = this->wait_select;
|
||||
break;
|
||||
default:
|
||||
LOG_F(WARNING, "%s: Unsupported DMA channel register read at 0x%X",
|
||||
this->get_name().c_str(), offset);
|
||||
|
||||
@@ -291,7 +291,11 @@ void MeshController::step_completed() {
|
||||
}
|
||||
|
||||
void MeshController::report_error(const int error) {
|
||||
switch(error) {
|
||||
switch (error) {
|
||||
case ARB_LOST:
|
||||
this->exception |= EXC_ARB_LOST;
|
||||
this->int_stat |= INT_EXCEPTION;
|
||||
break;
|
||||
case SEL_TIMEOUT:
|
||||
this->exception |= EXC_SEL_TIMEOUT;
|
||||
this->int_stat |= INT_EXCEPTION;
|
||||
|
||||
@@ -143,6 +143,12 @@ enum ScsiCommand : uint8_t {
|
||||
READ_TOC = 0x43,
|
||||
SET_CD_SPEED = 0xBB,
|
||||
READ_CD = 0xBE,
|
||||
|
||||
// vendor specific commands
|
||||
VENDOR_09 = 0x09,
|
||||
EJECT = 0xC0,
|
||||
READ_CDDA = 0xD8, //TOSHIBA
|
||||
READ_CDDA_MSF = 0xD9, //TOSHIBA
|
||||
};
|
||||
|
||||
enum ScsiSense : int {
|
||||
|
||||
@@ -45,6 +45,8 @@ void ScsiCdrom::process_command()
|
||||
{
|
||||
uint32_t lba;
|
||||
|
||||
uint32_t cdda_start, cdda_end, cdda_len;
|
||||
|
||||
this->pre_xfer_action = nullptr;
|
||||
this->post_xfer_action = nullptr;
|
||||
|
||||
@@ -98,6 +100,19 @@ void ScsiCdrom::process_command()
|
||||
this->switch_phase(ScsiPhase::DATA_IN);
|
||||
}
|
||||
break;
|
||||
case ScsiCommand::READ_CDDA:
|
||||
lba = READ_DWORD_BE_U(&cmd[2]);
|
||||
cdda_len = READ_DWORD_BE_U(&cmd[6]);
|
||||
this->read(lba, cdda_len, 12);
|
||||
break;
|
||||
case ScsiCommand::READ_CDDA_MSF:
|
||||
cdda_start = (cmd[3] * 60 * 75) + (cmd[4] * 75) + cmd[5];
|
||||
cdda_end = (cmd[7] * 60 * 75) + (cmd[8] * 75) + cmd[9];
|
||||
|
||||
cdda_len = (cdda_end > cdda_start) ? (cdda_end - cdda_start) : 0;
|
||||
|
||||
this->read(cdda_start, cdda_len, 12);
|
||||
break;
|
||||
default:
|
||||
LOG_F(ERROR, "%s: unsupported command 0x%X", this->name.c_str(), cmd[0]);
|
||||
this->illegal_command(cmd);
|
||||
|
||||
+41
-28
@@ -502,6 +502,15 @@ void ViaCuda::error_response(uint32_t error) {
|
||||
this->is_open_ended = false;
|
||||
}
|
||||
|
||||
void ViaCuda::one_byte_header(uint32_t pkt_type) {
|
||||
this->out_buf[0] = pkt_type;
|
||||
this->out_count = 1;
|
||||
this->out_pos = 0;
|
||||
this->out_handler = &ViaCuda::out_buf_handler;
|
||||
this->next_out_handler = &ViaCuda::null_out_handler;
|
||||
this->is_open_ended = false;
|
||||
}
|
||||
|
||||
void ViaCuda::process_packet() {
|
||||
if (this->in_count < 2) {
|
||||
LOG_F(ERROR, "Cuda: invalid packet (too few data)!");
|
||||
@@ -529,17 +538,33 @@ void ViaCuda::process_packet() {
|
||||
}
|
||||
}
|
||||
|
||||
void ViaCuda::append_data(uint8_t* src, int len) {
|
||||
if (len > 0) {
|
||||
std::memcpy(&this->out_buf[this->out_count], src, len);
|
||||
this->out_count += len;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void ViaCuda::append_data(T data) {
|
||||
switch(sizeof(T)) {
|
||||
case 1: this->out_buf[this->out_count] = data;
|
||||
case 2: WRITE_WORD_BE_U( &this->out_buf[this->out_count], data);
|
||||
case 4: WRITE_DWORD_BE_U(&this->out_buf[this->out_count], data);
|
||||
}
|
||||
this->out_count += sizeof(T);
|
||||
}
|
||||
template void ViaCuda::append_data(uint8_t data);
|
||||
template void ViaCuda::append_data(uint16_t data);
|
||||
template void ViaCuda::append_data(uint32_t data);
|
||||
|
||||
void ViaCuda::process_adb_command() {
|
||||
uint8_t adb_stat, output_size;
|
||||
|
||||
adb_stat = this->adb_bus_obj->process_command(&this->in_buf[1],
|
||||
this->in_count - 1);
|
||||
response_header(CUDA_PKT_ADB, adb_stat);
|
||||
output_size = this->adb_bus_obj->get_output_count();
|
||||
if (output_size) {
|
||||
std::memcpy(&this->out_buf[3], this->adb_bus_obj->get_output_buf(), output_size);
|
||||
this->out_count += output_size;
|
||||
}
|
||||
this->append_data(this->adb_bus_obj->get_output_buf(), this->adb_bus_obj->get_output_count());
|
||||
}
|
||||
|
||||
void ViaCuda::autopoll_handler() {
|
||||
@@ -558,11 +583,7 @@ void ViaCuda::autopoll_handler() {
|
||||
// prepare autopoll packet
|
||||
response_header(CUDA_PKT_ADB, ADB_STAT_OK | ADB_STAT_AUTOPOLL);
|
||||
this->out_buf[2] = poll_command; // put the proper ADB command
|
||||
uint8_t output_size = this->adb_bus_obj->get_output_count();
|
||||
if (output_size) {
|
||||
std::memcpy(&this->out_buf[3], this->adb_bus_obj->get_output_buf(), output_size);
|
||||
this->out_count += output_size;
|
||||
}
|
||||
this->append_data(this->adb_bus_obj->get_output_buf(), this->adb_bus_obj->get_output_count());
|
||||
|
||||
// assert TREQ
|
||||
this->via_portb &= ~CUDA_TREQ;
|
||||
@@ -584,12 +605,10 @@ void ViaCuda::autopoll_handler() {
|
||||
this->out_buf[2] = CUDA_GET_REAL_TIME;
|
||||
if (send_time || this->one_sec_mode == 1) {
|
||||
uint32_t real_time = this_time + this->time_offset;
|
||||
WRITE_DWORD_BE_U(&this->out_buf[3], real_time);
|
||||
this->out_count = 7;
|
||||
this->append_data(real_time);
|
||||
}
|
||||
} else if (this->one_sec_mode == 3) {
|
||||
response_header(CUDA_PKT_TICK, 0);
|
||||
this->out_count = 1;
|
||||
one_byte_header(CUDA_PKT_TICK);
|
||||
}
|
||||
this->last_time = this_time;
|
||||
|
||||
@@ -631,11 +650,10 @@ void ViaCuda::pseudo_command() {
|
||||
this->next_out_handler = &ViaCuda::pram_out_handler;
|
||||
} else if (addr >= CUDA_ROM_START) {
|
||||
// HACK: Cuda ROM dump requsted so let's partially fake it
|
||||
this->out_buf[3] = 0; // empty copyright string
|
||||
WRITE_WORD_BE_A(&this->out_buf[4], 0x0019U);
|
||||
WRITE_WORD_BE_A(&this->out_buf[6], CUDA_FW_VERSION_MAJOR);
|
||||
WRITE_WORD_BE_A(&this->out_buf[8], CUDA_FW_VERSION_MINOR);
|
||||
this->out_count += 7;
|
||||
this->append_data(uint8_t(0)); // empty copyright string
|
||||
this->append_data(uint16_t(0x0019U));
|
||||
this->append_data(uint16_t(CUDA_FW_VERSION_MAJOR));
|
||||
this->append_data(uint16_t(CUDA_FW_VERSION_MINOR));
|
||||
}
|
||||
this->is_open_ended = true;
|
||||
break;
|
||||
@@ -643,8 +661,7 @@ void ViaCuda::pseudo_command() {
|
||||
response_header(CUDA_PKT_PSEUDO, 0);
|
||||
uint32_t this_time = this->calc_real_time();
|
||||
uint32_t real_time = this_time + this->time_offset;
|
||||
WRITE_DWORD_BE_U(&this->out_buf[3], real_time);
|
||||
this->out_count = 7;
|
||||
this->append_data(real_time);
|
||||
break;
|
||||
}
|
||||
case CUDA_WRITE_MCU_MEM:
|
||||
@@ -707,19 +724,15 @@ void ViaCuda::pseudo_command() {
|
||||
break;
|
||||
case CUDA_GET_AUTOPOLL_RATE:
|
||||
response_header(CUDA_PKT_PSEUDO, 0);
|
||||
this->out_buf[3] = this->poll_rate;
|
||||
this->out_count++;
|
||||
this->append_data(this->poll_rate);
|
||||
break;
|
||||
case CUDA_SET_DEVICE_BITMAP:
|
||||
this->device_mask = READ_WORD_BE_U(&this->in_buf[2]);
|
||||
response_header(CUDA_PKT_PSEUDO, 0);
|
||||
this->device_mask = ((uint16_t)this->in_buf[2]) << 8;
|
||||
this->device_mask |= ((uint16_t)this->in_buf[3]);
|
||||
break;
|
||||
case CUDA_GET_DEVICE_BITMAP:
|
||||
response_header(CUDA_PKT_PSEUDO, 0);
|
||||
this->out_buf[2] = (uint8_t)((this->device_mask >> 8) & 0xFF);
|
||||
this->out_buf[3] = (uint8_t)((this->device_mask) & 0xFF);
|
||||
this->out_count += 2;
|
||||
this->append_data(this->device_mask);
|
||||
break;
|
||||
case CUDA_ONE_SECOND_MODE:
|
||||
LOG_F(INFO, "Cuda: One Second Interrupt Mode: %d", this->in_buf[2]);
|
||||
|
||||
@@ -266,6 +266,9 @@ private:
|
||||
void write(uint8_t new_state);
|
||||
void response_header(uint32_t pkt_type, uint32_t pkt_flag);
|
||||
void error_response(uint32_t error);
|
||||
void one_byte_header(uint32_t pkt_type);
|
||||
inline void append_data(uint8_t* src, int len);
|
||||
template <class T> inline void append_data(T data);
|
||||
void process_packet();
|
||||
void process_adb_command();
|
||||
void pseudo_command();
|
||||
|
||||
@@ -31,9 +31,19 @@ using namespace MaceEnet;
|
||||
|
||||
uint8_t MaceController::read(uint8_t reg_offset)
|
||||
{
|
||||
switch(reg_offset) {
|
||||
switch (reg_offset) {
|
||||
case MaceReg::Rcv_FIFO:
|
||||
return 0; //No FIFO yet
|
||||
case MaceReg::Rcv_Frame_Ctrl:
|
||||
return this->rcv_fc;
|
||||
case MaceReg::Xmit_Frame_Stat:
|
||||
return this->xmt_fs;
|
||||
case MaceReg::Xmit_Retry_Cnt:
|
||||
return this->xmt_retry;
|
||||
case MaceReg::Rcv_Frame_Stat:
|
||||
return this->rcv_fs;
|
||||
case MaceReg::FIFO_Frame_Cnt:
|
||||
return this->fifo_fc;
|
||||
case MaceReg::Interrupt: {
|
||||
uint8_t ret_val = this->int_stat;
|
||||
this->int_stat = 0;
|
||||
@@ -42,12 +52,26 @@ uint8_t MaceController::read(uint8_t reg_offset)
|
||||
}
|
||||
case MaceReg::Interrupt_Mask:
|
||||
return this->int_mask;
|
||||
case MaceReg::Poll:
|
||||
return this->poll_reg;
|
||||
case MaceReg::BIU_Config_Ctrl:
|
||||
return this->biu_ctrl;
|
||||
case MaceReg::FIFO_Config:
|
||||
return this->fifo_ctrl;
|
||||
case MaceReg::MAC_Config_Ctrl:
|
||||
return this->mac_cc;
|
||||
case MaceReg::PLS_Config_Ctrl:
|
||||
return this->pls_cc;
|
||||
case MaceReg::PHY_Config_Ctrl:
|
||||
return this->phy_cc;
|
||||
case MaceReg::Chip_ID_Lo:
|
||||
return this->chip_id & 0xFFU;
|
||||
case MaceReg::Chip_ID_Hi:
|
||||
return (this->chip_id >> 8) & 0xFFU;
|
||||
case MaceReg::Int_Addr_Config:
|
||||
return this->addr_cfg;
|
||||
case MaceReg::Missed_Pkt_Cnt:
|
||||
return this->missed_pkts;
|
||||
default:
|
||||
LOG_F(INFO, "%s: reading from register %d", this->name.c_str(), reg_offset);
|
||||
}
|
||||
@@ -64,9 +88,6 @@ void MaceController::write(uint8_t reg_offset, uint8_t value)
|
||||
case MaceReg::Interrupt_Mask:
|
||||
this->int_mask = value;
|
||||
break;
|
||||
case MaceReg::MAC_Config_Ctrl:
|
||||
this->mac_cfg = value;
|
||||
break;
|
||||
case MaceReg::BIU_Config_Ctrl:
|
||||
if (value & BIU_SWRST) {
|
||||
LOG_F(INFO, "%s: soft reset asserted", this->name.c_str());
|
||||
@@ -74,6 +95,12 @@ void MaceController::write(uint8_t reg_offset, uint8_t value)
|
||||
}
|
||||
this->biu_ctrl = value;
|
||||
break;
|
||||
case MaceReg::FIFO_Config:
|
||||
this->fifo_ctrl = value;
|
||||
break;
|
||||
case MaceReg::MAC_Config_Ctrl:
|
||||
this->mac_cfg = value;
|
||||
break;
|
||||
case MaceReg::PLS_Config_Ctrl:
|
||||
if (value != 7)
|
||||
LOG_F(WARNING, "%s: unsupported transceiver interface 0x%X in PLSCC",
|
||||
|
||||
+20
-8
@@ -99,14 +99,26 @@ public:
|
||||
void write(uint8_t reg_offset, uint8_t value);
|
||||
|
||||
private:
|
||||
uint16_t chip_id; // per-instance MACE Chip ID
|
||||
uint8_t addr_cfg = 0;
|
||||
uint8_t addr_ptr = 0;
|
||||
uint8_t rcv_fc = 1;
|
||||
uint8_t biu_ctrl = 0;
|
||||
uint8_t mac_cfg = 0;
|
||||
uint64_t phys_addr = 0;
|
||||
uint64_t log_addr = 0;
|
||||
uint16_t chip_id; // per-instance MACE Chip ID
|
||||
uint8_t addr_cfg = 0;
|
||||
uint8_t addr_ptr = 0;
|
||||
uint8_t xmt_fs = 0;
|
||||
uint8_t xmt_retry = 0;
|
||||
uint8_t rcv_fc = 1;
|
||||
uint8_t rcv_fs = 0;
|
||||
uint8_t biu_ctrl = 0;
|
||||
uint8_t fifo_ctrl = 0;
|
||||
|
||||
uint8_t poll_reg = 0;
|
||||
|
||||
uint8_t mac_cfg = 0;
|
||||
uint8_t mac_cc = 0;
|
||||
uint8_t pls_cc = 0;
|
||||
uint8_t phy_cc = 0;
|
||||
uint8_t fifo_fc = 0;
|
||||
uint8_t missed_pkts = 0;
|
||||
uint64_t phys_addr = 0;
|
||||
uint64_t log_addr = 0;
|
||||
|
||||
// interrupt stuff
|
||||
uint8_t int_stat = 0;
|
||||
|
||||
@@ -34,8 +34,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
static FlopImgType identify_image(ImgFile& img_file)
|
||||
{
|
||||
// WOZ images identification strings
|
||||
static uint8_t WOZ1_SIG[] = {0x57, 0x4F, 0x5A, 0x31, 0xFF, 0x0A, 0x0D, 0x0A};
|
||||
static uint8_t WOZ2_SIG[] = {0x57, 0x4F, 0x5A, 0x32, 0xFF, 0x0A, 0x0D, 0x0A};
|
||||
static const uint8_t WOZ1_SIG[] = {0x57, 0x4F, 0x5A, 0x31, 0xFF, 0x0A, 0x0D, 0x0A};
|
||||
static const uint8_t WOZ2_SIG[] = {0x57, 0x4F, 0x5A, 0x32, 0xFF, 0x0A, 0x0D, 0x0A};
|
||||
|
||||
uint8_t buf[8] = { 0 };
|
||||
|
||||
@@ -47,20 +47,23 @@ static FlopImgType identify_image(ImgFile& img_file)
|
||||
} else if (!std::memcmp(buf, WOZ2_SIG, sizeof(buf))) {
|
||||
return FlopImgType::WOZ2;
|
||||
} else {
|
||||
for (int offset = 0; offset <=84; offset += 84) {
|
||||
auto check_hfs_mfs = [](ImgFile& img, std::size_t offset) -> bool {
|
||||
/* 2 bytes needed for MFS/HFS signature */
|
||||
unsigned char buf[2];
|
||||
|
||||
// rewind to logical block 2
|
||||
img_file.read((char *)buf, 2*BLOCK_SIZE + offset, sizeof(buf));
|
||||
img.read((char *)buf, 2*BLOCK_SIZE + offset, sizeof(buf));
|
||||
|
||||
// check for HFS/MFS signature at the start of the logical block 2
|
||||
if ((buf[0] == 0x42 && buf[1] == 0x44) ||
|
||||
(buf[0] == 0xD2 && buf[1] == 0xD7)) {
|
||||
if (offset) {
|
||||
return FlopImgType::DC42;
|
||||
} else {
|
||||
return FlopImgType::RAW;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ((buf[0] == 0x42 && buf[1] == 0x44)
|
||||
|| (buf[0] == 0xD2 && buf[1] == 0xD7));
|
||||
};
|
||||
|
||||
if (check_hfs_mfs(img_file, 84))
|
||||
return FlopImgType::DC42;
|
||||
|
||||
if (check_hfs_mfs(img_file, 0))
|
||||
return FlopImgType::RAW;
|
||||
}
|
||||
|
||||
return FlopImgType::UNKNOWN;
|
||||
|
||||
@@ -350,10 +350,22 @@ public:
|
||||
return std::unique_ptr<MacIoTwo>(new MacIoTwo("paddington", MIO_DEV_ID_PADDINGTON));
|
||||
}
|
||||
|
||||
void set_fp_id(uint8_t id) {
|
||||
this->fp_id = id;
|
||||
}
|
||||
|
||||
void set_mon_id(uint8_t id) {
|
||||
this->mon_id = id;
|
||||
}
|
||||
|
||||
void set_media_bay_id(uint8_t id) {
|
||||
this->mb_id = id;
|
||||
}
|
||||
|
||||
void set_cpu_id(uint8_t id) {
|
||||
this->cpu_id = id;
|
||||
}
|
||||
|
||||
// MMIO device methods
|
||||
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;
|
||||
|
||||
@@ -39,9 +39,18 @@ MacIoTwo::MacIoTwo(std::string name, uint16_t dev_id) : MacIoBase(name, dev_id)
|
||||
|
||||
// connect IDE HW
|
||||
this->ide_0 = dynamic_cast<IdeChannel*>(gMachineObj->get_comp_by_name("Ide0"));
|
||||
this->ide_1 = dynamic_cast<IdeChannel*>(gMachineObj->get_comp_by_name("Ide1"));
|
||||
this->ide0_dma = std::unique_ptr<DMAChannel> (new DMAChannel("Ide0-Dma"));
|
||||
this->ide0_dma->register_dma_int(this, this->register_dma_int(IntSrc::DMA_IDE0));
|
||||
this->ide0_dma->connect(this->ide_0);
|
||||
this->ide_0->connect(this->ide0_dma.get());
|
||||
|
||||
this->ide_1 = dynamic_cast<IdeChannel*>(gMachineObj->get_comp_by_name_optional("Ide1"));
|
||||
this->ide1_dma = std::unique_ptr<DMAChannel> (new DMAChannel("Ide1-Dma"));
|
||||
this->ide1_dma->register_dma_int(this, this->register_dma_int(IntSrc::DMA_IDE1));
|
||||
if (this->ide_1) {
|
||||
this->ide1_dma->connect(this->ide_1);
|
||||
this->ide_1->connect(this->ide1_dma.get());
|
||||
}
|
||||
|
||||
// connect Ethernet HW (Heathrow and Paddington)
|
||||
if (this->device_id != MIO_DEV_ID_OHARE) {
|
||||
@@ -101,10 +110,10 @@ uint32_t MacIoTwo::read(uint32_t rgn_start, uint32_t offset, int size) {
|
||||
value = this->viacuda->read((offset >> 9) & 0xF);
|
||||
break;
|
||||
case 0x20: // IDE 0
|
||||
value = this->ide_0->read((offset >> 4) & 0x1F, size);
|
||||
value = this->ide_0->read((offset >> 4) & 0x3F, size);
|
||||
break;
|
||||
case 0x21: // IDE 1
|
||||
value = this->ide_1->read((offset >> 4) & 0x1F, size);
|
||||
value = this->ide_1 ? this->ide_1->read((offset >> 4) & 0x3F, size) : 0;
|
||||
break;
|
||||
default:
|
||||
if (sub_addr >= 0x60) {
|
||||
@@ -163,10 +172,11 @@ void MacIoTwo::write(uint32_t rgn_start, uint32_t offset, uint32_t value, int si
|
||||
this->viacuda->write((offset >> 9) & 0xF, value);
|
||||
break;
|
||||
case 0x20: // IDE 0
|
||||
this->ide_0->write((offset >> 4) & 0x1F, value, size);
|
||||
this->ide_0->write((offset >> 4) & 0x3F, value, size);
|
||||
break;
|
||||
case 0x21: // IDE 1
|
||||
this->ide_1->write((offset >> 4) & 0x1F, value, size);
|
||||
if (this->ide_1)
|
||||
this->ide_1->write((offset >> 4) & 0x3F, value, size);
|
||||
break;
|
||||
default:
|
||||
if (sub_addr >= 0x60) {
|
||||
|
||||
@@ -27,6 +27,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include <cinttypes>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
PsxCtrl::PsxCtrl(int bridge_num, std::string name)
|
||||
{
|
||||
|
||||
@@ -135,12 +135,39 @@ uint32_t CdromDrive::mode_sense_ex(bool is_sense_6, uint8_t* cmd_ptr, uint8_t* d
|
||||
resp_ptr[0] = page_code;
|
||||
|
||||
switch (page_code) {
|
||||
case 0x01:
|
||||
case ModePage::READ_ERROR_RECOVERY:
|
||||
resp_ptr[1] = 6; // data size
|
||||
std::memset(&resp_ptr[2], 0, 6);
|
||||
data_ptr[1] += 8; // adjust overall length
|
||||
break;
|
||||
case 0x2A:
|
||||
case ModePage::CDROM_AUDIO:
|
||||
resp_ptr[1] = 16; // page length
|
||||
std::memset(&resp_ptr[2], 0, 16);
|
||||
resp_ptr[2] = (1 << 2); //immediately return status
|
||||
|
||||
WRITE_WORD_BE_A(&resp_ptr[6], 75); // logical block per second of audio playback
|
||||
|
||||
resp_ptr[8] = 0x01; // Left Channel
|
||||
resp_ptr[9] = 0xFF; // Volume (0-255)
|
||||
resp_ptr[10] = 0x02; // Right Channel
|
||||
resp_ptr[11] = 0xFF; // Volume (0-255)
|
||||
|
||||
resp_ptr[12] = 0x04; // Output Port 2
|
||||
resp_ptr[13] = 0x00; // Volume (0-255)
|
||||
resp_ptr[14] = 0x08; // Output Port 3
|
||||
resp_ptr[15] = 0x00; // Volume (0-255)
|
||||
|
||||
data_ptr[1] += 8; // adjust overall length
|
||||
break;
|
||||
case ModePage::POWER_CONDITION:
|
||||
resp_ptr[1] = 10; // page length
|
||||
std::memset(&resp_ptr[2], 0, 10);
|
||||
resp_ptr[3] = 0; //idle and standby off
|
||||
WRITE_DWORD_BE_A(&resp_ptr[4], 0); // Idle Timer (100ms units)
|
||||
WRITE_DWORD_BE_A(&resp_ptr[8], 0); // Standby Timer (100ms units)
|
||||
data_ptr[1] += 12; // adjust overall length
|
||||
break;
|
||||
case ModePage::CDROM_CAPABILITIES:
|
||||
resp_ptr[1] = 18; // page data length
|
||||
std::memset(&resp_ptr[2], 0, 18);
|
||||
resp_ptr[2] = 0x03; // supports reading CD-R and CD-E
|
||||
@@ -152,7 +179,7 @@ uint32_t CdromDrive::mode_sense_ex(bool is_sense_6, uint8_t* cmd_ptr, uint8_t* d
|
||||
WRITE_WORD_BE_A(&resp_ptr[14], 706); // report current speed (4x)
|
||||
data_ptr[1] += 20; // adjust overall length
|
||||
break;
|
||||
case 0x31:
|
||||
case ModePage::VENDOR_PAGE_31:
|
||||
resp_ptr[1] = 14; // page data length
|
||||
std::memset(&resp_ptr[2], 0, 14);
|
||||
resp_ptr[8] = 0x31;
|
||||
|
||||
@@ -44,6 +44,16 @@ typedef struct {
|
||||
uint32_t start_lba;
|
||||
} TrackDescriptor;
|
||||
|
||||
enum ModePage {
|
||||
READ_ERROR_RECOVERY = 1,
|
||||
CDROM_PARAMS = 0xD,
|
||||
CDROM_AUDIO = 0xE,
|
||||
POWER_CONDITION = 0x1A,
|
||||
CDROM_CAPABILITIES = 0x2A,
|
||||
VENDOR_PAGE_31 = 0x31,
|
||||
ALL_PAGES = 0x3F,
|
||||
};
|
||||
|
||||
constexpr auto CDROM_MAX_TRACKS = 100;
|
||||
constexpr auto LEAD_OUT_TRK_NUM = 0xAA;
|
||||
constexpr auto CDR_STD_DATA_SIZE = 2048;
|
||||
|
||||
@@ -61,17 +61,25 @@ Display::Display(): impl(std::make_unique<Impl>()) {
|
||||
}
|
||||
|
||||
Display::~Display() {
|
||||
if (impl->cursor_texture)
|
||||
if (impl->cursor_texture) {
|
||||
SDL_DestroyTexture(impl->cursor_texture);
|
||||
impl->cursor_texture = 0;
|
||||
}
|
||||
|
||||
if (impl->disp_texture)
|
||||
if (impl->disp_texture) {
|
||||
SDL_DestroyTexture(impl->disp_texture);
|
||||
impl->disp_texture = 0;
|
||||
}
|
||||
|
||||
if (impl->renderer)
|
||||
if (impl->renderer) {
|
||||
SDL_DestroyRenderer(impl->renderer);
|
||||
impl->renderer = 0;
|
||||
}
|
||||
|
||||
if (impl->display_wnd)
|
||||
if (impl->display_wnd) {
|
||||
SDL_DestroyWindow(impl->display_wnd);
|
||||
impl->display_wnd = 0;
|
||||
}
|
||||
}
|
||||
|
||||
const double scale_step = std::pow(2.0, 1.0/8.0);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
The AMIC is the I/O controller used in the Power Mac 6100. Physically, it's located at 0x50F00000.
|
||||
The AMIC is the I/O controller used in the Power Mac 6100. Appropriately, it's the abbreviation for Apple Memory Mapped I/O Controller.
|
||||
Physically, it's located at 0x50F00000.
|
||||
|
||||
It also:
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ It also has a unique 37-pin connector dubbed the Geekport to allow hobbyists to
|
||||
| CPU 0 Interrupt Mask | 0x7FFFF0F0 | |
|
||||
| CPU 1 Interrupt Mask | 0x7FFFF1F0 | |
|
||||
| Interrupt sources | 0x7FFFF2F0 | |
|
||||
| Cross-proccessor interrupts | 0x7FFFF3F0 | |
|
||||
| Cross-processor interrupts | 0x7FFFF3F0 | |
|
||||
| Proc. resets, other stuff | 0x7FFFF4F0 | |
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# ROM
|
||||
# ROMs
|
||||
|
||||
The Old World ROM is always 4 megabytes (MB). The first three MB are reserved for the 68k code, while the last MB is for the PowerPC boot-up code.
|
||||
Old World ROMs are always 4 megabytes (MB). The first three MB are reserved for the 68k code, while the last MB is for the PowerPC boot-up code.
|
||||
|
||||
New World ROMs are 1 MB stubs containing Open Firmware and some basic drivers, but has an additional ROM stored on the Mac's hard disk to provide Toolbox functionality. The ROMs stored on the Mac's hard disk also had updates distributed.
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ pci_B1
|
||||
pci_C1
|
||||
```
|
||||
|
||||
Specified what devices are conntected to a particular PCI slot. Not supported on NuBus machines such as the Power Mac 6100.
|
||||
Specified what devices are connected to a particular PCI slot. Not supported on NuBus machines such as the Power Mac 6100.
|
||||
|
||||
```
|
||||
--adb_devices TEXT
|
||||
@@ -214,7 +214,7 @@ Currently, the Power Mac 6100 cannot boot any OS image containing Mac OS 9.0 or
|
||||
|
||||
### ATI Mach Support
|
||||
|
||||
The GUI engine is currently not fully implemented. As such, UI elements might not be rendered when trying to use this video card. To circumenvent this, you may wish to move the ATI Accelerator extension to the Extensions (Disabled) folder.
|
||||
The GUI engine is currently not fully implemented. As such, UI elements might not be rendered when trying to use this video card. To circumvent this, you may wish to move the ATI Accelerator extension to the Extensions (Disabled) folder.
|
||||
|
||||
### Currently Unimplemented Features
|
||||
|
||||
|
||||
Reference in new issue
Block a user