Add bpp field to stivale header
diff --git a/src/drivers/vbe.c b/src/drivers/vbe.c
index dddc3bc6..cd24ab9d 100644
--- a/src/drivers/vbe.c
+++ b/src/drivers/vbe.c
@@ -106,7 +106,7 @@ static int get_edid_info(struct edid_info_struct *buf) {
return 0;
}
-int init_vbe(uint64_t *framebuffer, uint16_t *pitch, uint16_t *target_width, uint16_t *target_height) {
+int init_vbe(uint64_t *framebuffer, uint16_t *pitch, uint16_t *target_width, uint16_t *target_height, uint16_t *target_bpp) {
print("vbe: Initialising...\n");
struct vbe_info_struct vbe_info;
@@ -119,7 +119,8 @@ int init_vbe(uint64_t *framebuffer, uint16_t *pitch, uint16_t *target_width, uin
print("vbe: Product revision: %s\n", (char *)rm_desegment(vbe_info.prod_rev_seg, vbe_info.prod_rev_off));
struct edid_info_struct edid_info;
- if (!*target_width || !*target_height) {
+ if (!*target_width || !*target_height || !*target_bpp) {
+ *target_bpp = 32;
if (get_edid_info(&edid_info)) {
print("vbe: EDID unavailable, defaulting to 1024x768\n");
*target_width = 1024;
@@ -132,7 +133,8 @@ int init_vbe(uint64_t *framebuffer, uint16_t *pitch, uint16_t *target_width, uin
*target_height += ((int)edid_info.det_timing_desc1[7] & 0xf0) << 4;
}
} else {
- print("vbe: Requested resolution of %ux%u\n", *target_width, *target_height);
+ print("vbe: Requested resolution of %ux%ux%u\n",
+ *target_width, *target_height, *target_bpp);
}
uint16_t *vid_modes = (uint16_t *)rm_desegment(vbe_info.vid_modes_seg,
@@ -143,7 +145,7 @@ int init_vbe(uint64_t *framebuffer, uint16_t *pitch, uint16_t *target_width, uin
get_vbe_mode_info(&vbe_mode_info, vid_modes[i]);
if (vbe_mode_info.res_x == *target_width
&& vbe_mode_info.res_y == *target_height
- && vbe_mode_info.bpp == 32) {
+ && vbe_mode_info.bpp == *target_bpp) {
print("vbe: Found matching mode %x, attempting to set\n", vid_modes[i]);
*framebuffer = (uint64_t)vbe_mode_info.framebuffer;
*pitch = (int)vbe_mode_info.pitch;
diff --git a/src/drivers/vbe.h b/src/drivers/vbe.h
index d7765595..180deb1a 100644
--- a/src/drivers/vbe.h
+++ b/src/drivers/vbe.h
@@ -1,6 +1,6 @@
#ifndef __DRIVERS__VBE_H__
#define __DRIVERS__VBE_H__
-int init_vbe(uint64_t *framebuffer, uint16_t *pitch, uint16_t *target_width, uint16_t *target_height);
+int init_vbe(uint64_t *framebuffer, uint16_t *pitch, uint16_t *target_width, uint16_t *target_height, uint16_t *target_bpp);
#endif
diff --git a/src/protos/stivale.c b/src/protos/stivale.c
index a6d02400..2d902234 100644
--- a/src/protos/stivale.c
+++ b/src/protos/stivale.c
@@ -9,9 +9,10 @@
struct stivale_header {
uint64_t stack;
- uint8_t video_mode; // 0 = default at boot (CGA text mode). 1 = graphical VESA
+ uint16_t video_mode; // 0 = default at boot (CGA text mode). 1 = graphical VESA
uint16_t framebuffer_width;
uint16_t framebuffer_height;
+ uint16_t framebuffer_bpp;
} __attribute__((packed));
struct stivale_module {
@@ -68,12 +69,14 @@ void stivale_load(struct echfs_file_handle *fd) {
stivale_struct.framebuffer_width = stivale_hdr.framebuffer_width;
stivale_struct.framebuffer_height = stivale_hdr.framebuffer_height;
+ stivale_struct.framebuffer_bpp = stivale_hdr.framebuffer_bpp;
if (stivale_hdr.video_mode == 1) {
init_vbe(&stivale_struct.framebuffer_addr,
&stivale_struct.framebuffer_pitch,
&stivale_struct.framebuffer_width,
- &stivale_struct.framebuffer_height);
+ &stivale_struct.framebuffer_height,
+ &stivale_struct.framebuffer_bpp);
}
volatile struct {
diff --git a/test/test.asm b/test/test.asm
index 69aee3e2..5b65394e 100644
--- a/test/test.asm
+++ b/test/test.asm
@@ -5,9 +5,10 @@ section .stivalehdr
stivale_header:
dq stack.top ; rsp
- db 1 ; video mode
- dw 0 ; fb_width
- dw 0 ; fb_height
+ dw 1 ; video mode
+ dw 800 ; fb_width
+ dw 600 ; fb_height
+ dw 16 ; fb_bpp
section .bss
