News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

16-bit hard drive acces question

Started by ninjarider, March 15, 2008, 12:05:52 AM

Previous topic - Next topic

ninjarider

while in 16 bit is the only method of hard drive access the old chs, or is there a way to use the lba method?

sinsi

From Ralf Brown

INT 13 - IBM/MS INT 13 Extensions - INSTALLATION CHECK
AH = 41h
BX = 55AAh
DL = drive (80h-FFh)
Return: CF set on error (extensions not supported)
    AH = 01h (invalid function)
CF clear if successful
    BX = AA55h if installed
    AH = major version of extensions
01h = 1.x
20h = 2.0 / EDD-1.0
21h = 2.1 / EDD-1.1
30h = EDD-3.0
    AL = internal use
    CX = API subset support bitmap (see #00271)
    DH = extension version (v2.0+ ??? -- not present in 1.x)
Note: the Phoenix Enhanced Disk Drive Specification v1.0 uses version 2.0 of
  the INT 13 Extensions API
SeeAlso: AH=42h"INT 13 Ext",AH=48h"INT 13 Ext"

Bitfields for IBM/MS INT 13 Extensions API support bitmap:
Bit(s) Description (Table 00271)
0 extended disk access functions (AH=42h-44h,47h,48h) supported
1 removable drive controller functions (AH=45h,46h,48h,49h,INT 15/AH=52h)
  supported
2 enhanced disk drive (EDD) functions (AH=48h,AH=4Eh) supported
extended drive parameter table is valid (see #00273,#00278)
3-15 reserved (0)


INT 13 - IBM/MS INT 13 Extensions - EXTENDED READ
AH = 42h
DL = drive number
DS:SI -> disk address packet (see #00272)
Return: CF clear if successful
    AH = 00h
CF set on error
    AH = error code (see #00234)
    disk address packet's block count field set to number of blocks
      successfully transferred
SeeAlso: AH=02h,AH=41h"INT 13 Ext",AH=43h"INT 13 Ext"

Format of disk address packet:
Offset Size Description (Table 00272)
00h BYTE size of packet (10h or 18h)
01h BYTE reserved (0)
02h WORD number of blocks to transfer (max 007Fh for Phoenix EDD)
04h DWORD -> transfer buffer
08h QWORD starting absolute block number
(for non-LBA devices, compute as
  (Cylinder*NumHeads + SelectedHead) * SectorPerTrack +
  SelectedSector - 1
10h QWORD (EDD-3.0, optional) 64-bit flat address of transfer buffer;
  used if DWORD at 04h is FFFFh:FFFFh
Light travels faster than sound, that's why some people seem bright until you hear them.

ninjarider

wow. i feel like an idiot. i was looking straight at it and didn't see it.

sinsi

 :bdg
Been there.
Done that.
Got the t-shirt.
Light travels faster than sound, that's why some people seem bright until you hear them.

MichaelW

This might save you a little time:

;---------------------------------------------------------------------------
; The IBM/MS Interrupt 13h Extensions provide BIOS support for Logical Block
; Address (LBA) mode and fixed disk drives that exceed the normal BIOS limit
; of 8.4GB (8,455,200,768 bytes).
;
; For the IBM/MS Interrupt 13h Extensions the drives are numbered as they
; are for the normal BIOS functions:
;       First diskette drive    = 0
;       Second diskette drive   = 1
;       First hard disk drive   = 80h
;       Second hard disk drive  = 81h
;       ...
;
; For the disk drive functions provided by the normal BIOS, cylinder and
; head numbers start at 0 and sector numbers start at 1. For the disk drive
; functions provided by the IBM/MS Interrupt 13h Extensions (for which
; sectors are referred to as "blocks"), block numbers start at 0.
;
; For the disk drive functions provided by the normal BIOS, the "safe"
; maximum number of sectors to read or write per call is the number of
; sectors per track (the interface limit is 255). For the disk drive
; functions provided by the IBM/MS Interrupt 13h Extensions, a value
; of 127 for the number of blocks to read or write per call should work
; for all implementations (the maximum specified in the ATA standard
; is 256).
;---------------------------------------------------------------------------

DISK_ADDRESS_PACKET STRUCT
  packetSize        BYTE  ?
  reserved          BYTE  ?
  blocksToTransfer  WORD  ?
  bufferOffset      WORD  ?
  bufferSegment     WORD  ?
  startBlockLow     DWORD ?
  startBlockHigh    DWORD ?
DISK_ADDRESS_PACKET ENDS

DRIVE_PARAMETERS_EX STRUCT
  bufferSize        WORD  ?
  informationFlags  WORD  ?
  cylinders         DWORD ?
  heads             DWORD ?
  sectorsPerTrack   DWORD ?
  totalSectorsLow   DWORD ?
  totalSectorsHigh  DWORD ?
  bytesPerSector    WORD  ?
DRIVE_PARAMETERS_EX ENDS

;-------------------------------------------
; Constants for the informationFlags member:
;-------------------------------------------

DMA_BOUNDARY_ERRORS_HANDLED_TRANSPARENTLY       EQU 1
CHS_INFORMATION_VALID                           EQU 2
REMOVABLE_DRIVE                                 EQU 4
WRITE_WITH_VERIFY_SUPPORTED                     EQU 8
DRIVE_HAS_CHANGE_LINE                           EQU 16
DRIVE_CAN_BE_LOCKED                             EQU 32
CHS_INFORMATION_SET_TO_MAX_SUPPORTED            EQU 64

;--------------------------------------------------------
; An incomplete listing of disk-related BIOS error codes:
;--------------------------------------------------------

BIOS_ERROR_INVALID_FUNCTION                     EQU 1
BIOS_ERROR_ADDRESS_MARK_NOT_FOUND               EQU 2
BIOS_ERROR_WRITE_PROTECT                        EQU 3
BIOS_ERROR_SECTOR_NOT_FOUND                     EQU 4
BIOS_ERROR_RESET_FAILED                         EQU 5
BIOS_ERROR_CHANGE_LINE_ACTIVE                   EQU 6
BIOS_ERROR_BAD_PARAMETER                        EQU 7
BIOS_ERROR_DMA_OVERRUN                          EQU 8
BIOS_ERROR_DMA_BOUNDARY                         EQU 9
BIOS_ERROR_BAD_SECTOR                           EQU 0Ah
BIOS_ERROR_BAD_TRACK                            EQU 0Bh
BIOS_ERROR_MEDIA_TYPE_NOT_FOUND                 EQU 0Ch
BIOS_ERROR_INVALID_NUMBER_OF_SECTORS            EQU 0Dh
BIOS_ERROR_CONTROL_DATA_ADDRESS_MARK_NOT_FOUND  EQU 0Eh
BIOS_ERROR_DMA_ARBITRATION_LEVEL_OUT_OF_RANGE   EQU 0Fh
BIOS_ERROR_CRC_OR_ECC_ON_READ                   EQU 10h
BIOS_ERROR_CORRECTED_DATA                       EQU 11h
BIOS_ERROR_CONTROLLER_FAILURE                   EQU 20h
BIOS_ERROR_NO_MEDIA_IN_DRIVE                    EQU 31h
BIOS_ERROR_SEEK_FAILED                          EQU 40h
BIOS_ERROR_TIMEOUT                              EQU 80h
BIOS_ERROR_DRIVE_NOT_READY                      EQU 0AAh
BIOS_ERROR_UNDEFINED                            EQU 0BBh
BIOS_ERROR_WRITE_FAULT                          EQU 0CCh
BIOS_ERROR_STATUS                               EQU 0E0h
BIOS_ERROR_SENSE_FAILED                         EQU 0FFh
eschew obfuscation