theseus-os/Theseus

Support single-core machines

tsoutsman opened this issue · 3 comments

Running make run QEMU_CPUS=1 currently fails with:

Theseus is shutting down, msg: Couldn't allocate frames for the final framebuffer
[E] kernel/nano_core/src/lib.rs:54: Theseus is shutting down, msg: Couldn't allocate frames for the final framebuffer
[T] kernel/panic_wrapper/src/lib.rs:32: at top of panic_wrapper: PanicInfo { payload: Any { .. }, message: Some(Couldn't allocate frames for the final framebuffer), location: Location { file: "kernel/nano_core/src/lib.rs", line: 57, col: 5 }, can_unwind: true }

Booting APs often complicates things, and so it would be nice to have the option to run Theseus with a single core.

yep, this is a long-running issue with how obnoxious it is to obtain and modify graphics modes using BIOS interrupts on x86. I think with the new bootloader support this will be fixed on its own, but we can certainly track it in an issue.

Another thought: this will actually be quite easy since we're implementing support for UEFI GOP. We can reuse the upcoming early framebuffer writer even in BIOS boot mode, as there is a field in the multiboot2 header that can be used to request that the bootloader (grub) puts us directly in graphical mode (rather than in VGA text mode).

In fact I already have the code to request that, I just haven't enabled it because we didn't previously have an early text outputter for graphical framebuffers.

; Below is the framebuffer tag, used to request a graphical (non-text) framebuffer and specify its size.
; By default, we ask the bootloader to switch modes to a graphical framebuffer for us,
; though this can be disabled by defining `VGA_TEXT_MODE`.
;
; NOTE: TODO: uncomment the below sections when we are ready to enable
; early boot-time usage of the graphical framebuffer by default.
;
; %ifndef VGA_TEXT_MODE
; align 8
; dw 5 ; type (5 means framebuffer tag)
; dw 0 ; flags. Bit 0 = `1` means this tag is optional, Bit 0 = `0` means it's mandatory.
; dd 20 ; size of this tag (20)
; dd 1280 ; width (in pixels)
; dd 1024 ; height (in pixels)
; dd 32 ; depth (pixel size in bits)
; %endif

Then, once we have an early text writer for graphical framebuffers, we can just have the bootloader set the graphics mode for us one time, during boot, and we'll never need to re-set it ourselves (unless we want to, optionally during AP boot or via a future graphics device driver).

This is now addressed thanks to the recent support for early graphical framebuffer support as well as propagating bootloader-provided graphical info throughout initialization. As of PR #891, you can fully boot into a single CPU machine as normal.