3 #include <lib/sys/vesa/vesa.h>
6 void dump_vesa_tables(struct upload_backend
*be
)
10 struct vesa_general_info
*gip
, gi
;
11 struct vesa_mode_info
*mip
, mi
;
12 uint16_t mode
, *mode_ptr
;
15 printf("Scanning VESA BIOS... ");
17 /* Allocate space in the bounce buffer for these structures */
18 vip
= lmalloc(sizeof *vip
);
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
);
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 */
47 rm
.edi
.w
[0] = OFFS(mip
);
49 __intcall(0x10, &rm
, &rm
);
51 /* Must be a supported mode */
52 if (rm
.eax
.w
[0] != 0x004f)
55 memcpy(&mi
, mip
, sizeof mi
);
57 sprintf(modefile
, "vesa/mode%04x.bin", mode
);
58 cpio_writefile(be
, modefile
, &mi
, sizeof mi
);