Commit Graph

436 Commits

Author SHA1 Message Date
joevt
e7eb1c8a66 Fix PCI interrupts and add devices.
- Use interrupt source instead of IRQ ID in the IrqMap.
- Add a get_interrupt_controller method to mirror the set_interrupt_controller method.
- Have PCI hosts use pcihost_device_postinit to add PCI devices. This was moved from bandit's device_postinit and allows for duplicate devices by appending the slot to the registered device name.
- Fix interrupts of Pippin.

Fix interrupts of cmd646
- Make it work like other PCI devices.
- IntDetails is built into the pcibase base class.
- IntDetails is initialized by calling pci_interrupt.
- pci_interrupt checks the "enable interrupts" flag before doing an interrupt.
2024-11-12 07:04:55 -07:00
joevt
9a2303c495 pci: Replace pci_name with get_name.
It's redundant to have two names.
2024-11-11 21:28:23 -07:00
joevt
fc89fec3e6 dbdma: Do interrupt after setting resCount and xferStatus. 2024-11-10 06:24:24 -07:00
joevt
15986a4e4f dbdma: Allow clearing only control bits.
Only control bits can be set and cleared by software.
Command bits and status bits cannot be cleared.
2024-11-10 06:23:35 -07:00
joevt
d56520d22a dbdma: Set active only when wake is set. 2024-11-10 06:22:38 -07:00
Mihai Parparita
f65f9b9845 Add a deterministic execution mode
Adds support for a --deterministic command-line option that makes
repeated runs the same:
- Keyboard and mouse input is ignored
- The sound server does a periodic pull from the DMA channel (so that
  it gets drained), but only does so via a periodic timer (instead of
  being driven by a cubeb callback, which could arrive at different
  times)
- Disk image writes are disabled (reads of a modified area still
  work via an in-memory copy)
- NVRAM writes are disabled
- The current time that ViaCuda initializes the guest OS is always the
  same.

This makes execution exactly the same each time, which should
make debugging of more subtle issues easier.

To validate that the deterministic mode is working, I've added a
periodic log of the current "time" (measured in cycle count), PC
and opcode. When comparing two runs with --log-no-uptime, the generated
log files are identical.
2024-11-09 22:48:06 -08:00
joevt
f415a63b76 dbdma: Allow Stop command to set xferStatus.
Some software may check the status flags of a Stop DBDMA descriptor.
2024-11-09 21:05:32 -07:00
joevt
50e661f804 dbdma: Resume should continue DBDMA program.
Just like Start does.
2024-11-09 21:05:27 -07:00
joevt
7ffafdc007 dbdma: Implement branch taken flag. 2024-11-09 20:31:54 -07:00
joevt
96875a1278 dbdma: Clear active flag if paused flag is set.
The active flag is cleared when the pause flag is set, so why shouldn't the active flag be cleared when the start flag is set with the pause flag is already set?
2024-11-09 19:59:52 -07:00
Maxim Poliakovski
86ce9b0bb1 dbdma: support for non-DWORD register reads. 2024-11-03 15:10:33 +01:00
Maxim Poliakovski
9915c15086 Initial CMD646U2 Ultra ATA controller emulation. 2024-10-09 14:49:09 +02:00
Keith Kaisershot
34e0ba84f1 Add AppleJack controller support, based on AdbMouse
All AppleJack controllers start in mouse emulation mode, behaving exactly like
ADB mice. Only upon receiving a Listen command on register 3 with handler ID
0x46 does the AppleJack switch protocols, albeit such a change consisting merely
of expanding register 0's buffer size to 4 bytes. In this state, the first 2
bytes remain defined as they are for an ADB mouse; the additional 16 bits carry
the respective states of each of the AppleJack controller's remaining 11 buttons
out of a possible supported 16.

