|
|
1.1 root 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:
7: typedef struct {
8: int width;
9: int height;
10: int depth;
11: int mode;
12: } ModeInfo;
13:
14: ModeInfo 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:
61: int 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",
127: (pm->height * pitch + 65535) / 65536);
128:
129: if (pm->depth == 4)
130: str = "VBE_MEMORYMODEL_PLANAR";
131: else if (pm->depth == 8)
132: str = "VBE_MEMORYMODEL_PACKED_PIXEL";
133: else
134: str = "VBE_MEMORYMODEL_DIRECT_COLOR";
135: printf("/*Bit8u MemoryModel*/ %s,\n", str);
136: printf("/*Bit8u BankSize*/ %d,\n", 0);
137: if (pm->depth == 4)
138: printf("/*Bit8u NumberOfImagePages*/ %d,\n", (pages / 4) - 1);
139: else
140: printf("/*Bit8u NumberOfImagePages*/ %d,\n", pages - 1);
141: printf("/*Bit8u Reserved_page*/ %d,\n", 0);
142:
143: // Direct Color fields (required for direct/6 and YUV/7 memory models)
144: switch(pm->depth) {
145: case 15:
146: r_size = 5;
147: r_pos = 10;
148: g_size = 5;
149: g_pos = 5;
150: b_size = 5;
151: b_pos = 0;
152: a_size = 1;
153: a_pos = 15;
154: break;
155: case 16:
156: r_size = 5;
157: r_pos = 11;
158: g_size = 6;
159: g_pos = 5;
160: b_size = 5;
161: b_pos = 0;
162: a_size = 0;
163: a_pos = 0;
164: break;
165: case 24:
166: r_size = 8;
167: r_pos = 16;
168: g_size = 8;
169: g_pos = 8;
170: b_size = 8;
171: b_pos = 0;
172: a_size = 0;
173: a_pos = 0;
174: break;
175: case 32:
176: r_size = 8;
177: r_pos = 16;
178: g_size = 8;
179: g_pos = 8;
180: b_size = 8;
181: b_pos = 0;
182: a_size = 8;
183: a_pos = 24;
184: break;
185: default:
186: r_size = 0;
187: r_pos = 0;
188: g_size = 0;
189: g_pos = 0;
190: b_size = 0;
191: b_pos = 0;
192: a_size = 0;
193: a_pos = 0;
194: break;
195: }
196:
197: printf("/*Bit8u RedMaskSize*/ %d,\n", r_size);
198: printf("/*Bit8u RedFieldPosition*/ %d,\n", r_pos);
199: printf("/*Bit8u GreenMaskSize*/ %d,\n", g_size);
200: printf("/*Bit8u GreenFieldPosition*/ %d,\n", g_pos);
201: printf("/*Bit8u BlueMaskSize*/ %d,\n", b_size);
202: printf("/*Bit8u BlueFieldPosition*/ %d,\n", b_pos);
203: printf("/*Bit8u RsvdMaskSize*/ %d,\n", a_size);
204: printf("/*Bit8u RsvdFieldPosition*/ %d,\n", a_pos);
205: if (pm->depth == 32)
206: printf("/*Bit8u DirectColorModeInfo*/ %s,\n",
207: "VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE");
208: else
209: printf("/*Bit8u DirectColorModeInfo*/ %s,\n", "0");
210:
211: // Mandatory information for VBE 2.0 and above
212: if (pm->depth > 4)
213: printf("/*Bit32u PhysBasePtr*/ %s,\n",
214: "VBE_DISPI_LFB_PHYSICAL_ADDRESS");
215: else
216: printf("/*Bit32u PhysBasePtr*/ %s,\n", "0");
217: printf("/*Bit32u OffScreenMemOffset*/ %d,\n", 0);
218: printf("/*Bit16u OffScreenMemSize*/ %d,\n", 0);
219: // Mandatory information for VBE 3.0 and above
220: printf("/*Bit16u LinBytesPerScanLine*/ %d,\n", pitch);
221: printf("/*Bit8u BnkNumberOfPages*/ %d,\n", 0);
222: printf("/*Bit8u LinNumberOfPages*/ %d,\n", 0);
223: printf("/*Bit8u LinRedMaskSize*/ %d,\n", r_size);
224: printf("/*Bit8u LinRedFieldPosition*/ %d,\n", r_pos);
225: printf("/*Bit8u LinGreenMaskSize*/ %d,\n", g_size);
226: printf("/*Bit8u LinGreenFieldPosition*/ %d,\n", g_pos);
227: printf("/*Bit8u LinBlueMaskSize*/ %d,\n", b_size);
228: printf("/*Bit8u LinBlueFieldPosition*/ %d,\n", b_pos);
229: printf("/*Bit8u LinRsvdMaskSize*/ %d,\n", a_size);
230: printf("/*Bit8u LinRsvdFieldPosition*/ %d,\n", a_pos);
231: printf("/*Bit32u MaxPixelClock*/ %d,\n", 0);
232: printf("} },\n");
233: }
234: }
235: printf("{ VBE_VESA_MODE_END_OF_LIST,\n");
236: printf("{ 0,\n");
237: printf("} },\n");
238: printf("};\n");
239: return 0;
240: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.