Commit Graph
60 Commits
Author SHA1 Message Date
Maxim Poliakovski 0e03cac082 Move memaccess.h to core/* 2026-06-07 20:32:46 +02:00
joevt bf7fc5fb5a viacuda: Postpone onesec timer if SR int pending. 2026-03-23 07:26:19 -07:00
dingusdevandTim Jarzombek 3decd4b9fc Cuda improvements
* Implements missing Cuda commands
* Proper One Second Mode handling
* Add Stat Response ADB bit
* Typo fixes

Co-Authored-By: Tim Jarzombek <tim@jarz.net>
2026-03-08 16:26:47 -07:00
joevt dd31610013 viacuda: Increase input buffer size to 259 bytes. 2026-03-08 10:13:08 -07:00
joevt b182e01218 viacuda: Avoid float in VIA timer calculations.
- float is limited to 24 bits so use longer uint32_t or uint64_t.
- Rename the formal parameter so it more closely matches the actual
  parameter. Also, don't hide the class field.
- Multiply is faster than divide.
2026-02-07 20:51:48 -07:00
dingusdev 213dd4c16e Update copyright info further 2026-01-30 08:12:04 -07:00
joevt 489bd0dfcf viacuda: Fix append_data. 2026-01-30 07:06:03 -07:00
Maxim Poliakovski e75ee8d32a Update copyright year. 2026-01-30 12:15:00 +01:00
Maxim Poliakovski 5883b39c2b viacuda: disable async packets during Sync transaction. 2026-01-23 02:12:44 +01:00
Maxim Poliakovski 1b7338960f viacuda: fix typo. 2026-01-22 15:21:13 +01: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
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
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
Maxim Poliakovski d19de22540 viacuda: use more appropriate command names. 2025-11-30 17:12:45 +01:00
dingusdev 7699075377 Cuda code cleanup
* Fix CUDA_SET_DEVICE_LIST
* Add out_count to CUDA_GET_DEVICE_LIST
* Use this in CUDA_SET_REAL_TIME
2025-11-29 15:58:27 -07:00
joevt a9b589af86 viacuda: Log SET_POWER_MESSAGES and TIMER_TICKLE.
Maybe these should use error_response instead of response_header?
2025-11-17 19:55:04 -07:00
Maxim Poliakovski d6db6c9d7c Cleanup I2C stuff. 2025-11-15 16:35:06 +01:00
Maxim Poliakovski 436c196ba5 viacuda: cleanup interrupt signaling. 2025-07-09 21:08:12 +02:00
Maxim Poliakovski 31bf69eba2 viacuda.cpp: fix CB2 interrupt line. 2025-07-07 19:04:28 +02:00
joevt 0f8876f348 viacuda: Post key events at startup.
Keys that are held down too early are ignored which makes it difficult
perform some tasks at startup:
- Shift key to disable extensions.
- Command-Option-O-F to enter Open Firmware.
- Command-Option-P-R to reset nvram.
- Capslock to boot MkLinux or Copland.

This change hopes to grab all the keys being pressed and post events for
all of them when the ADB bus is ready.
2025-06-29 06:49:15 -07:00
joevt 35f2ce14f1 Add type and description to device descriptors.
Add supports_types to device descriptors so that we can determine
supported types without having to create the hardware device.
Add description so that each device can have an optional description.
2025-05-28 17:58:08 +02:00
Maxim Poliakovski eb61ab8c61 viacuda: implement T1 free-run mode. 2025-05-26 21:37:19 +02:00
Maxim Poliakovski 89139f3bae viacuda: fix VIA T2 emulation. 2025-05-26 21:31:26 +02:00
Maxim Poliakovski 2419731dbc viacuda: fix VIA T1 one-shot emulation.
Implement T1 to closely match the Apple VIA cell spec.
2025-05-26 21:31:26 +02:00
joevt 434ceab25a Use explicit typecast of float to int. 2025-02-16 07:00:15 -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
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
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 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
dingusdev 7d6e87a0d3 Add stub for setting power messages 2024-07-26 07:31:31 -07:00
joevt 76f966845d viacuda: Use timer ids instead of timer flags. 2024-04-23 06:44:02 -07:00
joevt a22bc34816 viacuda: Fix get/set time and one sec modes.
The first packet the one sec mode should send is a mode 1 real time packet, same as GET_REAL_TIME.
A mode 2 packet is the same but doesn't include the time.
2024-04-22 07:22:49 -07:00
joevt 2b76d8a53a viacuda: Remove parameters from pseudo_command.
They are incomplete or unused (includes cmd and count but not the data and the count isn't used). Might as well get everything from the class fields in_buf and in_count.
2024-04-22 07:11:22 -07:00
joevt a5241d27c1 viacuda: Cleanup. 2024-04-21 06:03:32 -07:00
joevt 4479ecb1bb viacuda: One exit path for read. 2024-04-21 06:03:17 -07:00
joevt b454ab45fe viacuda: Spelling. 2024-04-21 06:02:52 -07:00
joevt d06d80619e viacuda: Add 1 Sec Timer, fix Get/Set Real Time.
GET_REAL_TIME was using the wrong offset and wasn't setting out_count.

May need to add time zone offset which could be different between host and guest.
get-time and set-time can be tested in Open Firmware.
SET_REAL_TIME is used by the Date/Time Control Panel when you change the date.
It is unknown what method Mac OS uses to get the time at boot. Mac OS 8.6 does not use GET_REAL_TIME during boot, so the time is left as 12:00 AM Jan 1, 1904.
2024-04-21 06:01:40 -07:00
Mihai Parparita 57e6e90002 Add support for the CUDA_RESTART_SYSTEM command
There are cases where when it's necessary (e.g. given uninitialized NVRAM,
the Beige G3 with the 10.2 install CD inserted will update the boot
device and restart to boot from it).

Restart support was done by wrapping the ppc_exec function in a loop and
checking for a restart power off reason. We also need to disconnect all
event listeners, since they will be recreated when the machine is
re-initialized.
2024-03-07 23:32:23 -08:00
Mihai Parparita 10af336cd1 Ensure that VIA timers are stopped when the object is destroyed. 2024-03-07 23:31:56 -08:00
Mihai Parparita 73272b28dd Implement the ADB keyboard
Besides generating KeyboardEvents in the SDL event handler and
returning the key state in the register 0 reads of the AdbKeyboard
device, we also needed to generalize the ADB bus polling a bit. We now
check all devices that have the service request bit set, instead of
hardcoding the mouse.

The SDL key event -> ADB raw key code mapping is based on BasiliskII/
SheepShaver's, but cleaned up a bit.
2023-10-11 23:43:20 -07:00
Mihai Parparita 35c86ad6bf Clean up #includes
Result of running IWYU (https://include-what-you-use.org/) and
applying most of the suggestions about unncessary includes and
forward declarations.

Was motivated by observing that <thread> was being included in
ppcopcodes.cpp even though it was unused (found while researching
the use of threads), but seems generally good to help with build
times and correctness.
2023-11-03 00:33:47 -07:00
dingusdev a7601c36bd Started work on keyboard input 2023-08-01 22:43:11 -07:00
Maxim Poliakovski 1a883ba73e viacuda: implement basic autopolling. 2023-08-02 00:07:17 +02:00
Maxim Poliakovski c254749493 viacuda: connect to new AdbBus device. 2023-07-26 04:50:05 +02:00
Maxim Poliakovski 0c0166b565 viacuda: fix packet response protocol.
Cuda needs to negate TREQ before sending the last byte of a
fixed-length response to avoid transfering an extraneous byte.
2023-07-26 04:22:08 +02:00
Maxim Poliakovski 094b3b5312 Fix Cuda response protocol. 2023-02-08 21:26:11 +01:00
Maxim Poliakovski 5b08f283e5 Hacks for debugging HW interrupts. 2022-08-27 17:38:53 +02:00
Maxim Poliakovski 994f8d7155 viacuda: fix interrupts. 2022-08-24 14:15:48 +02:00