VirtualBox

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

最後變更 在這個檔案從5608是 5475,由 vboxsync 提交於 17 年 前

export

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 8.5 KB
 
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{ 1600, 1200, 8 , 0x11C},
40{ 1600, 1200, 15 , 0x11D},
41{ 1600, 1200, 16 , 0x11E},
42{ 1600, 1200, 24 , 0x11F},
43
44 /* BOCHS/PLE, 86 'own' mode numbers */
45{ 320, 200, 32 , 0x140},
46{ 640, 400, 32 , 0x141},
47{ 640, 480, 32 , 0x142},
48{ 800, 600, 32 , 0x143},
49{ 1024, 768, 32 , 0x144},
50{ 1280, 1024, 32 , 0x145},
51{ 320, 200, 8 , 0x146},
52{ 1600, 1200, 32 , 0x147},
53{ 1152, 864, 8 , 0x148},
54{ 1152, 864, 15 , 0x149},
55{ 1152, 864, 16 , 0x14a},
56{ 1152, 864, 24 , 0x14b},
57{ 1152, 864, 32 , 0x14c},
58{ 0, },
59};
60
61int main(int argc, char **argv)
62{
63 const ModeInfo *pm;
64 int pages, pitch;
65 int r_size, r_pos, g_size, g_pos, b_size, b_pos, a_size, a_pos;
66 const char *str;
67 long vram_size = VBE_DISPI_TOTAL_VIDEO_MEMORY_MB * 1024 * 1024;
68
69 printf("/* THIS FILE IS AUTOMATICALLY GENERATED - DO NOT EDIT */\n\n");
70 printf("#define VBE_DISPI_TOTAL_VIDEO_MEMORY_MB %d\n\n", VBE_DISPI_TOTAL_VIDEO_MEMORY_MB);
71 printf("static ModeInfoListItem mode_info_list[]=\n");
72 printf("{\n");
73 for (pm = modes; pm->mode != 0; pm++) {
74 if (pm->depth == 4)
75 pitch = (pm->width + 7) / 8;
76 else
77 pitch = pm->width * ((pm->depth + 7) / 8);
78 pages = vram_size / (pm->height * pitch);
79 if (pages > 0) {
80 printf("{ 0x%04x, /* %dx%dx%d */\n",
81 pm->mode, pm->width, pm->height, pm->depth);
82 if (pm->depth == 4)
83 printf("{ /*Bit16u ModeAttributes*/ %s,\n",
84 "VBE_MODE_ATTRIBUTE_SUPPORTED | "
85 "VBE_MODE_ATTRIBUTE_EXTENDED_INFORMATION_AVAILABLE | "
86 "VBE_MODE_ATTRIBUTE_COLOR_MODE | "
87 "VBE_MODE_ATTRIBUTE_TTY_BIOS_SUPPORT | "
88 "VBE_MODE_ATTRIBUTE_GRAPHICS_MODE");
89 else
90 printf("{ /*Bit16u ModeAttributes*/ %s,\n",
91 "VBE_MODE_ATTRIBUTE_SUPPORTED | "
92 "VBE_MODE_ATTRIBUTE_EXTENDED_INFORMATION_AVAILABLE | "
93 "VBE_MODE_ATTRIBUTE_COLOR_MODE | "
94 "VBE_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER_MODE | "
95 "VBE_MODE_ATTRIBUTE_GRAPHICS_MODE");
96 printf("/*Bit8u WinAAttributes*/ %s,\n",
97 "VBE_WINDOW_ATTRIBUTE_RELOCATABLE | "
98 "VBE_WINDOW_ATTRIBUTE_READABLE | "
99 "VBE_WINDOW_ATTRIBUTE_WRITEABLE");
100
101 printf("/*Bit8u WinBAttributes*/ %d,\n", 0);
102
103 printf("/*Bit16u WinGranularity*/ %s,\n", "VBE_DISPI_BANK_SIZE_KB");
104
105 printf("/*Bit16u WinSize*/ %s,\n", "VBE_DISPI_BANK_SIZE_KB");
106
107 printf("/*Bit16u WinASegment*/ %s,\n", "VGAMEM_GRAPH");
108
109 printf("/*Bit16u WinBSegment*/ 0x%04x,\n", 0);
110
111 printf("/*Bit32u WinFuncPtr*/ %d,\n", 0);
112
113 printf("/*Bit16u BytesPerScanLine*/ %d,\n", pitch);
114
115 /* Mandatory information for VBE 1.2 and above */
116 printf("/*Bit16u XResolution*/ %d,\n", pm->width);
117 printf("/*Bit16u YResolution*/ %d,\n", pm->height);
118 printf("/*Bit8u XCharSize*/ %d,\n", 8);
119 printf("/*Bit8u YCharSize*/ %d,\n", 16);
120 if (pm->depth == 4) {
121 printf("/*Bit8u NumberOfPlanes*/ %d,\n", 4);
122 } else {
123 printf("/*Bit8u NumberOfPlanes*/ %d,\n", 1);
124 }
125 printf("/*Bit8u BitsPerPixel*/ %d,\n", pm->depth);
126 printf("/*Bit8u NumberOfBanks*/ %d,\n", 1); /* This would only be non-zero for CGA/HGC modes! */
127
128 if (pm->depth == 4)
129 str = "VBE_MEMORYMODEL_PLANAR";
130 else if (pm->depth == 8)
131 str = "VBE_MEMORYMODEL_PACKED_PIXEL";
132 else
133 str = "VBE_MEMORYMODEL_DIRECT_COLOR";
134 printf("/*Bit8u MemoryModel*/ %s,\n", str);
135 printf("/*Bit8u BankSize*/ %d,\n", 0);
136 if (pm->depth == 4)
137 printf("/*Bit8u NumberOfImagePages*/ %d,\n", (pages / 4) - 1);
138 else
139 printf("/*Bit8u NumberOfImagePages*/ %d,\n", pages - 1);
140 printf("/*Bit8u Reserved_page*/ %d,\n", 0);
141
142 /* Direct Color fields (required for direct/6 and YUV/7 memory models) */
143 switch(pm->depth) {
144 case 15:
145 r_size = 5;
146 r_pos = 10;
147 g_size = 5;
148 g_pos = 5;
149 b_size = 5;
150 b_pos = 0;
151 a_size = 1;
152 a_pos = 15;
153 break;
154 case 16:
155 r_size = 5;
156 r_pos = 11;
157 g_size = 6;
158 g_pos = 5;
159 b_size = 5;
160 b_pos = 0;
161 a_size = 0;
162 a_pos = 0;
163 break;
164 case 24:
165 r_size = 8;
166 r_pos = 16;
167 g_size = 8;
168 g_pos = 8;
169 b_size = 8;
170 b_pos = 0;
171 a_size = 0;
172 a_pos = 0;
173 break;
174 case 32:
175 r_size = 8;
176 r_pos = 16;
177 g_size = 8;
178 g_pos = 8;
179 b_size = 8;
180 b_pos = 0;
181 a_size = 8;
182 a_pos = 24;
183 break;
184 default:
185 r_size = 0;
186 r_pos = 0;
187 g_size = 0;
188 g_pos = 0;
189 b_size = 0;
190 b_pos = 0;
191 a_size = 0;
192 a_pos = 0;
193 break;
194 }
195
196 printf("/*Bit8u RedMaskSize*/ %d,\n", r_size);
197 printf("/*Bit8u RedFieldPosition*/ %d,\n", r_pos);
198 printf("/*Bit8u GreenMaskSize*/ %d,\n", g_size);
199 printf("/*Bit8u GreenFieldPosition*/ %d,\n", g_pos);
200 printf("/*Bit8u BlueMaskSize*/ %d,\n", b_size);
201 printf("/*Bit8u BlueFieldPosition*/ %d,\n", b_pos);
202 printf("/*Bit8u RsvdMaskSize*/ %d,\n", a_size);
203 printf("/*Bit8u RsvdFieldPosition*/ %d,\n", a_pos);
204 if (pm->depth == 32)
205 printf("/*Bit8u DirectColorModeInfo*/ %s,\n",
206 "VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE");
207 else
208 printf("/*Bit8u DirectColorModeInfo*/ %s,\n", "0");
209
210 /* Mandatory information for VBE 2.0 and above */
211 if (pm->depth > 4)
212 printf("/*Bit32u PhysBasePtr*/ %s,\n",
213 "VBE_DISPI_LFB_PHYSICAL_ADDRESS");
214 else
215 printf("/*Bit32u PhysBasePtr*/ %s,\n", "0");
216 printf("/*Bit32u OffScreenMemOffset*/ %d,\n", 0);
217 printf("/*Bit16u OffScreenMemSize*/ %d,\n", 0);
218 /* Mandatory information for VBE 3.0 and above */
219 printf("/*Bit16u LinBytesPerScanLine*/ %d,\n", pitch);
220 printf("/*Bit8u BnkNumberOfPages*/ %d,\n", 0);
221 printf("/*Bit8u LinNumberOfPages*/ %d,\n", 0);
222 printf("/*Bit8u LinRedMaskSize*/ %d,\n", r_size);
223 printf("/*Bit8u LinRedFieldPosition*/ %d,\n", r_pos);
224 printf("/*Bit8u LinGreenMaskSize*/ %d,\n", g_size);
225 printf("/*Bit8u LinGreenFieldPosition*/ %d,\n", g_pos);
226 printf("/*Bit8u LinBlueMaskSize*/ %d,\n", b_size);
227 printf("/*Bit8u LinBlueFieldPosition*/ %d,\n", b_pos);
228 printf("/*Bit8u LinRsvdMaskSize*/ %d,\n", a_size);
229 printf("/*Bit8u LinRsvdFieldPosition*/ %d,\n", a_pos);
230 printf("/*Bit32u MaxPixelClock*/ %d,\n", 0);
231 printf("} },\n");
232 }
233 }
234#ifndef VBOX /* We'll add the terminator ourselves, thank you. */
235 printf("{ VBE_VESA_MODE_END_OF_LIST,\n");
236 printf("{ 0,\n");
237 printf("} },\n");
238#endif
239 printf("};\n");
240 return 0;
241}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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