3 #include "../lib/sys/vesa/vesa.h"
7 void dump_vesa_tables(struct backend
*be
)
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
;
16 printf("Scanning VESA BIOS... ");
18 /* Allocate space in the bounce buffer for these structures */
19 vip
= lmalloc(sizeof *vip
);
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
);
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 */
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
);