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

Last change on this file since 114 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
RevLine 
[99]1; Project name : XTIDE Universal BIOS
[3]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
[99]14; BH: Number of user specified P-CHS sectors per track
15; BL: Number of user specified P-CHS heads
[3]16; Corrupts registers:
17; Nothing
18;--------------------------------------------------------------------
19AtaID_GetPCHS:
20 mov ax, [es:si+ATA1.wCylCnt] ; Cylinders (1...16383)
[99]21 mov bl, [es:si+ATA1.wHeadCnt] ; Heads (1...16)
22 mov bh, [es:si+ATA1.wSPT] ; Sectors per Track (1...63)
[3]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:
[99]36 push ds
37
38 push es
39 pop ds
[3]40 xor bx, bx
[99]41 test WORD [si+ATA1.wCaps], A1_wCaps_LBA
42 jz SHORT .GetChsSectorCount
43 ; Fall to .GetLbaSectorCount
[3]44
45;--------------------------------------------------------------------
[99]46; .GetLbaSectorCount
[3]47; Parameters:
48; BX: Zero
[99]49; DS:SI: Ptr to 512-byte ATA information read from the drive
[3]50; Returns:
51; BX:DX:AX: 48-bit sector count
52; Corrupts registers:
53; Nothing
54;--------------------------------------------------------------------
[99]55.GetLbaSectorCount:
56 test WORD [si+ATA6.wSetSup83], A6_wSetSup83_LBA48
[3]57 jz SHORT .GetLba28SectorCount
[99]58 mov ax, [si+ATA6.qwLBACnt]
59 mov dx, [si+ATA6.qwLBACnt+2]
60 mov bx, [si+ATA6.qwLBACnt+4]
61 pop ds
[3]62 ret
63.GetLba28SectorCount:
[99]64 mov ax, [si+ATA1.dwLBACnt]
65 mov dx, [si+ATA1.dwLBACnt+2]
66 pop ds
[3]67 ret
68
69;--------------------------------------------------------------------
[99]70; .GetChsSectorCount
[3]71; Parameters:
[99]72; DS:SI: Ptr to 512-byte ATA information read from the drive
[3]73; Returns:
74; DX:AX: 24-bit sector count
75; Corrupts registers:
76; Nothing
77;--------------------------------------------------------------------
[99]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
[3]83 ret
Note: See TracBrowser for help on using the repository browser.