VirtualBox

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

Last change on this file since 10485 was 6061, checked in by vboxsync, 17 years ago

Commented out 1600x1200 modes. Ubuntu fails too boot with them.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.6 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 printf("/* THIS FILE IS AUTOMATICALLY GENERATED - DO NOT EDIT */\n\n");
72 printf("#define VBE_DISPI_TOTAL_VIDEO_MEMORY_MB %d\n\n", VBE_DISPI_TOTAL_VIDEO_MEMORY_MB);
73 printf("static ModeInfoListItem mode_info_list[]=\n");
74 printf("{\n");
75 for (pm = modes; pm->mode != 0; pm++) {
76 if (pm->depth == 4)
77 pitch = (pm->width + 7) / 8;
78 else
79 pitch = pm->width * ((pm->depth + 7) / 8);
80 pages = vram_size / (pm->height * pitch);
81 if (pages > 0) {
82 printf("{ 0x%04x, /* %dx%dx%d */\n",
83 pm->mode, pm->width, pm->height, pm->depth);
84 if (pm->depth == 4)
85 printf("{ /*Bit16u ModeAttributes*/ %s,\n",
86 "VBE_MODE_ATTRIBUTE_SUPPORTED | "
87 "VBE_MODE_ATTRIBUTE_EXTENDED_INFORMATION_AVAILABLE | "
88 "VBE_MODE_ATTRIBUTE_COLOR_MODE | "
89 "VBE_MODE_ATTRIBUTE_TTY_BIOS_SUPPORT | "
90 "VBE_MODE_ATTRIBUTE_GRAPHICS_MODE");
91 else
92 printf("{ /*Bit16u ModeAttributes*/ %s,\n",
93 "VBE_MODE_ATTRIBUTE_SUPPORTED | "
94 "VBE_MODE_ATTRIBUTE_EXTENDED_INFORMATION_AVAILABLE | "
95 "VBE_MODE_ATTRIBUTE_COLOR_MODE | "
96 "VBE_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER_MODE | "
97 "VBE_MODE_ATTRIBUTE_GRAPHICS_MODE");
98 printf("/*Bit8u WinAAttributes*/ %s,\n",
99 "VBE_WINDOW_ATTRIBUTE_RELOCATABLE | "
100 "VBE_WINDOW_ATTRIBUTE_READABLE | "
101 "VBE_WINDOW_ATTRIBUTE_WRITEABLE");
102
103 printf("/*Bit8u WinBAttributes*/ %d,\n", 0);
104
105 printf("/*Bit16u WinGranularity*/ %s,\n", "VBE_DISPI_BANK_SIZE_KB");
106
107 printf("/*Bit16u WinSize*/ %s,\n", "VBE_DISPI_BANK_SIZE_KB");
108
109 printf("/*Bit16u WinASegment*/ %s,\n", "VGAMEM_GRAPH");
110
111 printf("/*Bit16u WinBSegment*/ 0x%04x,\n", 0);
112
113 printf("/*Bit32u WinFuncPtr*/ %d,\n", 0);
114
115 printf("/*Bit16u BytesPerScanLine*/ %d,\n", pitch);
116
117 /* Mandatory information for VBE 1.2 and above */
118 printf("/*Bit16u XResolution*/ %d,\n", pm->width);
119 printf("/*Bit16u YResolution*/ %d,\n", pm->height);
120 printf("/*Bit8u XCharSize*/ %d,\n", 8);
121 printf("/*Bit8u YCharSize*/ %d,\n", 16);
122 if (pm->depth == 4) {
123 printf("/*Bit8u NumberOfPlanes*/ %d,\n", 4);
124 } else {
125 printf("/*Bit8u NumberOfPlanes*/ %d,\n", 1);
126 }
127 printf("/*Bit8u BitsPerPixel*/ %d,\n", pm->depth);
128 printf("/*Bit8u NumberOfBanks*/ %d,\n", 1); /* This would only be non-zero for CGA/HGC modes! */
129
130 if (pm->depth == 4)
131 str = "VBE_MEMORYMODEL_PLANAR";
132 else if (pm->depth == 8)
133 str = "VBE_MEMORYMODEL_PACKED_PIXEL";
134 else
135 str = "VBE_MEMORYMODEL_DIRECT_COLOR";
136 printf("/*Bit8u MemoryModel*/ %s,\n", str);
137 printf("/*Bit8u BankSize*/ %d,\n", 0);
138 if (pm->depth == 4)
139 printf("/*Bit8u NumberOfImagePages*/ %d,\n", (pages / 4) - 1);
140 else
141 printf("/*Bit8u NumberOfImagePages*/ %d,\n", pages - 1);
142 printf("/*Bit8u Reserved_page*/ %d,\n", 0);
143
144 /* Direct Color fields (required for direct/6 and YUV/7 memory models) */
145 switch(pm->depth) {
146 case 15:
147 r_size = 5;
148 r_pos = 10;
149 g_size = 5;
150 g_pos = 5;
151 b_size = 5;
152 b_pos = 0;
153 a_size = 1;
154 a_pos = 15;
155 break;
156 case 16:
157 r_size = 5;
158 r_pos = 11;
159 g_size = 6;
160 g_pos = 5;
161 b_size = 5;
162 b_pos = 0;
163 a_size = 0;
164 a_pos = 0;
165 break;
166 case 24:
167 r_size = 8;
168 r_pos = 16;
169 g_size = 8;
170 g_pos = 8;
171 b_size = 8;
172 b_pos = 0;
173 a_size = 0;
174 a_pos = 0;
175 break;
176 case 32:
177 r_size = 8;
178 r_pos = 16;
179 g_size = 8;
180 g_pos = 8;
181 b_size = 8;
182 b_pos = 0;
183 a_size = 8;
184 a_pos = 24;
185 break;
186 default:
187 r_size = 0;
188 r_pos = 0;
189 g_size = 0;
190 g_pos = 0;
191 b_size = 0;
192 b_pos = 0;
193 a_size = 0;
194 a_pos = 0;
195 break;
196 }
197
198 printf("/*Bit8u RedMaskSize*/ %d,\n", r_size);
199 printf("/*Bit8u RedFieldPosition*/ %d,\n", r_pos);
200 printf("/*Bit8u GreenMaskSize*/ %d,\n", g_size);
201 printf("/*Bit8u GreenFieldPosition*/ %d,\n", g_pos);
202 printf("/*Bit8u BlueMaskSize*/ %d,\n", b_size);
203 printf("/*Bit8u BlueFieldPosition*/ %d,\n", b_pos);
204 printf("/*Bit8u RsvdMaskSize*/ %d,\n", a_size);
205 printf("/*Bit8u RsvdFieldPosition*/ %d,\n", a_pos);
206 if (pm->depth == 32)
207 printf("/*Bit8u DirectColorModeInfo*/ %s,\n",
208 "VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE");
209 else
210 printf("/*Bit8u DirectColorModeInfo*/ %s,\n", "0");
211
212 /* Mandatory information for VBE 2.0 and above */
213 if (pm->depth > 4)
214 printf("/*Bit32u PhysBasePtr*/ %s,\n",
215 "VBE_DISPI_LFB_PHYSICAL_ADDRESS");
216 else
217 printf("/*Bit32u PhysBasePtr*/ %s,\n", "0");
218 printf("/*Bit32u OffScreenMemOffset*/ %d,\n", 0);
219 printf("/*Bit16u OffScreenMemSize*/ %d,\n", 0);
220 /* Mandatory information for VBE 3.0 and above */
221 printf("/*Bit16u LinBytesPerScanLine*/ %d,\n", pitch);
222 printf("/*Bit8u BnkNumberOfPages*/ %d,\n", 0);
223 printf("/*Bit8u LinNumberOfPages*/ %d,\n", 0);
224 printf("/*Bit8u LinRedMaskSize*/ %d,\n", r_size);
225 printf("/*Bit8u LinRedFieldPosition*/ %d,\n", r_pos);
226 printf("/*Bit8u LinGreenMaskSize*/ %d,\n", g_size);
227 printf("/*Bit8u LinGreenFieldPosition*/ %d,\n", g_pos);
228 printf("/*Bit8u LinBlueMaskSize*/ %d,\n", b_size);
229 printf("/*Bit8u LinBlueFieldPosition*/ %d,\n", b_pos);
230 printf("/*Bit8u LinRsvdMaskSize*/ %d,\n", a_size);
231 printf("/*Bit8u LinRsvdFieldPosition*/ %d,\n", a_pos);
232 printf("/*Bit32u MaxPixelClock*/ %d,\n", 0);
233 printf("} },\n");
234 }
235 }
236#ifndef VBOX /* We'll add the terminator ourselves, thank you. */
237 printf("{ VBE_VESA_MODE_END_OF_LIST,\n");
238 printf("{ 0,\n");
239 printf("} },\n");
240#endif
241 printf("};\n");
242 return 0;
243}
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