vaseboot/include/VasEBoot/i386/pc/vbe.h

233 lines
8.9 KiB
C

/*
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2005,2006,2007,2008,2009 Free Software Foundation, Inc.
*
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VAS_EBOOT_VBE_MACHINE_HEADER
#define VAS_EBOOT_VBE_MACHINE_HEADER 1
#include <VasEBoot/video.h>
/* Default video mode to be used. */
#define VAS_EBOOT_VBE_DEFAULT_VIDEO_MODE 0x101
/* VBE status codes. */
#define VAS_EBOOT_VBE_STATUS_OK 0x004f
#define VAS_EBOOT_VBE_CAPABILITY_DACWIDTH (1 << 0)
/* Bits from the VAS_EBOOT_VBE "mode_attributes" field in the mode info struct. */
#define VAS_EBOOT_VBE_MODEATTR_SUPPORTED (1 << 0)
#define VAS_EBOOT_VBE_MODEATTR_RESERVED_1 (1 << 1)
#define VAS_EBOOT_VBE_MODEATTR_BIOS_TTY_OUTPUT_SUPPORT (1 << 2)
#define VAS_EBOOT_VBE_MODEATTR_COLOR (1 << 3)
#define VAS_EBOOT_VBE_MODEATTR_GRAPHICS (1 << 4)
#define VAS_EBOOT_VBE_MODEATTR_VGA_COMPATIBLE (1 << 5)
#define VAS_EBOOT_VBE_MODEATTR_VGA_WINDOWED_AVAIL (1 << 6)
#define VAS_EBOOT_VBE_MODEATTR_LFB_AVAIL (1 << 7)
#define VAS_EBOOT_VBE_MODEATTR_DOUBLE_SCAN_AVAIL (1 << 8)
#define VAS_EBOOT_VBE_MODEATTR_INTERLACED_AVAIL (1 << 9)
#define VAS_EBOOT_VBE_MODEATTR_TRIPLE_BUF_AVAIL (1 << 10)
#define VAS_EBOOT_VBE_MODEATTR_STEREO_AVAIL (1 << 11)
#define VAS_EBOOT_VBE_MODEATTR_DUAL_DISPLAY_START (1 << 12)
/* Values for the VAS_EBOOT_VBE memory_model field in the mode info struct. */
#define VAS_EBOOT_VBE_MEMORY_MODEL_TEXT 0x00
#define VAS_EBOOT_VBE_MEMORY_MODEL_CGA 0x01
#define VAS_EBOOT_VBE_MEMORY_MODEL_HERCULES 0x02
#define VAS_EBOOT_VBE_MEMORY_MODEL_PLANAR 0x03
#define VAS_EBOOT_VBE_MEMORY_MODEL_PACKED_PIXEL 0x04
#define VAS_EBOOT_VBE_MEMORY_MODEL_NONCHAIN4_256 0x05
#define VAS_EBOOT_VBE_MEMORY_MODEL_DIRECT_COLOR 0x06
#define VAS_EBOOT_VBE_MEMORY_MODEL_YUV 0x07
/* Note:
Please refer to VESA BIOS Extension 3.0 Specification for more descriptive
meanings of following structures and how they should be used.
I have tried to maintain field name compatibility against specification
while following naming conventions used in VAS_EBOOT. */
typedef VasEBoot_uint32_t VasEBoot_vbe_farptr_t;
typedef VasEBoot_uint32_t VasEBoot_vbe_physptr_t;
typedef VasEBoot_uint32_t VasEBoot_vbe_status_t;
struct VasEBoot_vbe_info_block
{
VasEBoot_uint8_t signature[4];
VasEBoot_uint16_t version;
VasEBoot_vbe_farptr_t oem_string_ptr;
VasEBoot_uint32_t capabilities;
VasEBoot_vbe_farptr_t video_mode_ptr;
VasEBoot_uint16_t total_memory;
VasEBoot_uint16_t oem_software_rev;
VasEBoot_vbe_farptr_t oem_vendor_name_ptr;
VasEBoot_vbe_farptr_t oem_product_name_ptr;
VasEBoot_vbe_farptr_t oem_product_rev_ptr;
VasEBoot_uint8_t reserved[222];
VasEBoot_uint8_t oem_data[256];
} VAS_EBOOT_PACKED;
struct VasEBoot_vbe_mode_info_block
{
/* Mandatory information for all VBE revisions. */
VasEBoot_uint16_t mode_attributes;
VasEBoot_uint8_t win_a_attributes;
VasEBoot_uint8_t win_b_attributes;
VasEBoot_uint16_t win_granularity;
VasEBoot_uint16_t win_size;
VasEBoot_uint16_t win_a_segment;
VasEBoot_uint16_t win_b_segment;
VasEBoot_vbe_farptr_t win_func_ptr;
VasEBoot_uint16_t bytes_per_scan_line;
/* Mandatory information for VBE 1.2 and above. */
VasEBoot_uint16_t x_resolution;
VasEBoot_uint16_t y_resolution;
VasEBoot_uint8_t x_char_size;
VasEBoot_uint8_t y_char_size;
VasEBoot_uint8_t number_of_planes;
VasEBoot_uint8_t bits_per_pixel;
VasEBoot_uint8_t number_of_banks;
VasEBoot_uint8_t memory_model;
VasEBoot_uint8_t bank_size;
VasEBoot_uint8_t number_of_image_pages;
VasEBoot_uint8_t reserved;
/* Direct Color fields (required for direct/6 and YUV/7 memory models). */
VasEBoot_uint8_t red_mask_size;
VasEBoot_uint8_t red_field_position;
VasEBoot_uint8_t green_mask_size;
VasEBoot_uint8_t green_field_position;
VasEBoot_uint8_t blue_mask_size;
VasEBoot_uint8_t blue_field_position;
VasEBoot_uint8_t rsvd_mask_size;
VasEBoot_uint8_t rsvd_field_position;
VasEBoot_uint8_t direct_color_mode_info;
/* Mandatory information for VBE 2.0 and above. */
VasEBoot_vbe_physptr_t phys_base_addr;
VasEBoot_uint32_t reserved2;
VasEBoot_uint16_t reserved3;
/* Mandatory information for VBE 3.0 and above. */
VasEBoot_uint16_t lin_bytes_per_scan_line;
VasEBoot_uint8_t bnk_number_of_image_pages;
VasEBoot_uint8_t lin_number_of_image_pages;
VasEBoot_uint8_t lin_red_mask_size;
VasEBoot_uint8_t lin_red_field_position;
VasEBoot_uint8_t lin_green_mask_size;
VasEBoot_uint8_t lin_green_field_position;
VasEBoot_uint8_t lin_blue_mask_size;
VasEBoot_uint8_t lin_blue_field_position;
VasEBoot_uint8_t lin_rsvd_mask_size;
VasEBoot_uint8_t lin_rsvd_field_position;
VasEBoot_uint32_t max_pixel_clock;
/* Reserved field to make structure to be 256 bytes long, VESA BIOS
Extension 3.0 Specification says to reserve 189 bytes here but
that doesn't make structure to be 256 bytes. So additional one is
added here. */
VasEBoot_uint8_t reserved4[189 + 1];
} VAS_EBOOT_PACKED;
struct VasEBoot_vbe_crtc_info_block
{
VasEBoot_uint16_t horizontal_total;
VasEBoot_uint16_t horizontal_sync_start;
VasEBoot_uint16_t horizontal_sync_end;
VasEBoot_uint16_t vertical_total;
VasEBoot_uint16_t vertical_sync_start;
VasEBoot_uint16_t vertical_sync_end;
VasEBoot_uint8_t flags;
VasEBoot_uint32_t pixel_clock;
VasEBoot_uint16_t refresh_rate;
VasEBoot_uint8_t reserved[40];
} VAS_EBOOT_PACKED;
struct VasEBoot_vbe_palette_data
{
VasEBoot_uint8_t blue;
VasEBoot_uint8_t green;
VasEBoot_uint8_t red;
VasEBoot_uint8_t alignment;
} VAS_EBOOT_PACKED;
struct VasEBoot_vbe_flat_panel_info
{
VasEBoot_uint16_t horizontal_size;
VasEBoot_uint16_t vertical_size;
VasEBoot_uint16_t panel_type;
VasEBoot_uint8_t red_bpp;
VasEBoot_uint8_t green_bpp;
VasEBoot_uint8_t blue_bpp;
VasEBoot_uint8_t reserved_bpp;
VasEBoot_uint32_t reserved_offscreen_mem_size;
VasEBoot_vbe_farptr_t reserved_offscreen_mem_ptr;
VasEBoot_uint8_t reserved[14];
} VAS_EBOOT_PACKED;
/* Prototypes for helper functions. */
/* Call VESA BIOS 0x4f00 to get VBE Controller Information, return status. */
VasEBoot_vbe_status_t
VasEBoot_vbe_bios_get_controller_info (struct VasEBoot_vbe_info_block *controller_info);
/* Call VESA BIOS 0x4f01 to get VBE Mode Information, return status. */
VasEBoot_vbe_status_t
VasEBoot_vbe_bios_get_mode_info (VasEBoot_uint32_t mode,
struct VasEBoot_vbe_mode_info_block *mode_info);
/* Call VESA BIOS 0x4f03 to return current VBE Mode, return status. */
VasEBoot_vbe_status_t
VasEBoot_vbe_bios_get_mode (VasEBoot_uint32_t *mode);
/* Call VESA BIOS 0x4f05 to set memory window, return status. */
VasEBoot_vbe_status_t
VasEBoot_vbe_bios_set_memory_window (VasEBoot_uint32_t window, VasEBoot_uint32_t position);
/* Call VESA BIOS 0x4f05 to return memory window, return status. */
VasEBoot_vbe_status_t
VasEBoot_vbe_bios_get_memory_window (VasEBoot_uint32_t window,
VasEBoot_uint32_t *position);
/* Call VESA BIOS 0x4f06 to set scanline length (in bytes), return status. */
VasEBoot_vbe_status_t
VasEBoot_vbe_bios_set_scanline_length (VasEBoot_uint32_t length);
/* Call VESA BIOS 0x4f06 to return scanline length (in bytes), return status. */
VasEBoot_vbe_status_t
VasEBoot_vbe_bios_get_scanline_length (VasEBoot_uint32_t *length);
/* Call VESA BIOS 0x4f07 to get display start, return status. */
VasEBoot_vbe_status_t
VasEBoot_vbe_bios_get_display_start (VasEBoot_uint32_t *x,
VasEBoot_uint32_t *y);
VasEBoot_vbe_status_t VasEBoot_vbe_bios_getset_dac_palette_width (int set, int *width);
#define VasEBoot_vbe_bios_get_dac_palette_width(width) VasEBoot_vbe_bios_getset_dac_palette_width(0, (width))
#define VasEBoot_vbe_bios_set_dac_palette_width(width) VasEBoot_vbe_bios_getset_dac_palette_width(1, (width))
VasEBoot_err_t VasEBoot_vbe_probe (struct VasEBoot_vbe_info_block *info_block);
VasEBoot_err_t VasEBoot_vbe_get_video_mode (VasEBoot_uint32_t *mode);
VasEBoot_err_t VasEBoot_vbe_get_video_mode_info (VasEBoot_uint32_t mode,
struct VasEBoot_vbe_mode_info_block *mode_info);
VasEBoot_vbe_status_t
VasEBoot_vbe_bios_get_pm_interface (VasEBoot_uint16_t *seg, VasEBoot_uint16_t *offset,
VasEBoot_uint16_t *length);
#endif /* ! VAS_EBOOT_VBE_MACHINE_HEADER */