hdt: Removing builting sleep support in say
[syslinux.git] / com32 / sysdump / vesa.c
blob42adc3daccef34b87e88353af6667c58fa286c88
1 #include <string.h>
2 #include <stdio.h>
3 #include <lib/sys/vesa/vesa.h>
4 #include "sysdump.h"
6 void dump_vesa_tables(struct upload_backend *be)
8 com32sys_t rm;
9 struct vesa_info *vip;
10 struct vesa_general_info *gip, gi;
11 struct vesa_mode_info *mip, mi;
12 uint16_t mode, *mode_ptr;
13 char modefile[64];
15 printf("Scanning VESA BIOS... ");
17 /* Allocate space in the bounce buffer for these structures */
18 vip = lmalloc(sizeof *vip);
19 gip = &vip->gi;
20 mip = &vip->mi;
22 memset(&rm, 0, sizeof rm);
23 memset(gip, 0, sizeof *gip);
25 gip->signature = VBE2_MAGIC; /* Get VBE2 extended data */
26 rm.eax.w[0] = 0x4F00; /* Get SVGA general information */
27 rm.edi.w[0] = OFFS(gip);
28 rm.es = SEG(gip);
29 __intcall(0x10, &rm, &rm);
30 memcpy(&gi, gip, sizeof gi);
32 if (rm.eax.w[0] != 0x004F)
33 return; /* Function call failed */
34 if (gi.signature != VESA_MAGIC)
35 return; /* No magic */
37 cpio_mkdir(be, "vesa");
39 cpio_writefile(be, "vesa/global.bin", &gi, sizeof gi);
41 mode_ptr = GET_PTR(gi.video_mode_ptr);
42 while ((mode = *mode_ptr++) != 0xFFFF) {
43 memset(mip, 0, sizeof *mip);
44 rm.eax.w[0] = 0x4F01; /* Get SVGA mode information */
45 rm.ecx.w[0] = mode;
46 rm.edi.w[0] = OFFS(mip);
47 rm.es = SEG(mip);
48 __intcall(0x10, &rm, &rm);
50 /* Must be a supported mode */
51 if (rm.eax.w[0] != 0x004f)
52 continue;
54 memcpy(&mi, mip, sizeof mi);
56 sprintf(modefile, "vesa/mode%04x.bin", mode);
57 cpio_writefile(be, modefile, &mi, sizeof mi);
60 lfree(vip);
61 printf("done.\n");