Home | History | Annotate | Download | only in sysdump
      1 #include <string.h>
      2 #include <stdio.h>
      3 #include <lib/sys/vesa/vesa.h>
      4 #include "sysdump.h"
      5 
      6 void dump_vesa_tables(struct upload_backend *be)
      7 {
      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];
     14 
     15     printf("Scanning VESA BIOS... ");
     16 
     17     /* Allocate space in the bounce buffer for these structures */
     18     vip = lmalloc(sizeof *vip);
     19     gip = &vip->gi;
     20     mip = &vip->mi;
     21 
     22     memset(&rm, 0, sizeof rm);
     23     memset(gip, 0, sizeof *gip);
     24 
     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);
     31 
     32     if (rm.eax.w[0] != 0x004F)
     33 	return;		/* Function call failed */
     34     if (gi.signature != VESA_MAGIC)
     35 	return;		/* No magic */
     36 
     37     cpio_mkdir(be, "vesa");
     38 
     39     cpio_writefile(be, "vesa/global.bin", &gi, sizeof gi);
     40 
     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);
     50 
     51 	/* Must be a supported mode */
     52 	if (rm.eax.w[0] != 0x004f)
     53 	    continue;
     54 
     55 	memcpy(&mi, mip, sizeof mi);
     56 
     57 	sprintf(modefile, "vesa/mode%04x.bin", mode);
     58 	cpio_writefile(be, modefile, &mi, sizeof mi);
     59     }
     60 
     61     lfree(vip);
     62     printf("done.\n");
     63 }
     64