* libcurses++, libc++ and liblightOS++ are installed into the crosscompiler directory
[lightOS.git] / kernel / include / kernel / x86 / vbe.hpp
blobbd75f50849bf9332d584b6191aeb917490a0d43e
1 /*
2 lightOS kernel
3 Copyright (C) 2006-2009 Jörg Pfähler
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 #ifndef LIGHTOS_KERNEL_X86_VBE_HPP
20 #define LIGHTOS_KERNEL_X86_VBE_HPP
22 /*! \addtogroup kernel kernel */
23 /*@{*/
24 /*! \addtogroup device device */
25 /*@{*/
27 #include <string>
28 #include <vector>
30 #ifdef _LIGHTOS_V86
32 namespace kernel
34 /*! The VESA BIOS Extensions */
35 class vbe
37 public:
38 /*! Information about a video mode */
39 struct videoMode
41 /*! The width in pixel */
42 unsigned int width;
43 /*! The height in pixel */
44 unsigned int height;
45 /*! The bits per pixel */
46 unsigned int bpp;
47 /*! The address of the frame buffer */
48 void *framebuffer;
50 /*! Get the vbe class instance */
51 inline static vbe &instance(){if (inst == 0)inst = new vbe();return *inst;}
52 /*! Get the major version */
53 unsigned int majorVersion() const{return major;}
54 /*! Get the minor version */
55 unsigned int minorVersion() const{return minor;}
56 /*! Get the OEM */
57 const std::string &oem() const{return oemName;}
58 /*! Get the vendor name */
59 const std::string &vendor() const{return vendorName;}
60 /*! Get the product name */
61 const std::string &product() const{return productName;}
62 /*! Get the product revision */
63 const std::string &revision() const{return productRevision;}
64 /*! Get the number of available modes */
65 unsigned int modeCount() const{return modes.size();}
66 /*! Get information about an mode */
67 bool getModeInfo(unsigned int index, videoMode &mode) const;
68 /*! Set the video mode */
69 bool setMode(unsigned int index);
70 private:
71 /*! The VBE info structure */
72 struct infoBlock
74 char signature[4];
75 unsigned short version;
76 unsigned int oemName;
77 unsigned int caps;
78 unsigned int videoMode;
79 unsigned short totalMemory;
80 unsigned short oemSoftwareRevision;
81 unsigned int oemVendorName;
82 unsigned int oemProductName;
83 unsigned int oemProductRevision;
84 unsigned char res[222];
85 unsigned char oemData[256];
86 }__attribute__((packed));
87 /*! The VBE mode info structure */
88 struct modeInfo
90 unsigned short attributes;
91 unsigned char winAAttributes;
92 unsigned char winBAttributes;
93 unsigned short winGranularity;
94 unsigned short winSize;
95 unsigned short winASegment;
96 unsigned short winBSegment;
97 unsigned int winFunc;
98 unsigned short bytesPerScanline;
99 unsigned short xResolution;
100 unsigned short yResolution;
101 unsigned char xCharSize;
102 unsigned char yCharSize;
103 unsigned char numberOfPlanes;
104 unsigned char bitsPerPixel;
105 unsigned char numberOfBanks;
106 unsigned char memoryModel;
107 unsigned char BankSize;
108 unsigned char numberOfImagePages;
109 unsigned char res1;
110 unsigned char redMaskSize;
111 unsigned char refFieldPosition;
112 unsigned char greenMaskSize;
113 unsigned char greenFieldPosition;
114 unsigned char blueMaskSize;
115 unsigned char blueFieldPosition;
116 unsigned char rsvdMaskSize;
117 unsigned char rsvdFieldPosition;
118 unsigned char directColorModeInfo;
119 unsigned int physicalBase;
120 unsigned int offscreenMemOffset;
121 unsigned short offscreenMemSize;
122 unsigned char res2[206];
123 }__attribute__((packed));
124 /*! The constructor */
125 vbe();
126 /*! The destructor */
127 ~vbe();
128 /*! The vbe instance */
129 static vbe *inst;
130 /*! The VBE major version */
131 unsigned int major;
132 /*! The VBE minor version */
133 unsigned int minor;
134 /*! The video memory size */
135 size_t videoMemory;
136 /*! OEM */
137 std::string oemName;
138 /*! Vendor name */
139 std::string vendorName;
140 /*! Product name */
141 std::string productName;
142 /*! The product revision */
143 std::string productRevision;
144 /*! List of available modes */
145 std::vector<unsigned short> modes;
146 /*! Information on the available modes */
147 std::vector<modeInfo*> modesInfo;
151 #endif
153 /*@}*/
154 /*@}*/
156 #endif