Home | History | Annotate | Line # | Download | only in lib
vbe.h revision 1.2.8.1
      1  1.2.8.1    bouyer /* $NetBSD: vbe.h,v 1.2.8.1 2011/02/17 11:59:45 bouyer Exp $ */
      2      1.1  jmcneill 
      3      1.1  jmcneill /*-
      4      1.1  jmcneill  * Copyright (c) 2009 Jared D. McNeill <jmcneill (at) invisible.ca>
      5      1.1  jmcneill  * All rights reserved.
      6      1.1  jmcneill  *
      7      1.1  jmcneill  * Redistribution and use in source and binary forms, with or without
      8      1.1  jmcneill  * modification, are permitted provided that the following conditions
      9      1.1  jmcneill  * are met:
     10      1.1  jmcneill  * 1. Redistributions of source code must retain the above copyright
     11      1.1  jmcneill  *    notice, this list of conditions and the following disclaimer.
     12      1.1  jmcneill  * 2. Redistributions in binary form must reproduce the above copyright
     13      1.1  jmcneill  *    notice, this list of conditions and the following disclaimer in the
     14      1.1  jmcneill  *    documentation and/or other materials provided with the distribution.
     15      1.1  jmcneill  *
     16      1.1  jmcneill  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     17      1.1  jmcneill  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     18      1.1  jmcneill  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     19      1.1  jmcneill  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     20      1.1  jmcneill  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21      1.1  jmcneill  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22      1.1  jmcneill  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23      1.1  jmcneill  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24      1.1  jmcneill  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25      1.1  jmcneill  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26      1.1  jmcneill  * POSSIBILITY OF SUCH DAMAGE.
     27      1.1  jmcneill  */
     28      1.1  jmcneill 
     29      1.1  jmcneill #define VBE_DEFAULT_MODE	0x101	/* 640x480x8 */
     30      1.1  jmcneill 
     31      1.1  jmcneill struct vbeinfoblock {
     32      1.1  jmcneill 	char VbeSignature[4];
     33      1.1  jmcneill 	uint16_t VbeVersion;
     34      1.1  jmcneill 	uint32_t OemStringPtr;
     35      1.1  jmcneill 	uint32_t Capabilities;
     36      1.1  jmcneill 	uint32_t VideoModePtr;
     37      1.1  jmcneill 	uint16_t TotalMemory;
     38      1.1  jmcneill 	uint16_t OemSoftwareRev;
     39      1.1  jmcneill 	uint32_t OemVendorNamePtr, OemProductNamePtr, OemProductRevPtr;
     40      1.1  jmcneill 	/* data area, in total max 512 bytes for VBE 2.0 */
     41      1.1  jmcneill 	uint8_t Reserved[222];
     42      1.1  jmcneill 	uint8_t OemData[256];
     43      1.1  jmcneill } __packed;
     44      1.1  jmcneill 
     45      1.1  jmcneill struct modeinfoblock {
     46      1.1  jmcneill 	/* Mandatory information for all VBE revisions */
     47      1.1  jmcneill 	uint16_t ModeAttributes;
     48      1.1  jmcneill 	uint8_t WinAAttributes, WinBAttributes;
     49      1.1  jmcneill 	uint16_t WinGranularity, WinSize, WinASegment, WinBSegment;
     50      1.1  jmcneill 	uint32_t WinFuncPtr;
     51      1.1  jmcneill 	uint16_t BytesPerScanLine;
     52      1.1  jmcneill 	/* Mandatory information for VBE 1.2 and above */
     53      1.1  jmcneill 	uint16_t XResolution, YResolution;
     54      1.1  jmcneill 	uint8_t XCharSize, YCharSize, NumberOfPlanes, BitsPerPixel;
     55      1.1  jmcneill 	uint8_t NumberOfBanks, MemoryModel, BankSize, NumberOfImagePages;
     56      1.1  jmcneill 	uint8_t Reserved1;
     57      1.1  jmcneill 	/* Direct Color fields
     58      1.1  jmcneill 	   (required for direct/6 and YUV/7 memory models) */
     59      1.1  jmcneill 	uint8_t RedMaskSize, RedFieldPosition;
     60      1.1  jmcneill 	uint8_t GreenMaskSize, GreenFieldPosition;
     61      1.1  jmcneill 	uint8_t BlueMaskSize, BlueFieldPosition;
     62      1.1  jmcneill 	uint8_t RsvdMaskSize, RsvdFieldPosition;
     63      1.1  jmcneill 	uint8_t DirectColorModeInfo;
     64      1.1  jmcneill 	/* Mandatory information for VBE 2.0 and above */
     65      1.1  jmcneill 	uint32_t PhysBasePtr;
     66      1.1  jmcneill 	uint32_t OffScreenMemOffset;	/* reserved in VBE 3.0 and above */
     67      1.1  jmcneill 	uint16_t OffScreenMemSize;	/* reserved in VBE 3.0 and above */
     68      1.1  jmcneill 
     69      1.1  jmcneill 	/* Mandatory information for VBE 3.0 and above */
     70      1.1  jmcneill 	uint16_t LinBytesPerScanLine;
     71      1.1  jmcneill 	uint8_t BnkNumberOfImagePages;
     72      1.1  jmcneill 	uint8_t LinNumberOfImagePages;
     73      1.1  jmcneill 	uint8_t LinRedMaskSize, LinRedFieldPosition;
     74      1.1  jmcneill 	uint8_t LinGreenMaskSize, LinGreenFieldPosition;
     75      1.1  jmcneill 	uint8_t LinBlueMaskSize, LinBlueFieldPosition;
     76      1.1  jmcneill 	uint8_t LinRsvdMaskSize, LinRsvdFieldPosition;
     77      1.1  jmcneill 	uint32_t MaxPixelClock;
     78      1.1  jmcneill 	uint8_t Reserved4[189];
     79      1.1  jmcneill } __packed;
     80      1.1  jmcneill 
     81      1.1  jmcneill struct paletteentry {
     82      1.1  jmcneill 	uint8_t Blue;
     83      1.1  jmcneill 	uint8_t Green;
     84      1.1  jmcneill 	uint8_t Red;
     85      1.1  jmcneill 	uint8_t Alignment;
     86      1.1  jmcneill } __packed;
     87      1.1  jmcneill 
     88  1.2.8.1    bouyer /* EDID */
     89  1.2.8.1    bouyer #define	EDID_MAGIC	{ 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00 }
     90  1.2.8.1    bouyer #define	EDID_DESC_BLOCK	0x36
     91  1.2.8.1    bouyer 
     92      1.1  jmcneill /* low-level VBE calls, from biosvbe.S */
     93      1.1  jmcneill int biosvbe_info(struct vbeinfoblock *);
     94      1.1  jmcneill int biosvbe_set_mode(int);
     95      1.1  jmcneill int biosvbe_get_mode_info(int, struct modeinfoblock *);
     96      1.1  jmcneill int biosvbe_palette_format(int);
     97      1.1  jmcneill int biosvbe_palette_data(int, int, struct paletteentry *);
     98  1.2.8.1    bouyer int biosvbe_ddc_caps(void);
     99  1.2.8.1    bouyer int biosvbe_ddc_read_edid(int, void *);
    100      1.1  jmcneill 
    101      1.1  jmcneill /* high-level VBE helpers, from vbe.c */
    102      1.1  jmcneill void vbe_init(void);
    103      1.2  jmcneill int vbe_commit(void);
    104      1.1  jmcneill int vbe_available(void);
    105      1.1  jmcneill int vbe_set_mode(int);
    106      1.1  jmcneill int vbe_set_palette(const uint8_t *, int);
    107      1.1  jmcneill void vbe_modelist(void);
    108      1.1  jmcneill 
    109      1.1  jmcneill void command_vesa(char *);
    110      1.1  jmcneill 
    111      1.1  jmcneill /* adjust physical address; boot code runs with %ds having a 64k offset */
    112      1.1  jmcneill #define VBEPHYPTR(x)	((uint8_t *)((x) - (64 * 1024)))
    113