Releasing debian version 3:6.03+dfsg-10.
[syslinux-debian.git] / com32 / sysdump / vesa.c
blob3540fc44f6b20d406f7fda5baa36390eb2443f09
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 memset(&rm, 0, sizeof rm);
45 rm.eax.w[0] = 0x4F01; /* Get SVGA mode information */
46 rm.ecx.w[0] = mode;
47 rm.edi.w[0] = OFFS(mip);
48 rm.es = SEG(mip);
49 __intcall(0x10, &rm, &rm);
51 /* Must be a supported mode */
52 if (rm.eax.w[0] != 0x004f)
53 continue;
55 memcpy(&mi, mip, sizeof mi);
57 sprintf(modefile, "vesa/mode%04x.bin", mode);
58 cpio_writefile(be, modefile, &mi, sizeof mi);
61 lfree(vip);
62 printf("done.\n");