浅析 Legacy INT 13h中断函数

浅析 Legacy INT 13h中断函数

在BIOS进入UEFI时代之后,似乎Legacy BIOS的东西正在走向死亡。但传统的legacy产物退出历史舞台还需要一个过程, legacy中断就是其中之一。本文要讲的INT 13h中断函数就是legacy中断中的一种。它主要是为磁盘操作服务。

Table of Contents

  • 1 文档 (Enhanced Disk Drive Spec 4.0)
  • 2 定义和缩写
  • 3 INT 13H 函数定义
  • 4 如何通过 INT 13h 判断EDD的版本

1 文档 (Enhanced Disk Drive Spec 4.0)

  • ftp://fission.dt.wdc.com/pub/standards/x3t13/project/d1386r4.pdf

2 定义和缩写

  • CHS: A method of addressing the contents of a storage device using logical cylinder (C), logical heads(H) and logical sectors(S).
  • LBA: Logical Block Address
  • BDA: BIOS Data Area
  • ATA: AT Atachment Device, known as IDE

3 INT 13H 函数定义

Function Definition
FN 00h Reset Disk Subsystem
FN 01h Get Status of Last Operation
FN 02h Read Sectors into Memory
FN 03h Write Sectors from Memory
FN 04h Verify Sectors
FN 08h Get Drive Parameters
FN 0Eh Read Buffer
FN 0Fh Write Buffer
FN 15h Get Disk Type
FN 18h Set Media Type
FN 19h Park Heads
FN 25h Identify Device Information
FN 41h Check Extension Present
FN 42h Extended Read
FN 43h Extended Write
FN 44h Verify Sectors
FN 45h Lock/Unlock Media
FN 46h Eject Removable Media
FN 48h Get Device Parameters
FN 49h Get Extended Media Change Status
FN 4ah Initiate Disk Enumation
FN 4bh Terminate Disk Enumation
FN 4ch Initiate Disk Enumation & Boot
FN 4dh Return Boot Catalog
FN 4eh Set Hardware Configuration
FN 50h Send Packet Command
FN 51h Security Protocol Command

4 如何通过 INT 13h 判断EDD的版本

注意到 FN 41h可以check Extension Present

Entry:
    AH 41h
    BX 55AAh
    DL BIOS device number
Exit:
    Carry clear, function complete without error
    AH Versions of Extension (30h - version 3.0, 21h - version 1.1)
    AL Verdor specific
    BX AA55h
    CX Interface support bit map (See below table)
    Carry set, function complete with error
    AH 01h (invalid command)
Bit Description
0 Fixed disk access subset shall be supported.
1 Device locking and injecting subset shall be supported
2 Enhanced Disk Drive subset shall be supported
3 64-bit Extensions are present
4:15 reserved
When the 64-bit extensions are present, the fields starting at offset 10h in the Device Address Packet are valid. 
所以只要调用FN 41h函数,然后check carry bit,确定carry bit没有被置起来,check AH的返回值。30h对应version 3.0. 21h对应version 1.1.

5. INT 13H Address Format 

使用INT 13H需要以下数据格式

浅析 Legacy INT 13h中断函数_第1张图片


你可能感兴趣的:(BIOS相关)