⚠️ Deprecated (2025): This driver is deprecated and replaced by UEFI Graphics Output Protocol (GOP) framebuffer. VESA/VBE is no longer used in UEFI boot. See Graphics System for modern GOP-based graphics.

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 system
  • vesa_enumerate_modes() - Enumerate available video modes

Mode Management

  • vesa_set_mode(mode_number) - Set video mode
  • vesa_get_mode() - Get current mode number
  • vesa_list_modes(buffer, size) - List all available modes

Framebuffer Access

  • vesa_get_framebuffer() - Get framebuffer address
  • vesa_get_width() - Get screen width
  • vesa_get_height() - Get screen height
  • vesa_get_pitch() - Get bytes per scanline
  • vesa_get_bpp() - Get bits per pixel

Double Buffering

  • vesa_enable_double_buffer() - Enable double buffering
  • vesa_disable_double_buffer() - Disable double buffering
  • vesa_swap_buffers() - Swap back buffer to front
  • vesa_get_back_buffer() - Get back buffer address

Drawing Functions

  • vesa_draw_pixel(x, y, color) - Draw a pixel
  • vesa_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:

  1. Call vesa_enable_double_buffer() to enable
  2. Draw to the back buffer using vesa_get_back_buffer()
  3. Call vesa_swap_buffers() to display the frame
  4. 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