source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm@ 67

Last change on this file since 67 was 3, checked in by Tomi Tilli, 15 years ago
File size: 2.9 KB
RevLine 
[3]1; File name : AtaID.asm
2; Project name : IDE BIOS
3; Created date : 6.4.2010
4; Last update : 9.4.2010
5; Author : Tomi Tilli
6; Description : Functions for accessing ATA information read with
7; IDENTIFY DEVICE command.
8
9; Section containing code
10SECTION .text
11
12;--------------------------------------------------------------------
13; Returns P-CHS values from ATA information.
14;
15; AtaID_GetPCHS
16; Parameters:
17; ES:SI: Ptr to 512-byte ATA information read from the drive
18; Returns:
19; AX: Number of user specified P-CHS cylinders
20; BL: Number of user specified P-CHS sectors per track
21; BH: Number of user specified P-CHS heads
22; Corrupts registers:
23; Nothing
24;--------------------------------------------------------------------
25ALIGN JUMP_ALIGN
26AtaID_GetPCHS:
27 mov ax, [es:si+ATA1.wCylCnt] ; Cylinders (1...16383)
28 mov bh, [es:si+ATA1.wHeadCnt] ; Heads (1...16)
29 mov bl, [es:si+ATA1.wSPT] ; Sectors per Track (1...63)
30 ret
31
32
33;--------------------------------------------------------------------
34; Returns total number of available sectors from ATA information.
35;
36; AtaID_GetTotalSectorCount
37; Parameters:
38; ES:SI: Ptr to 512-byte ATA information read from the drive
39; Returns:
40; BX:DX:AX: 48-bit sector count
41; Corrupts registers:
42; Nothing
43;--------------------------------------------------------------------
44ALIGN JUMP_ALIGN
45AtaID_GetTotalSectorCount:
46 xor bx, bx
47 test WORD [es:si+ATA1.wCaps], A1_wCaps_LBA
48 jz SHORT AtaID_GetChsSectorCount
49 ; Fall to AtaID_GetLbaSectorCount
50
51;--------------------------------------------------------------------
52; Returns total number of available sectors for LBA addressing.
53;
54; AtaID_GetLbaSectorCount
55; Parameters:
56; BX: Zero
57; ES:SI: Ptr to 512-byte ATA information read from the drive
58; Returns:
59; BX:DX:AX: 48-bit sector count
60; Corrupts registers:
61; Nothing
62;--------------------------------------------------------------------
63;ALIGN JUMP_ALIGN
64AtaID_GetLbaSectorCount:
65 test WORD [es:si+ATA6.wSetSup83], A6_wSetSup83_LBA48
66 jz SHORT .GetLba28SectorCount
67 mov ax, [es:si+ATA6.qwLBACnt]
68 mov dx, [es:si+ATA6.qwLBACnt+2]
69 mov bx, [es:si+ATA6.qwLBACnt+4]
70 ret
71ALIGN JUMP_ALIGN
72.GetLba28SectorCount:
73 mov ax, [es:si+ATA1.dwLBACnt]
74 mov dx, [es:si+ATA1.dwLBACnt+2]
75 ret
76
77;--------------------------------------------------------------------
78; Returns total number of available sectors for P-CHS addressing.
79;
80; AtaID_GetChsSectorCount
81; Parameters:
82; ES:SI: Ptr to 512-byte ATA information read from the drive
83; Returns:
84; DX:AX: 24-bit sector count
85; Corrupts registers:
86; Nothing
87;--------------------------------------------------------------------
88ALIGN JUMP_ALIGN
89AtaID_GetChsSectorCount:
90 mov al, [es:si+ATA1.wSPT] ; AL=Sectors per track
91 mul BYTE [es:si+ATA1.wHeadCnt] ; AX=Sectors per track * number of heads
92 mul WORD [es:si+ATA1.wCylCnt] ; DX:AX=Sectors per track * number of heads * number of cylinders
93 ret
Note: See TracBrowser for help on using the repository browser.