Compare commits

...
13 Commits
Author SHA1 Message Date
dingusdev 5bc1260dbb Start MTSPR/MFSPR refactor 2026-02-11 08:02:40 -07:00
dingusdev e46414721d Name DSISR bits 2026-01-22 19:07:43 -07:00
dingusdev 79784cd36c Initial improvements 2026-01-21 21:17:52 -07:00
joevt d693b0f443 maciotwo: Fix IDE read/write mask again.
Use the entire 4K range.
2026-01-20 07:07:11 -07:00
joevt 5c646e8270 maciotwo: Add methods to override OHARE_ID ids. 2026-01-17 08:40:45 -07:00
joevt 65c5d2425e maciotwo: Fix IDE read/write mask. 2026-01-17 07:02:06 -07:00
joevt f2676e0324 maciotwo: Make Ide1 optional.
Some Macs that use OHare do not have a second ATA bus exposed by Open
Firmware. Allow Ide1 to not be included.

# Conflicts:
#	devices/ioctrl/maciotwo.cpp
2026-01-17 06:54:44 -07:00
dingusdev 48adf99690 Documentation cleanup 2026-01-15 07:39:59 -07:00
joevt 3c0432053b atadefs: Add KeyLargo ATA interrupt register note. 2026-01-15 07:37:17 -07:00
joevt ebc2fcf216 atabasedevice: Add missing this. 2026-01-15 07:36:52 -07:00
joevt 25c74f76d2 idechannel: Fix read and write virtual methods. 2026-01-15 07:35:11 -07:00
dingusdev e3839bdea6 Start vendor-specific SCSI commands 2026-01-12 22:11:11 -07:00
dingusdev 742a810624 Restored floating point testing 2026-01-07 18:45:47 -07:00
16 changed files with 150 additions and 50 deletions

No files matched your search

