VirtualBox

source: vbox/trunk/src/VBox/Devices/Graphics/BIOS/vbetables-gen.c@ 97698

Last change on this file since 97698 was 62594, checked in by vboxsync, 8 years ago

warnings

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.5 KB
Line 
1/* Generate the VGABIOS VBE Tables */
2#include <stdlib.h>
3#include <stdio.h>
4
5#define VBE_DISPI_TOTAL_VIDEO_MEMORY_MB 8
6
7typedef struct {
8 int width;
9 int height;
10 int depth;
11 int mode;
12} ModeInfo;
13
14ModeInfo modes[] = {
15 /* standard VESA modes */
16{ 640, 400, 8 , 0x100},
17{ 640, 480, 8 , 0x101},
18{ 800, 600, 4 , 0x102},
19{ 800, 600, 8 , 0x103},
20{ 1024, 768, 4 , 0x104},
21{ 1024, 768, 8 , 0x105},
22{ 1280, 1024, 4 , 0x106},
23{ 1280, 1024, 8 , 0x107},
24{ 320, 200, 15 , 0x10D},
25{ 320, 200, 16 , 0x10E},
26{ 320, 200, 24 , 0x10F},
27{ 640, 480, 15 , 0x110},
28{ 640, 480, 16 , 0x111},
29{ 640, 480, 24 , 0x112},
30{ 800, 600, 15 , 0x113},
31{ 800, 600, 16 , 0x114},
32{ 800, 600, 24 , 0x115},
33{ 1024, 768, 15 , 0x116},
34{ 1024, 768, 16 , 0x117},
35{ 1024, 768, 24 , 0x118},
36{ 1280, 1024, 15 , 0x119},
37{ 1280, 1024, 16 , 0x11A},
38{ 1280, 1024, 24 , 0x11B},
39#if 0 /* Ubuntu fails with this */
40{ 1600, 1200, 8 , 0x11C},
41{ 1600, 1200, 15 , 0x11D},
42{ 1600, 1200, 16 , 0x11E},
43{ 1600, 1200, 24 , 0x11F},
44#endif
45
46 /* BOCHS/PLE, 86 'own' mode numbers */
47{ 320, 200, 32 , 0x140},
48{ 640, 400, 32 , 0x141},
49{ 640, 480, 32 , 0x142},
50{ 800, 600, 32 , 0x143},
51{ 1024, 768, 32 , 0x144},
52{ 1280, 1024, 32 , 0x145},
53{ 320, 200, 8 , 0x146},
54{ 1600, 1200, 32 , 0x147},
55{ 1152, 864, 8 , 0x148},
56{ 1152, 864, 15 , 0x149},
57{ 1152, 864, 16 , 0x14a},
58{ 1152, 864, 24 , 0x14b},
59{ 1152, 864, 32 , 0x14c},
60{ 0, },
61};
62
63int main(int argc, char **argv)
64{
65 const ModeInfo *pm;
66 int pages, pitch;
67 int r_size, r_pos, g_size, g_pos, b_size, b_pos, a_size, a_pos;
68 const char *str;
69 long vram_size = VBE_DISPI_TOTAL_VIDEO_MEMORY_MB * 1024 * 1024;
70
71 (void)argc; (void)argv;
72
73 printf("/* THIS FILE IS AUTOMATICALLY GENERATED - DO NOT EDIT */\n\n");
74 printf("#define VBE_DISPI_TOTAL_VIDEO_MEMORY_MB %d\n\n", VBE_DISPI_TOTAL_VIDEO_MEMORY_MB);
75 printf("static ModeInfoListItem mode_info_list[]=\n");
76 printf("{\n");
77 for (pm = modes; pm->mode != 0; pm++) {
78 if (pm->depth == 4)
79 pitch = (pm->width + 7) / 8;
80 else
81 pitch = pm->width * ((pm->depth + 7) / 8);
82 pages = vram_size / (pm->height * pitch);
83 if (pages > 0) {
84 printf("{ 0x%04x, /* %dx%dx%d */\n",
85 pm->mode, pm->width, pm->height, pm->depth);
86 if (pm->depth == 4)
87 printf("{ /*Bit16u ModeAttributes*/ %s,\n",
88 "VBE_MODE_ATTRIBUTE_SUPPORTED | "
89 "VBE_MODE_ATTRIBUTE_EXTENDED_INFORMATION_AVAILABLE | "
90 "VBE_MODE_ATTRIBUTE_COLOR_MODE | "
91 "VBE_MODE_ATTRIBUTE_TTY_BIOS_SUPPORT | "
92 "VBE_MODE_ATTRIBUTE_GRAPHICS_MODE");
93 else
94 printf("{ /*Bit16u ModeAttributes*/ %s,\n",
95 "VBE_MODE_ATTRIBUTE_SUPPORTED | "
96 "VBE_MODE_ATTRIBUTE_EXTENDED_INFORMATION_AVAILABLE | "
97 "VBE_MODE_ATTRIBUTE_COLOR_MODE | "
98 "VBE_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER_MODE | "
99 "VBE_MODE_ATTRIBUTE_GRAPHICS_MODE");
100 printf("/*Bit8u WinAAttributes*/ %s,\n",
101 "VBE_WINDOW_ATTRIBUTE_RELOCATABLE | "
102 "VBE_WINDOW_ATTRIBUTE_READABLE | "
103 "VBE_WINDOW_ATTRIBUTE_WRITEABLE");
104
105 printf("/*Bit8u WinBAttributes*/ %d,\n", 0);
106
107 printf("/*Bit16u WinGranularity*/ %s,\n", "VBE_DISPI_BANK_SIZE_KB");
108
109 printf("/*Bit16u WinSize*/ %s,\n", "VBE_DISPI_BANK_SIZE_KB");
110
111 printf("/*Bit16u WinASegment*/ %s,\n", "VGAMEM_GRAPH");
112
113 printf("/*Bit16u WinBSegment*/ 0x%04x,\n", 0);
114
115 printf("/*Bit32u WinFuncPtr*/ %d,\n", 0);
116
117 printf("/*Bit16u BytesPerScanLine*/ %d,\n", pitch);
118
119 /* Mandatory information for VBE 1.2 and above */
120 printf("/*Bit16u XResolution*/ %d,\n", pm->width);
121 printf("/*Bit16u YResolution*/ %d,\n", pm->height);
122 printf("/*Bit8u XCharSize*/ %d,\n", 8);
123 printf("/*Bit8u YCharSize*/ %d,\n", 16);
124 if (pm->depth == 4) {
125 printf("/*Bit8u NumberOfPlanes*/ %d,\n", 4);
126 } else {
127 printf("/*Bit8u NumberOfPlanes*/ %d,\n", 1);
128 }
129 printf("/*Bit8u BitsPerPixel*/ %d,\n", pm->depth);
130 printf("/*Bit8u NumberOfBanks*/ %d,\n", 1); /* This would only be non-zero for CGA/HGC modes! */
131
132 if (pm->depth == 4)
133 str = "VBE_MEMORYMODEL_PLANAR";
134 else if (pm->depth == 8)
135 str = "VBE_MEMORYMODEL_PACKED_PIXEL";
136 else
137 str = "VBE_MEMORYMODEL_DIRECT_COLOR";
138 printf("/*Bit8u MemoryModel*/ %s,\n", str);
139 printf("/*Bit8u BankSize*/ %d,\n", 0);
140 if (pm->depth == 4)
141 printf("/*Bit8u NumberOfImagePages*/ %d,\n", (pages / 4) - 1);
142 else
143 printf("/*Bit8u NumberOfImagePages*/ %d,\n", pages - 1);
144 printf("/*Bit8u Reserved_page*/ %d,\n", 0);
145
146 /* Direct Color fields (required for direct/6 and YUV/7 memory models) */
147 switch(pm->depth) {
148 case 15:
149 r_size = 5;
150 r_pos = 10;
151 g_size = 5;
152 g_pos = 5;
153 b_size = 5;
154 b_pos = 0;
155 a_size = 1;
156 a_pos = 15;
157 break;
158 case 16:
159 r_size = 5;
160 r_pos = 11;
161 g_size = 6;
162 g_pos = 5;
163 b_size = 5;
164 b_pos = 0;
165 a_size = 0;
166 a_pos = 0;
167 break;
168 case 24:
169 r_size = 8;
170 r_pos = 16;
171 g_size = 8;
172 g_pos = 8;
173 b_size = 8;
174 b_pos = 0;
175 a_size = 0;
176 a_pos = 0;
177 break;
178 case 32:
179 r_size = 8;
180 r_pos = 16;
181 g_size = 8;
182 g_pos = 8;
183 b_size = 8;
184 b_pos = 0;
185 a_size = 8;
186 a_pos = 24;
187 break;
188 default:
189 r_size = 0;
190 r_pos = 0;
191 g_size = 0;
192 g_pos = 0;
193 b_size = 0;
194 b_pos = 0;
195 a_size = 0;
196 a_pos = 0;
197 break;
198 }
199
200 printf("/*Bit8u RedMaskSize*/ %d,\n", r_size);
201 printf("/*Bit8u RedFieldPosition*/ %d,\n", r_pos);
202 printf("/*Bit8u GreenMaskSize*/ %d,\n", g_size);
203 printf("/*Bit8u GreenFieldPosition*/ %d,\n", g_pos);
204 printf("/*Bit8u BlueMaskSize*/ %d,\n", b_size);
205 printf("/*Bit8u BlueFieldPosition*/ %d,\n", b_pos);
206 printf("/*Bit8u RsvdMaskSize*/ %d,\n", a_size);
207 printf("/*Bit8u RsvdFieldPosition*/ %d,\n", a_pos);
208 if (pm->depth == 32)
209 printf("/*Bit8u DirectColorModeInfo*/ %s,\n",
210 "VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE");
211 else
212 printf("/*Bit8u DirectColorModeInfo*/ %s,\n", "0");
213
214 /* Mandatory information for VBE 2.0 and above */
215 if (pm->depth > 4)
216 printf("/*Bit32u PhysBasePtr*/ %s,\n",
217 "0xFFFF0000 /* Filled in at run-time; low word must be zero! */");
218 else
219 printf("/*Bit32u PhysBasePtr*/ %s,\n", "0");
220 printf("/*Bit32u OffScreenMemOffset*/ %d,\n", 0);
221 printf("/*Bit16u OffScreenMemSize*/ %d,\n", 0);
222 /* Mandatory information for VBE 3.0 and above */
223 printf("/*Bit16u LinBytesPerScanLine*/ %d,\n", pitch);
224 printf("/*Bit8u BnkNumberOfPages*/ %d,\n", 0);
225 printf("/*Bit8u LinNumberOfPages*/ %d,\n", 0);
226 printf("/*Bit8u LinRedMaskSize*/ %d,\n", r_size);
227 printf("/*Bit8u LinRedFieldPosition*/ %d,\n", r_pos);
228 printf("/*Bit8u LinGreenMaskSize*/ %d,\n", g_size);
229 printf("/*Bit8u LinGreenFieldPosition*/ %d,\n", g_pos);
230 printf("/*Bit8u LinBlueMaskSize*/ %d,\n", b_size);
231 printf("/*Bit8u LinBlueFieldPosition*/ %d,\n", b_pos);
232 printf("/*Bit8u LinRsvdMaskSize*/ %d,\n", a_size);
233 printf("/*Bit8u LinRsvdFieldPosition*/ %d,\n", a_pos);
234 printf("/*Bit32u MaxPixelClock*/ %d,\n", 0);
235 printf("} },\n");
236 }
237 }
238#ifndef VBOX /* We'll add the terminator ourselves, thank you. */
239 printf("{ VBE_VESA_MODE_END_OF_LIST,\n");
240 printf("{ 0,\n");
241 printf("} },\n");
242#endif
243 printf("};\n");
244 return 0;
245}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette