BIOS Enhanced Disk Drive Services
   HOME

TheInfoList



OR:

INT 13h is shorthand for
BIOS interrupt call BIOS implementations provide interrupts that can be invoked by operating systems and application programs to use the facilities of the firmware on IBM PC compatible computers. Traditionally, BIOS calls are mainly used by DOS programs and some ot ...
13 hex, the 20th
interrupt vector An interrupt vector table (IVT) is a data structure that associates a list of interrupt handlers with a list of interrupt requests in a table of interrupt vectors. Each entry of the interrupt vector table, called an interrupt vector, is the addre ...
in an
x86 x86 (also known as 80x86 or the 8086 family) is a family of complex instruction set computer (CISC) instruction set architectures initially developed by Intel, based on the 8086 microprocessor and its 8-bit-external-bus variant, the 8088. Th ...
-based (IBM PC-descended) computer system. The
BIOS In computing, BIOS (, ; Basic Input/Output System, also known as the System BIOS, ROM BIOS, BIOS ROM or PC BIOS) is a type of firmware used to provide runtime services for operating systems and programs and to perform hardware initialization d ...
typically sets up a
real mode Real mode, also called real address mode, is an operating mode of all x86-compatible CPUs. The mode gets its name from the fact that addresses in real mode always correspond to real locations in memory. Real mode is characterized by a 20- bit s ...
interrupt handler In computer systems programming, an interrupt handler, also known as an interrupt service routine (ISR), is a special block of code associated with a specific interrupt condition. Interrupt handlers are initiated by hardware interrupts, software ...
at this vector that provides sector-based hard disk and floppy disk read and write services using
cylinder-head-sector Cylinder-head-sector (CHS) is an early method for giving addresses to each physical block of data on a hard disk drive. It is a 3D-coordinate system made out of a vertical coordinate ''head'', a horizontal (or radial) coordinate ''cylinder'', an ...
(CHS) addressing. Modern PC BIOSes also include INT 13h extension functions, originated by IBM and Microsoft in 1992, that provide those same disk access services using 64-bit LBA addressing; with minor additions, these were quasi-standardized by Phoenix Technologies and others as the EDD ( Enhanced Disk Drive) BIOS extensions. INT is an x86 instruction that triggers a software interrupt, and 13hex is the interrupt number (as a
hexadecimal Hexadecimal (also known as base-16 or simply hex) is a Numeral system#Positional systems in detail, positional numeral system that represents numbers using a radix (base) of sixteen. Unlike the decimal system representing numbers using ten symbo ...
value) being called. Modern computers come with both BIOS INT 13h and
UEFI Unified Extensible Firmware Interface (UEFI, as an acronym) is a Specification (technical standard), specification for the firmware Software architecture, architecture of a computing platform. When a computer booting, is powered on, the UEFI ...
functionality that provides the same services and more, with the exception of UEFI Class 3 that completely removes CSM thus lacks INT 13h and other interrupts. Typically, UEFI drivers use LBA-addressing instead of CHS-addressing.


Overview