+19 -11
View File
@@ -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
+6
View File
@@ -106,6 +106,7 @@ enum SPR : int {
SPRG1 = 273,
SPRG2 = 274,
SPRG3 = 275,
EAR = 282,
TBL_S = 284, // supervisor TBL
TBU_S = 285, // supervisor TBU
PVR = 287,
@@ -303,6 +304,11 @@ enum XER : uint32_t {
SO = 1UL << 31
};
enum DSISR : uint32_t {
PROT = 1UL << 27,
STORE = 1UL << 25
};
//for inf and nan checks
enum FPOP : int {
DIV = 0x12,
+20 -14
View File
@@ -540,12 +540,11 @@ static TLBEntry* tlb2_target_entry(uint32_t gp_va)
}
}
static TLBEntry* itlb2_refill(uint32_t guest_va)
{
static TLBEntry* itlb2_refill(uint32_t guest_va) {
BATResult bat_res;
uint32_t phys_addr;
TLBEntry *tlb_entry;
uint16_t flags = 0;
TLBEntry* tlb_entry = nullptr;
uint16_t flags = 0;
/* instruction address translation if enabled */
if (ppc_state.msr & MSR::IR) {
@@ -555,11 +554,13 @@ static TLBEntry* itlb2_refill(uint32_t guest_va)
} else {
bat_res = ppc_block_address_translation<BATType::IBAT>(guest_va);
}
if (bat_res.hit) {
// check block protection
// only PP = 0 (no access) causes ISI exception
if (!bat_res.prot) {
mmu_exception_handler(Except_Type::EXC_ISI, 0x08000000);
return nullptr; // Stop refill on exception
}
phys_addr = bat_res.phys;
flags |= TLBFlags::TLBE_FROM_BAT; // tell the world we come from
@@ -567,7 +568,7 @@ static TLBEntry* itlb2_refill(uint32_t guest_va)
// page address translation
PATResult pat_res = page_address_translation(guest_va, true, !!(ppc_state.msr & MSR::PR), 0);
phys_addr = pat_res.phys;
flags = TLBFlags::TLBE_FROM_PAT; // tell the world we come from
flags |= TLBFlags::TLBE_FROM_PAT; // tell the world we come from
}
} else { // instruction translation disabled
phys_addr = guest_va;
@@ -577,18 +578,23 @@ static TLBEntry* itlb2_refill(uint32_t guest_va)
AddressMapEntry* rgn_desc = mem_ctrl_instance->find_range(phys_addr);
if (rgn_desc) {
if (rgn_desc->type & RT_MMIO) {
ABORT_F("Instruction fetch from MMIO region at 0x%08X!\n", phys_addr);
// TODO: ISI or Machine Check for this?
mmu_exception_handler(Except_Type::EXC_ISI, 0x40000000);
}
// refill the secondary TLB
const uint32_t tag = guest_va & ~0xFFFUL;
tlb_entry = tlb2_target_entry<TLBType::ITLB>(tag);
tlb_entry->tag = tag;
tlb_entry->flags = flags | TLBFlags::PAGE_MEM;
tlb_entry->host_va_offs_r = (int64_t)rgn_desc->mem_ptr - guest_va +
(phys_addr - rgn_desc->start);
const uint32_t page_base = guest_va & ~0xFFFUL;
tlb_entry = tlb2_target_entry<TLBType::ITLB>(page_base);
tlb_entry->tag = page_base;
tlb_entry->flags = flags | TLBFlags::PAGE_MEM;
// Calculate offset based on page base to ensure alignment
tlb_entry->host_va_offs_r = (int64_t)rgn_desc->mem_ptr - (int64_t)page_base +
((phys_addr & ~0xFFFUL) - rgn_desc->start);
tlb_entry->phys_tag = phys_addr & ~0xFFFUL;
} else {
ABORT_F("Instruction fetch from unmapped memory at 0x%08X!\n", phys_addr);
// TODO: ISI or Machine Check for this?
mmu_exception_handler(Except_Type::EXC_ISI, 0x40000000);
}
return tlb_entry;
@@ -618,7 +624,7 @@ static TLBEntry* dtlb2_refill(uint32_t guest_va, int is_write, bool is_dbg = fal
LOG_F(9, "BAT DSI exception in TLB2 refill!");
if (!is_dbg)
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::DSISR] = DSISR::PROT | (is_write << 25);
ppc_state.spr[SPR::DAR] = guest_va;
mmu_exception_handler(Except_Type::EXC_DSI, 0);
}
+45 -4
View File
@@ -936,6 +936,11 @@ void dppc_interpreter::ppc_mfspr(uint32_t opcode) {
}
switch (ref_spr) {
case SPR::XER:
case SPR::LR:
case SPR::CTR:
ppc_state.gpr[reg_d] = ppc_state.spr[ref_spr];
break;
case SPR::MQ:
if (!(is_601 || include_601)) {
ppc_exception_handler(Except_Type::EXC_PROGRAM, Exc_Cause::ILLEGAL_OP);
@@ -987,8 +992,23 @@ void dppc_interpreter::ppc_mfspr(uint32_t opcode) {
ppc_state.spr[TBL_S] = uint32_t(tbr_value);
break;
}
case SPR::DSISR:
case SPR::DAR:
case SPR::SRR0:
case SPR::SRR1:
case SPR::PVR:
case SPR::EAR:
ppc_state.gpr[reg_d] = ppc_state.spr[ref_spr];
break;
case SPR::SPRG0:
case SPR::SPRG1:
case SPR::SPRG2:
case SPR::SPRG3:
ppc_state.gpr[reg_d] = ppc_state.spr[ref_spr];
break;
default:
// FIXME: Unknown SPR should be noop or illegal instruction.
LOG_F(ERROR, "Mystery SPR in MFSPR: %d", ref_spr);
ppc_state.gpr[reg_d] = ppc_state.spr[ref_spr];
}
}
@@ -1010,6 +1030,13 @@ void dppc_interpreter::ppc_mtspr(uint32_t opcode) {
uint32_t val = ppc_state.gpr[reg_d];
switch (ref_spr) {
case SPR::XER:
ppc_state.spr[ref_spr] = val & 0xe000ff7f;
break;
case SPR::LR:
case SPR::CTR:
ppc_state.spr[ref_spr] = val;
break;
case SPR::MQ:
if (is_601 || include_601)
ppc_state.spr[ref_spr] = val;
@@ -1019,13 +1046,13 @@ void dppc_interpreter::ppc_mtspr(uint32_t opcode) {
case SPR::RTCL_U:
case SPR::RTCU_U:
case SPR::DEC_U:
if (!is_601) {
if (is_601) {
ppc_state.spr[ref_spr] = val;
}
else {
ppc_exception_handler(Except_Type::EXC_PROGRAM, Exc_Cause::ILLEGAL_OP);
}
break;
case SPR::XER:
ppc_state.spr[ref_spr] = val & 0xe000ff7f;
break;
case SPR::SDR1:
if (ppc_state.spr[ref_spr] != val) {
ppc_state.spr[ref_spr] = val;
@@ -1058,6 +1085,19 @@ void dppc_interpreter::ppc_mtspr(uint32_t opcode) {
ppc_state.spr[TBL_S] = (uint32_t)tbr_wr_value;
ppc_state.spr[TBU_S] = val;
break;
case SPR::DSISR:
case SPR::DAR:
case SPR::SRR0:
case SPR::SRR1:
case SPR::EAR:
ppc_state.spr[ref_spr] = val;
break;
case SPR::SPRG0:
case SPR::SPRG1:
case SPR::SPRG2:
case SPR::SPRG3:
ppc_state.spr[ref_spr] = val;
break;
case SPR::PVR:
break;
case 528:
@@ -1084,6 +1124,7 @@ void dppc_interpreter::ppc_mtspr(uint32_t opcode) {
break;
default:
// FIXME: Unknown SPR should be noop or illegal instruction.
LOG_F(ERROR, "Mystery SPR in MTSPR: %d", ref_spr);
ppc_state.spr[ref_spr] = val;
}
}
+2 -1
View File
@@ -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;
+2 -2
View File
@@ -111,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) {
@@ -160,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;
+2 -1
View File
@@ -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. */
+4 -4
View File
@@ -42,8 +42,8 @@ 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;
@@ -93,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
+6
View File
@@ -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 {
+15
View File
@@ -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);
+12
View File
@@ -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;
+10 -7
View File
@@ -44,11 +44,13 @@ MacIoTwo::MacIoTwo(std::string name, uint16_t dev_id) : MacIoBase(name, dev_id)
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->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));
this->ide1_dma->connect(this->ide_1);
this->ide_1->connect(this->ide1_dma.get());
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) {
@@ -108,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) & 0xFF, 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) & 0xFF, size) : 0;
break;
default:
if (sub_addr >= 0x60) {
@@ -170,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) & 0xFF, 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) & 0xFF, value, size);
break;
default:
if (sub_addr >= 0x60) {
+2 -1
View File
@@ -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:
+1 -1
View File
@@ -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 | |
+2 -2
View File
@@ -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.
+2 -2
View File
@@ -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