/*
 * vesa.h
 *
 * Copyright (C) 2016 Aleksandar Andrejevic <theflash@sdf.lonestar.org>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _VESA_H_
#define _VESA_H_

#include <video.h>

#define MAX_NUM_MODES 1024
#define VBE_BUFFER_SIZE 0x1000

#pragma pack(push, 1)

typedef struct
{
    dword_t signature;
    word_t version;
    word_t oem_string[2];
    dword_t capabilities;
    word_t videomodes[2];
    word_t total_memory;
} vbe_controller_info_t;

typedef struct
{
    word_t attributes;
    byte_t window_a_attr, window_b_attr;
    word_t window_gran;
    word_t window_size;
    word_t window_a_start_seg, window_b_start_seg;
    word_t window_pos[2];
    word_t bytes_per_sl;
    word_t width, height;
    byte_t char_width, char_height;
    byte_t num_planes, bpp, banks;
    byte_t mem_model_type, bank_size, num_image_pages;
    byte_t reserved;
    byte_t red_mask_size, red_field_pos;
    byte_t green_mask_size, green_field_pos;
    byte_t blue_mask_size, blue_field_pos;
    byte_t reserved_mask_size, reserved_field_pos;
    byte_t direct_color_info;
    dword_t video_buffer, offscreen;
    word_t offscreen_size;
} vbe_mode_info_t;

#pragma pack(pop)

dword_t vesa_driver_load(void);

#endif
