📄 probe.c
字号:
else { if (v25->vid36.cx != 0x1234 || v25->vid36.bp != 0x4321) video_36_bug |= 4; if (v25->vid36.dx != 0x5680) video_36_bug |= 8; } } /* check for VESA extensions */ if (verbose >= 6) printf("check VESA present\n"); if ((v3->vid4F00.ax == 0x4f) && strncmp("VESA", v3->vid4F00.sig, 4)==0) adapter++; if (adapter > 5) { /* reg.eax = 0x4f01; reg.ecx = 0x0101; 640x480x256 */ if ((v3->vid101.ax == 0x4f) && (v3->vid101.bits & 0x19) == 0x19) adapter ++; else adapter--; } if (adapter > 6) { /* reg.eax = 0x4f01; reg.ecx = 0x0103; 800x600x256 */ if ((v3->vid103.ax == 0x4f) && (v3->vid103.bits & 0x19) == 0x19) ; else adapter--; } } if (verbose>=2) printf ("mode = 0x%02x, columns = %d, rows = %d, page = %d\n", mode, col, row, page); return adapter;}/* print VGA/VESA mode information */void do_video(void){static char *display[] = { "unknown", "MDA", "CGA", "EGA", "MCGA", "VGA", "VGA/VESA", "VGA/VESA" }; int adapter; /* 0=unknown, 1=MDA,HGC, 2=CGA, 3=EGA, 4=MCGA, 5=VGA, 6=VESA (640), 7=VESA (800) */ if (notice(4)) exit(0); adapter = get_video();#if 0 if(adapter<0) { printf("No video mode information is available.\n"); return; }#endif printf("%s adapter:\n\n", display[adapter]); if (adapter < 3 || (adapter == 3 && egamem < 1) ) { printf("No graphic modes are supported\n"); } else { if (adapter != 4) printf(" 640x350x16 mode 0x0010\n"); if (adapter >= 5) { printf(" 640x480x16 mode 0x0012\n\n"); printf(" 320x200x256 mode 0x0013\n"); } if (adapter >= 6) printf(" 640x480x256 mode 0x0101\n"); if (adapter >= 7) printf(" 800x600x256 mode 0x0103\n"); } if (video_36_bug && (verbose>0 || (video_36_bug&(8+4)))) { /* setting video_36_bug is a side effect of get_video */ printf("\nEnable Screen Refresh %s.\n", (video_36_bug & 4) ? "bugs are present" : (video_36_bug & 8) ? "bug is present" : (video_36_bug == 1) ? "is not supported" : "is supported"); }}/* entry from lilo.c for the '-T' (tell) switch */void probe_tell (char *cmd){ struct Probes *pr = list; int n; char *arg; if (!(verbose>0)) printf("\n"); for (; pr->cmd; pr++) { n = strlen(pr->cmd); arg = NULL; if (pr->cmd[n-1] == '=') arg = cmd+n; if (!strncasecmp(cmd, pr->cmd, n)) { pr->prc(arg); printf("\n"); exit(0); } } printf("Unrecognized option to '-T' flag\n"); do_help(); printf("\n"); exit(1);}int bios_max_devs(void){ struct disk_geom geom; int i; if (!fetch() && !get_geom(0x80, &geom)) { i = (buf.s5.disk & 0x7f) + 1; if (geom.n_disks == i) return i; } return BIOS_MAX_DEVS; }#ifdef DEBUGstatic void dump_pt(unsigned char *pt){ int i, j; for (j=0; j<4; j++) { for (i=0; i<16; i++) { printf(" %02X", (int)(*pt++)); } printf("\n"); } printf("\n");}#endif/* * return the bios device code of the disk, based on the geometry * match with the probe data * side effect is to place the device code in geo->device * return -1 if indeterminate */int bios_device(GEOMETRY *geo, int device){ int bios1, bios, match, fd; int bios2, snmatch; int mbios[BD_MAX_HARD]; struct disk_geom bdata; DEVICE dev; unsigned char part[PART_TABLE_SIZE]; unsigned char extra[8]; int serial; if (fetch()) return -1; if (verbose>=5) printf("bios_dev: device %04X\n", device);#ifdef DEBUG fflush(stdout);#endif if (!has_partitions(device)) return -1; match = 0; bios1 = -1; /* signal error */ for (bios=0x80; bios<=buf.s5.disk; bios++) { mbios[bios-0x80] = 0; if (get_geom(bios, &bdata)) break; if (geo->cylinders == bdata.n_cyl && geo->heads == bdata.n_head && geo->sectors == bdata.n_sect) { match++; mbios[bios-0x80] = bios1 = bios; } } if (match == 1) { if (verbose>=5) printf("bios_dev: match on geometry alone (0x%02X)\n", bios1); return (geo->device = bios1); } device &= D_MASK(device); /* mask to primary device */ fd = dev_open(&dev,device,O_RDONLY); if (verbose>=5) printf("bios_dev: masked device %04X, which is %s\n", device, dev.name); if (lseek(fd, PART_TABLE_OFFSET-8, SEEK_SET)!=PART_TABLE_OFFSET-8) die("bios_device: seek to partition table - 8"); if (read(fd,extra,sizeof(extra))!= sizeof(extra)) die("bios_device: read partition table - 8"); serial = *(int*)(extra+2); if (lseek(fd, PART_TABLE_OFFSET, SEEK_SET)!=PART_TABLE_OFFSET) die("bios_device: seek to partition table"); if (read(fd,part,sizeof(part))!= sizeof(part)) die("bios_device: read partition table"); dev_close(&dev);#ifdef DEBUG if (verbose>=5) { printf("serial number = %08X\n", serial); dump_pt(part); }#endif if (verbose>=5) printf("bios_dev: geometry check found %d matches\n", match); snmatch = match = 0; bios2 = bios1 = -1; /* 'bios' is set leaving the 'for' above */ while (--bios >= 0x80) { get_geom(bios, &bdata); if (verbose>=5) { printf("bios_dev: (0x%02X) vol-ID=%08X *PT=%08lX\n", bios, bdata.serial_no, (long)bdata.pt);#ifdef DEBUG dump_pt((void*)bdata.pt);#endif } if ( !memcmp(part,bdata.pt,sizeof(part)) ) { match++; bios1 = bios; } if ( bdata.serial_no && serial==bdata.serial_no ) { snmatch++; bios2 = bios; } } if (verbose>=5) printf("bios_dev: PT match found %d match%s (0x%02X)\n", match, match==1 ? "" : "es", bios1&255); if (match != 1) { match = snmatch; bios1 = bios2; if (verbose>=5) printf("bios_dev: S/N match found %d match%s (0x%02X)\n", match, match==1 ? "" : "es", bios1); } if (match == 1) { get_geom(bios1, &bdata); if ( (geo->sectors && geo->sectors!=bdata.n_sect) || (geo->heads && geo->heads!=bdata.n_head) ) { unsigned int nblocks = geo->cylinders * geo->heads * geo->sectors; if (verbose>0 && !nowarn && !(warned[bios1-0x80]&2) ) { fprintf(errstd,"Warning: Kernel & BIOS return differing head/sector geometries for device 0x%02X\n", bios1); show_geom("Kernel", geo->cylinders, geo->heads, geo->sectors); show_geom(" BIOS", bdata.n_cyl, bdata.n_head, bdata.n_sect); warned[bios1-0x80] |= 2; }#if 1 geo->sectors = bdata.n_sect; geo->heads = bdata.n_head; if (bdata.n_total_blocks > nblocks) nblocks = bdata.n_total_blocks; geo->cylinders = nblocks / (bdata.n_head*bdata.n_sect);#endif } return (geo->device = bios1); } return -1;}#if BITMAPstatic void do_bitmap(char *file){ printf("Color, Positioning, and Timer information for file: %s\n", file); printf("...<unimplemented>...\n");}#endifstatic unsigned char dl,dh;static int get_bios(void){ if (fetch() || buf.s5.version<5) return -1;#if BETA_TEST if (verbose>=5) printf("get_bios 1\n");#endif dl = eq->boot_dx;#if BETA_TEST if (verbose>=5) printf("get_bios 2\n");#endif dh = eq->boot_dx >> 8; return eq->boot_dx;}void check_bios(void){#if BETA_TEST if (verbose>=5) printf("check_bios 1\n");#endif if (bios_passes_dl == DL_NOT_SET) { bios_passes_dl = DL_UNKNOWN; if (get_bios() < 0) return;#if BETA_TEST if (verbose>=5) printf("check_bios 2\n");#endif if (dl==0xFE) { if ( !((dh>=0x80 && dh<=DEV_MASK) || dh==0) ) bios_passes_dl = DL_BAD; } else if ( dl>=0x80 && dl<=DEV_MASK ) bios_passes_dl = DL_MAYBE; else if ( dl > 0 ) bios_passes_dl = DL_BAD; } /* already set, leave alone */#if BETA_TEST if (verbose>=5) printf("check_bios 3 bios_passes_dl=%d\n", (int)bios_passes_dl);#endif}void do_bios(void){ int code=1; static char *ord[] ={ "first", "second", "3rd", "4th", "5th", "6th", "7th", "8th", "9th", "10th", "11th", "12th", "13th", "14th", "15th", "16th" }; notice(5); if (get_bios() < 0) printf("No information available on the state of DL at boot.\n"); else { printf("BIOS provided boot device is 0x%02x (DX=0x%04X).\n", code=(dl==0xFE ? dh : dl), eq->boot_dx); bios_passes_dl = DL_NOT_SET; check_bios(); } printf("\nUnless overridden, 'bios-passes-dl = %s' will be assumed.", bios_passes_dl == DL_BAD ? "no" : bios_passes_dl == DL_MAYBE ? "maybe" : bios_passes_dl == DL_GOOD ? "yes" : "unknown" ); if (bios_passes_dl > DL_BAD) { char *cp = NULL; char *cn = NULL; if (code>=0 && code<2) { cp="floppy"; cn=ord[code]; } if (code>=0x80 && code<=0x8f) { cp="hard"; cn=ord[code&15]; } if (cp) printf(" If you\nactually booted from the %s %s drive, then this assumption is okay.", cn, cp);#if 0 if (bios_passes_dl == DL_MAYBE) printf("\nIf the BIOS always gets DL set correctly, you might consider specifying\n" " 'bios_passes_dl = yes' or '-Z1'.\n");#endif } printf("\n");}#if VOLIDstatic void do_volid(void){ int bios, n, i, k, sv, nv, unique; struct disk_geom geom; unsigned int serial[MAX_BIOS_DEVICES]; int uniq[MAX_BIOS_DEVICES], valid[MAX_BIOS_DEVICES]; if (notice(4)) exit(0); printf("\n BIOS Volume ID\n\n"); unique = 1; nv = n = 0; for (bios=0x80; bios<0x80+MAX_BIOS_DEVICES && !get_geom(bios, &geom); bios++) { int uq = 1; i = bios - 0x80;#if 0 if (i==0 || i==2) geom.serial_no = 0; if (i==4) geom.serial_no = serial[2];#endif serial[i] = geom.serial_no; valid[i] = sv = serial_valid(geom.serial_no, bios); nv |= !sv; if (sv) for (k=0; k<i; k++) uq &= (geom.serial_no != serial[k]); uniq[i] = uq; unique &= uq; n++; printf(" 0x%02X %08X %s%s\n", i+0x80, serial[i], uq ? "" : "*", sv ? "" : "-"); } printf("\nVolume ID's are%s unique.\n", unique ? " all" : " NOT"); if (nv) printf(" '-' marks an invalid Volume ID which will be automatically updated\n" "\tthe next time /sbin/lilo is executed.\n"); if (!unique) printf(" '*' marks a volume ID which is duplicated. Duplicated ID's must be\n" "\tresolved before installing a new boot loader. The volume ID may\n" "\tbe cleared using the '-z' and '-M' switches.\n" ); printf("\n");}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -