INT 13H - Wikipedia, the free encyclopedia

来源:互联网 发布:ubuntu如何安装deb软件 编辑:程序博客网 时间:2024/04/28 19:53

访问原文



INT 13H

From Wikipedia, the free encyclopedia
  (Redirected from INT 13)
This article may contain an excessive amount of intricate detail that may only interest a specific audience. Please help relocate any relevant information, and remove excessive detail that may be against Wikipedia inclusion policy. (June 2012)
This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed. (September 2010)
Not to be confused with Mode 13h.

INT 13H is shorthand for BIOS interrupt call 13hex, the 20th interrupt vector in an x86-based computer system. The BIOS typically sets up a real mode interrupt handler at this vector that provides sector-based hard disk and floppy disk read and write services using cylinder-head-sector (CHS) addressing.

INT is an x86 instruction that triggers a software interrupt, and 13hex vector passed to the instruction (interrupts start at zero, and are labeled with hexadecimal values).

Contents

  [hide] 
  • 1 Overview
  • 2 List of INT 13h services
    • 2.1 Drive Table
    • 2.2 Function Table
    • 2.3 INT 13h AH=00h: Reset Disk Drive
    • 2.4 INT 13h AH=01h: Get Status of Last Drive Operation
    • 2.5 INT 13h AH=02h: Read Sectors From Drive
    • 2.6 INT 13h AH=03h: Write Sectors To Drive
    • 2.7 INT 13h AH=04h: Verify Sectors From Drive
    • 2.8 INT 13h AH=05h: Format Track
    • 2.9 INT 13h AH=06h: Format Track Set Bad Sector Flags
    • 2.10 INT 13h AH=07h: Format Track Set Bad Sector Flags
    • 2.11 INT 13h AH=08h: Read Drive Parameters
    • 2.12 INT 13h AH=09h: Init Drive Pair Characteristics
    • 2.13 INT 13h AH=0Ah: Read Long Sectors From Drive
    • 2.14 INT 13h AH=41h: Check Extensions Present
    • 2.15 INT 13h AH=42h: Extended Read Sectors From Drive
    • 2.16 INT 13h AH=43h: Extended Write Sectors to Drive
    • 2.17 INT 13h AH=48h: Extended Read Drive Parameters
  • 3 See also
  • 4 References
  • 5 External links

[edit]Overview

See also: Enhanced BIOS

Under real mode operating systems, such as MS-DOS, calling INT 13h would jump into the computer's ROM-BIOS code for low-level disk services, which would carry out physical sector-based disk read or write operations for the program. In MS-DOS, it serves as the low-level interface for the built-in block device drivers for hard disks and floppy disks. This allows INT 25h and INT 26h to provide absolute disk read/write functions for logical sectors to the FAT file system driver in the DOS kernel, which handles file-related requests through MS-DOS API (INT 21h) functions.

Under protected mode operating systems, such as Microsoft Windows NT derivatives (e.g. NT4, 2000, XP, and Server 2003) and Linux with dosemu, the OS intercepts the call and passes it to the operating system's native disk I/O mechanism. Windows 9x and Windows for Workgroups 3.11 also bypass BIOS routines when using 32-bit File Access.

The original BIOS real-mode INT 13h interface supports drives of sizes up to about 504 MB using what is commonly referred to as physical CHS addressing. This limit originates from the hardware interface of the IBM PC/XT disk hardware. The BIOS used the cylinder-head-sector (CHS) address given in the INT 13h call, and transferred it directly to the hardware interface.

This interface was later extended to support addressing of up to exactly 8064 MB using what is commonly referred to as logical CHS addressing. This limit originates from a combination of the register value based calling convention used in the INT 13h interface, and the goal of maintaining backward compatibility. There were originally a number of BIOSes that offered incompatible versions of this interface, but eventually the computer industry standardized on the interface developed in the Microid Research ("MR BIOS") in 1989. This limit uses 1024 cylinders, 256 heads, 63 sectors, and 512 byte blocks, giving roughly 7.875 GB of addressing (1024 * 256 * 63 * 512).