For backward compatibility, honor both mouse clicks and shoulder button presses
on the host when considering the state of the emulated trigger buttons.
2024-10-06 23:43:50 -07:00
Keith Kaisershot
6696248158 adbbus: decouple ADB devices from CUDA
AdbMouse and AdbKeyboard are subdevices of the CUDA device alongside AdbBus.
This doesn't make sense because conceptually, ADB devices hang off of the ADB
bus, not CUDA itself. An ADB bus can exist without a CUDA present, for example
Egret on older 68K Macs and the PMU on newer Power Macs. Therefore, make the ADB
device list a subhierarchy of AdbBus instead. Add a new "adb_devices" property
belonging to AdbBus that can allow users to specify ADB devices on the command
line at machine creation time, independent of the emulated bus's host. Make this
property default to "Mouse,Keyboard" to preserve existing behavior.
2024-10-06 23:20:10 -07:00
dingusdev
e2ad753f4a More clean-up 2024-09-15 18:31:36 -07:00
dingusdev
9d9e826bb3 More code clean-up 2024-09-08 13:19:07 -07:00
joevt
f09710a5f7 viacuda: Do shutdown.
Shutdown will enter the debugger or quit depending on the execution mode.
Quit is different from shutdown since it is triggered outside the guest by using the host Quit menu item.
2024-08-31 18:09:12 -07:00
Maxim Poliakovski
ef62e8b965 New API for registering PCI interrupts. 2024-08-29 00:16:59 +02:00
Maxim Poliakovski
825314c869 atahd: clean up READ_MULTIPLE/WRITE_MULTIPLE. 2024-08-26 00:20:53 +02:00
Mihai Parparita
52f4d847dd Fixes for READ_MULTIPLE and WRITE_MULTIPLE commands
We may be transferring less data than can fit in a chunk, so we need
to ensure that xfer_cnt is clamped to 0 when transferring the last
chunk (otherwise it remains negative, and has_data() will return true).

It's also possible that the transfer size is bigger than a chunk but not
an even multiple of the chunk size, so we need to ensure that we don't
try to transfer a whole chunk in the last iteration.

More correctly initialize the device identification struct, to report
the maximum (word 47) and current (word 59) number of blocks that can be
transferred with READ_MULTIPLE and WRITE_MULTIPLE commands.

Fix post_xfer_action to write the actual data size that was written,
as opposed to an entire chunk (which may be larger).
2024-08-24 22:51:07 -07:00
dingusdev
ebf4b0e969 minor ATA tweaks
From @Wack0's branch
2024-08-24 12:58:19 -07:00
Mihai Parparita
8d95aa5ed3 Fix ATA HD initialization on Beige G3 when booting 9.2
1f2256ec81a/7ee8b9b2 were referencing a multiple_sector_count field,
but it was never set. This was resulting in an error being returned
(`READ MULTIPLE with SET MULTIPLE==0`).` We actually should use
`sec_per_block``, which bd16b7c69e introduced.
2024-08-22 22:38:48 -07:00
dingusdev
7ee8b9b2f0 Add missing variable 2024-08-22 20:49:11 -07:00
dingusdev
1f2256ec81 Additional ATA commands
Mostly from Wack0's NT4 fork.

Co-Authored-By: Rairii <2650838+Wack0@users.noreply.github.com>
2024-08-22 20:42:43 -07:00
Maxim Poliakovski
0518f2ae2f atahd: fix DIAGNOSTICS command. 2024-08-21 23:12:53 +02:00
Maxim Poliakovski
3bf088f2c8 atahd: fix RECALIBRATE command.
Although being optional in ATA-3 and absent in >= ATA-4,
RECALIBRATE is issued by Open Firmware 3.1.1 during device
initialization. If it fails, the drive is considered non-bootable.
2024-08-21 21:21:44 +02:00
Maxim Poliakovski
bd16b7c69e atahd: implement mandatory SET_MULTIPLE_MODE command. 2024-08-21 21:21:44 +02:00
Maxim Poliakovski
f5c91968a2 idechannel: split MacIO specific stuff into a separate class.
Now we got two classes: IdeChannel and MacioIdeChannel.
The former models a generic IDE channel so it can be used elsewhere.
The latter implements MacIO specific configuration register(s)
and interrupt signaling.
2024-08-20 16:55:31 +02:00
Maxim Poliakovski
4e78ac33c5 atabasedevice: disable device interrupts on reset. 2024-08-20 15:36:12 +02:00
Maxim Poliakovski
a34e0a4737 PCI-to-PCI bridges now return true in supports_io_space().
Doing so ensures that accesses to the I/O space are broadcasted
to the PCI-to-PCI bridges automatically.
2024-08-17 01:01:53 +02:00
Maxim Poliakovski
2c026259b1 pcibridge: improve formatting. 2024-08-17 01:01:53 +02:00
Maxim Poliakovski
cd36df5500 pcibridge: fix a bug in pci_io_write() caused by copy-and-paste coding. 2024-08-17 01:01:53 +02:00
Maxim Poliakovski
5ea7b8c5f8
Merge pull request #111 from mihaip/upstream-alignment
atapibasedevice: fix unaligned memory access
2024-08-16 12:56:08 +02:00
Mihai Parparita
372b9cae7a atapibasedevice: fix unaligned memory access
Both cmd_pkt and data_buf class members are cast to a uint16_t pointer,
so we need to make sure they are properly aligned, otherwise it is
undefined behavior.
2024-08-15 22:32:46 -07:00
Maxim Poliakovski
595478ed6f hwcomponent: add IDE_HOST component type. 2024-08-12 14:03:05 +02:00
Maxim Poliakovski
f9338b8dd9 pcihost: broadcast I/O requests to PCI-to-PCI bridges. 2024-08-11 15:51:06 +02:00
Maxim Poliakovski
20b2fb1bef viacuda: refactor emulation of the VIA registers.
Take the DDRA and DDRB registers into account as well because
there is software that tries to change state of the pins configured
as inputs.
This commit fixes Cuda for Rhapsody.
2024-08-04 21:43:06 +02:00
Maxim Poliakovski
f096eef66d viacuda.h: cosmetic improvements. 2024-08-04 21:43:06 +02:00
Rairii
4d7c520f18 adbmouse: only send first two bytes in standard/classic protocol as per spec
Fixes any mouse driver that only supports the classic protocol and expects register 0 reads to return two bytes.
2024-07-29 11:37:54 +01:00
joevt
7fdfd6109f atabasedevice: Set dev_id.
Extracted from @Wack0's Wack0/dingusppc-nt@529991bd78

Co-authored-by: Rairii <2650838+Wack0@users.noreply.github.com>
2024-07-27 09:10:28 -07:00
dingusdev
7d6e87a0d3 Add stub for setting power messages 2024-07-26 07:31:31 -07:00
Maxim Poliakovski
8d6f77ea71 mesh: implement EnaParityCheck and DisParityCheck commands. 2024-07-25 22:18:43 +02:00
Maxim Poliakovski
19ecc4f945 mesh: fix writes to BusStatus0 & BusStatus1 registers. 2024-07-24 17:50:02 +02:00
Maxim Poliakovski
babd8d974f dbdma: fix cmd.resCount update. 2024-07-22 17:45:48 +02:00
Maxim Poliakovski
9fc5bbb951 sc53c94: fix interrupt status for CMD_MSG_ACCEPTED. 2024-07-19 03:38:55 +02:00
Maxim Poliakovski
289a14dc7a scsidevice: release REQ before MESSAGE_IN phase. 2024-07-15 07:15:49 +02:00
Maxim Poliakovski
ba9fcd100d mesh: extend stub to a full implementation. 2024-07-15 03:34:43 +02:00
Maxim Poliakovski
889dc32a0a New base class for SCSI host controllers. 2024-07-15 03:28:45 +02:00
Maxim Poliakovski
4a425c4ecf dbdma: introduce new DMA API. 2024-07-15 02:09:15 +02:00
Maxim Poliakovski
293e869acb dbdma: break long lines. 2024-07-15 02:09:15 +02:00