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

Last change on this file since 121 was 99, checked in by Tomi Tilli, 14 years ago

Changes to XTIDE Universal BIOS:

  • Even more initialization code inlining.
File size: 2.5 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Functions for accessing ATA information read with
3; IDENTIFY DEVICE command.
4
5; Section containing code
6SECTION .text
7
8;--------------------------------------------------------------------
9; AtaID_GetPCHS
10; Parameters:
11; ES:SI: Ptr to 512-byte ATA information read from the drive
12; Returns:
13; AX: Number of user specified P-CHS cylinders
14; BH: Number of user specified P-CHS sectors per track
15; BL: Number of user specified P-CHS heads
16; Corrupts registers:
17; Nothing
18;--------------------------------------------------------------------
19AtaID_GetPCHS:
20 mov ax, [es:si+ATA1.wCylCnt] ; Cylinders (1...16383)
21 mov bl, [es:si+ATA1.wHeadCnt] ; Heads (1...16)
22 mov bh, [es:si+ATA1.wSPT] ; Sectors per Track (1...63)
23 ret
24
25
26;--------------------------------------------------------------------
27; AtaID_GetTotalSectorCount
28; Parameters:
29; ES:SI: Ptr to 512-byte ATA information read from the drive
30; Returns:
31; BX:DX:AX: 48-bit sector count
32; Corrupts registers:
33; Nothing
34;--------------------------------------------------------------------
35AtaID_GetTotalSectorCount:
36 push ds
37
38 push es
39 pop ds
40 xor bx, bx
41 test WORD [si+ATA1.wCaps], A1_wCaps_LBA
42 jz SHORT .GetChsSectorCount
43 ; Fall to .GetLbaSectorCount
44
45;--------------------------------------------------------------------
46; .GetLbaSectorCount
47; Parameters:
48; BX: Zero
49; DS:SI: Ptr to 512-byte ATA information read from the drive
50; Returns:
51; BX:DX:AX: 48-bit sector count
52; Corrupts registers:
53; Nothing
54;--------------------------------------------------------------------
55.GetLbaSectorCount:
56 test WORD [si+ATA6.wSetSup83], A6_wSetSup83_LBA48
57 jz SHORT .GetLba28SectorCount
58 mov ax, [si+ATA6.qwLBACnt]
59 mov dx, [si+ATA6.qwLBACnt+2]
60 mov bx, [si+ATA6.qwLBACnt+4]
61 pop ds
62 ret
63.GetLba28SectorCount:
64 mov ax, [si+ATA1.dwLBACnt]
65 mov dx, [si+ATA1.dwLBACnt+2]
66 pop ds
67 ret
68
69;--------------------------------------------------------------------
70; .GetChsSectorCount
71; Parameters:
72; DS:SI: Ptr to 512-byte ATA information read from the drive
73; Returns:
74; DX:AX: 24-bit sector count
75; Corrupts registers:
76; Nothing
77;--------------------------------------------------------------------
78.GetChsSectorCount:
79 mov al, [si+ATA1.wSPT] ; AL=Sectors per track
80 mul BYTE [si+ATA1.wHeadCnt] ; AX=Sectors per track * number of heads
81 mul WORD [si+ATA1.wCylCnt] ; DX:AX=Sectors per track * number of heads * number of cylinders
82 pop ds
83 ret
Note: See TracBrowser for help on using the repository browser.