To support even larger addressing modes, an interface known as INT 13h Extensions was introduced by Western Digital and Phoenix Technologies as part of BIOS Enhanced Disk Drive Services.[1] It uses 64-bit logical block addressing (LBA) which allows addressing up to 8 ZiB (the drive can also support 28-bit or 48-bit LBA which allows up to 128 GiB or 128 PiB respectively, assuming a 512-byte sector/block size). This is a packet interface, because it uses a pointer to a packet of information rather than the register based calling convention of the original INT 13h interface. This packet is a data structure that contains an interface version, data size, and LBAs.

All versions of MS-DOS, including MS-DOS 7, and Windows 95 contain a bug that prevents booting hard disks with 256 heads (register value 0xFF), [2] so many modern BIOS maps the drives to have at most 255 heads. Also some cache drivers will flush their buffers when detecting that MS-DOS is bypassed by applications that directly issues INT 13h requests. AMI BIOSes from around 1990-1991 trash word unaligned buffers. Some MS-DOS and TSR programs clobber interrupt enabling and registers so PC-DOS and MS-DOS install their own filters to prevent this.[3]

[edit]List of INT 13h services

[edit]Drive Table

DL = 00h1st floppy disk ( "drive A:" )DL = 01h2nd floppy disk ( "drive B:" )DL = 80h1st hard diskDL = 81h2nd hard disk

[edit]Function Table

AH = 00h Reset Disk DrivesAH = 01h Get Status of Last Drive OperationAH = 02h Read Sectors From DriveAH = 03h Write Sectors To DriveAH = 04h Verify SectorsAH = 05h Format TrackAH = 06h Format Track Set Bad Sector FlagsAH = 07h Format Drive starting at TrackAH = 08h Read Drive ParametersAH = 09hHDInitialize Disk ControllerAH = 0AhHDRead Long Sectors From DriveAH = 0BhHDWrite Long Sectors To DriveAH = 0ChHDMove Drive Head To CylinderAH = 0DhHDReset Disk DrivesAH = 0EhPS/2Controller Read TestAH = 0FhPS/2Controller Write TestAH = 10hHDTest Whether Drive Is ReadyAH = 11hHDRecalibrate DriveAH = 12hPS/2Controller RAM TestAH = 13hPS/2Drive TestAH = 14hHDController DiagnosticAH = 15h Read Drive TypeAH = 16hFDDetect Media ChangeAH = 17hFDSet Media Type For Format ( used by DOS versions <= 3.1 )AH = 18hFDSet Media Type For Format ( used by DOS versions >= 3.2 )AH = 19h Park HeadsAH = 41hEXTTest Whether Extensions Are AvailableAH = 42hEXTRead Sectors From DriveAH = 43hEXTWrite Sectors To DriveAH = 44hEXTVerify SectorsAH = 45hEXTLock/Unlock DriveAH = 46hEXTEject DriveAH = 47hEXTMove Drive Head To SectorAH = 48hEXTRead Drive ParametersAH = 49hEXTDetect Media Change

If the second column is empty then the function may be used both for floppy and hard disk.

  • FD: for floppy disk only.
  • HD: for hard disk only.
  • PS/2: for hard disk on PS/2 system only.
  • EXT: part of the Int 13h Extensions which were written in the 1990s to support hard drives with more than 8 GB.

[edit]INT 13h AH=00h: Reset Disk Drive

Parameters:

AH00hDLDrive

Results:

CFSet on error

[edit]INT 13h AH=01h: Get Status of Last Drive Operation

Parameters:

AH01hDLDrive$

$Bit 7=0 for floppy drive, bit 7=1 for fixed drive

Results:

ALReturn Code00hSuccess01hInvalid Command02hCannot Find Address Mark03hAttempted Write On Write Protected Disk04hSector Not Found05hReset Failed06hDisk change line 'active'07hDrive parameter activity failed08hDMA overrun09hAttempt to DMA over 64kb boundary0AhBad sector detected0BhBad cylinder (track) detected0ChMedia type not found0DhInvalid number of sectors0EhControl data address mark detected0FhDMA out of range10hCRC/ECC data error11hECC corrected data error20hController failure40hSeek failure80hDrive timed out, assumed not readyAAhDrive not readyBBhUndefined errorCChWrite faultE0hStatus errorFFhSense operation failedCFSet On Error, Clear If No Error

[edit]INT 13h AH=02h: Read Sectors From Drive

Parameters:

AH02hALSectors To Read CountCXTrack / SectorDHHeadDLDriveES:BXBuffer Address Pointer

Results:

CFSet On Error, Clear If No ErrorAHReturn CodeALActual Sectors Read Count

Remarks:
Register CX contains both the cylinder number (10 bits, possible values are 0 to 1023) and the sector number (6 bits, possible values are 1 to 63). Cylinder and Sector bits are numbered below:

CX =       ---CH--- ---CL---cylinder : 76543210 98sector   :            543210

Examples of translation:

CX := ( ( cylinder and 255 ) shl 8 ) or ( ( cylinder and 768 ) shr 2 ) or sector;cylinder := ( (CX and 0xFF00) shr 8 ) or ( (CX and 0xC0) shl 2)sector := CX and 63;

Addressing of Buffer should guarantee that the complete buffer is inside the given segment, i.e. ( BX + size_of_buffer ) <= 10000h. Otherwise the interrupt may fail with some BIOS or hardware versions.
Example: Assume you want to read 16 sectors (= 2000h bytes) and your buffer starts at memory address 4FF00h. Utilizing memory segmentation, there are different ways to calculate the register values, e.g.:

ES = segment         = 4F00hBX = offset          =  0F00hsum = memory address = 4FF00hwould be a good choice because 0F00h + 2000h = 2F00h <= 10000hES = segment         = 4000hBX = offset          =  FF00hsum = memory address = 4FF00hwould not be a good choice because FF00h + 2000h = 11F00h > 10000h

Function 02h of interrupt 13h may only read sectors of the first 16,450,560 sectors of your hard drive, to read sectors beyond the 8 GB limit you should use function 42h of Int 13h Extensions. Another alternate may be DOS interrupt 25h which reads sectors within a partition.

[edit]INT 13h AH=03h: Write Sectors To Drive

Parameters:

AH03hALSectors To Write CountCHTrackCLSectorDHHeadDLDriveES:BXBuffer Address Pointer

Results:

CFSet On Error, Clear If No ErrorAHReturn CodeALActual Sectors Written Count

[edit]INT 13h AH=04h: Verify Sectors From Drive

Parameters:

AH04hALSectors To Verify CountCHTrackCLSectorDHHeadDLDriveES:BXBuffer Address Pointer

Results:

CFSet On Error, Clear If No ErrorAHReturn CodeALActual Sectors Verified Count

[edit]INT 13h AH=05h: Format Track

Parameters:

AH05hALSectors To Format CountCHTrackCLSectorDHHeadDLDriveES:BXBuffer Address Pointer$

$4-byte address field (applies to PC/XT 286,AT, PS/1 and PS/2)

ByteMeaningAllowable Values1Track 2Head 3Sector 4Bytes/Sector0=128, 1-256, 2-512, 3-1024

Results:

CFSet On Error, Clear If No ErrorAHReturn Code

[edit]INT 13h AH=06h: Format Track Set Bad Sector Flags

Parameters:

AH06hALInterleaveCHTrackCLSectorDHHeadDLDrive

Results:

CFSet On Error, Clear If No ErrorAHReturn Code

[edit]INT 13h AH=07h: Format Track Set Bad Sector Flags

Parameters:

AH07hALInterleaveCHTrackCLSectorDHHeadDLDrive

Results:

CFSet On Error, Clear If No ErrorAHReturn Code

[edit]INT 13h AH=08h: Read Drive Parameters

Parameters:

RegistersAH08h = function number for read_drive_parametersDLdrive index (e.g. 1st HDD = 80h)ES:DI[4]set to 0000h:0000h to work around some buggy BIOS


Results:

CFSet On Error, Clear If No ErrorAHReturn CodeDLnumber of hard disk drivesDH[4]logical last index of heads = number_of - 1 (because index starts with 0)CX[7:6] [15:8][4] logical last index of cylinders = number_of - 1 (because index startswith 0)

[5:0][4] logical last index of sectors per track = number_of (because index starts with 1)

BL[4]drive type (only AT/PS2 floppies)ES:DI[4]pointer to drive parameter table (only for floppies)

Remarks:
Logical values of function 08h may/should differ from physical CHS values of function 48h.
Result register CX contains both cylinders and sector/track values, see remark of function 02h.

[edit]INT 13h AH=09h: Init Drive Pair Characteristics

Parameters:

