Compare commits

..
Author SHA1 Message Date
dingusdev 117b8dccfc Just trying to push silence in 2026-01-06 08:06:11 -07:00
dingusdev 2b4b0e8320 More work to help diagnose the issue 2026-01-05 18:56:21 -07:00
dingusdev 90d050531e Quick hack for Burgundy 2026-01-03 20:59:33 -07:00
dingusdev b5ddcf8ece Merge branch 'master' into awacs-pdm-fix 2026-01-03 19:17:48 -07:00
dingusdev dbc10ab027 Clean-up for mode_sense_ex 2026-01-03 16:44:08 -07:00
joevt 383f6dd9a1 atahd: Fix endianness in prepare_identify_info.
Use endian macros for fields that have a specific endianness.
2026-01-03 11:22:19 -07:00
joevt be04300846 ppcexec: Add missing registers for disassembly. 2026-01-03 11:18:33 -07:00
dingusdev e97da11386 First attempt at adding sound interrupt logic 2026-01-02 21:15:37 -07:00
dingusdev 10be145179 More fixes 2026-01-02 18:20:39 -07:00
Maxim Poliakovski 80c1ebe57d atahd: report max. PIO mode for a basic device.
Prepare identify info for advanced PIO and
Multiword DMA modes but leave them disabled
because ATA DMA doesn't work yet.
2026-01-02 22:12:53 +01:00
Maxim Poliakovski 5996358308 maciotwo: initialize and connect IDE DMA channels. 2026-01-02 21:30:21 +01:00
Maxim Poliakovski 380827e09b idechannel: inherit IdeChannel from DmaDevice. 2026-01-02 21:30:21 +01:00
Maxim Poliakovski c4be881d52 atabasedevice: add push_data and pull_data methods. 2026-01-02 21:30:21 +01:00
dingusdev 0236493902 More things to help diagnose AWACS freeze-ups 2026-01-01 21:54:05 -07:00
dingusdev b87585cf0e Merge branch 'master' into awacs-pdm-fix 2026-01-01 20:01:39 -07:00
joevt ae56bb3743 viacuda: Add append_data for setting out_buf. 2026-01-01 07:25:30 -07:00
joevt fd5bcddcb7 viacuda: Create method for single byte packets. 2026-01-01 07:20:24 -07:00
joevt af8124a525 display_sdl: Set to null after destroy. 2026-01-01 07:14:28 -07:00
dingusdev 8105defb0b Fill out MACE stub further
Last commit of 2025. This will be further expanded next year.
2025-12-31 21:29:49 -07:00
dingusdev 7429a4111e atadefs.h: add SLEEP command code. 2025-12-29 18:37:53 +01:00
dingusdev a69bffaad4 Merge branch 'master' into awacs-pdm-fix 2025-12-27 16:48:02 -07:00
dingusdev a537d09c63 Add Page Code 0x1a for CD ROM 2025-12-27 16:01:57 -07:00
dingusdev 7fdb11d64f Another fix-up attempt 2025-12-26 18:16:25 -07:00
dingusdev 5567041c2b Fix std prefix 2025-12-26 08:07:31 -07:00
dingusdev c94cfe0d40 Add GET_CONFIG to ATAPI CD-ROM 2025-12-26 07:22:48 -07:00
dingusdev 38ba5cbfa8 More work
Currently causes the PM6100 to stunlock after a warning message.
2025-12-20 10:12:16 -07:00
dingusdev 74b851d4e0 A little extra to add 2025-12-18 21:41:44 -07:00
dingusdev b3a38cdac3 More work 2025-12-18 20:51:41 -07:00
dingusdev 70da33b2af Initial AWACS DMA IN fix 2025-12-17 20:16:41 -07:00
Maxim Poliakovski 73d5a2374b viacuda: fix GET/SET_DEVICE_BITMAP again.
Keep only related stuff this time.
2025-12-08 02:53:36 +01:00
Maxim Poliakovski 017f559e90 Revert "viacuda: Fix CUDA_GET_DEVICE_BITMAP."
This reverts commit 2b0b926f52.
2025-12-08 02:53:36 +01:00
dingusdev 29f9ab14ee Merge pull request #157 from mrpapersonic/floppy-cleanup
Clean up floppy signature detection code.
2025-12-06 15:04:39 -07:00
dingusdev 17b2a1a6e4 Merge pull request #158 from mrpapersonic/libstdcpp-build-fix
Fix build fail on linux/libstdc++
2025-12-06 11:58:11 -07:00
Paper 77f1f72122 devices/memctrl/psx: fixed build fail on linux/libstdc++ 2025-12-06 13:00:46 -05:00
Paper 03ec9d9589 devices/floppy/floppyimg: use lambda function for HFS/MFS signature check
this is more obvious to read at a glance.
2025-12-06 08:51:35 -05:00
dingusdev b813a080da Add additional registers to read for DMAReg 2025-12-04 06:52:48 -07:00
joevt 2b0b926f52 viacuda: Fix CUDA_GET_DEVICE_BITMAP.
Bitmap should be at byte 3 and 4, not 2 and 3.
2025-12-02 07:44:53 -07:00
dingusdev 0ac0a5b77e Handle arbitration lost in Mesh 2025-12-01 08:29:05 -07:00
31 changed files with 522 additions and 123 deletions

No files matched your search

+2
View File
@@ -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
View File
@@ -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) {
+34 -1
View File
@@ -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;
@@ -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;
+3
View File
@@ -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;
};
+3
View File
@@ -146,6 +146,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 +163,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() {}
+14 -11
View File
@@ -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);
}
+1
View File
@@ -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;
+36
View File
@@ -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
+2
View File
@@ -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 {
+16
View File
@@ -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));
+7 -1
View File
@@ -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);
@@ -44,6 +45,9 @@ public:
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);
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;
+12 -3
View File
@@ -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);
@@ -479,7 +488,7 @@ DmaPullResult DMAChannel::pull_data(uint32_t req_len, uint32_t *avail_len, uint8
if (this->ch_stat & CH_STAT_DEAD || !(this->ch_stat & CH_STAT_ACTIVE)) {
// dead or idle channel? -> no more data
LOG_F(WARNING, "%s: Dead/idle channel -> no more data", this->get_name().c_str());
return DmaPullResult::NoMoreData;
return DmaPullResult::NoMorePullData;
}
// interpret DBDMA program until we get data or become idle
@@ -504,10 +513,10 @@ DmaPullResult DMAChannel::pull_data(uint32_t req_len, uint32_t *avail_len, uint8
this->res_count += this->queue_len;
this->queue_len = 0;
}
return DmaPullResult::MoreData; // tell the caller there is more data
return DmaPullResult::MorePullData; // tell the caller there is more data
}
return DmaPullResult::NoMoreData; // tell the caller there is no more data
return DmaPullResult::NoMorePullData; // tell the caller there is no more data
}
int DMAChannel::push_data(const char* src_ptr, int len) {
+7 -2
View File
@@ -29,8 +29,13 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <string>
enum DmaPullResult : int {
MoreData, // data source has more data to be pulled
NoMoreData, // data source has no more data to be pulled
MorePullData, // data source has more data to be pulled
NoMorePullData, // data source has no more data to be pulled
};
enum DmaPushResult : int {
MorePushData, // data source has more data to be pushed
NoMorePushData, // data source has no more data to be pushed
};
class DmaOutChannel {
+5 -1
View File
@@ -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;
+41 -28
View File
@@ -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]);
+3
View File
@@ -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 -4
View File
@@ -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
View File
@@ -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;
+16 -13
View File
@@ -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;
+121 -23
View File
@@ -78,8 +78,11 @@ AMIC::AMIC() : MMIODevice()
// initialize sound HW
this->snd_out_dma = std::unique_ptr<AmicSndOutDma>(new AmicSndOutDma());
this->snd_out_dma->init_interrupts(this, DMA1_INT_SOUND << DMA1_INT_SHIFT);
this->snd_in_dma = std::unique_ptr<AmicSndInDma>(new AmicSndInDma());
this->snd_in_dma->init_interrupts(this, DMA0_INT_SOUND << DMA0_INT_SHIFT);
this->awacs = std::unique_ptr<AwacDevicePdm> (new AwacDevicePdm());
this->awacs->set_dma_out(this->snd_out_dma.get());
this->awacs->set_dma_in(this->snd_in_dma.get());
// initialize on-board video
this->disp_id = std::unique_ptr<DisplayID> (new DisplayID());
@@ -150,6 +153,10 @@ uint32_t AMIC::read(uint32_t rgn_start, uint32_t offset, int size)
}
case 0x14: // Sound registers
switch (offset) {
case AMICReg::Snd_Ctrl_0:
case AMICReg::Snd_Ctrl_1:
case AMICReg::Snd_Ctrl_2:
return this->imm_snd_regs[offset & 3];
case AMICReg::Snd_Stat_0:
case AMICReg::Snd_Stat_1:
case AMICReg::Snd_Stat_2:
@@ -167,8 +174,12 @@ uint32_t AMIC::read(uint32_t rgn_start, uint32_t offset, int size)
}
case AMICReg::Snd_Out_Ctrl:
return this->snd_out_ctrl;
case AMICReg::Snd_In_Ctrl:
return this->snd_in_ctrl;
case AMICReg::Snd_Out_DMA:
return this->snd_out_dma->read_stat();
case AMICReg::Snd_In_DMA:
return this->snd_in_dma->read_stat();
}
break;
case 0x16: // SWIM3 registers
@@ -250,19 +261,19 @@ void AMIC::write(uint32_t rgn_start, uint32_t offset, uint32_t value, int size)
uint32_t mask;
// subdevices registers
switch(offset >> 12) {
case 0: // VIA1 registers
switch (offset >> 12) {
case 0: // VIA1 registers
case 1:
this->viacuda->write(offset >> 9, value);
return;
case 4: // SCC registers
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
case 0xA: // MACE registers
this->mace->write((offset >> 4) & 0x1F, value);
return;
case 0x10:
@@ -271,8 +282,8 @@ void AMIC::write(uint32_t rgn_start, uint32_t offset, uint32_t value, int size)
else
this->scsi->write((offset >> 4) & 0xF, value);
return;
case 0x14: // Sound registers
switch(offset) {
case 0x14: // Sound registers
switch (offset) {
case AMICReg::Snd_Ctrl_0:
case AMICReg::Snd_Ctrl_1:
case AMICReg::Snd_Ctrl_2:
@@ -282,42 +293,66 @@ void AMIC::write(uint32_t rgn_start, uint32_t offset, uint32_t value, int size)
if ((this->imm_snd_regs[0] & 0xC0) == PDM_SND_CTRL_VALID) {
this->awacs->write_ctrl(
(this->imm_snd_regs[1] >> 4) | (this->imm_snd_regs[0] & 0x3F),
((this->imm_snd_regs[1] & 0xF) << 8) | this->imm_snd_regs[2]
);
((this->imm_snd_regs[1] & 0xF) << 8) | this->imm_snd_regs[2]);
}
return;
case AMICReg::Snd_Buf_Size_Hi:
case AMICReg::Snd_Buf_Size_Lo:
SET_SIZE_BYTE(this->snd_buf_size, offset, value);
this->snd_buf_size &= ~3; // sound buffer size is always a multiple of 4
this->snd_buf_size &= ~3; // sound buffer size is always a multiple of 4
LOG_F(9, "AMIC: Sound buffer size set to 0x%X", this->snd_buf_size);
return;
case AMICReg::Snd_Out_Ctrl:
if ((value & 1) != (this->snd_out_ctrl & 1)) {
if (value & 1) {
this->snd_out_dma->init(this->dma_base & ~0x3FFFF,
this->snd_buf_size);
this->snd_out_dma->init(this->dma_base & ~0x3FFFF, this->snd_buf_size);
this->snd_out_dma->enable();
this->awacs->set_sample_rate((this->snd_out_ctrl >> 1) & 3);
this->awacs->dma_out_start();
this->snd_out_ctrl |= 1;
} else {
this->snd_out_dma->disable();
this->awacs->dma_out_pause();
this->snd_out_ctrl &= 0xFE;
}
}
this->snd_out_ctrl = value;
return;
case AMICReg::Snd_In_Ctrl:
LOG_F(INFO, "AMIC Sound In Ctrl updated, val=%x", value);
if ((value & 1) != (this->snd_in_ctrl & 1)) {
if (value & 1) {
this->snd_in_dma->init(this->dma_base & ~0x3FFFF, this->snd_buf_size);
this->snd_in_dma->enable();
this->awacs->set_sample_rate((this->snd_out_ctrl >> 1) & 3);
this->awacs->dma_in_start();
}
} else {
this->snd_in_dma->disable();
this->awacs->dma_in_pause();
}
if (value & 0x40) {
this->via2_ifr |= 0x10;
this->ack_via2_int(VIA2_INT_SOUND, 0);
} else {
this->via2_ifr |= 0x10;
this->ack_via2_int(VIA2_INT_SOUND, 1);
}
this->snd_in_ctrl = value;
return;
case AMICReg::Snd_Out_DMA:
this->snd_out_dma->write_dma_out_ctrl(value);
return;
case AMICReg::Snd_In_DMA:
LOG_F(WARNING, "SND IN DMA Value: 0x%x", value);
this->snd_in_dma->write_dma_in_ctrl(value);
return;
}
case 0x16: // SWIM3 registers
case 0x17:
case 0x16: // SWIM3 registers
case 0x17: {
this->swim3->write((offset >> 9) & 0xF, value);
return;
}
}
switch(offset) {
@@ -328,6 +363,7 @@ void AMIC::write(uint32_t rgn_start, uint32_t offset, uint32_t value, int size)
}
break;
case AMICReg::VIA2_IFR:
case AMICReg::VIA2_IFR_RBV:
// if bit 7 is set, clear the corresponding IRQ bit for each "1" in value
// writing any value to VIA2_IFR with bit 7 cleared has no effect
if (value & 0x80) {
@@ -598,10 +634,9 @@ AmicSndOutDma::AmicSndOutDma() : DmaOutChannel("SndOut")
this->enabled = false;
}
void AmicSndOutDma::init(uint32_t buf_base, uint32_t buf_samples)
{
this->out_buf0 = buf_base + AMIC_SND_BUF0_OFFS;
this->out_buf1 = buf_base + AMIC_SND_BUF1_OFFS;
void AmicSndOutDma::init(uint32_t buf_base, uint32_t buf_samples) {
this->out_buf0 = buf_base + AMIC_SND_OUT_BUF0_OFFS;
this->out_buf1 = buf_base + AMIC_SND_OUT_BUF1_OFFS;
this->out_buf_len = buf_samples * 2 * 2;
@@ -659,7 +694,7 @@ DmaPullResult AmicSndOutDma::pull_data(uint32_t req_len, uint32_t *avail_len,
// if it's false stop delivering sound data
// this will effectively stop audio playback
if (this->snd_buf_num && !this->enabled) {
return DmaPullResult::NoMoreData;
return DmaPullResult::NoMorePullData;
}
this->cur_buf_pos = 0; // reset buffer position
@@ -675,7 +710,70 @@ DmaPullResult AmicSndOutDma::pull_data(uint32_t req_len, uint32_t *avail_len,
*p_data = res.host_va;
this->cur_buf_pos += len;
*avail_len = len;
return DmaPullResult::MoreData;
return DmaPullResult::MorePullData;
}
AmicSndInDma::AmicSndInDma() : DmaInChannel("SndIn") {
this->dma_in_ctrl = 0;
this->enabled = false;
}
void AmicSndInDma::init(uint32_t buf_base, uint32_t buf_samples) {
this->in_buf0 = buf_base + AMIC_SND_IN_BUF0_OFFS;
this->in_buf1 = buf_base + AMIC_SND_IN_BUF1_OFFS;
this->in_buf_len = buf_samples * 2 * 2;
this->snd_buf_num = 0;
this->cur_buf_pos = 0;
this->irq_level = 0;
}
uint8_t AmicSndInDma::read_stat() {
return this->dma_in_ctrl;
}
void AmicSndInDma::write_dma_in_ctrl(uint8_t value) {
if (value & PDM_DMA_INTS_MASK) {
this->dma_in_ctrl &= ~(value & PDM_DMA_INTS_MASK);
this->update_irq();
}
// update sound input DMA interrupt enable bits
this->dma_in_ctrl = value;
}
int AmicSndInDma::push_data(const char* src_ptr, int len) {
len = 0x2000;
const char* silence[0x2000] = {(char *)0};
MapDmaResult res = mmu_map_dma_mem(
(this->snd_buf_num ? this->in_buf1 : this->in_buf0),
len, false);
uint8_t* p_data = res.host_va;
if (!res.is_writable) {
ABORT_F("AMIC: attempting DMA write to read-only memory");
}
std::memcpy(p_data, silence, len);
this->addr_ptr += len;
this->byte_count -= len;
if (!this->byte_count) {
//LOG_F(WARNING, "AMIC: DMA interrupts not implemented yet");
}
this->snd_buf_num ^= 1;
return DmaPushResult::NoMorePushData;
}
void AmicSndInDma::update_irq() {
uint8_t new_level = !!((this->dma_in_ctrl >> 4) & this->dma_in_ctrl);
if (new_level != this->irq_level) {
this->irq_level = new_level;
TimerManager::get_instance()->add_immediate_timer(
[this] { this->int_ctrl->ack_dma_int(this->snd_dma_irq_id, this->irq_level); });
}
}
// ============================ Floppy DMA stuff ===============================
@@ -726,7 +824,7 @@ int AmicFloppyDma::push_data(const char* src_ptr, int len)
DmaPullResult AmicFloppyDma::pull_data(uint32_t req_len, uint32_t *avail_len,
uint8_t **p_data)
{
return DmaPullResult::NoMoreData;
return DmaPullResult::NoMorePullData;
}
// ============================ SCSI DMA stuff ================================
@@ -822,7 +920,7 @@ void AmicSerialXmitDma::write_ctrl(const uint8_t value)
DmaPullResult AmicSerialXmitDma::pull_data(uint32_t req_len, uint32_t *avail_len,
uint8_t **p_data)
{
return DmaPullResult::NoMoreData;
return DmaPullResult::NoMorePullData;
}
static std::vector<std::string> Amic_Subdevices = {
@@ -833,4 +931,4 @@ static const DeviceDescription Amic_Descriptor = {
AMIC::create, Amic_Subdevices, {}, HWCompType::MMIO_DEV | HWCompType::INT_CTRL
};
REGISTER_DEVICE(Amic, Amic_Descriptor);
REGISTER_DEVICE(Amic, Amic_Descriptor);
+59 -8
View File
@@ -82,13 +82,16 @@ enum : uint64_t {
/** DMA interrupt bits. */
enum : uint64_t {
DMA0_INT_SHIFT = 24,
DMA0_INT_SOUND = 1 << 1,
DMA1_INT_SHIFT = 32,
DMA1_INT_SOUND = 1 << 1,
};
/** AMIC sound buffers are located at fixed offsets from DMA base. */
#define AMIC_SND_BUF0_OFFS 0x10000
#define AMIC_SND_BUF1_OFFS 0x12000
#define AMIC_SND_IN_BUF0_OFFS 0xC000
#define AMIC_SND_IN_BUF1_OFFS 0xE000
#define AMIC_SND_OUT_BUF0_OFFS 0x10000
#define AMIC_SND_OUT_BUF1_OFFS 0x12000
// PDM HWInit source defines two constants: kExpBit = 0x80 and kCmdBit = 0x40
// I don't know what they mean but it seems that their combination will
@@ -135,6 +138,48 @@ private:
uint8_t irq_level = 0;
};
class AmicSndInDma : public DmaInChannel {
public:
AmicSndInDma();
~AmicSndInDma() = default;
void init(uint32_t buf_base, uint32_t buf_samples);
void enable() {
this->enabled = true;
}
void disable() {
this->enabled = false;
}
uint8_t read_stat();
void update_irq();
void write_dma_in_ctrl(uint8_t value);
uint32_t get_cur_buf_pos() {
return this->cur_buf_pos;
}
int push_data(const char* src_ptr, int len);
void init_interrupts(InterruptCtrl* int_ctrl, uint64_t irq_id) {
this->int_ctrl = int_ctrl;
this->snd_dma_irq_id = irq_id;
}
private:
bool enabled = false;
uint8_t dma_in_ctrl;
uint32_t in_buf0;
uint32_t in_buf1;
uint32_t in_buf_len;
uint32_t snd_buf_num;
uint32_t cur_buf_pos;
InterruptCtrl* int_ctrl = nullptr;
uint64_t snd_dma_irq_id = 0;
uint32_t addr_ptr;
uint16_t byte_count;
uint8_t irq_level = 0;
};
/** AMIC-specific floppy DMA implementation. */
class AmicFloppyDma : public DmaBidirChannel {
public:
@@ -282,16 +327,20 @@ enum AMICReg : uint32_t {
Floppy_DMA_Ctrl = 0x32068,
SCC_DMA_Xmt_A_Ctrl = 0x32088,
// = 0x32092, // byte, read
// = 0x32093, // byte, read
SCC_RXA_Addr_Ptr_0 = 0x32090, // byte, read
SCC_RXA_Addr_Ptr_1 = 0x32091, // byte, read
SCC_RXA_Addr_Ptr_2 = 0x32092, // byte, read
SCC_RXA_Addr_Ptr_3 = 0x32093, // byte, read
SCC_RXA_Byte_Cnt_Hi = 0x32094, // 5 bits, read; byte, write 0x10
SCC_RXA_Byte_Cnt_Lo = 0x32095, // 8 bits, read; byte, write 0x00
SCC_DMA_Rcv_A_Ctrl = 0x32098,
// = 0x320A4, // byte, write 0x00
// = 0x320A5, // byte, write 0x07
SCC_TXB_Byte_Cnt_Hi = 0x320A4, // byte, write 0x00
SCC_TXB_Byte_Cnt_Lo = 0x320A5, // byte, write 0x07
SCC_DMA_Xmt_B_Ctrl = 0x320A8,
// = 0x320B2, // byte, read
// = 0x320B3, // byte, read
SCC_RXB_Addr_Ptr_0 = 0x320B0, // byte, read
SCC_RXB_Addr_Ptr_1 = 0x320B1, // byte, read
SCC_RXB_Addr_Ptr_2 = 0x320B2, // byte, read
SCC_RXB_Addr_Ptr_3 = 0x320B3, // byte, read
SCC_RXB_Byte_Cnt_Hi = 0x320B4, // 5 bits, read; byte, write 0x10
SCC_RXB_Byte_Cnt_Lo = 0x320B5, // 8 bits, read; byte, write 0x00
SCC_DMA_Rcv_B_Ctrl = 0x320B8,
@@ -335,6 +384,7 @@ private:
uint32_t scsi_dma_base = 0; // physical base address for SCSI DMA
uint16_t snd_buf_size = 0; // sound buffer size in bytes
uint8_t snd_out_ctrl = 0;
uint8_t snd_in_ctrl = 0;
// floppy DMA state
uint32_t floppy_addr_ptr;
@@ -373,6 +423,7 @@ private:
std::unique_ptr<AwacDevicePdm> awacs;
std::unique_ptr<AmicSndOutDma> snd_out_dma;
std::unique_ptr<AmicSndInDma> snd_in_dma;
std::unique_ptr<AmicFloppyDma> floppy_dma;
std::unique_ptr<AmicScsiDma> curio_dma;
std::unique_ptr<AmicSerialXmitDma> escc_xmit_b_dma;
+8 -1
View File
@@ -39,9 +39,16 @@ 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("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));
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) {
+1
View File
@@ -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)
{
+1 -1
View File
@@ -442,7 +442,7 @@ void EsccChannel::dma_out_tx()
uint8_t *data;
uint32_t avail_len;
if (dma_ch[1]->pull_data(256, &avail_len, &data) == MoreData) {
if (dma_ch[1]->pull_data(256, &avail_len, &data) == MorePullData) {
while(avail_len) {
this->send_byte(*data++);
avail_len--;
+16 -10
View File
@@ -99,7 +99,7 @@ void AwacsBase::dma_out_pause() {
this->out_stream_running = false;
}
static const char sound_input_data[2048] = {0};
static const char sound_input_data[8192] = {0};
static int sound_in_status = 0x10;
void AwacsBase::dma_in_data() {
@@ -107,15 +107,15 @@ void AwacsBase::dma_in_data() {
this->dma_in_ch->push_data(sound_input_data, sizeof(sound_input_data));
if (dma_in_ch->is_in_active()) {
auto dbdma_ch = dynamic_cast<DMAChannel*>(dma_in_ch);
sound_in_status <<= 1;
if (!sound_in_status)
sound_in_status = 1;
dbdma_ch->set_stat(sound_in_status);
LOG_F(INFO, "%s: status:%x", this->name.c_str(), sound_in_status);
//auto dbdma_ch = dynamic_cast<DMAChannel*>(dma_in_ch);
//sound_in_status <<= 1;
//if (!sound_in_status)
// sound_in_status = 1;
//dbdma_ch->set_stat(sound_in_status);
//LOG_F(INFO, "%s: status:%x", this->name.c_str(), sound_in_status);
this->dma_in_timer_id = TimerManager::get_instance()->add_oneshot_timer(
10000,
20000,
[this]() {
// re-enter the sequencer with the state specified in next_state
this->dma_in_timer_id = 0;
@@ -135,10 +135,16 @@ void AwacsBase::dma_in_stop() {
this->dma_in_timer_id = 0;
}
LOG_F(ERROR, "%s: dma_in_stop", this->name.c_str());
if (this->out_stream_ready) {
snd_server->close_out_stream();
this->out_stream_ready = false;
this->out_stream_running = false;
}
}
void AwacsBase::dma_in_pause() {
LOG_F(ERROR, "%s: dma_in_pause", this->name.c_str());
this->in_stream_running = false;
}
//=========================== PDM-style AWACs =================================
@@ -192,7 +198,7 @@ uint32_t AwacsScreamer::snd_ctrl_read(uint32_t offset, int size) {
value = this->snd_ctrl_reg;
break;
case AWAC_CODEC_CTRL_REG:
value = this->is_busy;
value = this->is_busy ? AWAC_BUSY_BIT : 0;
break;
case AWAC_CODEC_STATUS_REG:
value = (AWAC_AVAILABLE << 8) | (AWAC_MAKER_CRYSTAL << 16) |
@@ -232,7 +238,7 @@ void AwacsScreamer::snd_ctrl_write(uint32_t offset, uint32_t value, int size) {
LOG_F(9, "%s subframe = %d, reg = %d, data = %08X", this->name.c_str(),
subframe, reg_num, data);
if (!subframe)
this->shadow_regs[reg_num] = data;
this->codec_ctrl_reg = data;
break;
case AWAC_CLIP_COUNT:
this->clip_count = BYTESWAP_32(value);
+3
View File
@@ -73,8 +73,11 @@ protected:
bool out_stream_ready = false;
bool out_stream_running = false;
bool in_stream_ready = false;
bool in_stream_running = false;
int cur_sample_rate = -1;
int out_sample_rate = -1;
int in_sample_rate = -1;
};
/** AWACs PDM-style sound codec. */
+4
View File
@@ -69,6 +69,10 @@ void BurgundyCodec::snd_ctrl_write(uint32_t offset, uint32_t value, int size) {
value = BYTESWAP_32(value);
switch (offset) {
case AWAC_SOUND_CTRL_REG:
this->snd_ctrl_reg = BYTESWAP_32(value);
this->set_sample_rate((this->snd_ctrl_reg >> 8) & 7);
break;
case AWAC_CODEC_CTRL_REG:
this->last_ctrl_data = value;
reg_addr = (value >> 12) & 0xFF;
+2
View File
@@ -58,6 +58,8 @@ private:
uint8_t read_pos = 0;
uint8_t data_byte = 0;
uint32_t snd_ctrl_reg = 0;
uint32_t reg_array[BURGUNDY_NUM_REGS] = {};
};
+30 -3
View File
@@ -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;
+10
View File
@@ -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;
+12 -4
View File
@@ -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);