Adding upstream version 4.00~pre53+dfsg.
[syslinux-debian/hramrach.git] / com32 / sysdump / vesa.c
blob017f9e4f7bdc8c27623b3c773a0c99b7d08d7608
1 #include <string.h>
2 #include <stdio.h>
3 #include "../lib/sys/vesa/vesa.h"
4 #include "backend.h"
5 #include "sysdump.h"
7 void dump_vesa_tables(struct backend *be)
9 com32sys_t rm;
10 struct vesa_info *vip;
11 struct vesa_general_info *gip, gi;
12 struct vesa_mode_info *mip, mi;
13 uint16_t mode, *mode_ptr;
14 char modefile[64];
16 printf("Scanning VESA BIOS... ");
18 /* Allocate space in the bounce buffer for these structures */
19 vip = lmalloc(sizeof *vip);
20 gip = &vip->gi;
21 mip = &vip->mi;
23 memset(&rm, 0, sizeof rm);
24 memset(gip, 0, sizeof *gip);
26 gip->signature = VBE2_MAGIC; /* Get VBE2 extended data */
27 rm.eax.w[0] = 0x4F00; /* Get SVGA general information */
28 rm.edi.w[0] = OFFS(gip);
29 rm.es = SEG(gip);
30 __intcall(0x10, &rm, &rm);
31 memcpy(&gi, gip, sizeof gi);
33 if (rm.eax.w[0] != 0x004F)
34 return; /* Function call failed */
35 if (gi.signature != VESA_MAGIC)
36 return; /* No magic */
38 cpio_mkdir(be, "vesa");
40 cpio_writefile(be, "vesa/global.bin", &gi, sizeof gi);
42 mode_ptr = GET_PTR(gi.video_mode_ptr);
43 while ((mode = *mode_ptr++) != 0xFFFF) {
44 memset(mip, 0, sizeof *mip);
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");