Skip to content

Add support for FreeBSD and OpenBSD #2338

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

Merged
merged 3 commits into from
Mar 21, 2023
Merged

Add support for FreeBSD and OpenBSD #2338

merged 3 commits into from
Mar 21, 2023

Conversation

kcgen
Copy link
Member

@kcgen kcgen commented Mar 13, 2023

Also re-enables the PPC dynrec cores that were unfortunately disabled in the 2021 commit 5151610 as a result of some refactoring in SVN r4424, which broke the PPC backends. It's nice to finally revisit PPC land now that I have working hardware again.

2023-03-13-140628_1280x854_scrot

Using the normal core, I tested the following:

  • lots of video modes (4-bit, 8-bit, 15-bit, 16-bit, 24-bit, 32-bit)
  • all the CDDA codecs (Wav, Vorbis, FLAC, Opus, MP3, and Sony Wave64)
  • MIDI - both Fluidsynth and MT-32
  • audio devices: PC Speaker, Tandy, PS/1, CMS, SB*, Adlib, Adlib Gold
  • image mounts (CDROM and floppy)

They're all (still) working on big-endian, so that's good!

As for the PPC dynamic core, it now builds - but the OpenBSD kernel blocks it at runtime with an ABORT. OpenBSD has strict mmap requirements regarding R+W+X permission flags, despite Staging complying w/ W^X memory tagging using mprotect, so I'll have to switch to Linux or FreeBSD to get further.

@kcgen kcgen self-assigned this Mar 13, 2023
@kcgen kcgen requested review from FeralChild64 and johnnovak March 13, 2023 23:12
@kcgen kcgen added plumbing Issues related to low-level support functions and classes build system Build system related issues labels Mar 13, 2023
@kcgen
Copy link
Member Author

kcgen commented Mar 13, 2023

Only 122 MB of RAM consumed for the entire OS plus DOSBox Staging 🤯 😎

@johnnovak
Copy link
Member

johnnovak commented Mar 14, 2023

Nice to see that BSD support gets some well-deserved love! I much more prefer the BSD-philosophy than the Linux one (well-designed vs "organically grown", to be diplomatic about it 😅), so this is a welcome improvement! 🎉 Nice one @kcgen 🎊

@johnnovak
Copy link
Member

Does this thing even support OpenGL? If not, it will be a nice testbed for the software renderer backend of the OSD/UI stuff.

@kcgen
Copy link
Member Author

kcgen commented Mar 14, 2023

The BSDs are quite a pleasure to work with, having a consistent layout and configuration approach. I'm especially a fan of their end-to-end documentation; from the kernel up to the services.

Does this thing even support OpenGL?

Yes! (Zoom into the top left of the screenshot to see the log)-- hardware acceleration and even GLSL handling! Pretty amazing; it's the latest OpenBSD 7.2 circa late 2022 even running clang 13.x out of the box. Giving the old hardware plenty of legs!

@kcgen
Copy link
Member Author

kcgen commented Mar 15, 2023

Installing Gentoo Linux on the Powerbook G4; hopefully will have better luck being able to run and test the PPC dynrec core. (motivation being to check big-endian handling/bugs in all the new code added since the last round of big-endian fixes)

Copy link
Member

@johnnovak johnnovak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good @kcgen , nice build instructions. Out of interest, does the Linux binary run in the Linux compatibility mode of BSD? (I've just heard there is such a thing 😄 )

@kcgen
Copy link
Member Author

kcgen commented Mar 15, 2023

Looking good @kcgen , nice build instructions. Out of interest, does the Linux binary run in the Linux compatibility mode of BSD? (I've just heard there is such a thing smile )

Oh yes! I forgot the BSDs' have a Linux compatibility mode - so didn't try running it. I would imagine its libc MMAP wrapper would hit the same security rules in the OpenBSD kernel (then again, maybe to be compatible, they allow a lot more inside some runtime sandbox.. 🤷‍♂️ 😅 )

If I ever revisit OpenBSD, will have to remember to try. Thanks, @johnnovak !

@kcgen kcgen force-pushed the kc/openbsd-ppc-1 branch from adbda89 to 31e706c Compare March 16, 2023 19:29
kcgen added 3 commits March 20, 2023 13:30
We lost some cache memory setup and link closing calls
critical for PPC between these Aug 2020 commits:
 - c0ed954 and
 - 1f156b2

This commit re-adds them in the form of a lambda, which gets PPC
dynrec working again.
The PPC dynrec cores were disabled early 2021 in commit 5151610
as a result of syncing with upstream's r4424 SVN commit, which
refactored the cpu module in ways that broke the PPC dynrec
backends.

Unfortunately my own PowerPC was no longer working at that time,
so I wasn't able to help get it working again. Fortunately I have
a working MacBook G4 now, so can help again.

Note: the PPC 64-bit backends haven't been updated (because I
don't have such a system), however we should laeve it enabled for
the day someone /does/ have a system and can report it to the
project.

Then similar change can be made as done in this commit to get it
work again.

This commit also adds toggling of per-page W^X to Meson.
Also makes a couple minor compatibility fixes:

 - OpenBSD's thread name in Loguru

 - Update headers for the BSDs
@kcgen kcgen force-pushed the kc/openbsd-ppc-1 branch from 48bd86b to c42a202 Compare March 20, 2023 20:30
@kcgen kcgen changed the title Handle OpenBSD in the build system and code Add support for FreeBSD and OpenBSD Mar 21, 2023
@kcgen
Copy link
Member Author

kcgen commented Mar 21, 2023

I'm not hitting any regressions testing other dyn rec cores: x86, armV7, and aarch64, so will go ahead with the merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build system Build system related issues plumbing Issues related to low-level support functions and classes
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants