Skip to content

feat: Bochs VBE linear framebuffer support - #2523

Merged
sarahspberrypi merged 1 commit into
hermit-os:mainfrom
GloriousAlpaca:pr-bga-clean
Sep 2, 2026
Merged

feat: Bochs VBE linear framebuffer support#2523
sarahspberrypi merged 1 commit into
hermit-os:mainfrom
GloriousAlpaca:pr-bga-clean

Conversation

@GloriousAlpaca

Copy link
Copy Markdown

I'm currently working on porting Doom to Hermit and needed a feature to directly write pixel data into the Bochs Graphics Adaptor as Hermit currently only has support for VGA in textmode.

The feature currently adds standard BGA preparation (Link to OSDev) with a hardcoded resolution (640x400), bpp (32) and a systemcall (sys_get_framebuffer) to receive the address of the framebuffer.
The systemcall falls back to 0 if there was a failure in initializing the framebuffer (e.g. if pci is missing, or the bga feature is not enabled).

I have currently only tested this feature with c programs on a mac using Qemu. The feature is also only available on the x86_64 architecture.

@mkroening mkroening self-assigned this Jul 3, 2026
@mkroening
mkroening self-requested a review July 3, 2026 15:40

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Benchmark Results

Details
Benchmark Current: 66ab8bd Previous: 2e23902 Performance Ratio
startup_benchmark Build Time 92.04 s 80.34 s 1.15
startup_benchmark File Size 0.79 MB 0.80 MB 0.99
Startup Time - 1 core 0.72 s (±0.02 s) 0.75 s (±0.02 s) 0.97
Startup Time - 2 cores 0.72 s (±0.01 s) 0.74 s (±0.02 s) 0.98
Startup Time - 4 cores 0.72 s (±0.01 s) 0.74 s (±0.02 s) 0.96
multithreaded_benchmark Build Time 92.05 s 82.11 s 1.12
multithreaded_benchmark File Size 0.88 MB 0.86 MB 1.02
Multithreaded Pi Efficiency - 2 Threads 67.85 % (±5.94 %) 85.89 % (±6.61 %) 0.79
Multithreaded Pi Efficiency - 4 Threads 41.01 % (±2.47 %) 43.43 % (±2.56 %) 0.94
Multithreaded Pi Efficiency - 8 Threads 20.35 % (±1.41 %) 25.76 % (±1.53 %) 0.79
micro_benchmarks Build Time 213.08 s 80.40 s 2.65
micro_benchmarks File Size 0.88 MB 0.86 MB 1.02
Scheduling time - 1 thread 182.52 ticks (±41.13 ticks) 62.65 ticks (±4.06 ticks) 2.91
Scheduling time - 2 threads 104.74 ticks (±23.92 ticks) 34.08 ticks (±4.10 ticks) 3.07
Micro - Time for syscall (getpid) 8.06 ticks (±4.69 ticks) 3.45 ticks (±0.58 ticks) 2.34
Memcpy speed - (built_in) block size 4096 56475.45 MByte/s (±40588.17 MByte/s) 82448.38 MByte/s (±56997.13 MByte/s) 0.68
Memcpy speed - (built_in) block size 1048576 13722.71 MByte/s (±11204.20 MByte/s) 30585.98 MByte/s (±24707.84 MByte/s) 0.45
Memcpy speed - (built_in) block size 16777216 12109.74 MByte/s (±10062.50 MByte/s) 26340.06 MByte/s (±21720.96 MByte/s) 0.46
Memset speed - (built_in) block size 4096 56596.50 MByte/s (±40669.07 MByte/s) 82292.76 MByte/s (±56891.50 MByte/s) 0.69
Memset speed - (built_in) block size 1048576 14242.90 MByte/s (±11586.17 MByte/s) 31323.85 MByte/s (±25145.86 MByte/s) 0.45
Memset speed - (built_in) block size 16777216 12511.07 MByte/s (±10327.82 MByte/s) 27104.68 MByte/s (±22209.94 MByte/s) 0.46
Memcpy speed - (rust) block size 4096 56673.55 MByte/s (±39820.12 MByte/s) 74097.96 MByte/s (±51811.44 MByte/s) 0.76
Memcpy speed - (rust) block size 1048576 15792.84 MByte/s (±14006.89 MByte/s) 30361.60 MByte/s (±24602.37 MByte/s) 0.52
Memcpy speed - (rust) block size 16777216 12706.62 MByte/s (±10581.10 MByte/s) 27625.34 MByte/s (±22806.88 MByte/s) 0.46
Memset speed - (rust) block size 4096 56639.94 MByte/s (±39797.55 MByte/s) 74373.47 MByte/s (±51976.48 MByte/s) 0.76
Memset speed - (rust) block size 1048576 16139.04 MByte/s (±14198.27 MByte/s) 31110.89 MByte/s (±25033.24 MByte/s) 0.52
Memset speed - (rust) block size 16777216 13060.09 MByte/s (±10801.27 MByte/s) 28386.93 MByte/s (±23265.03 MByte/s) 0.46
alloc_benchmarks Build Time 211.82 s 74.76 s 2.83
alloc_benchmarks File Size 0.87 MB 0.87 MB 0.99
Allocations - Allocation success 91.38 % 91.31 % 1.00
Allocations - Deallocation success 100.00 % 100.00 % 1
Allocations - Pre-fail Allocations 61.60 % 61.44 % 1.00
Allocations - Average Allocation time 15388.52 Ticks (±2100.26 Ticks) 5860.58 Ticks (±98.43 Ticks) 2.63
Allocations - Average Allocation time (no fail) 17260.22 Ticks (±2292.97 Ticks) 6554.81 Ticks (±92.86 Ticks) 2.63
Allocations - Average Deallocation time 7191.18 Ticks (±1217.40 Ticks) 1805.01 Ticks (±250.35 Ticks) 3.98
mutex_benchmark Build Time 220.74 s 79.82 s 2.77
mutex_benchmark File Size 0.88 MB 0.86 MB 1.02
Mutex Stress Test Average Time per Iteration - 1 Threads 35.08 ns (±6.49 ns) 12.10 ns (±0.41 ns) 2.90
Mutex Stress Test Average Time per Iteration - 2 Threads 30.52 ns (±9.26 ns) 40.26 ns (±1.68 ns) 0.76

