Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r4000.cpp: Add TimerIntDis mux to IPEX5 #9718

Merged
merged 2 commits into from
May 13, 2022
Merged

Conversation

briceonk
Copy link
Contributor

@briceonk briceonk commented May 7, 2022

This change implements boot-mode setting bit 19, TimIntDis/TimerIntDis, which configures if the R4x00 will use IPEX5 as an external interrupt, or as an internal timer using the compare register as the threshold (which is the default). The Sony NEWS NWS-5000X has multiple external timers, including a free-running clock and a hardware clock that drives IPEX2. So, Sony disabled the internal timer using TimerIntDis and repurposed IPEX5 for other things.

Boot-Mode Setting Description:
Screenshot from 2022-04-30 21-05-17

Block diagram:
Screenshot from 2022-04-30 21-06-33

Test booting jazz.cpp to the WinNT installer, showing that the internal timer is still functional in the default config:
Screenshot from 2022-04-30 21-53-46

This is another change pulled in from #8854 since that PR is way too big. Apologies for taking so much time to restart the process of breaking it up into smaller, easier to review portions. The first part of the year is the build and competition season for the robotics team I mentor, so I had essentially no free time....

@MooglyGuy
Copy link
Contributor

This could be done better, and in a way that better matches the surrounding code as well as the datasheet.

The configuration bit is '1' if the timer is disabled, so m_timer_interrupt_enabled should be renamed to m_timer_interrupt_disabled so that its polarity matches the configuration bit.

Initialize the now-renamed m_timer_interrupt_disabled in the constructor where other things are initialized, not inline in the header.

If it's a boot configuration bit, then it's not going to change while the system is running. With that in mind, either conditionally avoid calling cp0_update_timer if m_timer_interrupt_disabled is true, or early-out from cp0_update_timer if it's true: The only purpose of cp0_timer_callback is to set CAUSE_IPEX5 when the timer elapses. If IPEX5 is instead externally-driven, then it makes no sense to still schedule the timer to fire.

@briceonk
Copy link
Contributor Author

briceonk commented May 7, 2022

This could be done better, and in a way that better matches the surrounding code as well as the datasheet.

The configuration bit is '1' if the timer is disabled, so m_timer_interrupt_enabled should be renamed to m_timer_interrupt_disabled so that its polarity matches the configuration bit.

Initialize the now-renamed m_timer_interrupt_disabled in the constructor where other things are initialized, not inline in the header.

If it's a boot configuration bit, then it's not going to change while the system is running. With that in mind, either conditionally avoid calling cp0_update_timer if m_timer_interrupt_disabled is true, or early-out from cp0_update_timer if it's true: The only purpose of cp0_timer_callback is to set CAUSE_IPEX5 when the timer elapses. If IPEX5 is instead externally-driven, then it makes no sense to still schedule the timer to fire.

Great feedback, thanks! I've made the requested changes.

jazz.cpp with extra debugging statements on this branch booting to the WinNT install CD-ROM:

new-jazz-int-enabled

news_r4k.cpp from my development branch booting to NEWS-OS 4.2.1RD:

news-interrupt-disabled

@cuavas cuavas requested a review from pmackinlay May 8, 2022 18:08
@cuavas cuavas merged commit 72a7060 into mamedev:master May 13, 2022
@briceonk briceonk deleted the r4k-timintdis branch May 13, 2022 16:10
wilbertpol pushed a commit to wilbertpol/mame that referenced this pull request May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants