Add bpp field to stivale header

This commit is contained in:
mintsuki 2020-03-27 05:58:37 +01:00
parent e39d7f5dd1
commit a234da8deb
4 changed files with 16 additions and 10 deletions

View File

@ -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;

View File

@ -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

View File

@ -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 {

View File

@ -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