stivale: Add support for extended colour information
diff --git a/STIVALE.md b/STIVALE.md
index c53a5c73..4b5a21cc 100644
--- a/STIVALE.md
+++ b/STIVALE.md
@@ -179,7 +179,16 @@ struct stivale_struct {
uint64_t epoch; // UNIX epoch at boot, read from system RTC
uint64_t flags; // Flags
// bit 0: 1 if booted with BIOS, 0 if booted with UEFI
+ // bit 1: 1 if extended colour information passed, 0 if not
// All other bits undefined.
+ // Extended colour information follows, only access if bit 1 of flags is set.
+ uint8_t fb_memory_model; // Memory model: 1=RGB, all other values undefined
+ uint8_t fb_red_mask_size; // RGB mask sizes and left shifts
+ uint8_t fb_red_mask_shift;
+ uint8_t fb_green_mask_size;
+ uint8_t fb_green_mask_shift;
+ uint8_t fb_blue_mask_size;
+ uint8_t fb_blue_mask_shift;
} __attribute__((packed));
```
diff --git a/limine-pxe.bin b/limine-pxe.bin
index c28edc50..9bea5b6f 100644
Binary files a/limine-pxe.bin and b/limine-pxe.bin differ
diff --git a/limine.bin b/limine.bin
index c2ab236f..d59d1e9a 100644
Binary files a/limine.bin and b/limine.bin differ
diff --git a/stage2.map b/stage2.map
index fb630dcd..e735979d 100644
Binary files a/stage2.map and b/stage2.map differ
diff --git a/stage2/protos/stivale.c b/stage2/protos/stivale.c
index 146264d4..ee812aab 100644
--- a/stage2/protos/stivale.c
+++ b/stage2/protos/stivale.c
@@ -28,6 +28,7 @@ struct stivale_struct stivale_struct = {0};
void stivale_load(char *config, char *cmdline) {
stivale_struct.flags |= (1 << 0); // set bit 0 since we are BIOS and not UEFI
+ stivale_struct.flags |= (1 << 1); // we give colour information
struct file_handle *kernel = conv_mem_alloc(sizeof(struct file_handle));
@@ -183,13 +184,21 @@ void stivale_load(char *config, char *cmdline) {
parse_resolution(&req_width, &req_height, &req_bpp, resolution);
struct vbe_framebuffer_info fbinfo;
- init_vbe(&fbinfo, req_width, req_height, req_bpp);
-
- stivale_struct.framebuffer_addr = (uint64_t)fbinfo.framebuffer_addr;
- stivale_struct.framebuffer_width = fbinfo.framebuffer_width;
- stivale_struct.framebuffer_height = fbinfo.framebuffer_height;
- stivale_struct.framebuffer_bpp = fbinfo.framebuffer_bpp;
- stivale_struct.framebuffer_pitch = fbinfo.framebuffer_pitch;
+ if (!init_vbe(&fbinfo, req_width, req_height, req_bpp))
+ panic("stivale: Unable to set video mode");
+
+ stivale_struct.framebuffer_addr = (uint64_t)fbinfo.framebuffer_addr;
+ stivale_struct.framebuffer_width = fbinfo.framebuffer_width;
+ stivale_struct.framebuffer_height = fbinfo.framebuffer_height;
+ stivale_struct.framebuffer_bpp = fbinfo.framebuffer_bpp;
+ stivale_struct.framebuffer_pitch = fbinfo.framebuffer_pitch;
+ stivale_struct.fb_memory_model = STIVALE_FBUF_MMODEL_RGB;
+ stivale_struct.fb_red_mask_size = fbinfo.red_mask_size;
+ stivale_struct.fb_red_mask_shift = fbinfo.red_mask_shift;
+ stivale_struct.fb_green_mask_size = fbinfo.green_mask_size;
+ stivale_struct.fb_green_mask_shift = fbinfo.green_mask_shift;
+ stivale_struct.fb_blue_mask_size = fbinfo.blue_mask_size;
+ stivale_struct.fb_blue_mask_shift = fbinfo.blue_mask_shift;
}
bool want_5lv = level5pg && (stivale_hdr.flags & (1 << 1));
diff --git a/stivale/stivale.h b/stivale/stivale.h
index 8e5c0891..89a24020 100644
--- a/stivale/stivale.h
+++ b/stivale/stivale.h
@@ -41,6 +41,10 @@ struct stivale_mmap_entry {
uint32_t unused;
} __attribute__((packed));
+enum {
+ STIVALE_FBUF_MMODEL_RGB = 1
+};
+
struct stivale_struct {
uint64_t cmdline;
uint64_t memory_map_addr;
@@ -55,6 +59,14 @@ struct stivale_struct {
uint64_t modules;
uint64_t epoch;
uint64_t flags; // bit 0: 1 if booted with BIOS, 0 if booted with UEFI
+ // bit 1: 1 if extended colour information passed, 0 if not
+ uint8_t fb_memory_model;
+ uint8_t fb_red_mask_size;
+ uint8_t fb_red_mask_shift;
+ uint8_t fb_green_mask_size;
+ uint8_t fb_green_mask_shift;
+ uint8_t fb_blue_mask_size;
+ uint8_t fb_blue_mask_shift;
} __attribute__((packed));
#endif
diff --git a/test/stivale.c b/test/stivale.c
index 4616ec6b..3ec63a0e 100644
--- a/test/stivale.c
+++ b/test/stivale.c
@@ -33,6 +33,17 @@ void stivale_main(struct stivale_struct *info) {
e9_printf("\tWidth: %d", info->framebuffer_width);
e9_printf("\tHeight: %d", info->framebuffer_height);
e9_printf("\tBPP: %d", info->framebuffer_bpp);
+ if (info->flags & (1 << 1)) {
+ e9_printf("\tExtended colour information passed:");
+ e9_printf("\t\tMemory model: %d", info->fb_memory_model);
+ e9_printf("\t\tRed mask size: %d", info->fb_red_mask_size);
+ e9_printf("\t\tRed mask shift: %d", info->fb_red_mask_shift);
+ e9_printf("\t\tGreen mask size: %d", info->fb_green_mask_size);
+ e9_printf("\t\tGreen mask shift: %d", info->fb_green_mask_shift);
+ e9_printf("\t\tBlue mask size: %d", info->fb_blue_mask_size);
+ e9_printf("\t\tBlue mask shift: %d", info->fb_blue_mask_shift);
+ }
+
e9_printf("RSDP at %x", info->rsdp);
e9_printf("Module map at %x with modules:", info->modules);
