void fips_harddrive::get_geometry (void) { union REGS regs; regs.h.ah = GET_DRIVE_PARAMS; regs.h.dl = number; int86 (DISK_INT,®s,®s); if (global.debug_mode) { fprintf (global.debugfile,"\nRegisters after call to int 13h 08h (drive %02Xh):\n\n",number); fprintf (global.debugfile," 00 sc/cl hd\n"); fprintf (global.debugfile,"al ah bl bh cl ch dl dh si di cflgs flags\n"); hexwrite ((byte *) ®s,16,global.debugfile); } if ((errorcode = regs.h.ah) != 0) return; geometry.heads = (dword) regs.h.dh + 1; geometry.sectors = (dword) regs.h.cl & 0x3f; geometry.cylinders = ((dword) regs.h.ch | (((dword) regs.h.cl << 2) & 0x300)) + 1; if (global.debug_mode) { fprintf (global.debugfile, "\nGeometry reported by BIOS:\n"); fprintf ( global.debugfile, "%ld cylinders, %ld heads, %ld sectors\n", geometry.cylinders, geometry.heads, geometry.sectors ); } }
static int pireset(int fd) { static uint8 ff = 0xff; if(hexwrite(fd, &ff, 1) < 0) return -1; /* This is fairly conservative. */ taskdelay(250); return 0; }
void fips_harddrive::reset (void) { union REGS regs; regs.h.ah = RESET_DISK; regs.h.dl = number; int86 (DISK_INT,®s,®s); if (global.debug_mode) { fprintf (global.debugfile,"\nRegisters after call to int 13h 00h (drive %02Xh):\n\n",number); fprintf (global.debugfile,"al ah bl bh cl ch dl dh si di cflgs flags\n"); hexwrite ((byte *) ®s,16,global.debugfile); } errorcode = regs.h.ah; }
boolean fips_partition::split (fips_harddrive hd) { if (read_boot_sector ()) error ("Error reading boot sector"); if (global.debug_mode) { fprintf ( global.debugfile, "\nBoot sector drive %02Xh, partition %u:\n\n", hd.number, number + 1 ); hexwrite ( boot_sector->data, 512, global.debugfile ); } get_bpb (); printx ("\nBoot sector:\n\n"); print_bpb (); get_info (); if (global.debug_mode) write_info_debugfile (); check (); fat16 fat1 (this,1); fat16 fat2 (this,2); fat1.check_against (&fat2); dword new_part_min_cylinder = min_cylinder (fat2, hd.geometry); if (ask_if_save()) save_root_and_boot(&hd,this); dword new_start_cylinder = ask_for_new_start_cylinder ( partition_info->start_cylinder, new_part_min_cylinder, partition_info->end_cylinder, hd.geometry.heads * hd.geometry.sectors ); fat2.check_empty ( new_start_cylinder * hd.geometry.heads * hd.geometry.sectors - partition_info->start_sector_abs ); hd.calculate_new_root (new_start_cylinder, this); hd.put_partition_table(); hd.get_partition_table(); printx ("\nNew partition table:\n\n"); hd.print_partition_table (); hd.check (FINAL_CHECK); if (ask_if_continue () == false) { return (false); } calculate_new_boot (); put_bpb (); get_bpb (); printx ("\nNew boot sector:\n\n"); print_bpb (); get_info (); if (global.debug_mode) write_info_debugfile (); check(); if (!global.test_mode) { ask_for_write_permission (); if (hd.write_root_sector ()) error ("Error writing root sector"); if (write_boot_sector ()) error ("Error writing boot sector"); printx ("Repartitioning complete\n"); } return (true); }