Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!uwvax!astroatc!nicmad!brown
From: brown@nicmad.UUCP (Mr. Video)
Newsgroups: comp.sys.ibm.pc
Subject: Re: Panic!  Hard drive crash.
Message-ID: <1419@nicmad.UUCP>
Date: Fri, 9-Jan-87 11:08:28 EST
Article-I.D.: nicmad.1419
Posted: Fri Jan  9 11:08:28 1987
Date-Received: Sat, 10-Jan-87 00:09:46 EST
References: <1514@PUCC.BITNET>
Reply-To: brown@nicmad.UUCP (Mr. Video)
Organization: Nicolet Instrument Corp. Madison WI
Lines: 224

In article <1514@PUCC.BITNET> 6101778@PUCC.BITNET writes:
>Uh huh.  And I even PARKed it first.  Oh well.  The question is
>does anyone have any specs on the BIOS interrupt(s) which talk
>directly to the hard drive controller card?  When I boot from a
>floppy (as I am forced to do), the system insists that drive C:
>is an invalid drive specifier.  What I hope to do is read as much
>of the root directory and FAT as I can onto a floppy, then reFORMAT
>the thing, then try to restore the sectors.
> 
>Am I doing the right thing?  Am I asking lots of stupid questions?
>Am I whining?  Thanks for listening, anyway.

Attached below in my interrupt 13h assembly language program, complete
with comments on what does what.  It is part of DISKREAD program that
I distributed a while ago.

Anyway, I suspect that your disk partition table is bad.  My program
would show that to you.  Unfortunately I haven't made my program
writable to sectors yet, like Norton's does.  But the program I made
does allow the moving of a sector from one place to another, like
another hard drive.  Copy the partition table from one good drive to
another and you will probably be ok.  But I suspect that won't be
the case.  It may also be that you are getting errors from the drive
and the data is really ok.  Running my program will also report errors
reported back from the hard drive controller.  Let me know if you want
the complete program.  In the meantime, the data you wanted is below.

Good luck.

Mike Brown


          TITLE         INT13
          PAGE          ,132

;********************************************************************
;*                                                                  *
;* INT13       Version 1.0       10/21/86                           *
;*                                                                  *
;* Copyright 1986 Michael L. Brown                                  *
;*                Nicolet Instrument Corp                           *
;*                5225 Verona Rd                                    *
;*                Madison, WI  53711                                *
;*                (608) 273-5039                                    *
;*                                                                  *
;* The user is hereby granted permission to use this program.       *
;* User may not sell program.  User may change and distribute this  *
;* program, but may not charge for it.  This program may be used    *
;* in other programs, but may not charge extra for its inclusion.   *
;*                                                                  *
;* See the BASIC program DISKREAD.BAS for where to send corrections,*
;* enhancements, etc.                                               *
;*                                                                  *
;********************************************************************
          PAGE
;********************************************************************
;*                                                                  *
;* An assembly language interface to the BASIC program DISKREAD,    *
;* which allows the BASIC program to read absolute hard disk        *
;* sectors.                                                         *
;*                                                                  *
;* BASIC syntax is:                                                 *
;*                                                                  *
;*      CALL INT13(ES%,BX%,AL%,AH%,CL%,CH%,DL%,DH%)                 *
;*                                                                  *
;* The registers work as follows:                                   *
;*                                                                  *
;*      AL%   Number of sectors to read/write                       *
;*      AH%   The DISKBIOS INT 13h operation:                       *
;*                00 Reset disk/diskette                            *
;*                01 Read status of last disk operation into AL%    *
;*                02 Read sectors into memory                       *
;*                03 Write sectors into memory                      *
;*                04 Verify the sectors                             *
;*                05 Format the track                               *
;*                06 Format the track & set bad sector flags        *
;*                07 Format the drive starting at track             *
;*                08 Return the current drive parameters            *
;*                09 Initialize drive pair characteristics          *
;*                     INT 41 points to data block                  *
;*                0A Read long                                      *
;*                0B Write long                                     *
;*                0C Seek                                           *
;*                0D Alternate disk reset (see DL)                  *
;*                0E Read sector buffer                             *
;*                0F Write sector buffer                            *
;*                10 Test drive ready                               *
;*                11 Recalibrate                                    *
;*                12 Controller RAM diagnostics                     *
;*                13 Drive diagnostics                              *
;*                14 Controller internal diagnostics                *
;*      CL%   Sector number (1-17, not checked)                     *
;*      CH%   Cylinder number (0-1023, not checked)                 *
;*      DL%   Drive number (80h-87h for disk, checked)              *
;*      DH%   Head number (0-7, not checked)                        *
;*                                                                  *
;* The cylinder (track) number is 10 bits, so the upper 2 bits      *
;* of the cylinder number are placed in the top 2 bits of CL%.      *
;* The remaining 8 bits are placed into CH%.  Even tho CL% and CH%  *
;* are 16 bit BASIC integers, to the 8088, CL and CH are 8 bits.    *
;*                                                                  *
;********************************************************************
          PAGE