Under
real mode Real mode, also called real address mode, is an operating mode of all x86-compatible CPUs. The mode gets its name from the fact that addresses in real mode always correspond to real locations in memory. Real mode is characterized by a 20- bit s ...
operating systems, such as
DOS DOS (, ) is a family of disk-based operating systems for IBM PC compatible computers. The DOS family primarily consists of IBM PC DOS and a rebranded version, Microsoft's MS-DOS, both of which were introduced in 1981. Later compatible syste ...
, 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 DOS, it serves as the low-level interface for the built-in block device drivers for
hard disks A hard disk drive (HDD), hard disk, hard drive, or fixed disk is an electro-mechanical data storage device that stores and retrieves digital data using magnetic storage with one or more rigid rapidly rotating platters coated with magnet ...
and
floppy disk A floppy disk or floppy diskette (casually referred to as a floppy, a diskette, or a disk) is a type of disk storage composed of a thin and flexible disk of a magnetic storage medium in a square or nearly square plastic enclosure lined with a ...
s. This allows INT 25h and INT 26h to provide absolute disk read/write functions for logical sectors to the
FAT In nutrition science, nutrition, biology, and chemistry, fat usually means any ester of fatty acids, or a mixture of such chemical compound, compounds, most commonly those that occur in living beings or in food. The term often refers specif ...
file system driver in the DOS kernel, which handles file-related requests through DOS API ( INT 21h) functions. Under
protected mode In computing, protected mode, also called protected virtual address mode, is an operational mode of x86-compatible central processing units (CPUs). It allows system software to use features such as Memory_segmentation, segmentation, virtual mem ...
operating systems, such as Microsoft Windows NT derivatives (e.g. NT4, 2000, XP, and Server 2003) and
Linux Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
with
dosemu DOSEMU, stylized as dosemu, is a compatibility layer software package that enables DOS operating systems (e.g., MS-DOS, DR-DOS, FreeDOS) and application software to run atop Linux on x86-based PCs (IBM PC compatible computers). Features It ...
, the OS intercepts the call and passes it to the operating system's native disk I/O mechanism.
Windows 9x Windows 9x is a generic term referring to a line of discontinued Microsoft Windows operating systems released from 1995 to 2000 and supported until 2006, which were based on the kernel introduced in Windows 95 and modified in succeeding version ...
and
Windows for Workgroups 3.11 Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
also bypass BIOS routines when using 32-bit Disk Access. Besides performing low-level disk access, INT 13h calls and related BIOS data structures also provide information about the types and capacities of disks (or other DASD devices) attached to the system; when a protected-mode OS boots, it may use that information from the BIOS to enumerate disk hardware so that it (the OS) can load and configure appropriate disk I/O drivers. The original BIOS real-mode INT 13h interface supports drives of sizes up to about 8 GB 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 Cylinder-head-sector (CHS) is an early method for giving addresses to each physical block of data on a hard disk drive. It is a 3D-coordinate system made out of a vertical coordinate ''head'', a horizontal (or radial) coordinate ''cylinder'', an ...
(CHS) address given in the INT 13h call, and transferred it directly to the hardware interface. A lesser limit, about 504 MB, was imposed by the combination of CHS addressing limits used by the BIOS and those used by ATA hard disks, which are dissimilar. When the CHS addressing limits of both the BIOS and ATA are combined (i.e. when they are applied simultaneously), the number of 512-byte sectors that can be addressed represent a total of about 504 MB. The 504 MB limit was overcome using ''CHS translation'', a technique by which the BIOS would simulate a fictitious CHS geometry at the INT 13h interface, while communicating with the ATA drive using its native logical CHS geometry. (By the time the 504 MB barrier was being approached, ATA disks had long before ceased to present their real physical geometry parameters at the external ATA interface.) Translation allows the BIOS, still using CHS addressing, to effectively address ATA disks with sizes up to 8064 MB, the native capacity of the BIOS CHS interface alone. (The ATA interface has a much larger native CHS addressing capacity, so once the "interference" of the CHS limits of BIOS and ATA was resolved by addressing, only the smaller limitation of the BIOS was significant.) ''CHS translation'' is sometimes referred to as ''logical CHS addressing'', but that is actually a misnomer since by the time of this BIOS development, ATA CHS addresses were already logical, not physical. The 8064 MB 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—dictating that the format or size of CHS addresses passed to INT 13h could not be changed to add more bits to one of the fields, e.g. the Cylinder-number field. This limit uses 1024 cylinders, 256 heads, 63 sectors, and 512 byte blocks, allowing exactly 7.875 GiB of addressing (102425663). There were briefly a number of BIOSes that offered incompatible versions of this interface—for example, AWARD AT BIOS and AMI 386sx BIOS have been extended to handle up to 4096 cylinders by placing bits 10 and 11 of the cylinder number into bits 6 and 7 of register DH. All versions of
MS-DOS MS-DOS ( ; acronym for Microsoft Disk Operating System, also known as Microsoft DOS) is an operating system for x86-based personal computers mostly developed by Microsoft. Collectively, MS-DOS, its rebranding as IBM PC DOS, and a few op ...
, (including MS-DOS 7 and
Windows 95 Windows 95 is a consumer-oriented operating system developed by Microsoft and the first of its Windows 9x family of operating systems, released to manufacturing on July 14, 1995, and generally to retail on August 24, 1995. Windows 95 merged ...
) have a bug which prevents booting disk drives with 256 heads (register value 0xFF), so many modern BIOSes provide CHS translation mappings with at most 255 (0xFE) heads, thus reducing the total addressable space to exactly 8032.5 MiB (approx 7.844 GiB). To support addressing of even larger disks, an interface known as INT 13h Extensions was introduced by IBM and Microsoft, then later re-published and slightly extended by
Phoenix Technologies Phoenix Technologies Ltd. is an American company that designs, develops and supports core system software for personal computers and other computing devices. The company's products commonly referred to as BIOS (Basic Input/Output System) or fir ...
as part of BIOS Enhanced Disk Drive Services (EDD). It defines new functions within the INT 13h service, all having function numbers greater than 40h, that use 64-bit
logical block addressing Logical block addressing (LBA) is a common scheme used for specifying the location of blocks of data stored on computer storage devices, generally secondary storage systems such as hard disk drives. LBA is a particularly simple linear addressin ...
(LBA), which allows addressing up to 8 ZiB. (An ATA drive can also support 28-bit or 48-bit LBA which allows up to 128
GiB Gib or GIB may refer to: Places * Gibraltar, British overseas territory ** Gibraltar International Airport, IATA code GIB ** Gibraltar national football team, FIFA code GIB * Mount Gibraltar, known as The Gib, New South Wales, Australia * 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 very simple data structure that contains an interface version, data size, and LBAs. For software backward-compatibility, the extended functions are implemented alongside the original CHS functions, and calls to functions from both sets can be intermixed, even for the same drive, with the caveat that the CHS functions cannot reach past the first 8064 MB of the disk. Some cache drivers flush their buffers when detecting that
DOS DOS (, ) is a family of disk-based operating systems for IBM PC compatible computers. The DOS family primarily consists of IBM PC DOS and a rebranded version, Microsoft's MS-DOS, both of which were introduced in 1981. Later compatible syste ...
is bypassed by directly issuing INT 13h from applications. A dummy read via INT 13h can be used as one of several methods to force cache flushing for unknown caches (e.g. before rebooting). AMI BIOSes from around 1990–1991 trash word unaligned buffers. Some DOS and
terminate-and-stay-resident program A terminate-and-stay-resident program (commonly TSR) is a computer program running under DOS that uses a system call to return control to DOS as though it has finished, but remains in computer memory so it can be reactivated later. This techni ...
s clobber interrupt enabling and registers so
PC DOS PC or pc may refer to: Arts and entertainment * Player character or playable character, a fictional character controlled by a human player, usually in role-playing games or computer games * '' Port Charles'', an American daytime TV soap opera * ...
and
MS-DOS MS-DOS ( ; acronym for Microsoft Disk Operating System, also known as Microsoft DOS) is an operating system for x86-based personal computers mostly developed by Microsoft. Collectively, MS-DOS, its rebranding as IBM PC DOS, and a few op ...
install their own filters to prevent this.


List of services

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 Extensions which were written in the 1990s to support hard drives with more than 8 GB.


: Reset Disk System


: Get Status of Last Drive Operation

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


: Read Sectors From Drive


Remarks

Register CX contains both the cylinder number (10
bit The bit is the most basic unit of information in computing and digital communication. The name is a portmanteau of binary digit. The bit represents a logical state with one of two possible values. These values are most commonly represented as ...
s, 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 98 sector : 543210 Examples of translation: CX := ( ( cylinder and 255 ) shl 8 ) or ( ( cylinder and 768 ) shr 2 ) or sector; cylinder := ( (CX and $FF00) shr 8 ) or ( (CX and $C0) 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
byte The byte is a unit of digital information that most commonly consists of eight bits. Historically, the byte was the number of bits used to encode a single character of text in a computer and for this reason it is the smallest addressable un ...
s) and your buffer starts at memory address 4FF00h. Utilizing
memory segmentation Memory segmentation is an operating system memory management technique of dividing a computer's primary memory into segments or sections. In a computer system using segmentation, a reference to a memory location includes a value that identifies ...
, there are different ways to calculate the register values, e.g.: ES = segment = 4F00h BX = offset = 0F00h sum = memory address = 4FF00h would be a good choice because 0F00h + 2000h = 2F00h <= 10000h ES = segment = 4000h BX = offset = FF00h sum = memory address = 4FF00h would 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 Extensions. Another alternate may be DOS interrupt 25h which reads sectors ''within'' a partition.


Code Example

RG 7c00h ; code starts at 7c00h xor ax, ax ; make sure ds is set to 0 mov ds, ax cld ; start putting in values: mov ah, 2h ; int13h function 2 mov al, 63 ; we want to read 63 sectors mov ch, 0 ; from cylinder number 0 mov cl, 2 ; the sector number 2 - second sector (starts from 1, not 0) mov dh, 0 ; head number 0 xor bx, bx mov es, bx ; es should be 0 mov bx, 7e00h ; 512bytes from origin address 7c00h int 13h jmp 7e00h ; jump to the next sector ; to fill this sector and make it bootable: times 510-($-$$) db 0 dw 0AA55h After this code section (which the asm file should start with), you may write code and it will be loaded to memory and executed. Notice how we didn't change dl (the drive). That is because when the computer first loads up, dl is set to the number of the drive that was booted, so assuming we want to read from the drive we booted from, there is no need to change dl.


: Write Sectors To Drive


: Verify Sectors From Drive


: Format Track


: Format Track Set Bad Sector Flags


: Format Drive Starting at Track


: Read Drive Parameters


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.


: Init Drive Pair Characteristics


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.


: Check Extensions Present


: Extended Read Sectors From Drive

As already stated with int 13h AH=02h, care must be taken to ensure that the complete buffer is inside the given segment, ''i.e. ( BX + size_of_buffer ) <= 10000h''


: Extended Write Sectors to Drive


: Extended Read Drive Parameters


Remark

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


INT 13h AH=4Bh: Get Drive Emulation Type


See also

* INT 10H *
BIOS interrupt call BIOS implementations provide interrupts that can be invoked by operating systems and application programs to use the facilities of the firmware on IBM PC compatible computers. Traditionally, BIOS calls are mainly used by DOS programs and some ot ...
*
Cylinder-head-sector Cylinder-head-sector (CHS) is an early method for giving addresses to each physical block of data on a hard disk drive. It is a 3D-coordinate system made out of a vertical coordinate ''head'', a horizontal (or radial) coordinate ''cylinder'', an ...
*
INT (x86 instruction) INT is an assembly language instruction for x86 processors that generates a software interrupt. It takes the interrupt number formatted as a byte value. When written in assembly language, the instruction is written like this: :INT ''X'' wher ...
* DPMI (DOS Protected Mode Interface) * Ralf Brown's Interrupt List *BIOS Enhanced Disk Driv
Specification


References


External links






Norton Guide about int 13h, ah = 00h .. 1ah
{{DEFAULTSORT:Int 13 IBM PC compatibles BIOS Interrupts