Update vesa.c

This commit is contained in:
2026-01-25 11:47:23 -08:00
committed by GitHub
parent 21a41158aa
commit 6590a84b72

View File

@@ -37,23 +37,28 @@ bool vesa_set_mode(uint16_t mode) {
// Get the VESA mode information // Get the VESA mode information
bool vesa_get_mode_info(uint16_t mode, vbe_mode_info_t* info) { bool vesa_get_mode_info(uint16_t mode, vbe_mode_info_t* info) {
uint16_t eax = VBE_FUNCTION_GET_MODE_INFO; uint16_t ax_ret;
uint32_t ebx = mode;
uint32_t ecx = 0; // Convert the 32-bit pointer to a Segment:Offset pair
uint32_t edx = 0; // IMPORTANT: 'info' MUST be located in the first 1MB of RAM
uint32_t ptr = (uint32_t)info;
uint16_t segment = (uint16_t)((ptr >> 4) & 0xFFFF);
uint16_t offset = (uint16_t)(ptr & 0x000F);
if (vesa_bios_call(VBE_FUNCTION_GET_MODE_INFO, &eax, &ebx, &ecx, &edx)) {
// Copy the information into the provided struct
uint32_t base = (uint32_t)info;
__asm__ __volatile__( __asm__ __volatile__(
"movw %%bx, %%es:%%di\n" "push %%es\n\t" // Save Protected Mode ES
: "movw %1, %%es\n\t" // Load the segment into ES
: "b" (base) "int $0x10\n\t" // BIOS Interrupt
: "%es", "%di", "memory" "pop %%es\n\t" // Restore Protected Mode ES
: "=a"(ax_ret) // Result in AX
: "r"(segment), // %1
"D"(offset), // %2 (DI)
"a"((uint16_t)VBE_FUNCTION_GET_MODE_INFO), // AX (0x4F01)
"c"(mode) // CX (The Mode Number)
: "memory", "cc" // Removed %es from clobbers
); );
return true;
} return ax_ret == 0x004F;
return false;
} }
// Get the VESA controller information // Get the VESA controller information