Skip to content

Commit

Permalink
Verify fallback VESA mode before attempting to set it
Browse files Browse the repository at this point in the history
The mode must be listed in the list of supported modes and it
must have the correct attributes (e.g., supported, having linear
frame buffer).
  • Loading branch information
Jiri Svoboda committed Jan 29, 2022
1 parent 485f899 commit 36aec61
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion kernel/arch/ia32/src/boot/vesa_real.inc
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,30 @@ vesa_init_real2:
no_mode:

/* No prefered mode found */
push %di
mov $e_vesa_init - vesa_init, %di
mov 2 + VESA_MODE_LIST_PTR_OFFSET(%di), %si
mov %si, %gs
mov VESA_MODE_LIST_PTR_OFFSET(%di), %si
pop %di

/* Check if list of supported modes contains fallback mode */
find_fallback_mode:

mov %gs:(%si), %cx

cmp $0x111, %cx
je fallback_mode_listed

cmp $VESA_END_OF_MODES, %cx
je text_mode

inc %si
inc %si
jmp find_fallback_mode /* 16-bit relative jump */

fallback_mode_listed:
/* Make sure fallback mode is really supported */
mov $0x111, %cx
push %di
push %cx
Expand All @@ -374,7 +397,13 @@ vesa_init_real2:
pop %di
cmp $VESA_OK, %ax
jnz text_mode
jz set_mode /* force relative jump */

/* Verify mode attributes */
and $0x99, %ax
cmp $0x99, %ax
jne text_mode

jmp set_mode /* 16-bit relative jump */

text_mode:

Expand Down

0 comments on commit 36aec61

Please sign in to comment.