📄 probe.c
字号:
pt_base = NULL; if (buf.s5.disk) { pt_base = (struct partition *)&buf.b[buf.s5.partitions]; } if (pt_base && drive <= (int)buf.s5.disk) {#if 0 geom->pt = &pt_base[(drive&15)*4];#else void *p = (void*)pt_base; int i = buf.s5.version >= 4 ? 8 : 0; p += (drive & 15) * (PART_TABLE_SIZE + i) + i; geom->pt = (struct partition *)p; if (i) geom->serial_no = *(int*)(p-6);#endif }#ifdef DEBUG printf("get_geom: PT->%08X S/N=%08X\n", (int)geom->pt, geom->serial_no);#endif /* regs.eax = 0x4100; check EDD extensions present */ /* regs.edx = drive; */ /* regs.ebx = 0x55AA; */#ifdef DEBUG printf("get_geom: int13, fn=41\n"); fflush(stdout);#endif if ((hd->fn41.flags&1)==0 && (hd->fn41.bx)==(unsigned short)0xAA55) { geom->EDD_flags = hd->fn41.cx; geom->EDD_rev = hd->fn41.ah; } if (((geom->EDD_flags) & EDD_SUBSET) || buf.s5.version >= 6) { edd_t *dp; dp = (edd_t*)hdp[drive-0x80 + 1];#ifdef DEBUG printf("get_geom: EDD dp = %08X\n", (int)dp); fflush(stdout);#endif /* update the pointer to the next drive */ hdp[drive-0x80 + 1] = (void*)dp + sizeof(edd_t); /* regs.eax = 0x4800; */ /* regs.edx = drive; */ #ifdef DEBUG printf("get_geom: int13, fn=48\n"); fflush(stdout);#endif if ((dp->reg.flags&1) == 0 && dp->reg.ah == 0) { if ((dp->info) & EDD_PARAM_GEOM_VALID) { if ((geom->n_sect != dp->sectors || geom->n_head != dp->heads) && ((verbose>0 && !lba32) || verbose>=4) && !nowarn && !(warned[drive-0x80]&1) ) { fprintf(errstd,"Warning: Int 0x13 function 8 and function 0x48 return different\n" "head/sector geometries for BIOS drive 0x%02X\n", drive); show_geom("fn 08", geom->n_cyl, geom->n_head, geom->n_sect); show_geom("fn 48", dp->cylinders, dp->heads, dp->sectors); warned[drive-0x80] |= 1; } /* prefer to return the fn 8 geometry */#if 0 geom->n_cyl = dp->cylinders; geom->n_head = dp->heads; geom->n_sect = dp->sectors;#endif total = dp->sectors; total *= dp->heads; total *= dp->cylinders; if (total > geom->n_total_blocks) geom->n_total_blocks = total; } if (dp->total_sectors > geom->n_total_blocks) geom->n_total_blocks = dp->total_sectors; } } return 0;}/* get the conventional memory size in Kb */static int get_conv_mem(void){#if 0 if(fetch()) { printf("No memory information is available.\n\n"); exit(0); }#else if (notice(4)) exit(0);#endif return (int)eq->mem;}/* print the conventional memory size */static void do_ebda(void){ int m, n, init; static char EBDA[]="Extended BIOS Data Area (EBDA)"; m = get_conv_mem() - EBDA_EXTRA;#if EBDA_EXTRA printf("*** BUGFIX - reported EBDA is increased by %dK - BUGFIX ***\n", EBDA_EXTRA);#endif if (m==640) printf(" no %s\n", EBDA); else printf(" %s = %dK\n", EBDA, 640-m); printf(" Conventional Memory = %dK 0x%06X\n", m, m<<10); m <<= 10; m -= 0x200; n = (select_loader()->size + SECTOR_SIZE - 1) / SECTOR_SIZE; n = m - (n+4+MAX_DESCR_SECS)*SECTOR_SIZE; init = (n - (MAX_SETUPSECS+1)*SECTOR_SIZE)>>4; if (init > DEF_INITSEG) init = DEF_INITSEG; printf("\n"); printf(" The First stage loader boots at: 0x%08X (0000:%04X)\n", FIRSTSEG<<4, FIRSTSEG<<4); printf(" The Second stage loader runs at: 0x%08X (%04X:%04X)\n", n, n>>4, n&15); printf(" The kernel cmdline is passed at: 0x%08X (%04X:%04X)\n", m, init, m-(init<<4));}static char *number(unsigned int n){ unsigned int k = 1000000000UL; /* 10^9 */ static char s[16]; char *cp = s; while (n<k && k>1) k /= 1000UL; sprintf(cp,"%u",n/k); n %= k; k /= 1000UL; while (k) { while (*++cp) ; sprintf(cp,",%03u",n/k); n %= k; k /= 1000UL; } return s;}/* print the CHS geometry information for the specified disk */static void print_geom(int dr, struct disk_geom geom){ char ch_ser[24] = { 0 }; char *sz = "KMGT"; char *sp = sz; unsigned int n, m=0;#ifdef DEBUG if (!dr) geom.n_total_blocks = 4000000000UL; /* 2.09Tb */#endif if (geom.serial_no) sprintf(ch_ser, "vol-ID: %08X", geom.serial_no); printf(" bios=0x%02x, cylinders=%d, heads=%d, sectors=%d\t%s\n", dr, geom.n_cyl, geom.n_head, geom.n_sect, ch_ser); n = geom.n_total_blocks/2; while (n > 999999) { n/=1000UL; n*=1024UL; n/=1000UL; sp++; } if (n > 999) { m = (n%1000UL)/10; n /= 1000UL; sp++; } if (m) printf("\t(%3u.%02u%cb", n, m, *sp); else printf("\t(%3u%cb", n, *sp); printf("%14s sectors)", number(geom.n_total_blocks)); if (geom.EDD_flags & EDD_PACKET) {/* printf("\tEDD packet calls allowed"); */ printf("\tLBA32 supported (EDD bios)"); } else printf("\tC:H:S supported (PC bios)"); printf("\n");}/* print disk drive geometry for all drives */static void do_geom_all(void){ int d, hd, dr; struct disk_geom geom; for (hd=0; hd<0x81; hd+=0x80) for (d=0; d<16; d++) { dr = d+hd; if (get_geom(dr, &geom)==0) { if (dr==0x80) printf("\nBIOS reports %d hard drive%s\n", (int) geom.n_disks, (int)geom.n_disks==1 ? "" : "s"); print_geom(dr, geom); } }}/* print disk drive geometry information for a particular drive */static void do_geom(char *bios){ int dr; struct disk_geom geom; dr = to_number(bios); if (get_geom(dr, &geom)==0) print_geom(dr, geom); else printf("Unrecognized BIOS device code 0x%02x\n", dr); }/* print an individual partition table entry */static void print_pt(int index, struct partition pt){ char bt[4], *ty, start[32], end[32], type[8]; char x; int i; for (x=i=0; i<sizeof(pt); i++) x |= ((char*)&pt)[i]; if (!x) { printf("%4d\t\t\t ** empty **\n", index); return; } strcpy(bt," "); sprintf(type, "0x%02x", (int)pt.sys_ind); sprintf(start, "%4d:%d:%d", (int)pt.cyl+((pt.sector&0xC0)<<2), (int)pt.head, (int)pt.sector & 0x3f ); sprintf(end, "%4d:%d:%d", (int)pt.end_cyl+((pt.end_sector&0xC0)<<2), (int)pt.end_head, (int)pt.end_sector & 0x3f ); ty = type; if (pt.boot_ind==0x80) bt[1]='*'; else if (pt.boot_ind==0) ; /* do nothing */ else { sprintf(bt+1,"%02x", (int)pt.boot_ind); } for (i=0; ptab[i].name; i++) { if (ptab[i].type == pt.sys_ind) { ty = ptab[i].name; break; } else if ((ptab[i].type|ptab[i].hide) == pt.sys_ind) { bt[0] = 'H'; ty = ptab[i].name; break; } } printf("%4d%18s%5s%11s%14s%12u%12u\n", index, ty, bt, start, end, pt.start_sect, pt.nr_sects);}/* partition table display */static void do_table(char *part){ struct partition pt [PART_MAX_MAX+1]; int volid; long long where[PART_MAX_MAX+1]; int i,j; int extd = (extended_pt || verbose>0); j = read_partitions(part, extd ? nelem(pt)-1 : 0, &volid, pt, verbose>=5 ? where : NULL); extd |= j>PART_MAX; printf(" vol-ID: %08X\n\n%s\n", (int)volid, phead); for (i=0; i<PART_MAX; i++) { print_pt(i+1, pt[i]); } i=4; if (extd) while (pt[i].sys_ind) { print_pt(i+1, pt[i]); i++; } if (verbose>=5) { printf("\n"); for (i=0; i<j; i++) printf("%4d%20lld%12d\n", i+1, where[i], (int)(where[i]/SECTOR_SIZE)); }}/* list partition change-rules */static void do_cr_pr(void){ CHANGE_RULE *cr; cr = change_rules; printf("\t\tType Normal Hidden\n"); if (!cr) printf("\t **** no change-rules defined ****\n"); while (cr) { printf ("%20s 0x%02x 0x%02x\n", cr->type, (int)cr->normal, (int)cr->hidden); cr = cr->next; }}static int egamem;static int mode, col, row, page;/*enum {VIDEO_UNKNOWN, VIDEO_MDA, VIDEO_CGA, VIDEO_EGA, VIDEO_MCGA, VIDEO_VGA, VIDEO_VESA, VIDEO_VESA_800}; */int get_video(void) /* return -1 on error, or adapter type [0..7] */{ int adapter = 0; /* 0=unknown, 1=MDA,HGC, 2=CGA, 3=EGA, 4=MCGA, 5=VGA, 6=VESA (640), 7=VESA (800) */ int okay = 1; int monitor; if(fetch()) return -1; if ((okay=buf.s5.vid)) { /* get current video mode */ /* reg.eax = 0x0F00; */ if (verbose >= 6) printf("get video mode\n"); mode = v1->vid0F.al; col = v1->vid0F.ah; page = v1->vid0F.bh; row = v1->vid0F.bl + 1; if (mode==7) { adapter=1; row = 25; okay = 0; } else if (col<80) { adapter=2; okay=0; } else adapter=2; /* at least CGA */ } if (okay>=2) { /* determine video adapter type */ /* reg.eax = 0x1200; call valid on EGA/VGA */ /* reg.ebx = 0xFF10; */ if (verbose >= 6) printf("determine adapter type\n"); if ((unsigned)(monitor = v2->vid12.bh) <= 1U) { adapter = 3; /* at least EGA */ egamem = v2->vid12.bl; } else { okay = 0; } } if (okay>=2) { /* check for VGA */ /* reg.eax = 0x1A00; get display combination */ if (verbose >= 6) printf("get display combination\n"); if ( v2->vid1A.al==0x1A ) { monitor = (v2->vid1A.bx >> ((verbose>=9)*8) ) & 0xFF; switch (monitor) { case 1: adapter = 1; break; case 2: adapter = 2; break; case 7: case 8: adapter = 5; /* VGA */ break; case 0xA: case 0xB: case 0xC: adapter = 4; /* MCGA */ break; default: okay = 0; break; } } else { okay = 0; } } if (okay>=3 && adapter==5) { /* check for BIOS bug (trashing DX) */ if (v25 && verbose >= 6) printf("check Enable Screen Refresh\n"); if (v25) { video_36_bug = 2; /* mark implemented */ if ((v25->vid36.ax & 0xFF) != 0x12) video_36_bug = 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -