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