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

Use framebuffer-based graphics mode instead of EGA text mode #125

Open
perlun opened this issue Oct 12, 2018 · 0 comments
Open

Use framebuffer-based graphics mode instead of EGA text mode #125

perlun opened this issue Oct 12, 2018 · 0 comments

Comments

@perlun
Copy link
Contributor

perlun commented Oct 12, 2018

Things have changed, and nowadays getting a graphical framebuffer setup by the bootloader is trivial - GRUB 2 supports it, you just ask for it and you get it. It's, in fact, almost easier to get a 1024x768x32 graphical framebuffer initialized than an 80x50 text mode set up - GRUB supports the former, but seems to resort to 80x25 if you ask for the latter.

Implementing support for graphical video modes is not trivial, we have to draw the font ourselves and handle scrolling. Having that said, it's clearly doable and paves the way for (eventually) playing around with Tornado our some other GUI ideas.

Here is the code that needs to be tweaked to get this done, from the Multiboot/GRUB perspective:

diff --git a/storm/include/storm/generic/multiboot.h b/storm/include/storm/generic/multiboot.h
index 3c39fdb..c2ffa4b 100644
--- a/storm/include/storm/generic/multiboot.h
+++ b/storm/include/storm/generic/multiboot.h
@@ -17,13 +17,18 @@ enum
     // Indicate that the boot loader should put information about available memory in the Multiboot info structure.
     MULTIBOOT_GET_MEMORY = BIT_VALUE(1),
 
-    // Indicate that the boot loader should put information about the current video mode in the Multiboot info structure.
+    // Indicate that the boot loader should put information about the current video mode in the Multiboot info
+    // structure, and that the kernel provides a requested video mode that the bootloader should preferrably
+    // initialize.
     MULTIBOOT_GET_VIDEO_MODE = BIT_VALUE(2),
 };
 
 #define MULTIBOOT_MAGIC         0x1BADB002
-#define MULTIBOOT_FLAGS         (MULTIBOOT_PAGE_ALIGN | \
-                                 MULTIBOOT_GET_MEMORY)
+#define MULTIBOOT_FLAGS         (                           \
+                                    MULTIBOOT_PAGE_ALIGN |  \
+                                    MULTIBOOT_GET_MEMORY |  \
+                                    MULTIBOOT_GET_VIDEO_MODE \
+                                )
 
 // More information about the multiboot format can be found in the GNU GRUB documentation available at
 // http://www.gnu.org/software/grub/.
diff --git a/storm/x86/init.c b/storm/x86/init.c
index 4cf9f6e..9885e17 100644
--- a/storm/x86/init.c
+++ b/storm/x86/init.c
@@ -77,7 +77,20 @@ uint32_t multiboot_header[] __attribute__ ((section(".init.pre"), unused)) =
 {
     MULTIBOOT_MAGIC,
     MULTIBOOT_FLAGS,
-    -(MULTIBOOT_MAGIC + MULTIBOOT_FLAGS)
+    -(MULTIBOOT_MAGIC + MULTIBOOT_FLAGS),
+
+    // The following are not used by us
+    0, // header_addr
+    0, // load_addr
+    0, // load_end_addr
+    0, // bss_end_addr
+    0, // entry_addr,
+
+    // https://www.gnu.org/software/grub/manual/multiboot/multiboot.html#Header-graphics-fields
+    0,      // Contains ‘0’ for linear graphics mode or ‘1’ for EGA-standard text mode.
+    1024,   // Width
+    768,    // Height
+    32      // Depth (0 in text mode)
 };
 
 // FIXME: Put those in another file. We should have a better system for local include files...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant