Adding upstream version 3.61+dfsg.
[syslinux-debian/hramrach.git] / com32 / samples / vesainfo.c
bloba1f00299eb96bd8dee71c5f4c7963395d870bb98
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)
22 static void print_modes(void)
24 static com32sys_t rm;
25 struct vesa_general_info *gi;
26 struct vesa_mode_info *mi;
27 uint16_t mode, *mode_ptr;
28 int lines;
30 /* Allocate space in the bounce buffer for these structures */
31 gi = &((struct vesa_info *)__com32.cs_bounce)->gi;
32 mi = &((struct vesa_info *)__com32.cs_bounce)->mi;
34 gi->signature = VBE2_MAGIC; /* Get VBE2 extended data */
35 rm.eax.w[0] = 0x4F00; /* Get SVGA general information */
36 rm.edi.w[0] = OFFS(gi);
37 rm.es = SEG(gi);
38 __intcall(0x10, &rm, &rm);
40 if ( rm.eax.w[0] != 0x004F ) {
41 printf("No VESA BIOS detected\n");
42 return;
43 } else if ( gi->signature != VESA_MAGIC ) {
44 printf("VESA information structure has bad magic, trying anyway...\n");
47 printf("VBE version %d.%d\n"
48 "Mode attrib h_res v_res bpp layout rpos gpos bpos\n",
49 (gi->version >> 8) & 0xff, gi->version & 0xff);
51 lines = 1;
53 mode_ptr = GET_PTR(gi->video_mode_ptr);
55 while ((mode = *mode_ptr++) != 0xFFFF) {
56 if (++lines >= 23) {
57 wait_key();
58 lines = 0;
61 rm.eax.w[0] = 0x4F01; /* Get SVGA mode information */
62 rm.ecx.w[0] = mode;
63 rm.edi.w[0] = OFFS(mi);
64 rm.es = SEG(mi);
65 __intcall(0x10, &rm, &rm);
67 /* Must be a supported mode */
68 if ( rm.eax.w[0] != 0x004f )
69 continue;
71 printf("0x%04x 0x%04x %5u %5u %3u %6u %4u %4u %4u\n",
72 mode, mi->mode_attr, mi->h_res, mi->v_res, mi->bpp,
73 mi->memory_layout, mi->rpos, mi->gpos, mi->bpos);
77 int main(void)
79 openconsole(&dev_rawcon_r, &dev_stdcon_w);
81 print_modes();
82 return 0;