-
Notifications
You must be signed in to change notification settings - Fork 111
Trap guestOS to run SDL-oriented applications #551
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3b4b3b4
to
35c9256
Compare
jserv
reviewed
Jan 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmarks
Benchmark suite | Current: f20b959 | Previous: 515e011 | Ratio |
---|---|---|---|
Dhrystone |
1324 Average DMIPS over 10 runs |
1306 Average DMIPS over 10 runs |
0.99 |
Coremark |
961.974 Average iterations/sec over 10 runs |
963.25 Average iterations/sec over 10 runs |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
387e715
to
a862132
Compare
jserv
reviewed
Feb 1, 2025
jserv
reviewed
Feb 1, 2025
To trap the guest OS SDL applications, virtual memory translation should be handled when accessing the bidirectional event queues in syscall_sdl.c. Additionally, when using the guest OS, the SDL application might be launched and terminated multiple times. To enhance the user experience, it is heuristic to properly handle three main types of exits: 1, SDL application built-in exit: The source code of the SDL application should be modified to call the syscall_exit(syscall number: 93) somewhere when executing cleanup routine before exit(). 2. Ctrl-c (SIGINT) exit: Detect the ctrl-c keycode. 3. SDL window Quit event: The source code of the SDL application should be modified to call the syscall_exit(syscall number: 93) when receiving SDL window Quit event. The main reason for handling these three types of exits is that SDL2_Mixer may malfunction if not properly initialized and destroyed, as it runs on the host side not on the guest side. Additionally, when terminating an SDL application in the guest OS, the previous SDL window should be closed. Moreover, the default audio backend of SDL2_Mixer(downloadable from brew or Linux distro pkg managers), FluidSynth, occasionally generates the warning: "fluidsynth: warning: Ringbuffer full, try increasing synth.polyphony!" This issue causes the audio to hang, leading to an unstable playback experience. Thus, dropping FluidSynth in favor of the Timidity backend, which provides a stable audio playback experience. Known issue: Calling SDL_DestroyWindow() on macOS does not close the previous SDL window. Close: sysprog21#510
a862132
to
515e011
Compare
Once this merged, I will upload more compact rootfs.cpio to rv32emu-prebuilt. |
Thank @ChinYikMing for contributing! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To trap the guest OS SDL applications, virtual memory translation should be handled when accessing the bidirectional event queues in syscall_sdl.c. Additionally, when using the guest OS, the SDL application might be launched and terminated multiple times. To enhance the user experience, it is heuristic to properly handle three main types of exits:
1, SDL application built-in exit: The source code of the SDL application should be modified to call the syscall_exit(syscall number: 93) somewhere when executing cleanup routine before exit().
2. Ctrl-c (SIGINT) exit: Detect the ctrl-c keycode.
3. SDL window Quit event: The source code of the SDL application should be modified to call the syscall_exit(syscall number: 93) when receiving SDL window Quit event.
The main reason for handling these three types of exits is that SDL2_Mixer may malfunction if not properly initialized and destroyed, as it runs on the host side not on the guest side. Additionally, when terminating an SDL application in the guest OS, the previous SDL window should be closed.
Moreover, the default audio backend of SDL2_Mixer(downloadable from brew or Linux distro pkg managers), FluidSynth, occasionally generates the warning: "fluidsynth: warning: Ringbuffer full, try increasing synth.polyphony!" This issue causes the audio to hang, leading to an unstable playback experience. Thus, dropping FluidSynth in favor of the Timidity backend, which provides a stable audio playback experience.
Known issue: Calling SDL_DestroyWindow() on macOS does not close the previous SDL window.
Close: #510
Note that the following steps are conducted on Ubuntu 22.04 x86-64 machine
Build SDL2_Mixer from source
Download https://github.com/libsdl-org/SDL_mixer and checkout to commit
de7b2f4d2a7e78db363cb26a66df4da1f9524e25
Disable FluidSynth
Might need to install some dependency library(see the error logs if it shows)
timidity/*
into/etc/
directory.Testing procedure
Unzip Image.zip and rootfs.cpio.zip to desired path.
Image.zip
rootfs.cpio.zip
Build rv32emu
doom-riscv
orquake
orsmolnes
)Expectation
Three SDL-oriented applications should be runable and can be exited with all three types of exits without any crash.
Update: (SDL2_mixer build from source on macOS/arm64)
The 1, 2, 4, 5 steps are same to Linux host, but a tiny change to step 3:
3. Build (note that this will override the pre-installed SDL2_Mixer)
Might need to install some dependency library(see the error logs if it shows)