;********************************************************************
;*                                                                  *
;* When the INT13 program returns to BASIC, the following values    *
;* are passed back:                                                 *
;*                                                                  *
;*      AH%   The DISKBIOS INT 13h error numbers:                   *
;*                00 Operation OK                                   *
;*                01 Bad command                                    *
;*                02 Bad address mark                               *
;*                04 Record not found                               *
;*                05 Bad reset                                      *
;*                07 Init failure                                   *
;*                09 DMA boundary                                   *
;*                0B Bad cylinder (track)                           *
;*                10 Bad ECC                                        *
;*                11 Data corrected  AL% contains burst length      *
;*                20 Bad controller                                 *
;*                40 Bad seek                                       *
;*                BB Undefined error                                *
;*                FF Sense failure                                  *
;*      ES%   Segment location of data                              *
;*      BX%   Offset location of data                               *
;*                                                                  *
;* If disk parameters wanted:                                       *
;*                                                                  *
;*      CL%   Maximum useable sector & top 2 cylinder bits          *
;*      CH%   Bottom 8 bits of cylinder number                      *
;*      DL%   Number of known drives attached                       *
;*      DH%   Maximum useable head number                           *
;*                                                                  *
;* Assemble this code using the MASM assembler:                     *
;*                                                                  *
;*      MASM INT13,,INT13;                                          *
;*                                                                  *
;********************************************************************
          PAGE
PARMLST   STRUC
SAVE_BP   DW            ?               ;Save contents of BP
RET_OFF   DW            ?               ;Return address of calling program
RET_SEG   DW            ?
REGDH     DW            ?               ;Offset from DS of 8th argument
REGDL     DW            ?               ;Offset from DS of 7th argument
REGCH     DW            ?               ;Offset from DS of 6th argument
REGCL     DW            ?               ;Offset from DS of 5th argument
REGAH     DW            ?               ;Offset from DS of 4th argument
REGAL     DW            ?               ;Offset from DS of 3rd argument
REGBX     DW            ?               ;Offset from DS of 2nd argument
REGES     DW            ?               ;Offset from DS of 1st argument
PARMLST   ENDS

PARM_SIZE EQU           REGES - REGDH + TYPE REGES

CODE SEGMENT BYTE PUBLIC 'CODE'
          ASSUME CS:CODE,DS:CODE

BUFFER    DB 512 DUP(0)                 ;Set aside area for disk data

INT13     PROC          FAR
          PUBLIC        INT13
          PUSH          BP              ;Save contents of BP
          MOV           BP,SP           ;Set addressability to params
          PUSH          DS              ;Save BASIC DS and ES values
          PUSH          ES
          MOV           SI,[BP].REGAL
          MOV           AL,[SI]         ;Number of sectors to read
          MOV           SI,[BP].REGAH
          MOV           AH,[SI]         ;Function to perform
          MOV           SI,[BP].REGCL
          MOV           CL,[SI]         ;Sector number
          MOV           SI,[BP].REGCH
          MOV           CH,[SI]         ;Cylinder number
          MOV           SI,[BP].REGDL
          MOV           DL,[SI]         ;Drive number
          MOV           SI,[BP].REGDH
          MOV           DH,[SI]         ;Head number
          PUSH          CS
          POP           ES              ;Set up segment address of buffer
          MOV           BX,OFFSET BUFFER ;Offset of the address of buffer
;
; Save the ES and BX values for the BASIC program
;
          MOV           SI,[BP].REGES
          MOV           [SI],ES         ;Save segment of buffer
          MOV           SI,[BP].REGBX
          MOV           [SI],BX         ;Save offset of buffer
;
; At this point do the interrupt to get the disk data
;
          INT           13H
;
; Now we pass the info back to the program
;
          MOV           SI,[BP].REGAL
          MOV           [SI],AL         ;Save AL
          MOV           SI,[BP].REGAH
          MOV           [SI],AH         ;Save AH
          MOV           SI,[BP].REGCL
          MOV           [SI],CL         ;Save CL
          MOV           SI,[BP].REGCH
          MOV           [SI],CH         ;Save CH
          MOV           SI,[BP].REGDL
          MOV           [SI],DL         ;Save DL
          MOV           SI,[BP].REGDH
          MOV           [SI],DH         ;Save DH
;
; Clean up and return to BASIC program
;
          POP           ES
          POP           DS
          POP           BP              ;Clean up stack
          RET           PARM_SIZE       ;Restore the stack
INT13     ENDP
CODE      ENDS
          END
-- 
	   ihnp4------\				|------------------------|
	 harvard-\     \			|        terminus:       |
Mr. Video   seismo!uwvax!nicmad!brown		| The clearing house for |
	 rutgers-/     /			|     rec.arts.drwho     |
	  decvax------/				|------------------------|
	terminus-----/