This comment was automatically generated by workflow using github-action-benchmark.

@mkroening mkroening left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR! :)

This is great! First I was wondering why we should use BGA instead of UEFI's GOP, which would also work on real machines, but I guess BGA is just easier at the moment. Since it is not that invasive, this is fine with me.

I am a bit confused regarding naming; maybe you could clear that up in a doc comment of the module or even the feature documentation. If I understand correctly, BGA is the Bochs Graphics Adapter, which we talk to via the VESA BIOS Extensions (VBE) API. But instead of talking to the BIOS via interrupts, we can just talk to the VBE API through the special BGA ports, right? In that case, the module names, feature names, and constant names make sense to me now.

Comment thread src/syscalls/system.rs Outdated
Comment thread src/syscalls/system.rs Outdated
Comment thread src/arch/x86_64/kernel/bga.rs Outdated
Comment thread src/arch/x86_64/kernel/bga.rs Outdated
Comment thread src/arch/x86_64/kernel/bga.rs Outdated
Comment thread src/arch/x86_64/kernel/bga.rs Outdated
Comment thread src/arch/x86_64/kernel/bga.rs Outdated
Comment thread src/arch/x86_64/kernel/bga.rs Outdated
Comment thread src/arch/x86_64/kernel/bga.rs Outdated
Comment thread src/arch/x86_64/kernel/bga.rs Outdated
Comment thread Cargo.toml
@mkroening

Copy link
Copy Markdown
Member

Ah, please also ensure that your PR does not include merge commits. Please rebase instead.

Comment thread src/arch/x86_64/kernel/bga.rs Outdated
@GloriousAlpaca

Copy link
Copy Markdown
Author

Thanks a lot for the feedback! I have pushed a commit, where I've addressed the feedback you've given. I have actually implemented the systemcall a bit differently than I've written before. Please do have a look if this is a good way to design it. I have also used structs instead of enums to consolidate the constants. Let me know if this is alright with you.

Comment thread src/syscalls/system.rs Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LLM review

The BGA driver implementation has several critical issues that need to be addressed, particularly around unsafe operations, error handling, and potential race conditions.

Comment thread src/arch/x86_64/kernel/bga.rs Outdated
Comment thread src/arch/x86_64/kernel/bga.rs
Comment thread src/arch/x86_64/kernel/bga.rs Outdated
Comment thread src/arch/x86_64/kernel/bga.rs Outdated
Comment thread src/arch/x86_64/kernel/bga.rs
Comment thread src/arch/x86_64/kernel/bga.rs
Comment thread src/syscalls/system.rs
Comment thread src/syscalls/system.rs Outdated
Comment thread src/arch/x86_64/kernel/bga.rs Outdated
Comment thread src/arch/x86_64/kernel/bga.rs Outdated
Comment thread src/arch/x86_64/kernel/bga.rs Outdated
Comment thread src/arch/x86_64/kernel/bga.rs Outdated
Comment thread src/arch/x86_64/kernel/bga.rs Outdated
@GloriousAlpaca
GloriousAlpaca force-pushed the pr-bga-clean branch 5 times, most recently from 34012fb to ff8a16b Compare August 11, 2026 13:52
Comment thread src/syscalls/system.rs Outdated
Comment thread src/syscalls/system.rs Outdated
@mkroening mkroening removed their assignment Aug 22, 2026
@mkroening
mkroening removed their request for review August 22, 2026 13:57
Comment thread src/arch/x86_64/kernel/mod.rs Outdated
@GloriousAlpaca
GloriousAlpaca force-pushed the pr-bga-clean branch 3 times, most recently from dcf5697 to 52e245a Compare August 26, 2026 12:42
Comment thread src/arch/x86_64/kernel/bga.rs
@sarahspberrypi
sarahspberrypi dismissed mkroening’s stale review September 2, 2026 13:13

Outdated/has been fixed

@sarahspberrypi
sarahspberrypi added this pull request to the merge queue Sep 2, 2026
Merged via the queue into hermit-os:main with commit d21c152 Sep 2, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants