📄 test4.c
字号:
else printf(" EAX=%lx EBX=00000000\n", E820_MAGIC); printf("\nFunction is not supported.\n"); } pause(); printf(SPACER "Int 15h Function E801h\t\t[EXT]\n" "Get Extended Memory Blocks\n\n" "Call With:\n "); reg.x.ax = 0xE801; print_regs(®); int86(0x15, ®, &oreg); printf("\nReturns:\n "); print_regs(&oreg); print_carry(oreg.x.cflag); if (!oreg.x.cflag) { printf("\nNumber of 1K blocks between 1M and 16M: %u\n", oreg.x.ax); printf( "Number of 64K blocks above 16M: %u\n", oreg.x.bx); t = 1024L*(oreg.x.ax+1024); t += 64L*1024L*oreg.x.bx; if (!hma) hma = t; else if (hma!=t) printf("A different amount of memory is reported by this function\n"); } else printf("\nFunction is not supported.\n"); pause(); printf(SPACER "Int 15h Function 88h\t\t[AT][PS/2]\n" "Get Extended Memory Size\n\n" "Call With:\n "); reg.x.ax = 0x8800; print_regs(®); int86(0x15, ®, ®); printf("\nReturns:\n "); print_regs(®); printf("\nThere is "); decimal( (unsigned long)reg.x.ax ); printf("K of extended memory.\n"); t = (reg.x.ax + 1024L) * 1024L; if (!hma) hma = t;} staticint get_video_mode(void){ int m, row, col; pause(); printf(SPACER "Int 10h Function 0Fh\t\t[MDA][CGA][PCjr]\n" "Get Video Mode\t\t\t[EGA][MCGA][VGA]\n\n" "Call With:\n "); reg.x.ax = 0x0F00; reg.x.bx = -1; print_regs(®); int86(0x10, ®, ®); printf("\nReturns:\n "); print_regs(®); m = reg.h.al; __set_es(0x40); /* address BIOS data area */ reg.h.bl = row = __peek_es(0x84); printf("Fetch 0040:0084 (rows-1) to BL\n" "--> "); print_regs(®); col = reg.h.ah; printf("\nVideo mode = 0x%02x (%dx%d %s)\n", m, col, row+1, m==7 ? "monochrome" : m==3 ? "color" : "unknown"); printf("Active display page = %d\n", (int)reg.h.bh); return !(m==7 || col<80);}staticint get_cfg_info(void){ pause(); printf(SPACER "Int 10h Function 12h\t\t[EGA][VGA]\n" "Subfunction 10h\n" "Get Configuration Information\n\n" "Call With:\n "); reg.x.ax = 0x1200; reg.x.bx = 0xFF10; print_regs(®); int86(0x10, ®, ®); printf("\nReturns:\n "); print_regs(®); if (reg.h.bh > 1) return 0; printf("\n%s display\n", reg.h.bh==0 ? "Color" : reg.h.bh==1 ? "Monochrome" : "Unknown"); printf("EGA memory = %dK\n", reg.h.bl <= 3 ? (reg.h.bl+1)*64 : 0); printf("Feature bits = 0x%02x\n", (int)reg.h.ch); printf("Configuration switch = 0x%02x\n", (int)reg.h.cl); return 1;}staticint enable_refresh(void){ pause(); printf(SPACER "Int 10h Function 12h\t\t[VGA]\n" "Subfunction 36h\n" "Enable Screen Refresh\n\n" "Call With:\n "); reg.x.ax = 0x1200; reg.x.bx = 0x0036; reg.x.cx = 0; reg.x.dx = 0x80; print_regs(®); int86(0x10, ®, &oreg); printf("\nReturns:\n "); print_regs(&oreg); printf("\n"); printf("Function is %ssupported.\n", oreg.h.al==0x12 ? "" : "NOT "); if (oreg.x.dx != reg.x.dx || oreg.x.cx != reg.x.cx || oreg.x.si != reg.x.si || oreg.x.di != reg.x.di) printf("Error: Register(s) are not preserved.\n"); reg.x.dx = 0; return 1;}staticint get_comb_code(void){static char *dcode[] = { "none", "Monochrome", "CGA", "reserved", "EGA (color)", "EGA (mono)", "PGA", "VGA (monochrome)", "VGA (color)", "reserved", "MCGA (digital color)", "MCGA (monochrome)", "MCGA (color)", "UNKNOWN" }; int code; pause(); printf(SPACER "Int 10h Function 1Ah\t\t[PS/2]\n" "Subfunction 00h\n" "Get Display Combination Code\n\n" "Call With:\n "); reg.x.ax = 0x1A00; reg.x.bx = reg.x.cx = 0; print_regs(®); int86(0x10, ®, ®); printf("\nReturns:\n "); print_regs(®); if (reg.h.al != 0x1A) return 0; code = reg.h.bl <= 12 ? reg.h.bl : 13; printf("\nActive display: %s\n", dcode[code]); code = reg.h.bh <= 12 ? reg.h.bh : 13; printf("Inactive display: %s\n", dcode[code]); return (reg.h.bl>=4);}static void print_io_status(int status){static char *errmsg[] = {"no error", "invalid command", /* 0-1 */ "address mark not found", "disk write-protected", /* 2-3 */ "sector not found", "reset failed", "floppy disk removed", /* 4-6 */ "bad parameter table", "DMA overrun", /* 7-8 */ "DMA crossed 64k boundary", "bad sector flag", /* 9-A */ "bad track flag", "media type not found", /* B-C */ "invalid number of sectors on format", /* D */ "control data address mark detected", /* E */ "DMA arbitration level out of range", /* F */ "uncorrectable CRC or ECC data error", /* 10 */ "ECC corrected data error" /* 11 */ }; char *err; if (status <= 0x11) err = errmsg[status]; else switch(status) { case 0x20: err = "controller failure"; break; case 0x40: err = "seek failed"; break; case 0x80: err = "disk timeout (failed to respond)"; break; case 0xAA: err = "drive not ready"; break; case 0xBB: err = "undefined error"; break; case 0xCC: err = "write fault"; break; case 0xE0: err = "status register error"; break; case 0xFF: err = "sense operation failed"; break; default: err = "???"; } printf(" BIOS error code = 0x%02x (%s)\n", status, err);}staticvoid do_edd(int dev){ int m, subset; pause(); printf(SPACER "Int 13h Function 41h\t\t[EDD]\n" "Check EDD Extensions Present (device %02xh)\n\n" "Call With:\n ", dev); reg.x.ax = 0x41ED; reg.x.bx = 0x55AA; reg.x.dx = dev; print_regs(®); int86(0x13, ®, &oreg); printf("\nReturns:\n "); print_regs(&oreg); print_carry(oreg.x.cflag); m = 0; if (oreg.x.cflag) print_io_status(oreg.h.ah); else if (oreg.x.bx == 0xAA55 && (oreg.x.cx&EDD_SUBSET+EDD_LOCK+EDD_PACKET)) { m = 1; printf("\nEnhanced Disk Drive support: "); yesno(subset=oreg.x.cx&EDD_SUBSET); printf("Drive locking and ejecting: "); yesno(oreg.x.cx&EDD_LOCK); printf("Device access using packet calls: "); yesno(oreg.x.cx&EDD_PACKET); printf("EDD extensions version%s (hex code %02xh)\n", oreg.h.ah==0x30 ? " 3.0" : oreg.h.ah==0x21 ? " 1.1" : "" ,oreg.h.ah); } if (m) { struct EDDparam { short size; /* size of this structure */ short flags; /* information flags */ long pcyls; /* number of physical cylinders */ long pheads; /* number of physical heads/cylinder */ long psects; /* number of physical sectors/track */ unsigned /* number of physical sectors on volume */ long sectors_lo, sectors_hi; /* this is 8 bytes long */ short sec_size; /* number of bytes per sector */ unsigned long params; /* EDD config params (valid only if EDD_SUBSET) */ } eddparam; pause(); m = !!(oreg.x.cx&EDD_SUBSET) && oreg.h.ah>=0x21; printf(SPACER "Int 13h Function 48h\t\t[EDD]\n" "EDD Get Drive Parameters (device %02xh)\n\n" "Call With:\n ", dev); eddparam.size = sizeof(eddparam); reg.x.si = &eddparam; /* DS:SI points to buffer */ reg.x.ax =0x48C6; segread(&sreg); print_sregs(&sreg); printf(" "); print_regs(®); int86x(0x13, ®, ®, &sreg); printf("\nReturns:\n "); print_sregs(&sreg); printf(" "); print_regs(®); print_carry(reg.x.cflag);#define fl eddparam.flags printf("\nDMA boundary errors handled transparently: "); yesno(fl&1); printf("Geometry supplied: "); yesno(fl&2); printf("Device is removable: "); yesno(fl&4); printf("Device supports write with verify: "); yesno(fl&8); if (fl&4) { printf("Device has change-line support: "); yesno(fl&16); printf("Device is lockable: "); yesno(fl&32); printf("No media present; geometry is set to maximum: "); yesno(fl&64); } printf("Disk geometry ("); if (fl&2) { printf("C:H:S) = %ld:%ld:%ld (", eddparam.pcyls, eddparam.pheads, eddparam.psects); } if (eddparam.sectors_hi == 0) decimal(eddparam.sectors_lo); else printf("0x%x%08x", eddparam.sectors_hi, eddparam.sectors_lo); printf(" sectors)\n");#undef fl m=1; if (m) { static char *cfunc[] = { "Enable Prefetch", "Disable Prefetch", "Set Maximum PIO Mode", "Set PIO Mode 0", "Set Default PIO Mode", "Enable DMA Maximum Mode", "Disable DMA" }; m = 0; /* start with subfn 0 */ pause(); printf(SPACER "Int 13h Function 4Eh\t\t[EDD]\n" "Subfunction 0?h\n" "EDD Set Hardware Configuration (device %02xh)\n\n" "Call With:\n ", dev); reg.x.ax = 0x4E00; reg.h.dl = dev; print_regs(®); int86(0x13, ®, ®); printf("\nReturns:\n "); print_regs(®); print_carry(reg.x.cflag); printf("\n"); for (m=0; m<nelem(cfunc); m++) { reg.x.ax = 0x4E00 + m; reg.h.dl = dev; int86(0x13, ®, ®); printf("Subfn(%d): %s <-- ", m, cfunc[m]); if (reg.x.cflag || reg.h.ah) { printf("is not supported.\n"); } else { printf("%s other drives on controller.\n", reg.h.al ? "affects" : "does not affect"); } } /* for */ } /* if (m) */ } /* if (m) */}staticint do_disk(int dev){static char *drvtyp[] = {"No drive present", "Floppy w/o change-line support", "Floppy with change-line support"};static char *dt[] = { "5.25\", 40 track, 360K", "5.25\", 80 track, 1.2M", "3.5\", 80 track, 720K", "3.5\", 80 track, 1.44M" }; int m, mm; int c,h,s; unsigned long sect; pause(); printf(SPACER "Int 13h Function 15h\t\t[AT][PS/2]\n" "Get Disk Type (device %02xh)\n\n" "Call With:\n ", dev); reg.x.ax = 0x1500; reg.x.bx = 0; reg.x.dx = dev; print_regs(®); int86(0x13, ®, &oreg); printf("\nReturns:\n "); print_regs(&oreg); print_carry(oreg.x.cflag); mm = (oreg.x.cflag==0 && oreg.h.ah!=0); m = mm || (dev&0x80)==0; if (oreg.x.cflag) print_io_status((int)oreg.h.ah); else { printf("\n%s", oreg.h.ah < 3 ? drvtyp[oreg.h.ah] : oreg.h.ah != 3 ? "unknown drive type" : ""); if (oreg.h.ah == 3) { printf("Fixed disk with "); sect = (long)oreg.x.cx<<16 | oreg.x.dx; decimal(sect); printf(" sectors = "); sizeit(sect); } printf("\n"); } if (m) { pause(); printf(SPACER "Int 13h Function 08h\t\t[PC][AT][PS/2]\n" "Get Drive Parameters (device %02xh)\n\n" "Call With:\n ", dev); reg.x.ax = 0x0800; reg.x.dx = dev; reg.x.di = 0x4321; reg.x.bx = 0x1234; segread(&sreg); sreg.es = 0; print_sregs(&sreg); printf(" "); print_regs(®); int86x(0x13, ®, &oreg, &sreg); printf("\nReturns:\n "); print_sregs(&sreg); printf(" "); print_regs(&oreg); print_carry(oreg.x.cflag); if (oreg.x.cflag) print_io_status((int)oreg.h.ah); else { last_good_disk = dev; if (mm) { printf("\n"); if (!(dev&0x80)) { printf("Disk type %d = %s\n", (int)oreg.h.bl, dt[(oreg.h.bl-1)&3] ); printf("Parameter table at %04x:%04x\n", sreg.es, oreg.x.di); } else { if (oreg.x.bx != reg.x.bx) printf("Error: Hard disk BIOS should not touch BX\n"); if (sreg.es != 0 || oreg.x.di != reg.x.di) printf("Error: Hard disk BIOS should not touch ES:DI\n"); } s = (oreg.h.cl & 0x3F); /* sectors 1..63 */ h = (int)oreg.h.dh + 1; /* heads 0..254 */ c = (((oreg.h.cl & 0xC0)<<2) | oreg.h.ch) + 1; printf("Disk geometry (C:H:S) = %d:%d:%d (", c, h, s); decimal( sect=(long)c*h*s ); printf(" sectors) = "); sizeit(sect); printf("\n%s disks on system = %d\n", dev&0x80 ? "Fixed" : "Floppy", oreg.h.dl); if (dev & 0x80) { if (dev == 0x80) num_hd = oreg.h.dl; do_edd(dev); } } } } return m;}staticint do_rw(int tries){ int code; while (tries--) { int86x(0x13, ®, &oreg, &sreg); if (oreg.x.cflag == 0 && oreg.x.ax == 0x0001) return 0; code = oreg.h.ah; oreg.x.ax = 0; int86(0x13, &oreg, &oreg); } return code;}staticvoid do_get_pt(int dev){ int m; char buf[SECTOR_SIZE]; printf("Get partition table (device = 0x%x): ", dev); segread(&sreg); sreg.es = sreg.ss; reg.x.ax = 0x0201; reg.x.bx = buf; reg.x.cx = 1; reg.x.dx = dev & 0xFF; m = do_rw(5); if (m) print_io_status(m); else printf(" okay"); printf("\n");}staticvoid do_vesa(void){ int i; char vesa[512]; pause(); printf(SPACER "Int 10h Function 4Fh\t\t[VESA]\n" "Subfunction 00h\n" "Check VESA Extensions Present\n\n" "Call With:\n "); reg.x.ax = 0x4F00; reg.x.bx = 0; segread(&sreg); sreg.es = sreg.ss; reg.x.di = &vesa[0]; print_sregs(&sreg); printf(" "); print_regs(®); int86x(0x10, ®, &oreg, &sreg); printf("\nReturns:\n "); print_sregs(&sreg); printf(" "); print_regs(&oreg); if (oreg.x.ax != 0x004F) { printf("\nVESA BIOS extensions not present\n"); return; } if (strncmp(vesa, "VESA", 4)) { printf("\nVESA signature not found\n"); return; } vesa[4] = 0; printf("\n\"%s\" BIOS extensions present\n", vesa); pause(); printf(SPACER "Int 10h Function 4Fh\t\t[VESA]\n" "Subfunction 01h\n" "Get VESA Mode Information 1\n\n" "Call With:\n "); reg.x.ax = 0x4F01; reg.x.cx = 0x101; segread(&sreg); sreg.es = sreg.ss; reg.x.di = &vesa[0]; print_sregs(&sreg); printf(" "); print_regs(®); int86x(0x10, ®, &oreg, &sreg); printf("\nReturns:\n "); print_sregs(&sreg); printf(" "); print_regs(&oreg); i = *(int*)vesa; /* get mode bits */ printf("\nMode bits: 0x%04x\n", i); printf("640x480x256 mode supported: "); yesno(!(0x19 & ~i)); pause(); printf(SPACER "Int 10h Function 4Fh\t\t[VESA]\n" "Subfunction 01h\n" "Get VESA Mode Information 3\n\n" "Call With:\n "); reg.x.ax = 0x4F01; reg.x.cx = 0x103; segread(&sreg); sreg.es = sreg.ss; reg.x.di = &vesa[0]; print_sregs(&sreg); printf(" "); print_regs(®); int86x(0x10, ®, &oreg, &sreg); printf("\nReturns:\n "); print_sregs(&sreg); printf(" "); print_regs(&oreg); i = *(int*)vesa; /* get mode bits */ printf("\nMode bits: 0x%04x\n", i); printf("800x600x256 mode supported: "); yesno(!(0x19 & ~i));}void main(void){ int m, i, dev; if (!is_msdos()) {/** atexit(pause); **/ video_fix(); /* for Dumb DELL computers */ }#if DEBUG>=1 && __MSDOS__==0 printf("Beginning of '___cstartup'\n"); print_regs(&__argr); printf("DS=%04x ES=%04x CS=%04x SS=%04x SP=%04x BP=%04x\n", __argseg.ds, __argseg.es, __argseg.cs, __argseg.ss, __argr.x.flags, __argr.x.cflag); segread(&sreg); printf("\nBeginning of '_main'\n"); print_sregs(&sreg);#endif banner(DISK_VERSION); v86test(); testDX();#if DEBUG>=2 sizeit((long)40*2*9); putch('\n'); sizeit((long)80*2*15); putch('\n'); sizeit((long)80*2*18); putch('\n'); sizeit((long)80*2*36); putch('\n'); sizeit((long)1024*255*63); putch('\n'); sizeit((long)24000*512); putch('\n');#endif get_equip_cfg(); get_conv_mem(); hma = 0; get_ext_mem(); if (hma>1024L*1024L) mov_ext_mem(); m = get_video_mode(); if (m) m = get_cfg_info(); if (m) m = enable_refresh(); if (m) m = get_comb_code(); if (m) do_vesa();#if DEBUG>=3 printf("\n\nm=%x\n", m);#endif dev = 0; m = 1; for (i=BD_MAX_FLOPPY; i && m;) { m = do_disk(dev); ++dev; if (--i == 0 && (dev & 0x80)==0) { dev = 0x80; i = BD_MAX_HARD; } if ((dev & 0x7F) >= num_hd) m = 0; } pause(); printf(SPACER); for (dev = 0x80; dev <= last_good_disk; dev++) do_get_pt(dev); if (!is_msdos()) { printf("\n\nInitial SEQ reg 1: 0x%02x\n", video_1); pause(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -