Adding upstream version 4.00~pre61+dfsg.
[syslinux-debian/hramrach.git] / com32 / modules / vesainfo.c
blob00181e472dcca198d2a7966877a4ed74c46cdfa4
1 /*
2 * vesainfo.c
4 * Dump information about what VESA graphics modes are supported.
5 */
7 #include <string.h>
8 #include <stdio.h>
9 #include <console.h>
10 #include <com32.h>
11 #include <inttypes.h>
12 #include "../lib/sys/vesa/vesa.h"
14 /* Wait for a keypress */
15 static void wait_key(void)
17 char ch;
18 while (fread(&ch, 1, 1, stdin) == 0) ;
21 static void print_modes(void)
23 static com32sys_t rm;
24 struct vesa_general_info *gi;
25 struct vesa_mode_info *mi;
26 uint16_t mode, *mode_ptr;
27 int lines;
29 /* Allocate space in the bounce buffer for these structures */
30 gi = &((struct vesa_info *)__com32.cs_bounce)->gi;
31 mi = &((struct vesa_info *)__com32.cs_bounce)->mi;
33 gi->signature = VBE2_MAGIC; /* Get VBE2 extended data */
34 rm.eax.w[0] = 0x4F00; /* Get SVGA general information */
35 rm.edi.w[0] = OFFS(gi);
36 rm.es = SEG(gi);
37 __intcall(0x10, &rm, &rm);
39 if (rm.eax.w[0] != 0x004F) {
40 printf("No VESA BIOS detected\n");
41 return;
42 } else if (gi->signature != VESA_MAGIC) {
43 printf("VESA information structure has bad magic, trying anyway...\n");
46 printf("VBE version %d.%d\n"
47 "Mode attrib h_res v_res bpp layout rpos gpos bpos\n",
48 (gi->version >> 8) & 0xff, gi->version & 0xff);
50 lines = 1;
52 mode_ptr = GET_PTR(gi->video_mode_ptr);
54 while ((mode = *mode_ptr++) != 0xFFFF) {
55 if (++lines >= 23) {
56 wait_key();
57 lines = 0;
60 rm.eax.w[0] = 0x4F01; /* Get SVGA mode information */
61 rm.ecx.w[0] = mode;
62 rm.edi.w[0] = OFFS(mi);
63 rm.es = SEG(mi);
64 __intcall(0x10, &rm, &rm);
66 /* Must be a supported mode */
67 if (rm.eax.w[0] != 0x004f)
68 continue;
70 printf("0x%04x 0x%04x %5u %5u %3u %6u %4u %4u %4u\n",
71 mode, mi->mode_attr, mi->h_res, mi->v_res, mi->bpp,
72 mi->memory_layout, mi->rpos, mi->gpos, mi->bpos);
76 int main(void)
78 openconsole(&dev_rawcon_r, &dev_stdcon_w);
80 print_modes();
81 return 0;