AH09hDLDrive

Results:

CFSet On Error, Clear If No ErrorAHReturn Code

[edit]INT 13h AH=0Ah: Read Long Sectors From Drive

The only difference between this function and function 02h (see above) is that function 0Ah reads 516 bytes per sector instead of only 512. The last 4 bytes contains the Error Correction Code (ECC), a checksum of sector data.

[edit]INT 13h AH=41h: Check Extensions Present

Parameters:

RegistersAH41h = function number for extensions check[5]DLdrive index (e.g. 1st HDD = 80h)BX55AAh

Results:

CFSet On Not Present, Clear If PresentAHError Code or Major Version NumberBXAA55hCXInterface support bitmask:

1 - Device Access using the packet structure
2 - Drive Locking and Ejecting
4 - Enhanced Disk Drive Support (EDD)

[edit]INT 13h AH=42h: Extended Read Sectors From Drive

Parameters:

RegistersAH42h = function number for extended readDLdrive index (e.g. 1st HDD = 80h)DS:SIsegment:offset pointer to the DAP, see belowDAP : Disk Address Packetoffset rangesizedescription00h1 bytesize of DAP = 16 = 10h01h1 byteunused, should be zero02h..03h2 bytesnumber of sectors to be read, (some Phoenix BIOSes are limited to a maximum of 127 sectors)04h..07h4 bytessegment:offset pointer to the memory buffer to which sectors will be transferred (note that x86 is little-endian: if declaring the segment and offset separately, the offset must be declared before the segment)08h..0Fh8 bytesabsolute number of the start of the sectors to be read (1st sector of drive has number 0)

Results:

CFSet On Error, Clear If No ErrorAHReturn Code

[edit]INT 13h AH=43h: Extended Write Sectors to Drive

Parameters:

RegistersAH43h = function number for extended writeALbit 0 = 0: close write check,

bit 0 = 1: open write check,

bit 1-7:reserved, set to 0

DLdrive index (e.g. 1st HDD = 80h)DS:SIsegment:offset pointer to the DAP

Results:

CFSet On Error, Clear If No ErrorAHReturn Code

[edit]INT 13h AH=48h: Extended Read Drive Parameters

Parameters:

RegistersAH48h = function number for extended_read_drive_parametersDLdrive index (e.g. 1st HDD = 80h)DS:SIsegment:offset pointer to Result Buffer, see belowResult Bufferoffset rangesizedescription00h..01h2 bytessize of Result Buffer = 30 = 1Eh02h..03h2 bytesinformation flags04h..07h4 bytesphysical number of cylinders = last index + 1 (because index starts with 0)08h..0Bh4 bytesphysical number of heads = last index + 1 (because index starts with 0)0Ch..0Fh4 bytesphysical number of sectors per track = last index (because index starts with 1)10h..17h8 bytesabsolute number of sectors = last index + 1 (because index starts with 0)18h..19h2 bytesbytes per sector1Ah..1Dh4 bytesoptional pointer to Enhanced Disk Drive (EDD) configuration parameters

which may be used for subsequent interrupt 13h Extension calls (if supported)


Results:

CFSet On Error, Clear If No ErrorAHReturn Code

Remark: Physical CHS values of function 48h may/should differ from logical values of function 08h.

[edit]See also

  • INT 10H
  • BIOS interrupt call
  • Cylinder-head-sector
  • INT (x86 instruction)
  • DPMI (DOS Protected Mode Interface)

[edit]References

  1. ^ [1]
  2. ^ Disk size limitations
  3. ^ ctyme.com - DISK - READ SECTOR(S) INTO MEMORY
  4. a b c d e f ctyme.com - DISK - GET DRIVE PARAMETERS (PC,XT286,CONV,PS,ESDI,SCSI)
  5. ^ ctyme.com - IBM/MS INT 13 Extensions - INSTALLATION CHECK

[edit]External links

  • BIOS Interrupt 13h Extensions
  • Ralf Brown's comprehensive Interrupt List
  • Norton Guide about int 13h, ah = 00h .. 1ah
View page ratings
Rate this page
What's this?
Trustworthy
Objective
Complete
Well-written
I am highly knowledgeable about this topic (optional)
Categories:
  • IBM PC compatibles
  • BIOS
  • Interrupts

0 0
原创粉丝点击