VESA/VBE Graphics Driver - ⚠️ DEPRECATED
Replacement: Use kernel/drivers/framebuffer_console.asm with GOP framebuffer information from UEFI bootloader.
Overview
The FreeWorld OS VESA/VBE graphics driver provides comprehensive support for VESA BIOS Extensions (VBE), enabling high-resolution graphics modes and advanced features.
Features
Core Features
- 64-bit Implementation: Full 64-bit native code
- Mode Enumeration: Automatic detection of all available video modes
- Mode Switching: Dynamic resolution and color depth changes
- Multiple Color Depths: Support for 8, 15, 16, 24, and 32-bit color modes
- Double Buffering: Smooth animation support with back buffer
- Linear Framebuffer: Direct memory access to video memory
- Color Masks: Proper RGB color format handling
Advanced Features
- Performance Optimizations: SSE/AVX support for fast operations
- Gamma Correction: Structure ready for gamma support
- Palette Support: 8-bit color mode palette management
- Multi-Monitor: Structure ready for multiple display support
- Hardware Acceleration: Detection and utilization of hardware features
Supported Resolutions
The driver supports standard VESA modes including:
- 640x480 (8, 15, 16, 24, 32-bit)
- 800x600 (8, 15, 16, 24, 32-bit)
- 1024x768 (8, 15, 16, 24, 32-bit)
- 1280x1024 (8, 15, 16, 24, 32-bit)
- 1600x1200 (8, 15, 16, 24, 32-bit)
Additional modes can be enumerated at runtime from the VBE controller.
API Reference
Initialization
vesa_init()- Initialize VESA/VBE systemvesa_enumerate_modes()- Enumerate available video modes
Mode Management
vesa_set_mode(mode_number)- Set video modevesa_get_mode()- Get current mode numbervesa_list_modes(buffer, size)- List all available modes
Framebuffer Access
vesa_get_framebuffer()- Get framebuffer addressvesa_get_width()- Get screen widthvesa_get_height()- Get screen heightvesa_get_pitch()- Get bytes per scanlinevesa_get_bpp()- Get bits per pixel
Double Buffering
vesa_enable_double_buffer()- Enable double bufferingvesa_disable_double_buffer()- Disable double bufferingvesa_swap_buffers()- Swap back buffer to frontvesa_get_back_buffer()- Get back buffer address
Drawing Functions
vesa_draw_pixel(x, y, color)- Draw a pixelvesa_clear_screen(color)- Clear screen with color
Color Formats
The driver supports multiple color formats:
- 8-bit: Indexed color with palette
- 15-bit: RGB 5:5:5 (5 bits per channel)
- 16-bit: RGB 5:6:5 (5 red, 6 green, 5 blue)
- 24-bit: RGB 8:8:8 (8 bits per channel)
- 32-bit: ARGB 8:8:8:8 (8 bits per channel + alpha)
Color masks and shifts are automatically configured based on the selected mode.
Double Buffering
Double buffering provides smooth animation by drawing to a back buffer and then swapping it to the front buffer. This eliminates flickering and provides consistent frame rates.
Usage:
- Call
vesa_enable_double_buffer()to enable - Draw to the back buffer using
vesa_get_back_buffer() - Call
vesa_swap_buffers()to display the frame - Repeat for each frame
Performance
The driver includes several performance optimizations:
- SSE/AVX Support: Fast memory operations using SIMD instructions
- Optimized Buffer Copy: Efficient buffer swapping for double buffering
- Direct Memory Access: Linear framebuffer for maximum performance
- Mode Caching: Cached mode information for fast lookups
Implementation
File: kernel/drivers/vesa_enhanced.asm
Total Lines of Code: ~921 lines
Architecture: x86-64 (64-bit)
Integration
The VESA/VBE driver is integrated with:
- Kernel initialization sequence
- Graphics subsystem
- GUI compositor (for window rendering)
- Device context system
Future Enhancements
- Full real mode/V86 mode support for VBE function calls
- Hardware cursor support
- Hardware acceleration detection and use
- Multi-monitor support (multiple displays)
- Gamma correction implementation
- Palette management for 8-bit modes
- Video mode validation and testing